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>
This commit is contained in:
@@ -859,7 +859,6 @@ func (ce *callEngine) callFunction(ctx context.Context, callCtx *wasm.CallContex
|
||||
|
||||
func (ce *callEngine) callGoFunc(ctx context.Context, callCtx *wasm.CallContext, f *function, stack []uint64) {
|
||||
lsn := f.parent.listener
|
||||
callCtx = callCtx.WithMemory(ce.callerMemory())
|
||||
if lsn != nil {
|
||||
params := stack[:f.source.Type.ParamNumInUint64]
|
||||
ctx = lsn.Before(ctx, callCtx, f.source.Definition, params)
|
||||
@@ -934,7 +933,7 @@ func (ce *callEngine) callNativeFunc(ctx context.Context, callCtx *wasm.CallCont
|
||||
frame.pc = op.us[0]
|
||||
}
|
||||
case wazeroir.OperationKindCall:
|
||||
ce.callFunction(ctx, callCtx, &functions[op.us[0]])
|
||||
ce.callFunction(ctx, f.source.Module.CallCtx, &functions[op.us[0]])
|
||||
frame.pc++
|
||||
case wazeroir.OperationKindCallIndirect:
|
||||
offset := ce.popValue()
|
||||
@@ -952,7 +951,7 @@ func (ce *callEngine) callNativeFunc(ctx context.Context, callCtx *wasm.CallCont
|
||||
panic(wasmruntime.ErrRuntimeIndirectCallTypeMismatch)
|
||||
}
|
||||
|
||||
ce.callFunction(ctx, callCtx, tf)
|
||||
ce.callFunction(ctx, f.source.Module.CallCtx, tf)
|
||||
frame.pc++
|
||||
case wazeroir.OperationKindDrop:
|
||||
ce.drop(op.rs[0])
|
||||
|
||||
Reference in New Issue
Block a user