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

ruby-changes:68739

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:09 +0900 (JST)
Subject: [ruby-changes:68739] 63e85de33a (master): Fix bug, block added with wrong blockid.

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

From 63e85de33a6b3cf4dbb2f7873c968576e201f0b6 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Mon, 25 Jan 2021 15:28:49 -0500
Subject: Fix bug, block added with wrong blockid.

---
 ujit.rb        | 2 +-
 ujit_codegen.c | 2 +-
 ujit_core.c    | 4 ++--
 ujit_iface.c   | 6 ++++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/ujit.rb b/ujit.rb
index 06de98e7cf..79eed46ff3 100644
--- a/ujit.rb
+++ b/ujit.rb
@@ -16,7 +16,7 @@ module UJIT https://github.com/ruby/ruby/blob/trunk/ujit.rb#L16
 
     # Sort the blocks by increasing addresses
     blocks.sort_by(&:address).each_with_index do |block, i|
-      str << "== BLOCK #{i+1}/#{blocks.length} ISEQ RANGE: [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
+      str << "== BLOCK #{i+1}/#{blocks.length}: #{block.code.length} BYTES, ISEQ RANGE [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
       str << "\n"
 
       cs.disasm(block.code, 0).each do |i|
diff --git a/ujit_codegen.c b/ujit_codegen.c
index 9ecf636dc3..a38ecf18bb 100644
--- a/ujit_codegen.c
+++ b/ujit_codegen.c
@@ -179,7 +179,7 @@ ujit_gen_block(ctx_t* ctx, block_t* block) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L179
             break;
         }
 
-        //fprintf(stderr, "compiling %s\n", insn_name(opcode));
+        //fprintf(stderr, "compiling %d: %s\n", insn_idx, insn_name(opcode));
         //print_str(cb, insn_name(opcode));
 
         // Call the code generation function
diff --git a/ujit_core.c b/ujit_core.c
index 0cb228e1f3..8d6680fc85 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -218,7 +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
-    add_block_version(blockid, block);
+    add_block_version(block->blockid, block);
 
     // For each successor block to compile
     for (;;) {
@@ -249,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
-        add_block_version(blockid, block);
+        add_block_version(block->blockid, block);
 
         // Patch the last branch address
         last_branch->dst_addrs[0] = cb_get_ptr(cb, block->start_pos);
diff --git a/ujit_iface.c b/ujit_iface.c
index 7c553f4b3c..3eb134a3bc 100644
--- a/ujit_iface.c
+++ b/ujit_iface.c
@@ -329,7 +329,7 @@ ujit_install_entry(VALUE mod, VALUE iseq) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L329
     return iseq;
 }
 
-/* Get the address of the UJIT::Block */
+/* Get the address of the the code associated with a UJIT::Block */
 static VALUE
 block_address(VALUE self)
 {
@@ -425,21 +425,23 @@ rb_ujit_init(void) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L425
     ujit_init_core();
     ujit_init_codegen();
 
+    // UJIT Ruby module
     VALUE mUjit = rb_define_module("UJIT");
     rb_define_module_function(mUjit, "install_entry", ujit_install_entry, 1);
     rb_define_module_function(mUjit, "blocks_for", ujit_blocks_for, 1);
 
+    // UJIT::Block (block version, code block)
     cUjitBlock = rb_define_class_under(mUjit, "Block", rb_cObject);
     rb_define_method(cUjitBlock, "address", block_address, 0);
     rb_define_method(cUjitBlock, "code", block_code, 0);
     rb_define_method(cUjitBlock, "iseq_start_index", iseq_start_index, 0);
     rb_define_method(cUjitBlock, "iseq_end_index", iseq_end_index, 0);
 
+    // UJIT disassembler interface
 #if HAVE_LIBCAPSTONE
     cUjitDisasm = rb_define_class_under(mUjit, "Disasm", rb_cObject);
     rb_define_alloc_func(cUjitDisasm, ujit_disasm_init);
     rb_define_method(cUjitDisasm, "disasm", ujit_disasm, 2);
-
     cUjitDisasmInsn = rb_struct_define_under(cUjitDisasm, "Insn", "address", "mnemonic", "op_str", NULL);
 #endif
 
-- 
cgit v1.2.1


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

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