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

ruby-changes:68693

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:12:26 +0900 (JST)
Subject: [ruby-changes:68693] a251059070 (master): Fix hash map key issue

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

From a251059070a4d42ac1a70fb3ce747cd791bfbe92 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 12 Jan 2021 12:30:11 -0500
Subject: Fix hash map key issue

---
 ujit_codegen.c |  8 ++++----
 ujit_core.c    | 13 +++++++++----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ujit_codegen.c b/ujit_codegen.c
index a9462622ae..980e3e6673 100644
--- a/ujit_codegen.c
+++ b/ujit_codegen.c
@@ -776,7 +776,10 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L776
     // Pointer to the klass field of the receiver &(recv->klass)
     x86opnd_t klass_opnd = mem_opnd(64, REG0, offsetof(struct RBasic, klass));
 
-    // Bail if receiver class is different from compiled time call cache class
+    // FIXME
+    //assume_method_lookup_stable(cd->cc, cme, ctx);
+
+    // Bail if receiver class is different from compile-time call cache class
     mov(cb, REG1, imm_opnd(cd->cc->klass));
     cmp(cb, klass_opnd, REG1);
     jne_ptr(cb, side_exit);
@@ -893,9 +896,6 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L896
 
     //print_str(cb, "before C call");
 
-    // FIXME
-    //assume_method_lookup_stable(cd->cc, cme, ctx);
-
     // Call the C function
     // VALUE ret = (cfunc->func)(recv, argv[0], argv[1]);
     // cfunc comes from compile-time cme->def, which we assume to be stable.
diff --git a/ujit_core.c b/ujit_core.c
index 9ebc3c1e56..e3086c4fba 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -86,18 +86,23 @@ uint8_t* find_block_version(blockid_t block, const ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L86
 }
 
 // Compile a new block version immediately
-uint8_t* gen_block_version(blockid_t block, const ctx_t* ctx)
+uint8_t* gen_block_version(blockid_t blockid, const ctx_t* ctx)
 {
     // Copy the context object to avoid modifying it
     ctx_t ctx_copy = *ctx;
 
     uint32_t num_instrs = 0;
-    uint8_t* block_ptr = ujit_compile_block(block.iseq, block.idx, &ctx_copy, &num_instrs);
+    uint8_t* p_block = ujit_compile_block(blockid.iseq, blockid.idx, &ctx_copy, &num_instrs);
+
+    // Need to allocate the blockid on the heap
+    // to store it in the hash table
+    blockid_t* p_blockid = (blockid_t*)malloc(sizeof(blockid_t));
+    memcpy(p_blockid, &blockid, sizeof(blockid_t));
 
     // Keep track of the new block version
-    st_insert(version_tbl, (st_data_t)&block, (st_data_t)block_ptr);
+    st_insert(version_tbl, (st_data_t)p_blockid, (st_data_t)p_block);
 
-    return block_ptr;
+    return p_block;
 }
 
 // Called by the generated code when a branch stub is executed
-- 
cgit v1.2.1


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

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