Skip to content

Commit 1dc8dde

Browse files
authored
Implement opt_nil_p and opt_empty_b by delegating to send (#35)
1 parent 6ec5388 commit 1dc8dde

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

yjit_codegen.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,10 +1625,35 @@ gen_opt_mod(jitstate_t* jit, ctx_t* ctx)
16251625
static codegen_status_t
16261626
gen_opt_ltlt(jitstate_t* jit, ctx_t* ctx)
16271627
{
1628-
// Delegate to send, call the ltlt method
1628+
// Delegate to send, call the method on the recv
16291629
return gen_opt_send_without_block(jit, ctx);
16301630
}
16311631

1632+
static codegen_status_t
1633+
gen_opt_nil_p(jitstate_t* jit, ctx_t* ctx)
1634+
{
1635+
// Delegate to send, call the method on the recv
1636+
return gen_opt_send_without_block(jit, ctx);
1637+
}
1638+
1639+
static codegen_status_t
1640+
gen_opt_empty_p(jitstate_t* jit, ctx_t* ctx)
1641+
{
1642+
// Delegate to send, call the method on the recv
1643+
return gen_opt_send_without_block(jit, ctx);
1644+
}
1645+
1646+
static codegen_status_t
1647+
gen_opt_not(jitstate_t* jit, ctx_t* ctx)
1648+
{
1649+
// TODO: can we implement a fast path?
1650+
// Most likely, almost every input to opt_not is true/false/nil?
1651+
1652+
// NOTE: we can't really delegate to OSWB because we currently
1653+
// don't support calls to methods on true/false/nil
1654+
return YJIT_CANT_COMPILE;
1655+
}
1656+
16321657
void
16331658
gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t shape)
16341659
{
@@ -2660,6 +2685,9 @@ yjit_init_codegen(void)
26602685
yjit_reg_op(BIN(opt_plus), gen_opt_plus);
26612686
yjit_reg_op(BIN(opt_mod), gen_opt_mod);
26622687
yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt);
2688+
yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p);
2689+
yjit_reg_op(BIN(opt_empty_p), gen_opt_empty_p);
2690+
yjit_reg_op(BIN(opt_not), gen_opt_not);
26632691
yjit_reg_op(BIN(opt_getinlinecache), gen_opt_getinlinecache);
26642692
yjit_reg_op(BIN(branchif), gen_branchif);
26652693
yjit_reg_op(BIN(branchunless), gen_branchunless);

0 commit comments

Comments
 (0)