Browse Source

optimizer: remove double xc_undo_pass_two/xc_redo_pass_two, avoid optimize more than once on same op_array

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@335 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 15 years ago
parent
commit
deb293c8be
  1. 17
      optimizer.c

17
optimizer.c

@ -18,6 +18,7 @@
#else
# define XCACHE_IS_CV 16
#endif
#define optimized_flag done_pass_two
typedef int bbid_t;
enum {
@ -510,7 +511,13 @@ static int xc_optimize_op_array(zend_op_array *op_array TSRMLS_DC) /* {{{ */
if (op_array->type != ZEND_USER_FUNCTION) {
return 0;
}
xc_undo_pass_two(op_array TSRMLS_CC);
/* don't optimize twice */
if (op_array->optimized_flag) {
return 0;
}
op_array->optimized_flag = 1;
#ifdef DEBUG
# if 0
TRACE("optimize file: %s", op_array->filename);
@ -542,10 +549,14 @@ static int xc_optimize_op_array(zend_op_array *op_array TSRMLS_DC) /* {{{ */
xc_dprint_zend_op_array(op_array, 0 TSRMLS_CC);
# endif
#endif
xc_redo_pass_two(op_array TSRMLS_CC);
return 0;
}
/* }}} */
int xc_clear_flag_optimized(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
op_array->done_pass_two = 0;
}
/* }}} */
void xc_optimize(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
xc_compile_result_t cr;
@ -557,7 +568,9 @@ void xc_optimize(zend_op_array *op_array TSRMLS_DC) /* {{{ */
xc_compile_result_init_cur(&cr, op_array TSRMLS_CC);
xc_apply_op_array(&cr, (apply_func_t) xc_undo_pass_two TSRMLS_CC);
/* op_array->done_pass_two is now used as if it's op_array->flag_optimized */
xc_apply_op_array(&cr, (apply_func_t) xc_optimize_op_array TSRMLS_CC);
xc_apply_op_array(&cr, (apply_func_t) xc_clear_flag_optimized TSRMLS_CC);
xc_apply_op_array(&cr, (apply_func_t) xc_redo_pass_two TSRMLS_CC);
xc_compile_result_free(&cr);

Loading…
Cancel
Save