ruby-changes:69089
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:47 +0900 (JST)
Subject: [ruby-changes:69089] dc8aca1883 (master): Use push and pop in jit_rb_obj_not to avoid corrupting types
https://git.ruby-lang.org/ruby.git/commit/?id=dc8aca1883 From dc8aca1883ebc76e02ff7097405d48f489c3535f Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Mon, 12 Jul 2021 12:33:24 -0700 Subject: Use push and pop in jit_rb_obj_not to avoid corrupting types --- yjit_codegen.c | 7 ++++--- 1 file 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 https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2409 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/