Skip invalidation for trace_ insns

This commit is contained in:
Takashi Kokubun 2023-02-19 23:05:29 -08:00
Родитель feb60f6f51
Коммит bef63f445b
2 изменённых файлов: 21 добавлений и 11 удалений

Просмотреть файл

@ -1,9 +1,10 @@
class RubyVM::MJIT::Block < Struct.new(
:pc, # @param [Integer] Starting PC
:ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?)
:start_addr, # @param [Integer] Starting address of this block's JIT code
:entry_exit, # @param [Integer] Address of entry exit (optional)
:incoming, # @param [Array<RubyVM::MJIT::BranchStub>] Incoming branches
:pc, # @param [Integer] Starting PC
:ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?)
:start_addr, # @param [Integer] Starting address of this block's JIT code
:entry_exit, # @param [Integer] Address of entry exit (optional)
: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

Просмотреть файл

@ -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