diff options
author | John Hawthorn <john@hawthorn.email> | 2021-07-12 12:33:24 -0700 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:37 -0400 |
commit | dc8aca1883ebc76e02ff7097405d48f489c3535f (patch) | |
tree | 64e47427ad19f15fe2c519998d4b1cbb6ceccb32 /yjit_codegen.c | |
parent | 0c390e99652a2a8880f06be17c663d3408e97772 (diff) |
Use push and pop in jit_rb_obj_not to avoid corrupting types
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index b75b6f26cf..577e104fe2 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -2409,18 +2409,19 @@ static bool jit_rb_obj_not(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) { const val_type_t recv_opnd = ctx_get_opnd_type(ctx, OPND_STACK(0)); - x86opnd_t out_opnd = ctx_stack_opnd(ctx, 0); if (recv_opnd.type == ETYPE_NIL || recv_opnd.type == ETYPE_FALSE) { ADD_COMMENT(cb, "rb_obj_not(nil_or_false)"); + ctx_stack_pop(ctx, 1); + x86opnd_t out_opnd = ctx_stack_push(ctx, TYPE_TRUE); mov(cb, out_opnd, imm_opnd(Qtrue)); - ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_TRUE); } else if (recv_opnd.is_heap || recv_opnd.type != ETYPE_UNKNOWN) { // Note: recv_opnd.type != ETYPE_NIL && recv_opnd.type != ETYPE_FALSE. ADD_COMMENT(cb, "rb_obj_not(truthy)"); + ctx_stack_pop(ctx, 1); + x86opnd_t out_opnd = ctx_stack_push(ctx, TYPE_FALSE); mov(cb, out_opnd, imm_opnd(Qfalse)); - ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_FALSE); } else { // jit_guard_known_klass() already ran on the receiver which should |