Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
# define ZREG_FP 14 /* IR_REG_R14 */
# define ZREG_IP 15 /* IR_REG_R15 */
# endif
# if defined(__linux__) && defined(__LP64__)
/* IR_EXITCALL saves both registers. Use one that the VM does not use for FP or IP. */
# if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
# define ZREG_TRACE_NUM 12 /* IR_REG_R12 */
# elif ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL
# define ZREG_TRACE_NUM 14 /* IR_REG_R14 */
# endif
# endif
# define ZREG_FIRST_FPR 16
# if defined(_WIN64)
# define IR_REGSET_PRESERVED ((1<<3) | (1<<5) | (1<<6) | (1<<7) | (1<<12) | (1<<13) | (1<<14) | (1<<15))
Expand All @@ -68,6 +76,11 @@
# define ZREG_FP 27 /* IR_REG_X27 */
# define ZREG_IP 28 /* IR_REG_X28 */
# endif
# if defined(__linux__) && defined(__LP64__) \
&& (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID || ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL)
/* X22 is callee-saved, captured by IR_EXITCALL. */
# define ZREG_TRACE_NUM 22 /* IR_REG_X22 */
# endif
# define ZREG_FIRST_FPR 32
# define IR_REGSET_PRESERVED ((1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23) | \
(1<<24) | (1<<25) | (1<<26) | (1<<27) | (1<<28)) /* all preserved registers */
Expand Down Expand Up @@ -2498,6 +2511,11 @@ static int zend_jit_trace_exit_stub(zend_jit_ctx *jit)
{
ir_ref ref, ret, if_zero, addr;

#ifdef ZREG_TRACE_NUM
/* Keep the trace number intact until IR_EXITCALL captures the registers. */
jit->ctx.fixed_regset |= 1u << ZREG_TRACE_NUM;
#endif

// EX(opline) = opline
ir_STORE(jit_EX(opline), jit_IP(jit));

Expand Down Expand Up @@ -17706,7 +17724,12 @@ static int zend_jit_trace_start(zend_jit_ctx *jit,

zend_jit_preserve_parent_regs(jit, ssa, parent, exit_num);

#ifdef ZREG_TRACE_NUM
jit->ctx.fixed_regset |= 1u << ZREG_TRACE_NUM;
ir_RSTORE(ZREG_TRACE_NUM, ir_CONST_U32(trace_num));
#else
ir_STORE(jit_EG(jit_trace_num), ir_CONST_U32(trace_num));
#endif

return 1;
}
Expand Down
4 changes: 4 additions & 0 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -8759,7 +8759,11 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3

int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf *regs)
{
#ifdef ZREG_TRACE_NUM
uint32_t trace_num = (uint32_t) regs->gpr[ZREG_TRACE_NUM];
#else
uint32_t trace_num = EG(jit_trace_num);
#endif
zend_execute_data *execute_data = EG(current_execute_data);
const zend_op *orig_opline = EX(opline);
const zend_op *opline;
Expand Down
Loading