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

ruby-changes:69114

From: Kevin <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:52 +0900 (JST)
Subject: [ruby-changes:69114] ba9aa1f8ef (master): Implement opt_div

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

From ba9aa1f8efb77c6cf58ec4ea6bb81ced17acbc2b Mon Sep 17 00:00:00 2001
From: Kevin Deisz <kevin.deisz@g...>
Date: Tue, 6 Jul 2021 16:26:56 -0400
Subject: Implement opt_div

---
 bootstraptest/test_yjit.rb | 10 ++++++++++
 yjit_codegen.c             |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 14b901fbf1..7fe637a86b 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -36,6 +36,16 @@ assert_equal '12', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L36
   mult(6, 2)
 }
 
+# Test for opt_div
+assert_equal '3', %q{
+  def div(a, b)
+    a / b
+  end
+
+  div(6, 2)
+  div(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 ab838a233a..8cb5a105ce 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1940,6 +1940,13 @@ gen_opt_mult(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1940
     return gen_opt_send_without_block(jit, ctx);
 }
 
+static codegen_status_t
+gen_opt_div(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
@@ -3470,6 +3477,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3477
     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_div), gen_opt_div);
     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/

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