mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 12:04:01 +02:00
Fix MicroJIT argument copying for CFUNC calls
This commit is contained in:
parent
37e4350e80
commit
d49edada2e
1 changed files with 14 additions and 10 deletions
|
@ -492,13 +492,10 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
||||||
|
|
||||||
struct rb_call_data * cd = (struct rb_call_data *)ctx_get_arg(ctx, 0);
|
struct rb_call_data * cd = (struct rb_call_data *)ctx_get_arg(ctx, 0);
|
||||||
int32_t argc = (int32_t)vm_ci_argc(cd->ci);
|
int32_t argc = (int32_t)vm_ci_argc(cd->ci);
|
||||||
const struct rb_callcache *cc = cd->cc;
|
|
||||||
|
|
||||||
// Callee method ID
|
// Callee method ID
|
||||||
ID mid = vm_ci_mid(cd->ci);
|
ID mid = vm_ci_mid(cd->ci);
|
||||||
|
|
||||||
//printf("jitting call to \"%s\", argc: %lu\n", rb_id2name(mid), argc);
|
|
||||||
|
|
||||||
// Don't JIT calls with keyword splat
|
// Don't JIT calls with keyword splat
|
||||||
if (vm_ci_flag(cd->ci) & VM_CALL_KW_SPLAT)
|
if (vm_ci_flag(cd->ci) & VM_CALL_KW_SPLAT)
|
||||||
{
|
{
|
||||||
|
@ -541,8 +538,6 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("JITting call to C function \"%s\", argc: %lu\n", rb_id2name(mid), argc);
|
//printf("JITting call to C function \"%s\", argc: %lu\n", rb_id2name(mid), argc);
|
||||||
//print_str(cb, rb_id2name(mid));
|
|
||||||
//print_ptr(cb, RCX);
|
|
||||||
|
|
||||||
// Create a size-exit to fall back to the interpreter
|
// Create a size-exit to fall back to the interpreter
|
||||||
uint8_t* side_exit = ujit_side_exit(ocb, ctx, ctx->pc);
|
uint8_t* side_exit = ujit_side_exit(ocb, ctx, ctx->pc);
|
||||||
|
@ -551,6 +546,12 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
||||||
x86opnd_t recv = ctx_stack_opnd(ctx, argc);
|
x86opnd_t recv = ctx_stack_opnd(ctx, argc);
|
||||||
mov(cb, REG0, recv);
|
mov(cb, REG0, recv);
|
||||||
|
|
||||||
|
//print_str(cb, "");
|
||||||
|
//print_str(cb, "calling CFUNC:");
|
||||||
|
//print_str(cb, rb_id2name(mid));
|
||||||
|
//print_str(cb, "recv");
|
||||||
|
//print_ptr(cb, recv);
|
||||||
|
|
||||||
// Check that the receiver is a heap object
|
// Check that the receiver is a heap object
|
||||||
test(cb, REG0, imm_opnd(RUBY_IMMEDIATE_MASK));
|
test(cb, REG0, imm_opnd(RUBY_IMMEDIATE_MASK));
|
||||||
jnz_ptr(cb, side_exit);
|
jnz_ptr(cb, side_exit);
|
||||||
|
@ -608,8 +609,10 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print_str(cb, "calling CFUNC:");
|
|
||||||
print_str(cb, rb_id2name(mid));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Increment the stack pointer by 3 (in the callee)
|
// Increment the stack pointer by 3 (in the callee)
|
||||||
// sp += 3
|
// sp += 3
|
||||||
|
@ -677,10 +680,11 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
|
||||||
lea(cb, RAX, ctx_sp_opnd(ctx));
|
lea(cb, RAX, ctx_sp_opnd(ctx));
|
||||||
|
|
||||||
// Copy the arguments from the stack to the C argument registers
|
// Copy the arguments from the stack to the C argument registers
|
||||||
for (int32_t i = argc; i >= 0; --i)
|
// self is the 0th argument and is at index argc from the stack top
|
||||||
|
for (int32_t i = 0; i < argc + 1; ++i)
|
||||||
{
|
{
|
||||||
// Recv is at index argc
|
x86opnd_t stack_opnd = mem_opnd(64, RAX, -(argc + 1 - i) * 8);
|
||||||
x86opnd_t stack_opnd = mem_opnd(64, RAX, -(i+1) * 8);
|
//print_ptr(cb, stack_opnd);
|
||||||
x86opnd_t c_arg_reg = C_ARG_REGS[i];
|
x86opnd_t c_arg_reg = C_ARG_REGS[i];
|
||||||
mov(cb, c_arg_reg, stack_opnd);
|
mov(cb, c_arg_reg, stack_opnd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue