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

ruby-changes:69050

From: Aaron <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:39 +0900 (JST)
Subject: [ruby-changes:69050] 0fdcdd267f (master): fix alignment

https://git.ruby-lang.org/ruby.git/commit/?id=0fdcdd267f

From 0fdcdd267f7c3a482467f60e00049b88da1ae88c Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 13 Jul 2021 16:04:56 -0700
Subject: fix alignment

---
 yjit_codegen.c | 10 +++-------
 yjit_core.c    |  2 --
 yjit_utils.c   |  4 ++++
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 25d265432d..0ee795129a 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -238,14 +238,12 @@ yjit_save_regs(codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L238
     push(cb, REG_CFP);
     push(cb, REG_EC);
     push(cb, REG_SP);
-    push(cb, REG_SP); // Maintain 16-byte RSP alignment
 }
 
 // Restore YJIT registers after a C call
 static void
 yjit_load_regs(codeblock_t* cb)
 {
-    pop(cb, REG_SP); // Maintain 16-byte RSP alignment
     pop(cb, REG_SP);
     pop(cb, REG_EC);
     pop(cb, REG_CFP);
@@ -2717,11 +2715,9 @@ gen_send_cfunc(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2715
     // Pop the C function arguments from the stack (in the caller)
     ctx_stack_pop(ctx, argc + 1);
 
-    if (block) {
-        // Write interpreter SP into CFP.
-        // Needed in case the callee yields to the block.
-        jit_save_sp(jit, ctx);
-    }
+    // Write interpreter SP into CFP.
+    // Needed in case the callee yields to the block.
+    jit_save_sp(jit, ctx);
 
     // Save YJIT registers
     yjit_save_regs(cb);
diff --git a/yjit_core.c b/yjit_core.c
index ae771fb7c4..22527e24a6 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -675,7 +675,6 @@ uint8_t* get_branch_target( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L675
     push(ocb, REG_CFP);
     push(ocb, REG_EC);
     push(ocb, REG_SP);
-    push(ocb, REG_SP);
 
     // Call branch_stub_hit(branch_idx, target_idx, ec)
     mov(ocb, C_ARG_REGS[2], REG_EC);
@@ -685,7 +684,6 @@ uint8_t* get_branch_target( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L684
 
     // Restore the yjit registers
     pop(ocb, REG_SP);
-    pop(ocb, REG_SP);
     pop(ocb, REG_EC);
     pop(ocb, REG_CFP);
 
diff --git a/yjit_utils.c b/yjit_utils.c
index 02e5dbb3b0..4e764f0aea 100644
--- a/yjit_utils.c
+++ b/yjit_utils.c
@@ -95,9 +95,13 @@ void print_str(codeblock_t* cb, const char* str) https://github.com/ruby/ruby/blob/trunk/yjit_utils.c#L95
         cb_write_byte(cb, (uint8_t)str[i]);
     cb_write_byte(cb, 0);
 
+    push(cb, RSP); // Alignment
+
     // Call the print function
     mov(cb, RAX, const_ptr_opnd((void*)&print_str_cfun));
     call(cb, RAX);
 
+    pop(cb, RSP); // Alignment
+
     pop_regs(cb);
 }
-- 
cgit v1.2.1


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

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