mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +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)
|
def invalidate_block(block)
|
||||||
iseq = block.iseq
|
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 this block from the version array
|
||||||
remove_block(iseq, block)
|
remove_block(iseq, block)
|
||||||
|
|
||||||
|
@ -286,6 +289,11 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
def mjit_blocks(iseq)
|
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
|
unless iseq.body.mjit_blocks
|
||||||
iseq.body.mjit_blocks = Hash.new { |h, k| h[k] = {} }
|
iseq.body.mjit_blocks = Hash.new { |h, k| h[k] = {} }
|
||||||
# For some reason, rb_mjit_iseq_mark didn't protect this Hash
|
# For some reason, rb_mjit_iseq_mark didn't protect this Hash
|
||||||
|
|
|
@ -241,6 +241,11 @@ module RubyVM::MJIT # :nodoc: all
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def imemo_type(ptr)
|
||||||
|
_ptr = ptr.to_i
|
||||||
|
Primitive.cexpr! 'UINT2NUM(imemo_type((VALUE)NUM2SIZET(_ptr)))'
|
||||||
|
end
|
||||||
|
|
||||||
#========================================================================================
|
#========================================================================================
|
||||||
#
|
#
|
||||||
# Old stuff
|
# Old stuff
|
||||||
|
@ -670,6 +675,10 @@ module RubyVM::MJIT # :nodoc: all
|
||||||
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_ZSUPER) }
|
Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_ZSUPER) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def C.imemo_iseq
|
||||||
|
Primitive.cexpr! %q{ UINT2NUM(imemo_iseq) }
|
||||||
|
end
|
||||||
|
|
||||||
def C.INVALID_SHAPE_ID
|
def C.INVALID_SHAPE_ID
|
||||||
Primitive.cexpr! %q{ ULONG2NUM(INVALID_SHAPE_ID) }
|
Primitive.cexpr! %q{ ULONG2NUM(INVALID_SHAPE_ID) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -420,6 +420,7 @@ generator = BindingGenerator.new(
|
||||||
VM_METHOD_TYPE_UNDEF
|
VM_METHOD_TYPE_UNDEF
|
||||||
VM_METHOD_TYPE_ZSUPER
|
VM_METHOD_TYPE_ZSUPER
|
||||||
VM_METHOD_TYPE_REFINED
|
VM_METHOD_TYPE_REFINED
|
||||||
|
imemo_iseq
|
||||||
],
|
],
|
||||||
ULONG: %w[
|
ULONG: %w[
|
||||||
INVALID_SHAPE_ID
|
INVALID_SHAPE_ID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue