diff options
| author | Nikita Popov <nikic@php.net> | 2015-12-29 11:16:08 +0100 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2015-12-29 23:14:53 +0100 |
| commit | 65e456f3649c649d8450325fc677442380911598 (patch) | |
| tree | 5328e908895f890e22eba0f3c6b05bd4624d161b /Zend/zend_closures.c | |
| parent | 4440436821404ff3c76682726e63d1aaf381f73a (diff) | |
| download | php-git-65e456f3649c649d8450325fc677442380911598.tar.gz | |
Introduce BIND_LEXICAL
This opcodes inserts a local CV into the closure static variable
table. This replaces the previous mechanism of having static
variables marked as LEXICAL, which perform a symtable lookup
during copying.
This means a) functions which contain closures no longer have to
rebuild their symtable (better performance) and b) we can now track
used variables in SSA.
Diffstat (limited to 'Zend/zend_closures.c')
| -rw-r--r-- | Zend/zend_closures.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index beca1cef07..4d3a97c0ac 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -570,11 +570,8 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent closure->func.common.prototype = (zend_function*)closure; closure->func.common.fn_flags |= ZEND_ACC_CLOSURE; if (closure->func.op_array.static_variables) { - HashTable *static_variables = closure->func.op_array.static_variables; - - ALLOC_HASHTABLE(closure->func.op_array.static_variables); - zend_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0); - zend_hash_apply_with_arguments(static_variables, zval_copy_static_var, 1, closure->func.op_array.static_variables); + closure->func.op_array.static_variables = + zend_array_dup(closure->func.op_array.static_variables); } if (UNEXPECTED(!closure->func.op_array.run_time_cache)) { closure->func.op_array.run_time_cache = func->op_array.run_time_cache = zend_arena_alloc(&CG(arena), func->op_array.cache_size); @@ -629,6 +626,14 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas } /* }}} */ +void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var) /* {{{ */ +{ + zend_closure *closure = (zend_closure *) Z_OBJ_P(closure_zv); + HashTable *static_variables = closure->func.op_array.static_variables; + zend_hash_update(static_variables, var_name, var); +} +/* }}} */ + /* * Local variables: * tab-width: 4 |
