diff options
author | Takashi Kokubun <[email protected]> | 2023-03-01 22:06:57 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-05 23:28:59 -0800 |
commit | 706f6272d9340f54b30bd9c83c97c5c22d2e894d (patch) | |
tree | 316ad5070bd02e2a391b4e9e2d6f05a83516b5f7 /lib/ruby_vm/mjit/compiler.rb | |
parent | 7dcdffebc8da9319bc2a0a2e0d9e90fdc140d79c (diff) |
Guard against GC of random ISEQs
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7448
Diffstat (limited to 'lib/ruby_vm/mjit/compiler.rb')
-rw-r--r-- | lib/ruby_vm/mjit/compiler.rb | 8 |
1 files changed, 8 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 |