ruby-changes:69199
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:23:21 +0900 (JST)
Subject: [ruby-changes:69199] 922aed92b5 (master): Add codegen for rb_true and rb_false
https://git.ruby-lang.org/ruby.git/commit/?id=922aed92b5 From 922aed92b5e4602571d191e62904304458c9998d Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Wed, 30 Jun 2021 16:53:49 -0700 Subject: Add codegen for rb_true and rb_false These are used by .nil? and therefore opt_nil_p --- yjit_codegen.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/yjit_codegen.c b/yjit_codegen.c index 9eff50b2e4..77a0e02de4 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -2813,6 +2813,28 @@ jit_rb_obj_not(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2813 return true; } +// Codegen for rb_true() +static bool +jit_rb_true(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const rb_callable_method_entry_t *cme, rb_iseq_t *block, const int32_t argc) +{ + ADD_COMMENT(cb, "nil? == true"); + ctx_stack_pop(ctx, 1); + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_TRUE); + mov(cb, stack_ret, imm_opnd(Qtrue)); + return true; +} + +// Codegen for rb_false() +static bool +jit_rb_false(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const rb_callable_method_entry_t *cme, rb_iseq_t *block, const int32_t argc) +{ + ADD_COMMENT(cb, "nil? == false"); + ctx_stack_pop(ctx, 1); + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_FALSE); + mov(cb, stack_ret, imm_opnd(Qfalse)); + return true; +} + // Check if we know how to codegen for a particular cfunc method static method_codegen_t lookup_cfunc_codegen(const rb_method_definition_t *def) @@ -4103,4 +4125,7 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L4125 yjit_method_codegen_table = st_init_numtable(); yjit_reg_method(rb_cBasicObject, "!", jit_rb_obj_not); + + yjit_reg_method(rb_cNilClass, "nil?", jit_rb_true); + yjit_reg_method(rb_mKernel, "nil?", jit_rb_false); } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/