com php-src: Better fix for bug #72854 (avoid extra copy and creating reference to stack variable): Zend/zend_execute.c

From: Date: Thu, 29 Sep 2016 07:56:01 +0000
Subject: com php-src: Better fix for bug #72854 (avoid extra copy and creating reference to stack variable): Zend/zend_execute.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94779@lists.php.net to get a copy of this message
Commit: e7f4355d9b6777bc9fc44ac3a109c52f5d304889 Author: Dmitry Stogov <dmitry@zend.com> Thu, 29 Sep 2016 10:56:01 +0300 Parents: 581e8904839e4e2417028507bb92296e8faac84d Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e7f4355d9b6777bc9fc44ac3a109c52f5d304889 Log: Better fix for bug #72854 (avoid extra copy and creating reference to stack variable) Bugs: https://bugs.php.net/72854 Changed paths: M Zend/zend_execute.c Diff: diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 2882f3d..326c719 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -576,7 +576,6 @@ static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execu static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr) { zend_reference *ref; - zval garbage; if (EXPECTED(!Z_ISREF_P(value_ptr))) { ZVAL_NEW_REF(value_ptr, value_ptr); @@ -586,9 +585,18 @@ static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *v ref = Z_REF_P(value_ptr); GC_REFCOUNT(ref)++; - ZVAL_COPY_VALUE(&garbage, variable_ptr); + if (Z_REFCOUNTED_P(variable_ptr)) { + zend_refcounted *garbage = Z_COUNTED_P(variable_ptr); + + if (--GC_REFCOUNT(garbage) == 0) { + ZVAL_REF(variable_ptr, ref); + zval_dtor_func_for_ptr(garbage); + return; + } else { + GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr); + } + } ZVAL_REF(variable_ptr, ref); - zval_ptr_dtor(&garbage); } /* this should modify object only if it's empty */

« previous php.cvs (#94779) next »