summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/rjit/compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-12 21:14:35 -0700
committerTakashi Kokubun <[email protected]>2023-03-12 21:14:43 -0700
commita23f64221e9b006fef74544ffbbca5d09115f807 ()
tree2544b741a0c4f1b9066d7725f55083b7e0657166 /lib/ruby_vm/rjit/compiler.rb
parente28f83703ac880f62e9be8a4e8481aae74096cf9 (diff)
RJIT: Fix block finding logic
like YJIT does
-rw-r--r--lib/ruby_vm/rjit/compiler.rb33
1 files changed, 25 insertions, 8 deletions
@@ -257,7 +257,7 @@ module RubyVM::RJIT
end
incr_counter(:compiled_block_count)
- set_block(iseq, block)
end
def leave_exit
@@ -274,35 +274,52 @@ module RubyVM::RJIT
end
def list_blocks(iseq, pc)
- rjit_blocks(iseq)[pc].values
end
# @param [Integer] pc
# @param [RubyVM::RJIT::Context] ctx
# @return [RubyVM::RJIT::Block,NilClass]
def find_block(iseq, pc, ctx)
- rjit_blocks(iseq)[pc][ctx]
end
# @param [RubyVM::RJIT::Block] block
- def set_block(iseq, block)
- rjit_blocks(iseq)[block.pc][block.ctx] = block
end
# @param [RubyVM::RJIT::Block] block
def remove_block(iseq, block)
- rjit_blocks(iseq)[block.pc].delete(block.ctx)
end
def rjit_blocks(iseq)
# Guard against ISEQ GC at random moments
unless C.imemo_type_p(iseq, C.imemo_iseq)
- return Hash.new { |h, k| h[k] = {} }
end
unless iseq.body.rjit_blocks
- iseq.body.rjit_blocks = Hash.new { |h, k| h[k] = {} }
# For some reason, rb_rjit_iseq_mark didn't protect this Hash
# from being freed. So we rely on GC_REFS to keep the Hash.
GC_REFS << iseq.body.rjit_blocks