compiler: adds support for FunctionListeners (#869)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2022-11-29 15:15:49 +09:00
committed by GitHub
parent b49622b881
commit 84d733eb0a
29 changed files with 352 additions and 114 deletions

View File

@@ -3,13 +3,15 @@ package wasm
import (
"context"
"errors"
"github.com/tetratelabs/wazero/experimental"
)
// Engine is a Store-scoped mechanism to compile functions declared or imported by a module.
// This is a top-level type implemented by an interpreter or compiler.
type Engine interface {
// CompileModule implements the same method as documented on wasm.Engine.
CompileModule(ctx context.Context, module *Module) error
CompileModule(ctx context.Context, module *Module, listeners []experimental.FunctionListener) error
// CompiledModuleCount is exported for testing, to track the size of the compilation cache.
CompiledModuleCount() uint32

View File

@@ -9,6 +9,7 @@ import (
"testing"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/experimental"
"github.com/tetratelabs/wazero/internal/leb128"
"github.com/tetratelabs/wazero/internal/sys"
"github.com/tetratelabs/wazero/internal/testing/hammer"
@@ -362,7 +363,9 @@ func newStore() (*Store, *Namespace) {
}
// CompileModule implements the same method as documented on wasm.Engine.
func (e *mockEngine) CompileModule(context.Context, *Module) error { return nil }
func (e *mockEngine) CompileModule(context.Context, *Module, []experimental.FunctionListener) error {
return nil
}
// LookupFunction implements the same method as documented on wasm.Engine.
func (e *mockModuleEngine) LookupFunction(*TableInstance, FunctionTypeID, Index) (Index, error) {