Skip to content

Commit e5b7fc0

Browse files
committed
Expose the origin of exit points in zend_jit_dump_exit_info()
1 parent d246584 commit e5b7fc0

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(Z
106106

107107
static int zend_jit_trace_op_len(const zend_op *opline);
108108
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline);
109-
static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags);
109+
static uint32_t _zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags ZEND_FILE_LINE_DC);
110+
#define zend_jit_trace_get_exit_point(to_opline, flags) _zend_jit_trace_get_exit_point(to_opline, flags ZEND_FILE_LINE_CC)
110111
static const void *zend_jit_trace_get_exit_addr(uint32_t n);
111112
static void zend_jit_trace_add_code(const void *start, uint32_t size);
112113
static zend_string *zend_jit_func_name(const zend_op_array *op_array);

ext/opcache/jit/zend_jit_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ typedef struct _zend_jit_trace_exit_info {
456456
uint32_t stack_offset;
457457
zend_jit_ref_snapshot poly_func;
458458
zend_jit_ref_snapshot poly_this;
459+
#if ZEND_DEBUG
460+
const char *filename;
461+
int lineno;
462+
#endif
459463
} zend_jit_trace_exit_info;
460464

461465
typedef struct _zend_jit_trace_stack {

ext/opcache/jit/zend_jit_trace.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static uint32_t zend_jit_exit_point_by_addr(const void *addr)
132132
return (uint32_t)-1;
133133
}
134134

135-
static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags)
135+
static uint32_t _zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags ZEND_FILE_LINE_DC)
136136
{
137137
zend_jit_trace_info *t = &zend_jit_traces[ZEND_JIT_TRACE_NUM];
138138
uint32_t exit_point;
@@ -178,7 +178,12 @@ static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t
178178
&& memcmp(t->stack_map + t->exit_info[i].stack_offset, stack, stack_size * sizeof(zend_jit_trace_stack)) == 0)) {
179179
if (t->exit_info[i].opline == to_opline
180180
&& t->exit_info[i].flags == flags
181-
&& t->exit_info[i].stack_size == stack_size) {
181+
&& t->exit_info[i].stack_size == stack_size
182+
#if ZEND_DEBUG
183+
&& strcmp(t->exit_info[i].filename, __zend_filename) == 0
184+
&& t->exit_info[i].lineno == __zend_lineno
185+
#endif
186+
) {
182187
return i;
183188
}
184189
}
@@ -202,6 +207,10 @@ static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t
202207
t->exit_info[exit_point].stack_offset = stack_offset;
203208
t->exit_info[exit_point].poly_func = (zend_jit_ref_snapshot){.reg = ZREG_NONE};
204209
t->exit_info[exit_point].poly_this = (zend_jit_ref_snapshot){.reg = ZREG_NONE};
210+
#if ZEND_DEBUG
211+
t->exit_info[exit_point].filename = __zend_filename;
212+
t->exit_info[exit_point].lineno = __zend_lineno;
213+
#endif
205214
}
206215

207216
return exit_point;
@@ -8096,6 +8105,9 @@ static void zend_jit_dump_exit_info(zend_jit_trace_info *t)
80968105
fprintf(stderr, ":unknown(zval_copy(%s))", zend_reg_name(STACK_REG(stack, j)));
80978106
}
80988107
}
8108+
#if ZEND_DEBUG
8109+
fprintf(stderr, " %s:%d", t->exit_info[i].filename, t->exit_info[i].lineno);
8110+
#endif
80998111
fprintf(stderr, "\n");
81008112
}
81018113
}

0 commit comments

Comments
 (0)