com php-src: Reintroduce use of FETCH_GLOBAL_LOCK: Zend /zend_compile.c

From: Date: Thu, 10 Dec 2015 18:04:59 +0000
Subject: com php-src: Reintroduce use of FETCH_GLOBAL_LOCK: Zend /zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90210@lists.php.net to get a copy of this message
Commit: c8a64e289c23aee4fdeb8c906f504cf4d61adeea Author: Nikita Popov <nikic@php.net> Thu, 10 Dec 2015 18:51:03 +0100 Parents: 7ea1cf2e571d6522730f4e4876d34990f3bca69e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c8a64e289c23aee4fdeb8c906f504cf4d61adeea Log: Reintroduce use of FETCH_GLOBAL_LOCK Just found this old AST todo... It no longer makes sense as an optimization due to the introduction of BIND_GLOBAL, however it ensures that the global variable name is not evaluated twice, which is presumably something we wish to guarantee. Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 363319e..f59228a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3642,12 +3642,16 @@ void zend_compile_global_var(zend_ast *ast) /* {{{ */ zend_op *opline = zend_emit_op(NULL, ZEND_BIND_GLOBAL, &result, &name_node); zend_alloc_cache_slot(opline->op2.constant); } else { - zend_emit_op(&result, ZEND_FETCH_W, &name_node, NULL); - - // TODO.AST Avoid double fetch - //opline->extended_value = ZEND_FETCH_GLOBAL_LOCK; - - zend_emit_assign_ref_znode(var_ast, &result); + /* name_ast should be evaluated only. FETCH_GLOBAL_LOCK instructs FETCH_W + * to not free the name_node operand, so it can be reused in the following + * ASSIGN_REF, which then frees it. */ + zend_op *opline = zend_emit_op(&result, ZEND_FETCH_W, &name_node, NULL); + opline->extended_value = ZEND_FETCH_GLOBAL_LOCK; + + zend_emit_assign_ref_znode( + zend_ast_create(ZEND_AST_VAR, zend_ast_create_znode(&name_node)), + &result + ); } } /* }}} */

« previous php.cvs (#90210) next »