Generates typeIDs at compilation time (#1218)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-03-09 20:46:08 -08:00
committed by GitHub
parent 4d90a5c364
commit 24e4d5dfa0
13 changed files with 126 additions and 58 deletions

View File

@@ -203,6 +203,13 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte) (CompiledMod
c := &compiledModule{module: internal, compiledEngine: r.store.Engine}
// typeIDs are static and compile-time known.
typeIDs, err := r.store.GetFunctionTypeIDs(internal.TypeSection)
if err != nil {
return nil, err
}
c.typeIDs = typeIDs
listeners, err := buildListeners(ctx, internal)
if err != nil {
return nil, err
@@ -276,7 +283,7 @@ func (r *runtime) InstantiateModule(
}
// Instantiate the module.
mod, err = r.store.Instantiate(ctx, code.module, name, sysCtx)
mod, err = r.store.Instantiate(ctx, code.module, name, sysCtx, code.typeIDs)
if err != nil {
// If there was an error, don't leak the compiled module.
if code.closeWithModule {