@@ -626,7 +626,9 @@ static void jit_SNAPSHOT(zend_jit_ctx *jit, ir_ref addr)
626626 uint32_t exit_point = 0, n = 0;
627627
628628 if (addr < 0) {
629- exit_point = zend_jit_exit_point_by_addr((void*)(uintptr_t) jit->ctx.ir_base[addr].val.u64);
629+ /* addr is not always the address of the *last* exit point,
630+ * so we can not optimize this to 'exit_point = t->exit_count-1' */
631+ exit_point = zend_jit_exit_point_by_addr(ptr);
630632 ZEND_ASSERT(exit_point != -1);
631633 if (t->exit_info[exit_point].flags & ZEND_JIT_EXIT_METHOD_CALL) {
632634 n = 2;
@@ -710,24 +712,26 @@ uint32_t zend_jit_duplicate_exit_point(ir_ctx *ctx, zend_jit_trace_info *t, uint
710712 return new_exit_point;
711713}
712714
713- zend_jit_ref_snapshot zend_jit_resolve_ref_snapshot(ir_ctx *ctx, ir_ref snapshot_ref, ir_insn *snapshot, int op)
715+ static void zend_jit_resolve_ref_snapshot(zend_jit_ref_snapshot *dest, ir_ctx *ctx, ir_ref snapshot_ref, ir_insn *snapshot, int op)
714716{
715717 int8_t *reg_ops = ctx->regs[snapshot_ref];
716718 ZEND_ASSERT(reg_ops[op] != ZREG_NONE);
717719
718- zend_jit_ref_snapshot rs = {
719- .reg = reg_ops[op],
720- };
720+ int8_t reg = reg_ops[op];
721+ int32_t offset;
721722
722- if (IR_REG_SPILLED(rs.reg)) {
723- rs.reg = ((ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FP : IR_REG_SP) | IR_REG_SPILL_LOAD;
724- rs.offset = ir_get_spill_slot_offset(ctx, ir_insn_op(snapshot, op));
723+ if (IR_REG_SPILLED(reg)) {
724+ reg = ((ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FP : IR_REG_SP) | IR_REG_SPILL_LOAD;
725+ offset = ir_get_spill_slot_offset(ctx, ir_insn_op(snapshot, op));
726+ } else {
727+ offset = 0;
725728 }
726729
727- return rs;
730+ dest->reg = reg;
731+ dest->offset = offset;
728732}
729733
730- bool zend_jit_ref_snapshot_equals(zend_jit_ref_snapshot *a, zend_jit_ref_snapshot *b)
734+ static bool zend_jit_ref_snapshot_equals(const zend_jit_ref_snapshot *a, const zend_jit_ref_snapshot *b)
731735{
732736 return a->reg == b->reg
733737 && (!IR_REG_SPILLED(a->reg) || (a->offset == b->offset));
@@ -745,8 +749,9 @@ void *zend_jit_snapshot_handler(ir_ctx *ctx, ir_ref snapshot_ref, ir_insn *snaps
745749 exit_flags = t->exit_info[exit_point].flags;
746750
747751 if (exit_flags & ZEND_JIT_EXIT_METHOD_CALL) {
748- zend_jit_ref_snapshot func = zend_jit_resolve_ref_snapshot(ctx, snapshot_ref, snapshot, n - 1);
749- zend_jit_ref_snapshot this = zend_jit_resolve_ref_snapshot(ctx, snapshot_ref, snapshot, n);
752+ zend_jit_ref_snapshot func, this;
753+ zend_jit_resolve_ref_snapshot(&func, ctx, snapshot_ref, snapshot, n - 1);
754+ zend_jit_resolve_ref_snapshot(&this, ctx, snapshot_ref, snapshot, n);
750755
751756 if ((exit_flags & ZEND_JIT_EXIT_FIXED)
752757 && (!zend_jit_ref_snapshot_equals(&t->exit_info[exit_point].poly_func, &func)
0 commit comments