diff options
-rw-r--r-- | lib/ruby_vm/mjit/compiler.rb | 8 | ||||
-rw-r--r-- | mjit_c.rb | 9 | ||||
-rwxr-xr-x | tool/mjit/bindgen.rb | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb index 892b250895..e6dde1d824 100644 --- a/lib/ruby_vm/mjit/compiler.rb +++ b/lib/ruby_vm/mjit/compiler.rb @@ -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 @@ -241,6 +241,11 @@ module RubyVM::MJIT # :nodoc: all } end + def imemo_type(ptr) + _ptr = ptr.to_i + Primitive.cexpr! 'UINT2NUM(imemo_type((VALUE)NUM2SIZET(_ptr)))' + end + #======================================================================================== # # Old stuff @@ -670,6 +675,10 @@ module RubyVM::MJIT # :nodoc: all Primitive.cexpr! %q{ UINT2NUM(VM_METHOD_TYPE_ZSUPER) } end + def C.imemo_iseq + Primitive.cexpr! %q{ UINT2NUM(imemo_iseq) } + end + def C.INVALID_SHAPE_ID Primitive.cexpr! %q{ ULONG2NUM(INVALID_SHAPE_ID) } end diff --git a/tool/mjit/bindgen.rb b/tool/mjit/bindgen.rb index 92b3ae1932..b8fd7308e9 100755 --- a/tool/mjit/bindgen.rb +++ b/tool/mjit/bindgen.rb @@ -420,6 +420,7 @@ generator = BindingGenerator.new( VM_METHOD_TYPE_UNDEF VM_METHOD_TYPE_ZSUPER VM_METHOD_TYPE_REFINED + imemo_iseq ], ULONG: %w[ INVALID_SHAPE_ID |