[前][次][番号順一覧][スレッド一覧]

ruby-changes:69011

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:16:34 +0900 (JST)
Subject: [ruby-changes:69011] 10c0275b11 (master): Use jmp with memory operand for smaller code size

https://git.ruby-lang.org/ruby.git/commit/?id=10c0275b11

From 10c0275b114d05631e649caaf7b2ddce893b5692 Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Mon, 19 Apr 2021 18:50:56 -0400
Subject: Use jmp with memory operand for smaller code size

---
 yjit_codegen.c | 8 +++-----
 1 file 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) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2090
     // 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) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2101
     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;
 }
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]