Files
wazero/internal/engine/compiler/arch_arm64.s
Takeshi Yoneda ad968dc3fe Pass correct api.Module to host functions (#1213)
Fixes #1211

Previously, host functions are getting api.Module for the "originating" module, 
which is the module for api.Function currently invoked, except that the api.Module 
is modified by withMemory with the caller's memory instance, therefore there 
haven't been no problem for most cases. The only issues were the methods 
besides Memory() of api.Module, and this commit fixes them.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-08 15:05:48 +09:00

22 lines
784 B
ArmAsm

#include "funcdata.h"
#include "textflag.h"
// nativecall(codeSegment, ce, moduleInstanceAddress)
TEXT ·nativecall(SB), NOSPLIT|NOFRAME, $0-24
// Load the address of *callEngine into arm64ReservedRegisterForCallEngine.
MOVD ce+8(FP), R0
// In arm64, return address is stored in R30 after jumping into the code.
// We save the return address value into archContext.compilerReturnAddress in Engine.
// Note that the const 144 drifts after editting Engine or archContext struct. See TestArchContextOffsetInEngine.
MOVD R30, 144(R0)
// Load the address of *wasm.ModuleInstance into arm64CallingConventionModuleInstanceAddressRegister.
MOVD moduleInstanceAddress+16(FP), R29
// Load the address of native code.
MOVD codeSegment+0(FP), R1
// Jump to native code.
JMP (R1)