Skip to content

Commit 31d75ea

Browse files
committed
Use jmp with memory operand for smaller code size
1 parent 439744d commit 31d75ea

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

yjit_codegen.c

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

2022-
// Load the JIT return address
2023-
mov(cb, REG1, member_opnd(REG_CFP, rb_control_frame_t, jit_return));
2024-
20252022
// Pop the current frame (ec->cfp++)
20262023
// Note: the return PC is already in the previous CFP
20272024
add(cb, REG_CFP, imm_opnd(sizeof(rb_control_frame_t)));
@@ -2033,8 +2030,9 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
20332030
mov(cb, REG_SP, member_opnd(REG_CFP, rb_control_frame_t, sp));
20342031
mov(cb, mem_opnd(64, REG_SP, -SIZEOF_VALUE), REG0);
20352032

2036-
// Jump to the JIT return address
2037-
jmp_rm(cb, REG1);
2033+
// Jump to the JIT return address in the frame that was popped
2034+
const int32_t offset_to_jit_return = -((int32_t)sizeof(rb_control_frame_t)) + (int32_t)offsetof(rb_control_frame_t, jit_return);
2035+
jmp_rm(cb, mem_opnd(64, REG_CFP, offset_to_jit_return));
20382036

20392037
return YJIT_END_BLOCK;
20402038
}

0 commit comments

Comments
 (0)