Skip to content

Commit 8eb70cd

Browse files
committed
Revert no longer needed change to lazy class loading
1 parent 6797713 commit 8eb70cd

File tree

1 file changed

+38
-48
lines changed

1 file changed

+38
-48
lines changed

Zend/zend_inheritance.c

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,55 +2485,45 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
24852485
p = ce->function_table.arData;
24862486
end = p + ce->function_table.nNumUsed;
24872487
for (; p != end; p++) {
2488-
zend_function *func = Z_PTR(p->val);
2489-
ZEND_ASSERT(func->common.scope == pce);
2490-
ZEND_ASSERT(func->common.prototype == NULL);
2491-
if (func->type == ZEND_USER_FUNCTION) {
2492-
zend_op_array *op_array = &func->op_array, *new_op_array;
2493-
void ***run_time_cache_ptr;
2494-
size_t alloc_size;
2495-
2496-
op_array = Z_PTR(p->val);
2497-
alloc_size = sizeof(zend_op_array) + sizeof(void *);
2498-
if (op_array->static_variables) {
2499-
alloc_size += sizeof(HashTable *);
2500-
}
2501-
new_op_array = zend_arena_alloc(&CG(arena), alloc_size);
2502-
Z_PTR(p->val) = new_op_array;
2503-
memcpy(new_op_array, op_array, sizeof(zend_op_array));
2504-
run_time_cache_ptr = (void***)(new_op_array + 1);
2505-
*run_time_cache_ptr = NULL;
2506-
new_op_array->fn_flags &= ~ZEND_ACC_IMMUTABLE;
2507-
new_op_array->scope = ce;
2508-
ZEND_MAP_PTR_INIT(new_op_array->run_time_cache, run_time_cache_ptr);
2509-
if (op_array->static_variables) {
2510-
HashTable **static_variables_ptr = (HashTable **) (run_time_cache_ptr + 1);
2511-
*static_variables_ptr = NULL;
2512-
ZEND_MAP_PTR_INIT(new_op_array->static_variables_ptr, static_variables_ptr);
2513-
}
2514-
2515-
zend_update_inherited_handler(constructor);
2516-
zend_update_inherited_handler(destructor);
2517-
zend_update_inherited_handler(clone);
2518-
zend_update_inherited_handler(__get);
2519-
zend_update_inherited_handler(__set);
2520-
zend_update_inherited_handler(__call);
2521-
zend_update_inherited_handler(__isset);
2522-
zend_update_inherited_handler(__unset);
2523-
zend_update_inherited_handler(__tostring);
2524-
zend_update_inherited_handler(__callstatic);
2525-
zend_update_inherited_handler(__debugInfo);
2526-
zend_update_inherited_handler(__serialize);
2527-
zend_update_inherited_handler(__unserialize);
2528-
} else {
2529-
/* We should encounter internal methods only in enums. */
2530-
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_ENUM);
2531-
zend_internal_function *new_func =
2532-
zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
2533-
Z_PTR(p->val) = new_func;
2534-
memcpy(new_func, func, sizeof(zend_internal_function));
2535-
new_func->scope = ce;
2488+
zend_op_array *op_array, *new_op_array;
2489+
void ***run_time_cache_ptr;
2490+
size_t alloc_size;
2491+
2492+
op_array = Z_PTR(p->val);
2493+
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
2494+
ZEND_ASSERT(op_array->scope == pce);
2495+
ZEND_ASSERT(op_array->prototype == NULL);
2496+
alloc_size = sizeof(zend_op_array) + sizeof(void *);
2497+
if (op_array->static_variables) {
2498+
alloc_size += sizeof(HashTable *);
2499+
}
2500+
new_op_array = zend_arena_alloc(&CG(arena), alloc_size);
2501+
Z_PTR(p->val) = new_op_array;
2502+
memcpy(new_op_array, op_array, sizeof(zend_op_array));
2503+
run_time_cache_ptr = (void***)(new_op_array + 1);
2504+
*run_time_cache_ptr = NULL;
2505+
new_op_array->fn_flags &= ~ZEND_ACC_IMMUTABLE;
2506+
new_op_array->scope = ce;
2507+
ZEND_MAP_PTR_INIT(new_op_array->run_time_cache, run_time_cache_ptr);
2508+
if (op_array->static_variables) {
2509+
HashTable **static_variables_ptr = (HashTable **) (run_time_cache_ptr + 1);
2510+
*static_variables_ptr = NULL;
2511+
ZEND_MAP_PTR_INIT(new_op_array->static_variables_ptr, static_variables_ptr);
25362512
}
2513+
2514+
zend_update_inherited_handler(constructor);
2515+
zend_update_inherited_handler(destructor);
2516+
zend_update_inherited_handler(clone);
2517+
zend_update_inherited_handler(__get);
2518+
zend_update_inherited_handler(__set);
2519+
zend_update_inherited_handler(__call);
2520+
zend_update_inherited_handler(__isset);
2521+
zend_update_inherited_handler(__unset);
2522+
zend_update_inherited_handler(__tostring);
2523+
zend_update_inherited_handler(__callstatic);
2524+
zend_update_inherited_handler(__debugInfo);
2525+
zend_update_inherited_handler(__serialize);
2526+
zend_update_inherited_handler(__unserialize);
25372527
}
25382528
}
25392529

0 commit comments

Comments
 (0)