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

ruby-changes:69021

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:16:35 +0900 (JST)
Subject: [ruby-changes:69021] 23f88957e6 (master): Switch to 2-comparison heap object check

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

From 23f88957e691cbc11375627bbc26a35cd3a3465c Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Mon, 19 Apr 2021 13:50:47 -0400
Subject: Switch to 2-comparison heap object check

---
 yjit_codegen.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index b986395426..42ed63b3de 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -626,21 +626,15 @@ gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L626
 static void
 guard_self_is_heap(codeblock_t *cb, x86opnd_t self_opnd, uint8_t *side_exit, ctx_t *ctx)
 {
+
     // `self` is constant throughout the entire region, so we only need to do this check once.
     if (!ctx->self_type.is_heap) {
-        // FIXME: use two-comparison test
         ADD_COMMENT(cb, "guard self is heap");
+        RUBY_ASSERT(Qfalse < Qnil);
         test(cb, self_opnd, imm_opnd(RUBY_IMMEDIATE_MASK));
         jnz_ptr(cb, side_exit);
-        cmp(cb, self_opnd, imm_opnd(Qfalse));
-        je_ptr(cb, side_exit);
         cmp(cb, self_opnd, imm_opnd(Qnil));
-        je_ptr(cb, side_exit);
-
-        // maybe we can do
-        // RUBY_ASSERT(Qfalse < Qnil);
-        // cmp(cb, self_opnd, imm_opnd(Qnil));
-        // jbe(cb, side_exit);
+        jbe_ptr(cb, side_exit);
 
         ctx->self_type.is_heap = 1;
     }
@@ -1433,12 +1427,11 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t* ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1427
     {
         // FIXME: use two comparisons instead of 3 here
         ADD_COMMENT(cb, "guard not immediate");
+        RUBY_ASSERT(Qfalse < Qnil);
         test(cb, REG0, imm_opnd(RUBY_IMMEDIATE_MASK));
         jnz_ptr(cb, side_exit);
-        cmp(cb, REG0, imm_opnd(Qfalse));
-        je_ptr(cb, side_exit);
         cmp(cb, REG0, imm_opnd(Qnil));
-        je_ptr(cb, side_exit);
+        jbe_ptr(cb, side_exit);
 
         ctx_set_opnd_type(ctx, insn_opnd, TYPE_HEAP);
     }
-- 
cgit v1.2.1


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

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