summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-02-19 23:05:29 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 23:28:59 -0800
commitbef63f445b85bcfea5e76a724ee3b03be35a82cf (patch)
treec64fe805b9488080d85cba4a87305c2c71315e52 /lib/ruby_vm/mjit/compiler.rb
parentfeb60f6f5107561f2e83e3f53b1db52d2b201708 (diff)
Skip invalidation for trace_ insns
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7448
Diffstat (limited to 'lib/ruby_vm/mjit/compiler.rb')
-rw-r--r--lib/ruby_vm/mjit/compiler.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb
index 967adec2aa..f19e1bd6fb 100644
--- a/lib/ruby_vm/mjit/compiler.rb
+++ b/lib/ruby_vm/mjit/compiler.rb
@@ -203,6 +203,12 @@ module RubyVM::MJIT
break
when CantCompile
@exit_compiler.compile_side_exit(jit.pc, ctx, asm)
+
+ # If this is the first instruction, this block never needs to be invalidated.
+ if block.pc == iseq.body.iseq_encoded.to_i + index * C.VALUE.size
+ block.invalidated = true
+ end
+
break
else
raise "compiling #{insn.name} returned unexpected status: #{status.inspect}"
@@ -224,11 +230,14 @@ module RubyVM::MJIT
remove_block(iseq, block)
# Invalidate the block with entry exit
- @cb.with_write_addr(block.start_addr) do
- asm = Assembler.new
- asm.comment('invalidate_block')
- asm.jmp(block.entry_exit)
- @cb.write(asm)
+ unless block.invalidated
+ @cb.with_write_addr(block.start_addr) do
+ asm = Assembler.new
+ asm.comment('invalidate_block')
+ asm.jmp(block.entry_exit)
+ @cb.write(asm)
+ end
+ block.invalidated = true
end
# Re-stub incoming branches