summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-06-07 09:35:11 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:35 -0400
commited636b59edf18199c9a3477bfb7b514c7756778a (patch)
treefed8c9af1f317114224921631dfb83676ae7c5e0 /yjit_codegen.c
parentd77c989ac73274a0908746c0f861fb8936f64dfc (diff)
Add duparray to YJIT codegen
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 26a718ef32..d5291fc660 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -623,6 +623,28 @@ gen_newarray(jitstate_t* jit, ctx_t* ctx)
return YJIT_KEEP_COMPILING;
}
+// dup array
+static codegen_status_t
+gen_duparray(jitstate_t* jit, ctx_t* ctx)
+{
+ VALUE ary = jit_get_arg(jit, 0);
+
+ // Save the PC and SP because we are allocating
+ jit_save_pc(jit, REG0);
+ jit_save_sp(jit, ctx);
+
+ // call rb_ary_resurrect(VALUE ary);
+ yjit_save_regs(cb);
+ jit_mov_gc_ptr(jit, cb, C_ARG_REGS[0], ary);
+ call_ptr(cb, REG0, (void *)rb_ary_resurrect);
+ yjit_load_regs(cb);
+
+ x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_ARRAY);
+ mov(cb, stack_ret, RAX);
+
+ return YJIT_KEEP_COMPILING;
+}
+
// new hash initialized from top N values
static codegen_status_t
gen_newhash(jitstate_t* jit, ctx_t* ctx)
@@ -3033,6 +3055,7 @@ yjit_init_codegen(void)
yjit_reg_op(BIN(pop), gen_pop);
yjit_reg_op(BIN(adjuststack), gen_adjuststack);
yjit_reg_op(BIN(newarray), gen_newarray);
+ yjit_reg_op(BIN(duparray), gen_duparray);
yjit_reg_op(BIN(newhash), gen_newhash);
yjit_reg_op(BIN(concatstrings), gen_concatstrings);
yjit_reg_op(BIN(putnil), gen_putnil);