Skip to content

Commit c188797

Browse files
committed
Setup RETURN counters for nested frames
1 parent 28b4761 commit c188797

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ struct _zend_jit_trace_stack_frame {
359359
zend_jit_trace_stack_frame *call;
360360
zend_jit_trace_stack_frame *prev;
361361
const zend_function *func;
362+
const zend_op *call_opline;
362363
uint32_t call_level;
363364
uint32_t _info;
364365
zend_jit_trace_stack stack[1];
@@ -382,6 +383,7 @@ struct _zend_jit_trace_stack_frame {
382383
_frame->call = NULL; \
383384
_frame->prev = NULL; \
384385
_frame->func = (const zend_function*)_func; \
386+
_frame->call_opline = NULL; \
385387
_frame->call_level = 0; \
386388
_frame->_info = (((uint32_t)(num_args)) << TRACE_FRAME_SHIFT_NUM_ARGS) & TRACE_FRAME_MASK_NUM_ARGS; \
387389
_frame->_info |= _flags; \

ext/opcache/jit/zend_jit_trace.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,20 +4023,24 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
40234023
call = frame->call;
40244024
assert(call && &call->func->op_array == p->op_array);
40254025

4026-
/* Check if SEND_UNPACK/SEND_ARRAY may cause enter at different opline */
4027-
if ((opline->opcode == ZEND_DO_UCALL
4028-
|| opline->opcode == ZEND_DO_FCALL_BY_NAME
4029-
|| opline->opcode == ZEND_DO_FCALL)
4030-
&& opline > op_array->opcodes
4031-
&& ((opline-1)->opcode == ZEND_SEND_ARRAY
4032-
|| (opline-1)->opcode == ZEND_SEND_UNPACK)
4033-
&& p->op_array->num_args
4034-
&& (p->op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0
4035-
&& ((p+1)->op == ZEND_JIT_TRACE_VM
4036-
|| (p+1)->op == ZEND_JIT_TRACE_END)
4037-
&& TRACE_FRAME_NUM_ARGS(call) < p->op_array->num_args
4038-
&& !zend_jit_trace_opline_guard(&dasm_state, (p+1)->opline)) {
4039-
goto jit_failure;
4026+
if (opline->opcode == ZEND_DO_UCALL
4027+
|| opline->opcode == ZEND_DO_FCALL_BY_NAME
4028+
|| opline->opcode == ZEND_DO_FCALL) {
4029+
4030+
frame->call_opline = opline;
4031+
4032+
/* Check if SEND_UNPACK/SEND_ARRAY may cause enter at different opline */
4033+
if (opline > op_array->opcodes
4034+
&& ((opline-1)->opcode == ZEND_SEND_ARRAY
4035+
|| (opline-1)->opcode == ZEND_SEND_UNPACK)
4036+
&& p->op_array->num_args
4037+
&& (p->op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0
4038+
&& ((p+1)->op == ZEND_JIT_TRACE_VM
4039+
|| (p+1)->op == ZEND_JIT_TRACE_END)
4040+
&& TRACE_FRAME_NUM_ARGS(call) < p->op_array->num_args
4041+
&& !zend_jit_trace_opline_guard(&dasm_state, (p+1)->opline)) {
4042+
goto jit_failure;
4043+
}
40404044
}
40414045

40424046
if ((p+1)->op == ZEND_JIT_TRACE_END) {
@@ -4288,6 +4292,19 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42884292
|| opline->opcode == ZEND_DO_FCALL_BY_NAME) {
42894293
zend_jit_trace_setup_ret_counter(opline, jit_extension->offset);
42904294
}
4295+
if (JIT_G(current_frame)
4296+
&& JIT_G(current_frame)->prev) {
4297+
frame = JIT_G(current_frame)->prev;
4298+
do {
4299+
if (frame->call_opline) {
4300+
op_array = &frame->func->op_array;
4301+
jit_extension =
4302+
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
4303+
zend_jit_trace_setup_ret_counter(frame->call_opline, jit_extension->offset);
4304+
}
4305+
frame = frame->prev;
4306+
} while (frame);
4307+
}
42914308
}
42924309
}
42934310

0 commit comments

Comments
 (0)