summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maximechevalierb@gmail.com>2021-05-11 12:51:05 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:35 -0400
commit3677b233ddc5c0410b71590e709bb9e940e58fa3 (patch)
treeeb16da2cbc5881842cba2ae5f34248609ed6c77f
parentd6412126bcafb4a123aebe4f614e45d5d1064948 (diff)
Implement opt_nil_p and opt_empty_b by delegating to send (#35)
-rw-r--r--yjit_codegen.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 5e5b3b2f35..00a69942df 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1627,10 +1627,35 @@ gen_opt_mod(jitstate_t* jit, ctx_t* ctx)
static codegen_status_t
gen_opt_ltlt(jitstate_t* jit, ctx_t* ctx)
{
- // Delegate to send, call the ltlt method
+ // Delegate to send, call the method on the recv
return gen_opt_send_without_block(jit, ctx);
}
+static codegen_status_t
+gen_opt_nil_p(jitstate_t* jit, ctx_t* ctx)
+{
+ // Delegate to send, call the method on the recv
+ return gen_opt_send_without_block(jit, ctx);
+}
+
+static codegen_status_t
+gen_opt_empty_p(jitstate_t* jit, ctx_t* ctx)
+{
+ // Delegate to send, call the method on the recv
+ return gen_opt_send_without_block(jit, ctx);
+}
+
+static codegen_status_t
+gen_opt_not(jitstate_t* jit, ctx_t* ctx)
+{
+ // TODO: can we implement a fast path?
+ // Most likely, almost every input to opt_not is true/false/nil?
+
+ // NOTE: we can't really delegate to OSWB because we currently
+ // don't support calls to methods on true/false/nil
+ return YJIT_CANT_COMPILE;
+}
+
void
gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t shape)
{
@@ -2661,6 +2686,9 @@ yjit_init_codegen(void)
yjit_reg_op(BIN(opt_plus), gen_opt_plus);
yjit_reg_op(BIN(opt_mod), gen_opt_mod);
yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt);
+ yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p);
+ yjit_reg_op(BIN(opt_empty_p), gen_opt_empty_p);
+ yjit_reg_op(BIN(opt_not), gen_opt_not);
yjit_reg_op(BIN(opt_getinlinecache), gen_opt_getinlinecache);
yjit_reg_op(BIN(branchif), gen_branchif);
yjit_reg_op(BIN(branchunless), gen_branchunless);