summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorAlan Wu <[email protected]>2021-04-19 18:50:56 -0400
committerAlan Wu <[email protected]>2021-10-20 18:19:34 -0400
commit10c0275b114d05631e649caaf7b2ddce893b5692 (patch)
treeb77cc6806f98c812a32e4754dd5fc9bbbd534268 /yjit_codegen.c
parent1610dc0864a330006085ac9e9d6428b89d6c0ccd (diff)
Use jmp with memory operand for smaller code size
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 39a2667f5d..f52de12bf2 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -2090,9 +2090,6 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
// Load the return value
mov(cb, REG0, ctx_stack_pop(ctx, 1));
- // Load the JIT return address
- mov(cb, REG1, member_opnd(REG_CFP, rb_control_frame_t, jit_return));
-
// Pop the current frame (ec->cfp++)
// Note: the return PC is already in the previous CFP
add(cb, REG_CFP, imm_opnd(sizeof(rb_control_frame_t)));
@@ -2104,8 +2101,9 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
mov(cb, REG_SP, member_opnd(REG_CFP, rb_control_frame_t, sp));
mov(cb, mem_opnd(64, REG_SP, -SIZEOF_VALUE), REG0);
- // Jump to the JIT return address
- jmp_rm(cb, REG1);
+ // Jump to the JIT return address in the frame that was popped
+ const int32_t offset_to_jit_return = -((int32_t)sizeof(rb_control_frame_t)) + (int32_t)offsetof(rb_control_frame_t, jit_return);
+ jmp_rm(cb, mem_opnd(64, REG_CFP, offset_to_jit_return));
return YJIT_END_BLOCK;
}