Don't call zend_attach/detach_symbol_table() for op_arrays without local variables

This commit is contained in:
Dmitry Stogov 2021-12-16 17:37:01 +03:00
parent 3a3eeb4f83
commit 79fac32d6b
3 changed files with 36 additions and 13 deletions

View file

@ -3839,7 +3839,9 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
EX(call) = NULL;
EX(return_value) = return_value;
if (op_array->last_var) {
zend_attach_symbol_table(execute_data);
}
if (!ZEND_MAP_PTR(op_array->run_time_cache)) {
void *ptr;

View file

@ -2863,7 +2863,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
LOAD_NEXT_OPLINE();
ZEND_VM_LEAVE();
} else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) {
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
zend_destroy_static_vars(&EX(func)->op_array);
destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array));
@ -2874,7 +2876,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
if (EX(func)->op_array.last_var > 0) {
zend_attach_symbol_table(execute_data);
}
if (UNEXPECTED(EG(exception) != NULL)) {
zend_rethrow_exception(execute_data);
HANDLE_EXCEPTION_LEAVE();
@ -2905,11 +2909,14 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
} else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
zend_array *symbol_table = EX(symbol_table);
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
old_execute_data = EX(prev_execute_data);
while (old_execute_data) {
if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
if (old_execute_data->symbol_table == symbol_table) {
if (old_execute_data->symbol_table == symbol_table
&& old_execute_data->func->op_array.last_var > 0) {
zend_attach_symbol_table(old_execute_data);
}
break;

View file

@ -1145,7 +1145,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper
LOAD_NEXT_OPLINE();
ZEND_VM_LEAVE();
} else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) {
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
zend_destroy_static_vars(&EX(func)->op_array);
destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array));
@ -1156,7 +1158,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper
execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
if (EX(func)->op_array.last_var > 0) {
zend_attach_symbol_table(execute_data);
}
if (UNEXPECTED(EG(exception) != NULL)) {
zend_rethrow_exception(execute_data);
HANDLE_EXCEPTION_LEAVE();
@ -1187,11 +1191,14 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper
} else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
zend_array *symbol_table = EX(symbol_table);
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
old_execute_data = EX(prev_execute_data);
while (old_execute_data) {
if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
if (old_execute_data->symbol_table == symbol_table) {
if (old_execute_data->symbol_table == symbol_table
&& old_execute_data->func->op_array.last_var > 0) {
zend_attach_symbol_table(old_execute_data);
}
break;
@ -55398,7 +55405,9 @@ zend_leave_helper_SPEC_LABEL:
LOAD_NEXT_OPLINE();
ZEND_VM_LEAVE();
} else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) {
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
zend_destroy_static_vars(&EX(func)->op_array);
destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array));
@ -55409,7 +55418,9 @@ zend_leave_helper_SPEC_LABEL:
execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
if (EX(func)->op_array.last_var > 0) {
zend_attach_symbol_table(execute_data);
}
if (UNEXPECTED(EG(exception) != NULL)) {
zend_rethrow_exception(execute_data);
HANDLE_EXCEPTION_LEAVE();
@ -55440,11 +55451,14 @@ zend_leave_helper_SPEC_LABEL:
} else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
zend_array *symbol_table = EX(symbol_table);
if (EX(func)->op_array.last_var > 0) {
zend_detach_symbol_table(execute_data);
}
old_execute_data = EX(prev_execute_data);
while (old_execute_data) {
if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
if (old_execute_data->symbol_table == symbol_table) {
if (old_execute_data->symbol_table == symbol_table
&& old_execute_data->func->op_array.last_var > 0) {
zend_attach_symbol_table(old_execute_data);
}
break;