mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 21:51:32 +00:00
feat(singlepass-backend) Inject FuncCtx
to the function pointer of an host function.
This commit is contained in:
@ -554,18 +554,24 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
|
|||||||
// Emits a tail call trampoline that loads the address of the target import function
|
// Emits a tail call trampoline that loads the address of the target import function
|
||||||
// from Ctx and jumps to it.
|
// from Ctx and jumps to it.
|
||||||
|
|
||||||
|
let imported_funcs_addr = vm::Ctx::offset_imported_funcs();
|
||||||
|
let imported_func = vm::ImportedFunc::size() as usize * id;
|
||||||
|
let imported_func_addr = imported_func + vm::ImportedFunc::offset_func() as usize;
|
||||||
|
let imported_func_ctx_addr = imported_func + vm::ImportedFunc::offset_func_ctx() as usize;
|
||||||
|
|
||||||
a.emit_mov(
|
a.emit_mov(
|
||||||
Size::S64,
|
Size::S64,
|
||||||
Location::Memory(GPR::RDI, vm::Ctx::offset_imported_funcs() as i32),
|
Location::Memory(GPR::RDI, imported_funcs_addr as i32),
|
||||||
Location::GPR(GPR::RAX),
|
Location::GPR(GPR::RAX),
|
||||||
);
|
);
|
||||||
a.emit_mov(
|
a.emit_mov(
|
||||||
Size::S64,
|
Size::S64,
|
||||||
Location::Memory(
|
Location::Memory(GPR::RAX, imported_func_ctx_addr as i32),
|
||||||
GPR::RAX,
|
Location::GPR(GPR::RDI),
|
||||||
(vm::ImportedFunc::size() as usize * id + vm::ImportedFunc::offset_func() as usize)
|
);
|
||||||
as i32,
|
a.emit_mov(
|
||||||
),
|
Size::S64,
|
||||||
|
Location::Memory(GPR::RAX, imported_func_addr as i32),
|
||||||
Location::GPR(GPR::RAX),
|
Location::GPR(GPR::RAX),
|
||||||
);
|
);
|
||||||
a.emit_jmp_location(Location::GPR(GPR::RAX));
|
a.emit_jmp_location(Location::GPR(GPR::RAX));
|
||||||
|
Reference in New Issue
Block a user