summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-05-25 17:05:26 +0300
committerDmitry Stogov <dmitry@zend.com>2020-05-25 17:05:26 +0300
commitbfc56ed511dd2d9bc03111149b58ee708c33743c (patch)
treea34d598722546575c4e9802407fe1847c2754173
parent3376f19742cc68448a26404df98f709f5255a262 (diff)
downloadphp-git-bfc56ed511dd2d9bc03111149b58ee708c33743c.tar.gz
Keep trace number in EG(jit_trace_num) instead of EG(reserved)[zend_func_info_rid]
-rw-r--r--Zend/zend_execute_API.c2
-rw-r--r--Zend/zend_globals.h2
-rw-r--r--ext/opcache/jit/zend_jit_disasm_x86.c1
-rw-r--r--ext/opcache/jit/zend_jit_trace.c2
-rw-r--r--ext/opcache/jit/zend_jit_x86.dasc15
5 files changed, 8 insertions, 14 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 6986841db2..1b48bed125 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -794,9 +794,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
if (func->type == ZEND_USER_FUNCTION) {
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);
+ uint32_t orig_jit_trace_num = EG(jit_trace_num);
zend_init_func_execute_data(call, &func->op_array, fci->retval);
zend_execute_ex(call);
+ EG(jit_trace_num) = orig_jit_trace_num;
EG(opline_before_exception) = current_opline_before_exception;
if (call_via_handler) {
/* We must re-initialize function again */
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 298c22fe61..1d64d001f6 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -164,6 +164,8 @@ struct _zend_executor_globals {
struct _zend_execute_data *current_execute_data;
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;
int ticks_count;
diff --git a/ext/opcache/jit/zend_jit_disasm_x86.c b/ext/opcache/jit/zend_jit_disasm_x86.c
index 97937f5afc..f94bf1af3a 100644
--- a/ext/opcache/jit/zend_jit_disasm_x86.c
+++ b/ext/opcache/jit/zend_jit_disasm_x86.c
@@ -385,6 +385,7 @@ static int zend_jit_disasm_init(void)
REGISTER_EG(vm_stack_top);
REGISTER_EG(vm_stack_end);
REGISTER_EG(symbol_table);
+ REGISTER_EG(jit_trace_num);
#undef REGISTER_EG
#endif
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index d438b09bc1..7279e52086 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -4994,7 +4994,7 @@ blacklist:
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);
const zend_op *orig_opline = EX(opline);
const zend_op *opline;
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 0d0ec990b1..867ffbd74b 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -2853,8 +2853,8 @@ static int zend_jit_trace_begin(dasm_State **Dst, uint32_t trace_num)
{
current_trace_num = trace_num;
- | //EG(reserved)[zend_func_info_rid] = trace_num;
- | MEM_OP2_1_ZTS mov, aword, executor_globals, reserved[zend_func_info_rid], trace_num, r0
+ | // EG(jit_trace_num) = trace_num;
+ | MEM_OP2_1_ZTS mov, dword, executor_globals, jit_trace_num, trace_num, r0
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)]
}
- 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;
| MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, FP, r0