ruby-changes:69248
From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:24:21 +0900 (JST)
Subject: [ruby-changes:69248] d0a213b30d (master): Remove a memory load in gen_send_iseq
https://git.ruby-lang.org/ruby.git/commit/?id=d0a213b30d From d0a213b30d04372d1a1b5012246ac7da3236db31 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Wed, 22 Sep 2021 16:11:45 -0400 Subject: Remove a memory load in gen_send_iseq Instead of loading from meory for REG_SP, do a register rename instead. It's cheaper. --- yjit_codegen.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index ac7f866d9e..e3a23b3bb8 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -3477,15 +3477,16 @@ 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#L3477 // .block_code = 0, // .__bp__ = sp, // }; - mov(cb, member_opnd(REG_CFP, rb_control_frame_t, block_code), imm_opnd(0)); + mov(cb, REG1, recv); + mov(cb, member_opnd(REG_CFP, rb_control_frame_t, self), REG1); + mov(cb, REG_SP, REG0); // Switch to the callee's REG_SP mov(cb, member_opnd(REG_CFP, rb_control_frame_t, sp), REG0); mov(cb, member_opnd(REG_CFP, rb_control_frame_t, __bp__), REG0); sub(cb, REG0, imm_opnd(sizeof(VALUE))); mov(cb, member_opnd(REG_CFP, rb_control_frame_t, ep), REG0); - mov(cb, REG0, recv); - mov(cb, member_opnd(REG_CFP, rb_control_frame_t, self), REG0); jit_mov_gc_ptr(jit, cb, REG0, (VALUE)iseq); mov(cb, member_opnd(REG_CFP, rb_control_frame_t, iseq), REG0); + mov(cb, member_opnd(REG_CFP, rb_control_frame_t, block_code), imm_opnd(0)); // No need to set cfp->pc since the callee sets it whenever calling into routines // that could look at it through jit_save_pc(). @@ -3532,9 +3533,6 @@ 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#L3533 //print_str(cb, "calling Ruby func:"); //print_str(cb, rb_id2name(vm_ci_mid(ci))); - // Load the updated SP from the CFP - mov(cb, REG_SP, member_opnd(REG_CFP, rb_control_frame_t, sp)); - // Directly jump to the entry point of the callee gen_direct_jump( jit, -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/