Skip to content

Commit d2d5738

Browse files
committed
Fixed tracing JIT support for ZEND_RETURN_BY_REF in CALL VM
1 parent 0bf2bfc commit d2d5738

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int zend_may_overflow(const zend_op *opline, const zend_op_array *op_arra
111111
static void ZEND_FASTCALL zend_runtime_jit(void);
112112

113113
static int zend_jit_trace_op_len(const zend_op *opline);
114-
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline, zend_jit_trace_rec *trace);
114+
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline);
115115
static uint32_t zend_jit_trace_get_exit_point(const zend_op *from_opline, const zend_op *to_opline, zend_jit_trace_rec *trace, uint32_t flags);
116116
static const void *zend_jit_trace_get_exit_addr(uint32_t n);
117117
static void zend_jit_trace_add_code(const void *start, uint32_t size);

ext/opcache/jit/zend_jit_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static zend_string *zend_jit_trace_name(const zend_op_array *op_array, uint32_t
240240
return buf.s;
241241
}
242242

243-
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline, zend_jit_trace_rec *trace)
243+
static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline)
244244
{
245245
switch (opline->opcode) {
246246
case ZEND_IS_IDENTICAL:

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,18 +3148,24 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
31483148
zend_jit_check_exception(Dst);
31493149
}
31503150

3151-
if (!GCC_GLOBAL_REGS) {
3151+
while (trace->op != ZEND_JIT_TRACE_VM && trace->op != ZEND_JIT_TRACE_END) {
3152+
trace++;
3153+
}
3154+
3155+
if (!GCC_GLOBAL_REGS
3156+
&& (trace->op != ZEND_JIT_TRACE_END || trace->stop != ZEND_JIT_TRACE_STOP_RETURN)) {
31523157
if (opline->opcode == ZEND_RETURN ||
3158+
opline->opcode == ZEND_RETURN_BY_REF ||
31533159
opline->opcode == ZEND_DO_UCALL ||
31543160
opline->opcode == ZEND_DO_FCALL_BY_NAME ||
31553161
opline->opcode == ZEND_DO_FCALL) {
31563162
| MEM_OP2_2_ZTS mov, FP, aword, executor_globals, current_execute_data, r0
31573163
}
31583164
}
31593165

3160-
if (zend_jit_trace_may_exit(op_array, opline, trace)) {
3166+
if (zend_jit_trace_may_exit(op_array, opline)) {
31613167
// TODO: try to avoid this check ???
3162-
if (opline->opcode == ZEND_RETURN) {
3168+
if (opline->opcode == ZEND_RETURN || opline->opcode == ZEND_RETURN_BY_REF) {
31633169
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
31643170
| cmp IP, zend_jit_halt_op
31653171
| je ->trace_halt
@@ -3171,9 +3177,6 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
31713177
| jl ->trace_halt
31723178
}
31733179
}
3174-
while (trace->op != ZEND_JIT_TRACE_VM && trace->op != ZEND_JIT_TRACE_END) {
3175-
trace++;
3176-
}
31773180
if (trace->op != ZEND_JIT_TRACE_END || trace->stop != ZEND_JIT_TRACE_STOP_RETURN) {
31783181
const zend_op *next_opline = trace->opline;
31793182
const zend_op *exit_opline = NULL;
@@ -3221,25 +3224,6 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
32213224
| CMP_IP next_opline
32223225
| jne &exit_addr
32233226
}
3224-
} else {
3225-
while (trace->op != ZEND_JIT_TRACE_VM && trace->op != ZEND_JIT_TRACE_END) {
3226-
trace++;
3227-
}
3228-
// TODO: remove this ???
3229-
if (opline->opcode == ZEND_RETURN
3230-
&& trace->op == ZEND_JIT_TRACE_END
3231-
&& trace->stop == ZEND_JIT_TRACE_STOP_RETURN) {
3232-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
3233-
| cmp IP, zend_jit_halt_op
3234-
| je ->trace_halt
3235-
} else if (GCC_GLOBAL_REGS) {
3236-
| test IP, IP
3237-
| je ->trace_halt
3238-
} else {
3239-
| test eax, eax
3240-
| jl ->trace_halt
3241-
}
3242-
}
32433227
}
32443228

32453229
last_valid_opline = trace->opline;

0 commit comments

Comments
 (0)