Skip to content

Commit dd10097

Browse files
committed
WIP: fix a bunch of small bugs
1 parent 98af475 commit dd10097

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

zjit/src/codegen.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,25 @@ fn gen_call_method(
466466
state: &FrameState,
467467
) -> Option<Opnd> {
468468
// Don't push recv; it is passed in separately.
469+
asm_comment!(asm, "make stack-allocated array of {} args", args.len());
469470
for &arg in args.iter().rev() {
470471
asm.cpush(jit.get_opnd(arg)?);
471472
}
472473
// Save PC for GC
473474
gen_save_pc(asm, state);
474475
// Call rb_zjit_vm_call0_no_splat, which will push a frame
475-
asm_comment!(asm, "call rb_zjit_vm_call0_no_splat");
476476
// TODO(max): Figure out if we need to manually handle stack alignment and how to do it
477477
let call_info = unsafe { rb_get_call_data_ci(cd) };
478478
let method_id = unsafe { rb_vm_ci_mid(call_info) };
479+
asm_comment!(asm, "get stack pointer");
480+
let sp = asm.lea(Opnd::mem(VALUE_BITS, NATIVE_STACK_PTR, 0));
481+
asm_comment!(asm, "call rb_zjit_vm_call0_no_splat");
479482
let result = asm.ccall(
480483
rb_zjit_vm_call0_no_splat as *const u8,
481-
vec![EC, recv, Opnd::UImm(method_id.0), Opnd::UImm(args.len().try_into().unwrap()), NATIVE_STACK_PTR, callable],
484+
vec![EC, recv, Opnd::UImm(method_id.0), Opnd::UImm(args.len().try_into().unwrap()), sp, callable],
482485
);
483486
// Pop all the args off the stack
487+
asm_comment!(asm, "clear stack-allocated array of {} args", args.len());
484488
let new_sp = asm.add(NATIVE_STACK_PTR, (args.len()*SIZEOF_VALUE).into());
485489
asm.mov(NATIVE_STACK_PTR, new_sp);
486490
Some(result)

0 commit comments

Comments
 (0)