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

ruby-changes:68897

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:15:07 +0900 (JST)
Subject: [ruby-changes:68897] 0881e018b5 (master): Add comments and asserts for clarity

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

From 0881e018b567362ba6405eeb788d76d770653978 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 6 Apr 2021 12:19:45 -0400
Subject: Add comments and asserts for clarity

---
 yjit_core.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/yjit_core.c b/yjit_core.c
index 9add2b5f29..f74c5e9318 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -455,18 +455,6 @@ branch_stub_hit(const uint32_t branch_idx, const uint32_t target_idx, rb_executi https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L455
 
     // If this block hasn't yet been compiled
     if (!p_block) {
-        // If the new block will be placed next right after the branch
-        if (cb->write_pos == branch->end_pos) {
-            //fprintf(stderr, "target idx %d will be placed next\n", target_idx);
-            branch->shape = (uint8_t)target_idx;
-
-            // Rewrite the branch with the new, potentially more compact shape
-            cb_set_pos(cb, branch->start_pos);
-            branch->gen_fn(cb, branch->dst_addrs[0], branch->dst_addrs[1], branch->shape);
-            RUBY_ASSERT(cb->write_pos <= branch->end_pos && "can't enlarge branches");
-            branch->end_pos = cb->write_pos;
-        }
-
         // Limit the number of block versions
         ctx_t generic_ctx = DEFAULT_CTX;
         generic_ctx.stack_size = target_ctx->stack_size;
@@ -478,7 +466,21 @@ branch_stub_hit(const uint32_t branch_idx, const uint32_t target_idx, rb_executi https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L466
             }
         }
 
+        // If the new block can be generated right after the branch (at cb->write_pos)
+        if (cb->write_pos == branch->end_pos) {
+            // Change the branch shape to indicate the target block will be placed next
+            branch->shape = (uint8_t)target_idx;
+
+            // Rewrite the branch with the new, potentially more compact shape
+            cb_set_pos(cb, branch->start_pos);
+            branch->gen_fn(cb, branch->dst_addrs[0], branch->dst_addrs[1], branch->shape);
+            RUBY_ASSERT(cb->write_pos <= branch->end_pos && "can't enlarge branches");
+            branch->end_pos = cb->write_pos;
+        }
+
         p_block = gen_block_version(target, target_ctx, ec);
+        RUBY_ASSERT(p_block);
+        RUBY_ASSERT(branch->shape != (uint8_t)target_idx || p_block->start_pos == branch->end_pos);
     }
 
     // Add this branch to the list of incoming branches for the target
-- 
cgit v1.2.1


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

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