diff options
author | John Hawthorn <[email protected]> | 2021-09-08 17:48:08 -0700 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:40 -0400 |
commit | 692f94ba0c878b30ebf96480b0f7e58f7f0ffa08 (patch) | |
tree | b608726afabd82728da71081b0e77548df272686 /yjit_codegen.c | |
parent | 4b58d698b14752f4dfd405637df384c758cae396 (diff) |
Add jit_rb_obj_equal
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index c0734fddaf..5ac4e0d9d1 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -2969,6 +2969,26 @@ jit_rb_false(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const rb return true; } +// Codegen for rb_obj_equal() +// object identity comparison +static bool +jit_rb_obj_equal(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, "equal?"); + x86opnd_t obj1 = ctx_stack_pop(ctx, 1); + x86opnd_t obj2 = ctx_stack_pop(ctx, 1); + + mov(cb, REG0, obj1); + cmp(cb, REG0, obj2); + mov(cb, REG0, imm_opnd(Qtrue)); + mov(cb, REG1, imm_opnd(Qfalse)); + cmovne(cb, REG0, REG1); + + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_IMM); + mov(cb, stack_ret, REG0); + 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) @@ -4270,4 +4290,11 @@ yjit_init_codegen(void) yjit_reg_method(rb_cNilClass, "nil?", jit_rb_true); yjit_reg_method(rb_mKernel, "nil?", jit_rb_false); + + yjit_reg_method(rb_cBasicObject, "==", jit_rb_obj_equal); + yjit_reg_method(rb_cBasicObject, "equal?", jit_rb_obj_equal); + yjit_reg_method(rb_mKernel, "eql?", jit_rb_obj_equal); + yjit_reg_method(rb_cModule, "==", jit_rb_obj_equal); + yjit_reg_method(rb_cSymbol, "==", jit_rb_obj_equal); + yjit_reg_method(rb_cSymbol, "===", jit_rb_obj_equal); } |