mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Invalidate blocks on global constant changes
This commit is contained in:
parent
b5fbc9f59f
commit
7dcdffebc8
Notes:
git
2023-03-06 07:29:49 +00:00
7 changed files with 88 additions and 46 deletions
|
@ -15,6 +15,7 @@ module RubyVM::MJIT
|
|||
@exit_compiler = exit_compiler
|
||||
@bop_blocks = Set.new # TODO: actually invalidate this
|
||||
@cme_blocks = Hash.new { |h, k| h[k] = Set.new }
|
||||
@const_blocks = Hash.new { |h, k| h[k] = Set.new }
|
||||
@patches = {}
|
||||
|
||||
# freeze # workaround a binding.irb issue. TODO: resurrect this
|
||||
|
@ -37,6 +38,13 @@ module RubyVM::MJIT
|
|||
@cme_blocks[cme.to_i] << jit.block
|
||||
end
|
||||
|
||||
def assume_stable_constant_names(jit, idlist)
|
||||
(0..).each do |i|
|
||||
break if (id = idlist[i]) == 0
|
||||
@const_blocks[id] << jit.block
|
||||
end
|
||||
end
|
||||
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
def record_global_inval_patch(asm, target)
|
||||
asm.pos_marker do |address|
|
||||
|
@ -57,6 +65,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
# TODO: re-generate branches that refer to this block
|
||||
end
|
||||
@cme_blocks.delete(cme.to_i)
|
||||
end
|
||||
|
||||
def on_constant_ic_update(iseq, ic, insn_idx)
|
||||
|
@ -77,6 +86,12 @@ module RubyVM::MJIT
|
|||
@compiler.invalidate_blocks(iseq, pc.to_i)
|
||||
end
|
||||
|
||||
def on_constant_state_changed(id)
|
||||
@const_blocks.fetch(id, []).each do |block|
|
||||
@compiler.invalidate_block(block)
|
||||
end
|
||||
end
|
||||
|
||||
def on_tracing_invalidate_all
|
||||
invalidate_all
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue