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

ruby-changes:68979

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:33 +0900 (JST)
Subject: [ruby-changes:68979] adbd7ff332 (master): Fix frozen check (use jnz) and move heap object check.

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

From adbd7ff332a34e674d7e6281134248b1292fe60f Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Wed, 21 Apr 2021 17:24:49 -0400
Subject: Fix frozen check (use jnz) and move heap object check.

---
 yjit_codegen.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index bae2275208..ea4dfa9215 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -771,11 +771,6 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L771
     struct rb_iv_index_tbl_entry *ent;
     struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(comptime_receiver);
 
-    // Bail if this is a heap object, because this needs a write barrier
-    ADD_COMMENT(cb, "guard value is immediate");
-    test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
-    jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
-
     // Lookup index for the ivar the instruction loads
     if (iv_index_tbl && rb_iv_index_tbl_lookup(iv_index_tbl, id, &ent)) {
         uint32_t ivar_index = ent->index;
@@ -783,12 +778,16 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L778
         x86opnd_t val_to_write = ctx_stack_pop(ctx, 1);
         mov(cb, REG1, val_to_write);
 
-        x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
+        // Bail if the value to write is a heap object, because this needs a write barrier
+        ADD_COMMENT(cb, "guard value is immediate");
+        test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
+        jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
 
         // Bail if this object is frozen
         ADD_COMMENT(cb, "guard self is not frozen");
+        x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
         test(cb, flags_opnd, imm_opnd(RUBY_FL_FREEZE));
-        jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
+        jnz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
 
         // Pop receiver if it's on the temp stack
         if (!reg0_opnd.is_self) {
-- 
cgit v1.2.1


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

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