ruby-changes:69003
From: Kevin <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:39 +0900 (JST)
Subject: [ruby-changes:69003] b0ae4fdcfb (master): Implement opt_mult
https://git.ruby-lang.org/ruby.git/commit/?id=b0ae4fdcfb From b0ae4fdcfbe0004908adcc44f0ae0e3a3762917b Mon Sep 17 00:00:00 2001 From: Kevin Deisz <kevin.deisz@g...> Date: Tue, 6 Jul 2021 14:45:36 -0400 Subject: Implement opt_mult Basically the same thing as opt_mod, but for multiplying. --- bootstraptest/test_yjit.rb | 10 ++++++++++ yjit_codegen.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 4bf9bc4262..14b901fbf1 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -26,6 +26,16 @@ assert_equal '2', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L26 mod(7, 5) } +# Test for opt_mult +assert_equal '12', %q{ + def mult(a, b) + a * b + end + + mult(6, 2) + mult(6, 2) +} + # BOP redefined methods work when JIT compiled assert_equal 'false', %q{ def less_than x diff --git a/yjit_codegen.c b/yjit_codegen.c index 0c1b0da7a4..ab838a233a 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -1794,7 +1794,7 @@ gen_opt_aset(jitstate_t *jit, ctx_t *ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1794 x86opnd_t arg1 = ctx_stack_pop(ctx, 1); x86opnd_t arg0 = ctx_stack_pop(ctx, 1); - // Call rb_vm_opt_mod(VALUE recv, VALUE obj) + // Call rb_vm_opt_aset(VALUE recv, VALUE obj) yjit_save_regs(cb); mov(cb, C_ARG_REGS[0], arg0); mov(cb, C_ARG_REGS[1], arg1); @@ -1933,6 +1933,13 @@ gen_opt_plus(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1933 return YJIT_KEEP_COMPILING; } +static codegen_status_t +gen_opt_mult(jitstate_t* jit, ctx_t* ctx) +{ + // Delegate to send, call the method on the recv + return gen_opt_send_without_block(jit, ctx); +} + VALUE rb_vm_opt_mod(VALUE recv, VALUE obj); static codegen_status_t @@ -3462,6 +3469,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3469 yjit_reg_op(BIN(opt_or), gen_opt_or); yjit_reg_op(BIN(opt_minus), gen_opt_minus); yjit_reg_op(BIN(opt_plus), gen_opt_plus); + yjit_reg_op(BIN(opt_mult), gen_opt_mult); yjit_reg_op(BIN(opt_mod), gen_opt_mod); yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt); yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/