Skip invalidation for trace_ insns

This commit is contained in:
Takashi Kokubun 2023-02-19 23:05:29 -08:00
parent feb60f6f51
commit bef63f445b
Notes: git 2023-03-06 07:29:56 +00:00
2 changed files with 21 additions and 11 deletions

View file

@ -1,9 +1,10 @@
class RubyVM::MJIT::Block < Struct.new( class RubyVM::MJIT::Block < Struct.new(
:pc, # @param [Integer] Starting PC :pc, # @param [Integer] Starting PC
:ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?) :ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?)
:start_addr, # @param [Integer] Starting address of this block's JIT code :start_addr, # @param [Integer] Starting address of this block's JIT code
:entry_exit, # @param [Integer] Address of entry exit (optional) :entry_exit, # @param [Integer] Address of entry exit (optional)
:incoming, # @param [Array<RubyVM::MJIT::BranchStub>] Incoming branches :incoming, # @param [Array<RubyVM::MJIT::BranchStub>] Incoming branches
:invalidated, # @param [TrueClass,FalseClass] true if already invalidated
) )
def initialize(incoming: [], **) = super def initialize(incoming: [], invalidated: false, **) = super
end end

View file

@ -203,6 +203,12 @@ module RubyVM::MJIT
break break
when CantCompile when CantCompile
@exit_compiler.compile_side_exit(jit.pc, ctx, asm) @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 break
else else
raise "compiling #{insn.name} returned unexpected status: #{status.inspect}" raise "compiling #{insn.name} returned unexpected status: #{status.inspect}"
@ -224,11 +230,14 @@ module RubyVM::MJIT
remove_block(iseq, block) remove_block(iseq, block)
# Invalidate the block with entry exit # Invalidate the block with entry exit
@cb.with_write_addr(block.start_addr) do unless block.invalidated
asm = Assembler.new @cb.with_write_addr(block.start_addr) do
asm.comment('invalidate_block') asm = Assembler.new
asm.jmp(block.entry_exit) asm.comment('invalidate_block')
@cb.write(asm) asm.jmp(block.entry_exit)
@cb.write(asm)
end
block.invalidated = true
end end
# Re-stub incoming branches # Re-stub incoming branches