mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
Guard against GC of random ISEQs
This commit is contained in:
parent
7dcdffebc8
commit
706f6272d9
Notes:
git
2023-03-06 07:29:49 +00:00
3 changed files with 18 additions and 0 deletions
|
@ -143,6 +143,9 @@ module RubyVM::MJIT
|
|||
|
||||
def invalidate_block(block)
|
||||
iseq = block.iseq
|
||||
# Avoid touching GCed ISEQs. We assume it won't be re-entered.
|
||||
return if C.imemo_type(iseq) != C.imemo_iseq
|
||||
|
||||
# Remove this block from the version array
|
||||
remove_block(iseq, block)
|
||||
|
||||
|
@ -286,6 +289,11 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
def mjit_blocks(iseq)
|
||||
# Tolerate GC on any ISEQ
|
||||
if C.imemo_type(iseq) != C.imemo_iseq
|
||||
return Hash.new { |h, k| h[k] = {} }
|
||||
end
|
||||
|
||||
unless iseq.body.mjit_blocks
|
||||
iseq.body.mjit_blocks = Hash.new { |h, k| h[k] = {} }
|
||||
# For some reason, rb_mjit_iseq_mark didn't protect this Hash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue