Skip to content

Commit 195808c

Browse files
maximecbXrXr
authored andcommitted
Implement opt_nil_p and opt_empty_b by delegating to send (#35)
1 parent 38955f5 commit 195808c

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
@@ -1627,10 +1627,35 @@ gen_opt_mod(jitstate_t* jit, ctx_t* ctx)
16271627
static codegen_status_t
16281628
gen_opt_ltlt(jitstate_t* jit, ctx_t* ctx)
16291629
{
1630-
// Delegate to send, call the ltlt method
1630+
// Delegate to send, call the method on the recv
16311631
return gen_opt_send_without_block(jit, ctx);
16321632
}
16331633

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

0 commit comments

Comments
 (0)