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

ruby-changes:68733

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:12:39 +0900 (JST)
Subject: [ruby-changes:68733] 439e1089b7 (master): Implement opt_le, opt_ge in ujit

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

From 439e1089b72ebb11314b3f548c8bb5bdf02a91a1 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Wed, 3 Feb 2021 11:25:34 -0500
Subject: Implement opt_le, opt_ge in ujit

---
 ujit_codegen.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/ujit_codegen.c b/ujit_codegen.c
index 33b0e8edd6..3b66e8fa40 100644
--- a/ujit_codegen.c
+++ b/ujit_codegen.c
@@ -339,7 +339,7 @@ gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L339
 
     // Compute the offset from BP to the local
     int32_t local_idx = (int32_t)jit_get_arg(jit, 0);
-    const int32_t offs = -8 * local_idx;
+    const int32_t offs = -sizeof(VALUE) * local_idx;
 
     // Load the local from the block
     mov(cb, REG0, mem_opnd(64, REG0, offs));
@@ -541,8 +541,11 @@ gen_setinstancevariable(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L541
     return true;
 }
 
+// Conditional move operation used by comparison operators
+typedef void (*cmov_fn)(codeblock_t* cb, x86opnd_t opnd0, x86opnd_t opnd1);
+
 static bool
-gen_opt_lt(jitstate_t* jit, ctx_t* ctx)
+gen_fixnum_cmp(jitstate_t* jit, ctx_t* ctx, cmov_fn cmov_op)
 {
     // Create a size-exit to fall back to the interpreter
     // Note: we generate the side-exit before popping operands from the stack
@@ -579,7 +582,7 @@ gen_opt_lt(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L582
     mov(cb, REG1, arg0);
     cmp(cb, REG1, arg1);
     mov(cb, REG1, imm_opnd(Qtrue));
-    cmovl(cb, REG0, REG1);
+    cmov_op(cb, REG0, REG1);
 
     // Push the output on the stack
     x86opnd_t dst = ctx_stack_push(ctx, T_NONE);
@@ -588,6 +591,24 @@ gen_opt_lt(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L591
     return true;
 }
 
+static bool
+gen_opt_lt(jitstate_t* jit, ctx_t* ctx)
+{
+    return gen_fixnum_cmp(jit, ctx, cmovl);
+}
+
+static bool
+gen_opt_le(jitstate_t* jit, ctx_t* ctx)
+{
+    return gen_fixnum_cmp(jit, ctx, cmovle);
+}
+
+static bool
+gen_opt_ge(jitstate_t* jit, ctx_t* ctx)
+{
+    return gen_fixnum_cmp(jit, ctx, cmovge);
+}
+
 static bool
 gen_opt_and(jitstate_t* jit, ctx_t* ctx)
 {
@@ -1331,6 +1352,8 @@ ujit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L1352
     ujit_reg_op(BIN(getinstancevariable), gen_getinstancevariable, false);
     ujit_reg_op(BIN(setinstancevariable), gen_setinstancevariable, false);
     ujit_reg_op(BIN(opt_lt), gen_opt_lt, false);
+    ujit_reg_op(BIN(opt_le), gen_opt_le, false);
+    ujit_reg_op(BIN(opt_ge), gen_opt_ge, false);
     ujit_reg_op(BIN(opt_and), gen_opt_and, false);
     ujit_reg_op(BIN(opt_minus), gen_opt_minus, false);
     ujit_reg_op(BIN(opt_plus), gen_opt_plus, false);
-- 
cgit v1.2.1


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

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