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

ruby-changes:69079

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:46 +0900 (JST)
Subject: [ruby-changes:69079] 595fdf8d66 (master): Assign directly to C_ARG_REGS now when possible

https://git.ruby-lang.org/ruby.git/commit/?id=595fdf8d66

From 595fdf8d669da043fd0ca4bed7cb0c593595a80c Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Mon, 9 Aug 2021 23:49:44 -0700
Subject: Assign directly to C_ARG_REGS now when possible

---
 yjit_codegen.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index b828c5f532..b4733ef1ee 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1531,7 +1531,6 @@ gen_setinstancevariable(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1531
     x86opnd_t val_opnd = ctx_stack_pop(ctx, 1);
 
     // Call rb_vm_setinstancevariable(iseq, obj, id, val, ic);
-    // Out of order because we're going to corrupt REG_SP and REG_CFP
     mov(cb, C_ARG_REGS[1], member_opnd(REG_CFP, rb_control_frame_t, self));
     mov(cb, C_ARG_REGS[3], val_opnd);
     mov(cb, C_ARG_REGS[2], imm_opnd(id));
@@ -1584,14 +1583,11 @@ gen_defined(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1583
     x86opnd_t v_opnd = ctx_stack_pop(ctx, 1);
 
     // Call vm_defined(ec, reg_cfp, op_type, obj, v)
-    // Out of order because we're going to corrupt REG_SP and REG_CFP
-    yjit_save_regs(cb);
-    mov(cb, R9, REG_CFP);
     mov(cb, C_ARG_REGS[0], REG_EC);
-    mov(cb, C_ARG_REGS[1], R9);
-    mov(cb, C_ARG_REGS[4], v_opnd); // depends on REG_SP
-    mov(cb, C_ARG_REGS[2], imm_opnd(op_type)); // clobers REG_SP
+    mov(cb, C_ARG_REGS[1], REG_CFP);
+    mov(cb, C_ARG_REGS[2], imm_opnd(op_type));
     jit_mov_gc_ptr(jit, cb, C_ARG_REGS[3], (VALUE)obj);
+    mov(cb, C_ARG_REGS[4], v_opnd);
     call_ptr(cb, REG0, (void *)rb_vm_defined);
 
     // if (vm_defined(ec, GET_CFP(), op_type, obj, v)) {
@@ -1948,14 +1944,12 @@ gen_opt_aref(jitstate_t *jit, ctx_t *ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1944
             jit_save_pc(jit, REG0);
 
             // About to change REG_SP which these operands depend on. Yikes.
-            mov(cb, R8, recv_opnd);
-            mov(cb, R9, idx_opnd);
+            mov(cb, C_ARG_REGS[0], recv_opnd);
+            mov(cb, C_ARG_REGS[1], idx_opnd);
 
             // Write sp to cfp->sp since rb_hash_aref might need to call #hash on the key
             jit_save_sp(jit, ctx);
 
-            mov(cb, C_ARG_REGS[0], R8);
-            mov(cb, C_ARG_REGS[1], R9);
             call_ptr(cb, REG0, (void *)rb_hash_aref);
 
             // Push the return value onto the stack
@@ -2961,15 +2955,12 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2955
     if (leaf_builtin && !block && leaf_builtin->argc + 1 <= NUM_C_ARG_REGS) {
         ADD_COMMENT(cb, "inlined leaf builtin");
 
-        // Get a pointer to the top of the stack
-        lea(cb, REG0, ctx_stack_opnd(ctx, 0));
-
         // Call the builtin func (ec, recv, arg1, arg2, ...)
         mov(cb, C_ARG_REGS[0], REG_EC);
 
         // Copy self and arguments
         for (int32_t i = 0; i < leaf_builtin->argc + 1; i++) {
-            x86opnd_t stack_opnd = mem_opnd(64, REG0, -(leaf_builtin->argc - i) * SIZEOF_VALUE);
+            x86opnd_t stack_opnd = ctx_stack_opnd(ctx, leaf_builtin->argc - i);
             x86opnd_t c_arg_reg = C_ARG_REGS[i + 1];
             mov(cb, c_arg_reg, stack_opnd);
         }
@@ -3613,12 +3604,9 @@ gen_opt_invokebuiltin_delegate(jitstate_t *jit, ctx_t *ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3604
         mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, ep));
     }
 
-    // Save self from CFP
-    mov(cb, REG1, member_opnd(REG_CFP, rb_control_frame_t, self));
-
     // Call the builtin func (ec, recv, arg1, arg2, ...)
-    mov(cb, C_ARG_REGS[0], REG_EC); // clobbers REG_CFP
-    mov(cb, C_ARG_REGS[1], REG1); // self, clobbers REG_EC
+    mov(cb, C_ARG_REGS[0], REG_EC);
+    mov(cb, C_ARG_REGS[1], member_opnd(REG_CFP, rb_control_frame_t, self));
 
     // Copy arguments from locals
     for (int32_t i = 0; i < bf->argc; i++) {
-- 
cgit v1.2.1


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

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