From 9ecedc3925f7c764916025c78bdc626cf45ef46b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Wed, 28 Jul 2021 17:09:55 -0700 Subject: [PATCH] Fix issue #2329 based on @olonho suggestion --- lib/compiler-singlepass/src/codegen_x64.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/compiler-singlepass/src/codegen_x64.rs b/lib/compiler-singlepass/src/codegen_x64.rs index bd02ddc2a4a..9d5fe93b522 100644 --- a/lib/compiler-singlepass/src/codegen_x64.rs +++ b/lib/compiler-singlepass/src/codegen_x64.rs @@ -5388,6 +5388,8 @@ impl<'a> FuncGen<'a> { let vmcaller_checked_anyfunc_func_ptr = self.vmoffsets.vmcaller_checked_anyfunc_func_ptr() as usize; + let vmcaller_checked_anyfunc_vmctx = + self.vmoffsets.vmcaller_checked_anyfunc_vmctx() as usize; self.emit_call_sysv( |this| { @@ -5403,6 +5405,14 @@ impl<'a> FuncGen<'a> { this.trap_table .offset_to_code .insert(offset, TrapCode::StackOverflow); + + // We set the context pointer + this.assembler.emit_mov( + Size::S64, + Location::Memory(GPR::RAX, vmcaller_checked_anyfunc_vmctx as i32), + Machine::get_param_location(0), + ); + this.assembler.emit_call_location(Location::Memory( GPR::RAX, vmcaller_checked_anyfunc_func_ptr as i32,