Skip to content

Commit

Permalink
Merge pull request #69 from semvis123/fix/wazero-version
Browse files Browse the repository at this point in the history
Update Wazero to v1.1.0
  • Loading branch information
jerbob92 authored May 16, 2023
2 parents c2eecc8 + 6c8e5ad commit ef9d97c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.5
github.com/stretchr/testify v1.8.2
github.com/tetratelabs/wazero v1.0.0
github.com/tetratelabs/wazero v1.1.0
golang.org/x/net v0.8.0
golang.org/x/text v0.8.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tetratelabs/wazero v1.0.0 h1:sCE9+mjFex95Ki6hdqwvhyF25x5WslADjDKIFU5BXzI=
github.com/tetratelabs/wazero v1.0.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ=
github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
8 changes: 6 additions & 2 deletions webassembly/imports/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ import (
// - Closing the wazero.Runtime has the same effect as closing the result.
// - To add more functions to the "env" module, use FunctionExporter.
// - To instantiate into another wazero.Namespace, use FunctionExporter.
func Instantiate(ctx context.Context, r wazero.Runtime) (api.Closer, error) {
func Instantiate(ctx context.Context, r wazero.Runtime, mod wazero.CompiledModule) (api.Closer, error) {
builder := r.NewHostModuleBuilder("env")
emscripten.NewFunctionExporter().ExportFunctions(builder)
exporter, err := emscripten.NewFunctionExporterForModule(mod)
if err != nil {
return nil, err
}
exporter.ExportFunctions(builder)
NewFunctionExporter().ExportFunctions(builder)
return builder.Instantiate(ctx)
}
Expand Down
12 changes: 6 additions & 6 deletions webassembly/webassembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ func Init(config Config) (pdfium.Pool, error) {
return nil, fmt.Errorf("could not instantiate webassembly wasi_snapshot_preview1 module: %w", err)
}

// Add basic Emscripten specific methods.
if _, err := imports.Instantiate(poolContext, runtime); err != nil {
runtime.Close(poolContext)
return nil, fmt.Errorf("could not instantiate webassembly emscripten/env module: %w", err)
}

compiledModule, err := runtime.CompileModule(poolContext, config.WASM)
if err != nil {
runtime.Close(poolContext)
return nil, fmt.Errorf("could not compile webassembly module: %w", err)
}

// Add basic Emscripten specific methods.
if _, err := imports.Instantiate(poolContext, runtime, compiledModule); err != nil {
runtime.Close(poolContext)
return nil, fmt.Errorf("could not instantiate webassembly emscripten/env module: %w", err)
}

factory := pool.NewPooledObjectFactory(
func(goctx.Context) (interface{}, error) {
newWorker := &worker{
Expand Down

0 comments on commit ef9d97c

Please sign in to comment.