1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Port and test duparray and splatarray (https://github.com/Shopify/ruby/pull/337)

* Port duparray opcode

* Port and test splatarray
This commit is contained in:
Noah Gibbs 2022-07-22 17:08:35 +01:00 committed by Takashi Kokubun
parent e9f9b8f43b
commit b1ed4d9b94
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD

View file

@ -1181,29 +1181,29 @@ fn gen_newarray(
KeepCompiling KeepCompiling
} }
/*
// dup array // dup array
fn gen_duparray( fn gen_duparray(
jit: &mut JITState, jit: &mut JITState,
ctx: &mut Context, ctx: &mut Context,
cb: &mut CodeBlock, asm: &mut Assembler,
_ocb: &mut OutlinedCb, _ocb: &mut OutlinedCb,
) -> CodegenStatus { ) -> CodegenStatus {
let ary = jit_get_arg(jit, 0); let ary = jit_get_arg(jit, 0);
// Save the PC and SP because we are allocating // Save the PC and SP because we are allocating
jit_prepare_routine_call(jit, ctx, cb, REG0); jit_prepare_routine_call(jit, ctx, asm);
// call rb_ary_resurrect(VALUE ary); // call rb_ary_resurrect(VALUE ary);
jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], ary); let new_ary = asm.ccall(
call_ptr(cb, REG0, rb_ary_resurrect as *const u8); rb_ary_resurrect as *const u8,
vec![ary.into()],
);
let stack_ret = ctx.stack_push(Type::Array); let stack_ret = ctx.stack_push(Type::Array);
mov(cb, stack_ret, RAX); asm.mov(stack_ret, new_ary);
KeepCompiling KeepCompiling
} }
*/
// dup hash // dup hash
fn gen_duphash( fn gen_duphash(
@ -1226,34 +1226,30 @@ fn gen_duphash(
KeepCompiling KeepCompiling
} }
/*
// call to_a on the array on the stack // call to_a on the array on the stack
fn gen_splatarray( fn gen_splatarray(
jit: &mut JITState, jit: &mut JITState,
ctx: &mut Context, ctx: &mut Context,
cb: &mut CodeBlock, asm: &mut Assembler,
_ocb: &mut OutlinedCb, _ocb: &mut OutlinedCb,
) -> CodegenStatus { ) -> CodegenStatus {
let flag = jit_get_arg(jit, 0); let flag = jit_get_arg(jit, 0);
// Save the PC and SP because the callee may allocate // Save the PC and SP because the callee may allocate
// Note that this modifies REG_SP, which is why we do it first // Note that this modifies REG_SP, which is why we do it first
jit_prepare_routine_call(jit, ctx, cb, REG0); jit_prepare_routine_call(jit, ctx, asm);
// Get the operands from the stack // Get the operands from the stack
let ary_opnd = ctx.stack_pop(1); let ary_opnd = ctx.stack_pop(1);
// Call rb_vm_splat_array(flag, ary) // Call rb_vm_splat_array(flag, ary)
jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], flag); let ary = asm.ccall(rb_vm_splat_array as *const u8, vec![flag.into(), ary_opnd]);
mov(cb, C_ARG_REGS[1], ary_opnd);
call_ptr(cb, REG1, rb_vm_splat_array as *const u8);
let stack_ret = ctx.stack_push(Type::Array); let stack_ret = ctx.stack_push(Type::Array);
mov(cb, stack_ret, RAX); asm.mov(stack_ret, ary);
KeepCompiling KeepCompiling
} }
*/
// new range initialized from top 2 values // new range initialized from top 2 values
fn gen_newrange( fn gen_newrange(
@ -5988,7 +5984,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_newhash => Some(gen_newhash), YARVINSN_newhash => Some(gen_newhash),
YARVINSN_duphash => Some(gen_duphash), YARVINSN_duphash => Some(gen_duphash),
YARVINSN_newarray => Some(gen_newarray), YARVINSN_newarray => Some(gen_newarray),
//YARVINSN_duparray => Some(gen_duparray), YARVINSN_duparray => Some(gen_duparray),
//YARVINSN_checktype => Some(gen_checktype), //YARVINSN_checktype => Some(gen_checktype),
YARVINSN_opt_lt => Some(gen_opt_lt), YARVINSN_opt_lt => Some(gen_opt_lt),
/* /*
@ -5998,8 +5994,8 @@ fn get_gen_fn(opcode: VALUE) -> Option<InsnGenFn> {
YARVINSN_opt_mod => Some(gen_opt_mod), YARVINSN_opt_mod => Some(gen_opt_mod),
YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze), YARVINSN_opt_str_freeze => Some(gen_opt_str_freeze),
YARVINSN_opt_str_uminus => Some(gen_opt_str_uminus), YARVINSN_opt_str_uminus => Some(gen_opt_str_uminus),
YARVINSN_splatarray => Some(gen_splatarray),
*/ */
YARVINSN_splatarray => Some(gen_splatarray),
YARVINSN_newrange => Some(gen_newrange), YARVINSN_newrange => Some(gen_newrange),
YARVINSN_putstring => Some(gen_putstring), YARVINSN_putstring => Some(gen_putstring),
/* /*