Skip to content

Commit d837fc8

Browse files
authored
Merge pull request #198 from jhawthorn/nil_true_false
Add codegen for rb_true and rb_false
2 parents 42755a9 + 8a95d79 commit d837fc8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

yjit_codegen.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,6 +2812,28 @@ jit_rb_obj_not(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const
28122812
return true;
28132813
}
28142814

2815+
// Codegen for rb_true()
2816+
static bool
2817+
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)
2818+
{
2819+
ADD_COMMENT(cb, "nil? == true");
2820+
ctx_stack_pop(ctx, 1);
2821+
x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_TRUE);
2822+
mov(cb, stack_ret, imm_opnd(Qtrue));
2823+
return true;
2824+
}
2825+
2826+
// Codegen for rb_false()
2827+
static bool
2828+
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)
2829+
{
2830+
ADD_COMMENT(cb, "nil? == false");
2831+
ctx_stack_pop(ctx, 1);
2832+
x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_FALSE);
2833+
mov(cb, stack_ret, imm_opnd(Qfalse));
2834+
return true;
2835+
}
2836+
28152837
// Check if we know how to codegen for a particular cfunc method
28162838
static method_codegen_t
28172839
lookup_cfunc_codegen(const rb_method_definition_t *def)
@@ -4102,4 +4124,7 @@ yjit_init_codegen(void)
41024124
yjit_method_codegen_table = st_init_numtable();
41034125

41044126
yjit_reg_method(rb_cBasicObject, "!", jit_rb_obj_not);
4127+
4128+
yjit_reg_method(rb_cNilClass, "nil?", jit_rb_true);
4129+
yjit_reg_method(rb_mKernel, "nil?", jit_rb_false);
41054130
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy