diff options
author | Maxime Chevalier-Boisvert <[email protected]> | 2021-04-15 15:00:07 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:33 -0400 |
commit | f2530f884eff1910fb69201cb0a009332fa1b150 (patch) | |
tree | 5623e3733a70affab5e0ec2fa9a590c67190e42e /yjit_codegen.c | |
parent | 6250506de2f11bc45d1d7a0cfb2a4d15390c16ca (diff) |
Improve codegen and type tracking in putobject
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 17 |
1 files 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) { // 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) } 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; |