diff options
Diffstat (limited to 'lib/ruby_vm/mjit/invariants.rb')
-rw-r--r-- | lib/ruby_vm/mjit/invariants.rb | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/ruby_vm/mjit/invariants.rb b/lib/ruby_vm/mjit/invariants.rb index e68a6e5503..0e8063c0c6 100644 --- a/lib/ruby_vm/mjit/invariants.rb +++ b/lib/ruby_vm/mjit/invariants.rb @@ -78,6 +78,28 @@ module RubyVM::MJIT end def on_tracing_invalidate_all + invalidate_all + end + + def on_update_references + invalidate_all + end + + # @param jit [RubyVM::MJIT::JITState] + # @param block [RubyVM::MJIT::Block] + def ensure_block_entry_exit(jit, cause:) + block = jit.block + if block.entry_exit.nil? + block.entry_exit = Assembler.new.then do |asm| + @exit_compiler.compile_entry_exit(block.pc, block.ctx, asm, cause:) + @ocb.write(asm) + end + end + end + + private + + def invalidate_all # On-Stack Replacement @patches.each do |address, target| # TODO: assert patches don't overlap each other @@ -88,6 +110,7 @@ module RubyVM::MJIT @cb.write(asm) end end + @patches.clear # Avoid reusing past code Compiler.reset_blocks @@ -99,18 +122,6 @@ module RubyVM::MJIT iseq.body.total_calls = 0 end end - - # @param jit [RubyVM::MJIT::JITState] - # @param block [RubyVM::MJIT::Block] - def ensure_block_entry_exit(jit, cause:) - block = jit.block - if block.entry_exit.nil? - block.entry_exit = Assembler.new.then do |asm| - @exit_compiler.compile_entry_exit(block.pc, block.ctx, asm, cause:) - @ocb.write(asm) - end - end - end end end end |