diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-02-10 14:41:45 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 22:41:35 -0800 |
| commit | 1bdc23f35b31625cf570f6e8bc85b8289d783a71 (patch) | |
| tree | a229182f70e464e00773f7ab094d67ebed63d559 /lib/ruby_vm | |
| parent | b379ccf755b8f30d3b029f124e2870dcd4a87dab (diff) | |
Redo compilation of all ISEQs after invalidation
Diffstat (limited to 'lib/ruby_vm')
| -rw-r--r-- | lib/ruby_vm/mjit/compiler.rb | 6 | ||||
| -rw-r--r-- | lib/ruby_vm/mjit/invariants.rb | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb index 2ad01ef669..5aac3626fa 100644 --- a/lib/ruby_vm/mjit/compiler.rb +++ b/lib/ruby_vm/mjit/compiler.rb @@ -33,6 +33,12 @@ module RubyVM::MJIT attr_accessor :write_pos IseqBlocks = Hash.new { |h, k| h[k] = {} } + DeadBlocks = [] # invalidated IseqBlocks, but kept for safety + + def self.reset_blocks + DeadBlocks << IseqBlocks.dup + IseqBlocks.clear + end def self.decode_insn(encoded) INSNS.fetch(C.rb_vm_insn_decode(encoded)) diff --git a/lib/ruby_vm/mjit/invariants.rb b/lib/ruby_vm/mjit/invariants.rb index 6dd8e65bc9..d291ade9bf 100644 --- a/lib/ruby_vm/mjit/invariants.rb +++ b/lib/ruby_vm/mjit/invariants.rb @@ -58,8 +58,9 @@ module RubyVM::MJIT end def on_tracing_invalidate_all - # TODO: assert patches don't overlap each other + # On-Stack Replacement @patches.each do |address, target| + # TODO: assert patches don't overlap each other @cb.with_write_addr(address) do asm = Assembler.new asm.comment('on_tracing_invalidate_all') @@ -67,6 +68,16 @@ module RubyVM::MJIT @cb.write(asm) end end + + # Avoid reusing past code + Compiler.reset_blocks + + C.mjit_for_each_iseq do |iseq| + # Disable entering past code + iseq.body.jit_func = 0 + # Compile this again if not converted to trace_* insns + iseq.body.total_calls = 0 + end end private |
