ruby-changes:68998
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:38 +0900 (JST)
Subject: [ruby-changes:68998] f2530f884e (master): Improve codegen and type tracking in putobject
https://git.ruby-lang.org/ruby.git/commit/?id=f2530f884e From f2530f884eff1910fb69201cb0a009332fa1b150 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Thu, 15 Apr 2021 15:00:07 -0400 Subject: Improve codegen and type tracking in putobject --- yjit_codegen.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index 5b6acad46a..b986395426 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -454,7 +454,6 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L454 { // Keep track of the fixnum type tag x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_FIXNUM); - x86opnd_t imm = imm_opnd((int64_t)arg); // 64-bit immediates can't be directly written to memory @@ -475,17 +474,17 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L474 } else { - // Load the argument from the bytecode sequence. - // We need to do this as the argument can change due to GC compaction. - x86opnd_t pc_plus_one = const_ptr_opnd((void*)(jit->pc + 1)); - mov(cb, RAX, pc_plus_one); - mov(cb, RAX, mem_opnd(64, RAX, 0)); + // Load the value to push into REG0 + // Note that this value may get moved by the GC + VALUE put_val = jit_get_arg(jit, 0); + jit_mov_gc_ptr(jit, cb, REG0, put_val); - // TODO: check if argument is a heap object + // TODO: check for more specific types like array, string, symbol, etc. + val_type_t val_type = SPECIAL_CONST_P(put_val)? TYPE_IMM:TYPE_HEAP; // Write argument at SP - x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_UNKNOWN); - mov(cb, stack_top, RAX); + x86opnd_t stack_top = ctx_stack_push(ctx, val_type); + mov(cb, stack_top, REG0); } return YJIT_KEEP_COMPILING; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/