summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-02-20 13:28:26 +0300
committerDmitry Stogov <dmitry@zend.com>2015-02-20 13:28:26 +0300
commitd85113702cc6030a9149f518c55953ccb6933a7c (patch)
treed203e105d433a87050fca191298d1757d4aeeaba /Zend/zend_compile.c
parent582aa41d6fb7bf803b5d731ec9f5d6627d01c4c7 (diff)
downloadphp-git-d85113702cc6030a9149f518c55953ccb6933a7c.tar.gz
Lazy duplication of op_array->static_variables
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 36055258f6..67b6183159 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -865,7 +865,9 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
(*op_array->refcount)++;
if (op_array->static_variables) {
- op_array->static_variables = zend_array_dup(op_array->static_variables);
+ if (!(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) {
+ GC_REFCOUNT(op_array->static_variables)++;
+ }
}
op_array->run_time_cache = NULL;
} else if (function->type == ZEND_INTERNAL_FUNCTION) {
@@ -3092,6 +3094,12 @@ static void zend_compile_static_var_common(zend_ast *var_ast, zval *value, zend_
zend_hash_init(CG(active_op_array)->static_variables, 8, NULL, ZVAL_PTR_DTOR, 0);
}
+ if (GC_REFCOUNT(CG(active_op_array)->static_variables) > 1) {
+ if (!(GC_FLAGS(CG(active_op_array)->static_variables) & IS_ARRAY_IMMUTABLE)) {
+ GC_REFCOUNT(CG(active_op_array)->static_variables)--;
+ }
+ CG(active_op_array)->static_variables = zend_array_dup(CG(active_op_array)->static_variables);
+ }
zend_hash_update(CG(active_op_array)->static_variables, Z_STR(var_node.u.constant), value);
opline = zend_emit_op(&result, by_ref ? ZEND_FETCH_W : ZEND_FETCH_R, &var_node, NULL);