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

ruby-changes:68732

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:12:39 +0900 (JST)
Subject: [ruby-changes:68732] 4f47181be6 (master): Keep track of multiple versions per blockid

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

From 4f47181be689e9cfc2cbce332aa4d538afd35da1 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Sun, 24 Jan 2021 23:08:11 -0500
Subject: Keep track of multiple versions per blockid

---
 ujit_core.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/ujit_core.c b/ujit_core.c
index c7a2c7acab..0cb228e1f3 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -139,6 +139,24 @@ int ctx_diff(const ctx_t* src, const ctx_t* dst) https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L139
     return diff;
 }
 
+// Add a block version to the map
+static void add_block_version(blockid_t blockid, block_t* block)
+{
+    // If there exists a version for this block id
+    block_t* first_version = NULL;
+    st_lookup(version_tbl, (st_data_t)&blockid, (st_data_t*)&first_version);
+
+    // Link to the next version in a linked list
+    if (first_version != NULL) {
+        RUBY_ASSERT(block->next == NULL);
+        block->next = first_version;
+    }
+
+    // Add the block version to the map
+    st_insert(version_tbl, (st_data_t)&blockid, (st_data_t)block);
+    RUBY_ASSERT(find_block_version(blockid, &block->ctx) != NULL);
+}
+
 // Add an incoming branch for a given block version
 static void add_incoming(block_t* p_block, uint32_t branch_idx)
 {
@@ -200,8 +218,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx) https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L218
     ujit_gen_block(ctx, block);
 
     // Keep track of the new block version
-    st_insert(version_tbl, (st_data_t)&block->blockid, (st_data_t)block);
-    RUBY_ASSERT(find_block_version(blockid, start_ctx) != NULL);
+    add_block_version(blockid, block);
 
     // For each successor block to compile
     for (;;) {
@@ -232,7 +249,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx) https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L249
         ujit_gen_block(ctx, block);
 
         // Keep track of the new block version
-        st_insert(version_tbl, (st_data_t)&block->blockid, (st_data_t)block);
+        add_block_version(blockid, block);
 
         // Patch the last branch address
         last_branch->dst_addrs[0] = cb_get_ptr(cb, block->start_pos);
-- 
cgit v1.2.1


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

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