diff options
author | Takashi Kokubun <[email protected]> | 2023-02-24 13:19:42 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-05 23:28:59 -0800 |
commit | 63d96ccbcd21653ac1e5afd96dbd72bc78900de0 (patch) | |
tree | 71e0548566475f9aaa22a9c5fd91a51d2c6577ac /lib/ruby_vm/mjit/invariants.rb | |
parent | 44c4a2d80d72f1261cfe41ca04ac8e9b826793ca (diff) |
Invalidate everything on GC.compact
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7448
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 |