summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2021-07-17 03:26:46 -0700
committerAlan Wu <[email protected]>2021-10-20 18:19:39 -0400
commitc210fade27c2f39f078c9b1aec71a05532fb832b (patch)
tree3947355e6e0f5572d38261946df6c16080eb3a7b /yjit_codegen.c
parent3a3f7066986b6d0a24a6f7c72d2304381269b30d (diff)
Implement newrange
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 08ac6f0ec6..0abf2376c6 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -917,6 +917,28 @@ gen_splatarray(jitstate_t* jit, ctx_t* ctx)
return YJIT_KEEP_COMPILING;
}
+// new range initialized from top 2 values
+static codegen_status_t
+gen_newrange(jitstate_t* jit, ctx_t* ctx)
+{
+ rb_num_t flag = (rb_num_t)jit_get_arg(jit, 0);
+
+ // rb_range_new() allocates and can raise
+ jit_prepare_routine_call(jit, ctx, REG0);
+
+ // val = rb_range_new(low, high, (int)flag);
+ mov(cb, C_ARG_REGS[0], ctx_stack_opnd(ctx, 1));
+ mov(cb, C_ARG_REGS[1], ctx_stack_opnd(ctx, 0));
+ mov(cb, C_ARG_REGS[2], imm_opnd(flag));
+ call_ptr(cb, REG0, (void *)rb_range_new);
+
+ ctx_stack_pop(ctx, 2);
+ x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_HEAP);
+ mov(cb, stack_ret, RAX);
+
+ return YJIT_KEEP_COMPILING;
+}
+
static void
guard_object_is_heap(codeblock_t *cb, x86opnd_t object_opnd, ctx_t *ctx, uint8_t *side_exit)
{
@@ -4014,6 +4036,7 @@ yjit_init_codegen(void)
yjit_reg_op(BIN(splatarray), gen_splatarray);
yjit_reg_op(BIN(expandarray), gen_expandarray);
yjit_reg_op(BIN(newhash), gen_newhash);
+ yjit_reg_op(BIN(newrange), gen_newrange);
yjit_reg_op(BIN(concatstrings), gen_concatstrings);
yjit_reg_op(BIN(putnil), gen_putnil);
yjit_reg_op(BIN(putobject), gen_putobject);