8000 Merge pull request #111 from Shopify/yjit-better-putobject · github/ruby@c8740b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8740b0

Browse files
authored
Merge pull request #111 from Shopify/yjit-better-putobject
YJIT: Improve codegen and type tracking in putobject
2 parents 629a0b2 + 1bba31a commit c8740b0

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

yjit_codegen.c

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

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

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

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

490489
return YJIT_KEEP_COMPILING;

0 commit comments

Comments
 (0)
0