Skip to content

Commit fbb1ce1

Browse files
committed
Use jmp with memory operand for smaller code size
1 parent 761d0d1 commit fbb1ce1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

yjit_codegen.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,9 +2090,6 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
20902090
// Load the return value
20912091
mov(cb, REG0, ctx_stack_pop(ctx, 1));
20922092

2093-
// Load the JIT return address
2094-
mov(cb, REG1, member_opnd(REG_CFP, rb_control_frame_t, jit_return));
2095-
20962093
// Pop the current frame (ec->cfp++)
20972094
// Note: the return PC is already in the previous CFP
20982095
add(cb, REG_CFP, imm_opnd(sizeof(rb_control_frame_t)));
@@ -2104,8 +2101,9 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
21042101
mov(cb, REG_SP, member_opnd(REG_CFP, rb_control_frame_t, sp));
21052102
mov(cb, mem_opnd(64, REG_SP, -SIZEOF_VALUE), REG0);
21062103

2107-
// Jump to the JIT return address
2108-
jmp_rm(cb, REG1);
2104+
// Jump to the JIT return address in the frame that was popped
2105+
const int32_t offset_to_jit_return = -((int32_t)sizeof(rb_control_frame_t)) + (int32_t)offsetof(rb_control_frame_t, jit_return);
2106+
jmp_rm(cb, mem_opnd(64, REG_CFP, offset_to_jit_return));
21092107

21102108
return YJIT_END_BLOCK;
21112109
}

0 commit comments

Comments
 (0)