ruby-changes:68996
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:37 +0900 (JST)
Subject: [ruby-changes:68996] 3677b233dd (master): Implement opt_nil_p and opt_empty_b by delegating to send (#35)
https://git.ruby-lang.org/ruby.git/commit/?id=3677b233dd From 3677b233ddc5c0410b71590e709bb9e940e58fa3 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maximechevalierb@g...> Date: Tue, 11 May 2021 12:51:05 -0400 Subject: Implement opt_nil_p and opt_empty_b by delegating to send (#35) --- yjit_codegen.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1627 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) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2686 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); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/