@@ -2812,6 +2812,28 @@ jit_rb_obj_not(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const
2812
2812
return true;
2813
2813
}
2814
2814
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
+
2815
2837
// Check if we know how to codegen for a particular cfunc method
2816
2838
static method_codegen_t
2817
2839
lookup_cfunc_codegen (const rb_method_definition_t * def )
@@ -4102,4 +4124,7 @@ yjit_init_codegen(void)
4102
4124
yjit_method_codegen_table = st_init_numtable ();
4103
4125
4104
4126
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 );
4105
4130
}
0 commit comments