Skip to content

Commit 1bba31a

Browse files
author
Maxime Chevalier-Boisvert
committed
Improve codegen and type tracking in putobject
1 parent 10f54ed commit 1bba31a

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

yjit_codegen.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx)
454454
{
455455
// Keep track of the fixnum type tag
456456
x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_FIXNUM);
457-
458457
x86opnd_t imm = imm_opnd((int64_t)arg);
459458

460459
// 64-bit immediates can't be directly written to memory
@@ -475,17 +474,17 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx)
475474
}
476475
else
477476
{
478-
// Load the argument from the bytecode sequence.
479-
// We need to do this as the argument can change due to GC compaction.
480-
x86opnd_t pc_plus_one = const_ptr_opnd((void*)(jit->pc + 1));
481-
mov(cb, RAX, pc_plus_one);
482-
mov(cb, RAX, mem_opnd(64, RAX, 0));
477+
// Load the value to push into REG0
478+
// Note that this value may get moved by the GC
479+
VALUE put_val = jit_get_arg(jit, 0);
480+
jit_mov_gc_ptr(jit, cb, REG0, put_val);
483481

484-
// TODO: check if argument is a heap object
482+
// TODO: check for more specific types like array, string, symbol, etc.
483+
val_type_t val_type = SPECIAL_CONST_P(put_val)? TYPE_IMM:TYPE_HEAP;
485484

486485
// Write argument at SP
487-
x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_UNKNOWN);
488-
mov(cb, stack_top, RAX);
486+
x86opnd_t stack_top = ctx_stack_push(ctx, val_type);
487+
mov(cb, stack_top, REG0);
489488
}
490489

491490
return YJIT_KEEP_COMPILING;

0 commit comments

Comments
 (0)