From cacf2f3709a570560085e6a95c3a78e8fb8cc0f5 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 10 Feb 2023 21:54:35 -0800 Subject: [PATCH] Set 0 to cfp->pc on C func send --- lib/ruby_vm/mjit/insn_compiler.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 386a97eb26..33c7db5435 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -1294,7 +1294,10 @@ module RubyVM::MJIT asm.comment('set up new frame') cfp_offset = -C.rb_control_frame_t.size # callee CFP - # Not setting PC since JIT code will do that as needed + # For ISEQ, JIT code will set it as needed. However, C func needs 0 there for svar frame detection. + if iseq.nil? + asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:pc)], 0) + end asm.mov(:rax, iseq.to_i) asm.mov([CFP, cfp_offset + C.rb_control_frame_t.offsetof(:iseq)], :rax) self_index = ctx.sp_offset - (1 + argc) # TODO: +1 for VM_CALL_ARGS_BLOCKARG