From 93c728ce9143b2f32e5d3073c8d2c87da8e0db54 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 22 Sep 2025 22:25:01 +0100 Subject: YJIT: Pass iseq pointer to get/set classvariable functions (#14625) * YJIT: Pass iseq pointer to get/set classvariable functions Since we already have the iseq pointer, we can actually save one memory read by passing it directly. We need to wrap the iseq in a VALUE so it can be marked correctly by GC. * YJIT: Fix missing GC marking when passing iseq to rb_vm_setinstancevariable Without wrapping the iseq in a `Operand::Value`, the iseq would not be marked correctly by GC and when compacting the heap, the iseq would be lost and cause a crash. --- yjit/src/codegen.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 85fed25d24..67841d2fdc 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -3148,7 +3148,7 @@ fn gen_set_ivar( asm.ccall( rb_vm_setinstancevariable as *const u8, vec![ - Opnd::const_ptr(jit.iseq as *const u8), + VALUE(jit.iseq as usize).into(), Opnd::mem(64, CFP, RUBY_OFFSET_CFP_SELF), ivar_name.into(), val_opnd, @@ -10207,7 +10207,7 @@ fn gen_getclassvariable( let val_opnd = asm.ccall( rb_vm_getclassvariable as *const u8, vec![ - Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ), + VALUE(jit.iseq as usize).into(), CFP, Opnd::UImm(jit.get_arg(0).as_u64()), Opnd::UImm(jit.get_arg(1).as_u64()), @@ -10231,7 +10231,7 @@ fn gen_setclassvariable( asm.ccall( rb_vm_setclassvariable as *const u8, vec![ - Opnd::mem(64, CFP, RUBY_OFFSET_CFP_ISEQ), + VALUE(jit.iseq as usize).into(), CFP, Opnd::UImm(jit.get_arg(0).as_u64()), val, -- cgit v1.2.3