Keep trace number in EG(jit_trace_num) instead of EG(reserved)[zend_func_info_rid]

This commit is contained in:
Dmitry Stogov 2020-05-25 17:05:26 +03:00
parent 3376f19742
commit bfc56ed511
5 changed files with 8 additions and 14 deletions

View file

@ -794,9 +794,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
if (func->type == ZEND_USER_FUNCTION) { if (func->type == ZEND_USER_FUNCTION) {
int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
const zend_op *current_opline_before_exception = EG(opline_before_exception); const zend_op *current_opline_before_exception = EG(opline_before_exception);
uint32_t orig_jit_trace_num = EG(jit_trace_num);
zend_init_func_execute_data(call, &func->op_array, fci->retval); zend_init_func_execute_data(call, &func->op_array, fci->retval);
zend_execute_ex(call); zend_execute_ex(call);
EG(jit_trace_num) = orig_jit_trace_num;
EG(opline_before_exception) = current_opline_before_exception; EG(opline_before_exception) = current_opline_before_exception;
if (call_via_handler) { if (call_via_handler) {
/* We must re-initialize function again */ /* We must re-initialize function again */

View file

@ -164,6 +164,8 @@ struct _zend_executor_globals {
struct _zend_execute_data *current_execute_data; struct _zend_execute_data *current_execute_data;
zend_class_entry *fake_scope; /* used to avoid checks accessing properties */ zend_class_entry *fake_scope; /* used to avoid checks accessing properties */
uint32_t jit_trace_num; /* Used by tracing JIT to reference the currently running trace */
zend_long precision; zend_long precision;
int ticks_count; int ticks_count;

View file

@ -385,6 +385,7 @@ static int zend_jit_disasm_init(void)
REGISTER_EG(vm_stack_top); REGISTER_EG(vm_stack_top);
REGISTER_EG(vm_stack_end); REGISTER_EG(vm_stack_end);
REGISTER_EG(symbol_table); REGISTER_EG(symbol_table);
REGISTER_EG(jit_trace_num);
#undef REGISTER_EG #undef REGISTER_EG
#endif #endif

View file

@ -4994,7 +4994,7 @@ blacklist:
int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf *regs) int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf *regs)
{ {
uint32_t trace_num = (uint32_t)(uintptr_t)EG(reserved)[zend_func_info_rid]; uint32_t trace_num = EG(jit_trace_num);
zend_execute_data *execute_data = EG(current_execute_data); zend_execute_data *execute_data = EG(current_execute_data);
const zend_op *orig_opline = EX(opline); const zend_op *orig_opline = EX(opline);
const zend_op *opline; const zend_op *opline;

View file

@ -2853,8 +2853,8 @@ static int zend_jit_trace_begin(dasm_State **Dst, uint32_t trace_num)
{ {
current_trace_num = trace_num; current_trace_num = trace_num;
| //EG(reserved)[zend_func_info_rid] = trace_num; | // EG(jit_trace_num) = trace_num;
| MEM_OP2_1_ZTS mov, aword, executor_globals, reserved[zend_func_info_rid], trace_num, r0 | MEM_OP2_1_ZTS mov, dword, executor_globals, jit_trace_num, trace_num, r0
return 1; return 1;
} }
@ -8588,17 +8588,6 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| call aword [r0 + offsetof(zend_internal_function, handler)] | call aword [r0 + offsetof(zend_internal_function, handler)]
} }
if (trace) {
// TODO: This is a quick dirty fix ??????
//
// Internal function may call another trace that,
// replaces EG(trace_id) and the following side exit
// from this trace is going to be mad !!!!!!
//
// Lets set EG(trace_id) once again...
zend_jit_trace_begin(Dst, current_trace_num);
}
| // EG(current_execute_data) = execute_data; | // EG(current_execute_data) = execute_data;
| MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, FP, r0 | MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, FP, r0