diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 8363fe247d805..aab83bce4ecfc 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -140,14 +140,12 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s src->pDestructor = orig_dtor; } -static void zend_accel_function_hash_copy(HashTable *target, HashTable *source) +static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, HashTable *source, bool call_observers) { zend_function *function1, *function2; Bucket *p, *end; zval *t; - bool call_observers = zend_observer_function_declared_observed; - zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0); p = source->arData; end = p + source->nNumUsed; @@ -164,6 +162,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source) } } target->nInternalPointer = 0; + return; failure: @@ -183,13 +182,21 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source) } } -static void zend_accel_class_hash_copy(HashTable *target, HashTable *source) +static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, HashTable *source) +{ + _zend_accel_function_hash_copy(target, source, 0); +} + +static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, HashTable *source) +{ + _zend_accel_function_hash_copy(target, source, 1); +} + +static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, HashTable *source, bool call_observers) { Bucket *p, *end; zval *t; - bool call_observers = zend_observer_class_linked_observed; - zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0); p = source->arData; end = p + source->nNumUsed; @@ -238,6 +245,16 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source) target->nInternalPointer = 0; } +static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, HashTable *source) +{ + _zend_accel_class_hash_copy(target, source, 0); +} + +static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, HashTable *source) +{ + _zend_accel_class_hash_copy(target, source, 1); +} + void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script) { zend_op_array *op_array = &persistent_script->script.main_op_array; @@ -377,11 +394,19 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, } if (zend_hash_num_elements(&persistent_script->script.function_table) > 0) { - zend_accel_function_hash_copy(CG(function_table), &persistent_script->script.function_table); + if (EXPECTED(!zend_observer_function_declared_observed)) { + zend_accel_function_hash_copy(CG(function_table), &persistent_script->script.function_table); + } else { + zend_accel_function_hash_copy_notify(CG(function_table), &persistent_script->script.function_table); + } } if (zend_hash_num_elements(&persistent_script->script.class_table) > 0) { - zend_accel_class_hash_copy(CG(class_table), &persistent_script->script.class_table); + if (EXPECTED(!zend_observer_class_linked_observed)) { + zend_accel_class_hash_copy(CG(class_table), &persistent_script->script.class_table); + } else { + zend_accel_class_hash_copy_notify(CG(class_table), &persistent_script->script.class_table); + } } if (persistent_script->num_early_bindings) {