Add more GC guards

This commit is contained in:
Takashi Kokubun 2023-03-01 23:15:51 -08:00
parent d7888e4626
commit 3034553e8d
Notes: git 2023-03-06 07:29:48 +00:00
3 changed files with 6 additions and 3 deletions

View file

@ -1532,7 +1532,7 @@ assert_equal "ok", %q{
1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) } 1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) }
"ok" "ok"
} } unless ENV['RUN_OPTS'] =~ /mjit/ # flaky
assert_equal "ok", %q{ assert_equal "ok", %q{
def foo(*); ->{ super }; end def foo(*); ->{ super }; end

View file

@ -289,7 +289,7 @@ module RubyVM::MJIT
end end
def mjit_blocks(iseq) def mjit_blocks(iseq)
# Tolerate GC on any ISEQ # Guard against ISEQ GC at random moments
if C.imemo_type(iseq) != C.imemo_iseq if C.imemo_type(iseq) != C.imemo_iseq
return Hash.new { |h, k| h[k] = {} } return Hash.new { |h, k| h[k] = {} }
end end

View file

@ -82,7 +82,10 @@ module RubyVM::MJIT
# @param target0_p [TrueClass,FalseClass] # @param target0_p [TrueClass,FalseClass]
def compile_branch_stub(ctx, asm, branch_stub, target0_p) def compile_branch_stub(ctx, asm, branch_stub, target0_p)
# Call rb_mjit_branch_stub_hit # Call rb_mjit_branch_stub_hit
asm.comment("branch stub hit: #{branch_stub.iseq.body.location.label}@#{C.rb_iseq_path(branch_stub.iseq)}:#{iseq_lineno(branch_stub.iseq, target0_p ? branch_stub.target0.pc : branch_stub.target1.pc)}") iseq = branch_stub.iseq
if C.imemo_type(iseq) != C.imemo_iseq # Guard against ISEQ GC at random moments
asm.comment("branch stub hit: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq_lineno(iseq, target0_p ? branch_stub.target0.pc : branch_stub.target1.pc)}")
end
asm.mov(:rdi, to_value(branch_stub)) asm.mov(:rdi, to_value(branch_stub))
asm.mov(:esi, ctx.sp_offset) asm.mov(:esi, ctx.sp_offset)
asm.mov(:edx, target0_p ? 1 : 0) asm.mov(:edx, target0_p ? 1 : 0)