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

ruby-changes:68812

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:12:39 +0900 (JST)
Subject: [ruby-changes:68812] 8a61e848c0 (master): Minor changes to disasm output. Fix GCC warning.

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

From 8a61e848c09779312dab159e8a625872de034272 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Fri, 22 Jan 2021 15:24:04 -0500
Subject: Minor changes to disasm output. Fix GCC warning.

---
 ujit.rb      | 9 +++++++--
 ujit_iface.c | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ujit.rb b/ujit.rb
index 43be881c05..3697e50b1c 100644
--- a/ujit.rb
+++ b/ujit.rb
@@ -1,5 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ujit.rb#L1
 module UJIT
   def self.disasm(iseq)
+    if iseq.is_a? Method
+        iseq = RubyVM::InstructionSequence.of(iseq)
+    end
+
     blocks = UJIT.blocks_for(iseq)
     return if blocks.empty?
 
@@ -10,13 +14,14 @@ module UJIT https://github.com/ruby/ruby/blob/trunk/ujit.rb#L14
     str << iseq.disasm
     str << "\n"
 
+    # Sort the blocks by increasing addresses
     blocks.sort_by(&:address).reverse.each do |block|
-      str << "== ISEQ RANGE: #{block.iseq_start_index} -> #{block.iseq_end_index} ".ljust(80, "=")
+      str << "== ISEQ RANGE: [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
       str << "\n"
 
       cs.disasm(block.code, 0).each do |i|
         str << sprintf(
-          "\t0x%<address>x:\t%<instruction>s\t%<details>s\n",
+          "\t%<address>04X:\t%<instruction>s\t%<details>s\n",
           address: i.address,
           instruction: i.mnemonic,
           details: i.op_str
diff --git a/ujit_iface.c b/ujit_iface.c
index 591d9c044c..981c882ceb 100644
--- a/ujit_iface.c
+++ b/ujit_iface.c
@@ -397,7 +397,7 @@ ujit_disasm(VALUE self, VALUE code, VALUE from) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L397
     cs_insn *insns;
 
     TypedData_Get_Struct(self, csh, &ujit_disasm_type, handle);
-    count = cs_disasm(*handle, (uint8_t *)StringValuePtr(code), RSTRING_LEN(code), NUM2INT(from), 0, &insns);
+    count = cs_disasm(*handle, (uint8_t*)StringValuePtr(code), RSTRING_LEN(code), NUM2INT(from), 0, &insns);
     VALUE insn_list = rb_ary_new_capa(count);
 
     for (size_t i = 0; i < count; i++) {
-- 
cgit v1.2.1


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

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