From 805f49630dcfc57a58ac809f7ef4477183baa9d2 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 5 Oct 2020 11:31:24 -0400 Subject: [PATCH] Fix MicroJIT's putobject against GC copmaction --- ujit_compile.c | 11 ++++++----- 1 file 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); }