summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-10-05 11:31:24 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:24 -0400
commit805f49630dcfc57a58ac809f7ef4477183baa9d2 (patch)
tree61668a9cddab1454958be4643a4068294ccc4fcb
parente9ecf80d209ee32c2606b625ad73d48f4103ee51 (diff)
Fix MicroJIT's putobject against GC copmaction
-rw-r--r--ujit_compile.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ujit_compile.c b/ujit_compile.c
index 6740a80765..5c2e05f84d 100644
--- a/ujit_compile.c
+++ b/ujit_compile.c
@@ -308,13 +308,14 @@ void gen_putnil(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
void gen_putobject(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
{
- // Get the argument
- VALUE object = ctx_get_arg(ctx, 0);
- x86opnd_t ptr_imm = const_ptr_opnd((void*)object);
+ // Load the argument from the bytecode sequence.
+ // We need to do this as the argument can chanage due to GC compaction.
+ x86opnd_t pc_imm = const_ptr_opnd((void*)ctx->pc);
+ mov(cb, RAX, pc_imm);
+ mov(cb, RAX, mem_opnd(64, RAX, 8)); // One after the opcode
- // Write constant at SP
+ // Write argument at SP
x86opnd_t stack_top = ctx_stack_push(ctx, 1);
- mov(cb, RAX, ptr_imm);
mov(cb, stack_top, RAX);
}