Skip to content

Commit ad3c920

Browse files
committed
Fix zend_jit_leave_func
1 parent 54cd812 commit ad3c920

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

ext/opcache/jit/zend_jit_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ extern const zend_op *zend_jit_halt_op;
201201
return; \
202202
} while(0)
203203
# define ZEND_VM_ENTER_BIT 0
204-
# define ZEND_VM_RETURN_VAL 0
204+
# define ZEND_VM_RETURN_VAL 0
205205
#else
206206
# define EXECUTE_DATA_D zend_execute_data* execute_data
207207
# define EXECUTE_DATA_C execute_data

ext/opcache/jit/zend_jit_ir.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -11091,7 +11091,8 @@ static int zend_jit_leave_func(zend_jit_ctx *jit,
1109111091
} else if (GCC_GLOBAL_REGS) {
1109211092
ir_GUARD(jit_IP(jit), jit_STUB_ADDR(jit, jit_stub_trace_halt));
1109311093
} else {
11094-
ir_GUARD(ir_LT(ref, ir_CONST_I32(0)), jit_STUB_ADDR(jit, jit_stub_trace_halt));
11094+
ir_GUARD(ir_NE(ref, ir_CONST_ADDR(ZEND_VM_RETURN_VAL)), jit_STUB_ADDR(jit, jit_stub_trace_halt));
11095+
jit_LOAD_IP(jit, ref);
1109511096
}
1109611097
}
1109711098

ext/opcache/jit/zend_jit_vm_helpers.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_leave_top_func_helper(ZEND_OPCODE
105105
#ifdef HAVE_GCC_GLOBAL_REGS
106106
opline = zend_jit_halt_op;
107107
#else
108-
return NULL; // ZEND_VM_RETURN
108+
return (const zend_op*)ZEND_VM_RETURN_VAL; // ZEND_VM_RETURN
109109
#endif
110110
}
111111

@@ -364,15 +364,15 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_trace_c
364364
opline = NULL;
365365
return;
366366
#else
367-
return NULL; // ZEND_VM_RETURN()
367+
return (const zend_op*)ZEND_VM_RETURN_VAL; // ZEND_VM_RETURN()
368368
#endif
369369
}
370370
execute_data = EG(current_execute_data);
371371
opline = execute_data ? EX(opline) : NULL;
372372
#ifdef HAVE_GCC_GLOBAL_REGS
373373
return;
374374
#else
375-
return opline ? (zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT) : NULL; // ZEND_VM_ENTER() : ZEND_VM_RETURN()
375+
return (const zend_op*)((uintptr_t)opline | ZEND_VM_ENTER_BIT); // ZEND_VM_ENTER() / ZEND_VM_RETURN()
376376
#endif
377377
} else {
378378
zend_vm_opcode_handler_t handler = (zend_vm_opcode_handler_t)ZEND_OP_TRACE_INFO(opline, offset)->orig_handler;
@@ -942,7 +942,12 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
942942
if (UNEXPECTED(execute_data != prev_execute_data)) {
943943
#else
944944
opline = handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
945+
# ifdef ZEND_HIGH_HALF_KERNEL
945946
if ((intptr_t)opline <= 0) {
947+
# else
948+
if ((uintptr_t)opline & ZEND_VM_ENTER_BIT) {
949+
# endif
950+
opline = (const zend_op*)((uintptr_t)opline & ~ZEND_VM_ENTER_BIT);
946951
if (opline == NULL) {
947952
stop = ZEND_JIT_TRACE_STOP_RETURN;
948953
opline = NULL;
@@ -952,7 +957,6 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
952957
/* return after interrupt handler */
953958
ZEND_ASSERT(0 && "TODO");
954959
}
955-
opline = (zend_op*)((uintptr_t)opline & ~ZEND_VM_ENTER_BIT);
956960
execute_data = EG(current_execute_data);
957961
#endif
958962

0 commit comments

Comments
 (0)