aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ruby_vm
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-04-01 22:39:15 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2023-04-01 22:39:16 -0700
commit87dc06ed242ab6524cc51404513a8b0dad9fe1e3 (patch)
treefbf6a528bc11f9b5f4723eae1a2bdeca0652351b /lib/ruby_vm
parentbf2617b8a679b5ef7eabfa3feb2ef2686d1291f0 (diff)
downloadruby-87dc06ed242ab6524cc51404513a8b0dad9fe1e3.tar.gz
RJIT: Comment a location for each block
Diffstat (limited to 'lib/ruby_vm')
-rw-r--r--lib/ruby_vm/rjit/compiler.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/ruby_vm/rjit/compiler.rb b/lib/ruby_vm/rjit/compiler.rb
index 5673926b6f..49dbbdd6c9 100644
--- a/lib/ruby_vm/rjit/compiler.rb
+++ b/lib/ruby_vm/rjit/compiler.rb
@@ -58,7 +58,6 @@ module RubyVM::RJIT
jit = JITState.new(iseq:, cfp:)
asm = Assembler.new
- asm.comment("Block: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq.body.location.first_lineno}")
compile_prologue(asm)
compile_block(asm, jit:)
iseq.body.jit_func = @cb.write(asm)
@@ -214,8 +213,10 @@ module RubyVM::RJIT
jit.block = block
asm.block(block)
- # Compile each insn
iseq = jit.iseq
+ asm.comment("Block: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq_lineno(iseq, pc)}")
+
+ # Compile each insn
index = (pc - iseq.body.iseq_encoded.to_i) / C.VALUE.size
while index < iseq.body.iseq_size
insn = self.class.decode_insn(iseq.body.iseq_encoded[index])
@@ -330,5 +331,11 @@ module RubyVM::RJIT
end
iseq.body.rjit_blocks
end
+
+ def iseq_lineno(iseq, pc)
+ C.rb_iseq_line_no(iseq, (pc - iseq.body.iseq_encoded.to_i) / C.VALUE.size)
+ rescue RangeError # bignum too big to convert into `unsigned long long' (RangeError)
+ -1
+ end
end
end