Top-levels FunctionDefinition to allow access to all function metadata (#686)
This top-levels `api.FunctionDefinition` which was formerly experimental, and also adds import metadata to it. Now, it holds all metadata known at compile time. Here are the public API visible changes: * api.ExportedFunction - replaced with api.FunctionDefinition as it is usable for all types of functions. * api.Function - `.ParamTypes/ResultTypes()` are replaced with `.Definition(). * api.FunctionDefinition - extracted from experimental and adds `.Import()` to get the any imported module and function name. * experimental.FunctionDefinition - replaced with api.FunctionDefinition. * experimental.FunctionListenerFactory - adds first arg of the instantiated module name, as it can be different than compiled. * wazero.CompiledModule - Adds `.ImportedFunctions()` and changes result type of `.ExportedFunctions()` to api.FunctionDefinition. Internally, logic to create function definition are consolidated between host and wasm-defined functions, notably wasm.Module now includes `.BuildFunctionDefinitions()` which reduces duplication in wasm.ModuleInstance `.BuildFunctions()`, This obviates #681 by deleting the `ExportedFunction` type which overlaps with this information. This fixes #637 as it includes more metadata including imports. Signed-off-by: Adrian Cole <adrian@tetrate.io> Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -176,6 +176,9 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte, cConfig Comp
|
||||
|
||||
internal.AssignModuleID(binary)
|
||||
|
||||
// Now that the module is validated, cache the function definitions.
|
||||
internal.BuildFunctionDefinitions()
|
||||
|
||||
if err = r.store.Engine.CompileModule(ctx, internal); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user