mirror of
https://github.com/php/php-src.git
synced 2026-04-01 05:02:27 +02:00
Preloading: Don't move conditional functions to back to scripts
Conditional function declaration may be referenced by functions or classes that have been preloaded, so we should not move them back to scripts. What we probably should be doing though is to discard conditional functions that are not used in the optimizer. This is probably reasonably common for polyfills, where we will be able to const-eval the conditions and drop the BBs declaring the functions, but won't delete the function declarations themselves.
This commit is contained in:
@@ -3596,7 +3596,6 @@ static void preload_link(void)
|
||||
zend_string *key;
|
||||
zend_bool found, changed;
|
||||
uint32_t i;
|
||||
zend_op_array *op_array;
|
||||
dtor_func_t orig_dtor;
|
||||
zend_function *function;
|
||||
|
||||
@@ -3790,28 +3789,6 @@ static void preload_link(void)
|
||||
EG(class_table)->pDestructor = orig_dtor;
|
||||
zend_hash_rehash(EG(class_table));
|
||||
|
||||
/* Move run-time declared functions back to scripts */
|
||||
orig_dtor = EG(function_table)->pDestructor;
|
||||
EG(function_table)->pDestructor = NULL;
|
||||
ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(EG(function_table), key, zv) {
|
||||
op_array = Z_PTR_P(zv);
|
||||
if (op_array->type == ZEND_INTERNAL_FUNCTION) {
|
||||
break;
|
||||
}
|
||||
if (op_array->fn_flags & (ZEND_ACC_TOP_LEVEL|ZEND_ACC_CLOSURE)) {
|
||||
continue;
|
||||
}
|
||||
script = zend_hash_find_ptr(preload_scripts, op_array->filename);
|
||||
ZEND_ASSERT(script);
|
||||
zend_hash_add(&script->script.function_table, key, zv);
|
||||
ZVAL_UNDEF(zv);
|
||||
zend_string_release(key);
|
||||
EG(function_table)->nNumOfElements--;
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
EG(function_table)->pDestructor = orig_dtor;
|
||||
zend_hash_rehash(EG(function_table));
|
||||
|
||||
|
||||
/* Remove DECLARE opcodes */
|
||||
ZEND_HASH_FOREACH_PTR(preload_scripts, script) {
|
||||
zend_op_array *op_array = &script->script.main_op_array;
|
||||
|
||||
Reference in New Issue
Block a user