From c818660a768168b25112df0d2f3cc4046e975f19 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 30 Jun 2022 21:06:50 +0800 Subject: [PATCH] Updates dependencies Signed-off-by: Adrian Cole --- engines/wazero/wazero.go | 15 +++++++++------ go.mod | 4 ++-- go.sum | 8 ++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/engines/wazero/wazero.go b/engines/wazero/wazero.go index 15e36c9..96c188a 100644 --- a/engines/wazero/wazero.go +++ b/engines/wazero/wazero.go @@ -4,13 +4,14 @@ import ( "context" "errors" "fmt" - "github.com/tetratelabs/wazero/assemblyscript" + "io" "sync/atomic" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/api" - "github.com/tetratelabs/wazero/wasi" + "github.com/tetratelabs/wazero/assemblyscript" + "github.com/tetratelabs/wazero/wasi_snapshot_preview1" "github.com/wapc/wapc-go" ) @@ -118,13 +119,15 @@ func (e *engine) New(ctx context.Context, source []byte, hostCallHandler wapc.Ho WithStdout(&stdout{m}) // redirect Stdout to the logger mod = m - if _, err = wasi.InstantiateSnapshotPreview1(ctx, r); err != nil { + if _, err = wasi_snapshot_preview1.Instantiate(ctx, r); err != nil { _ = r.Close(ctx) return } // This disables the abort message as no other engines write it. - if _, err = assemblyscript.NewModuleBuilder(r).WithAbortMessageDisabled().Instantiate(ctx); err != nil { + envBuilder := r.NewModuleBuilder("env") + assemblyscript.NewFunctionExporter().WithAbortMessageDisabled().ExportFunctions(envBuilder) + if _, err = envBuilder.Instantiate(ctx, r); err != nil { _ = r.Close(ctx) return } @@ -179,7 +182,7 @@ func instantiateWapcHost(ctx context.Context, r wazero.Runtime, callHandler wapc ExportFunction("__guest_error", h.guestError). ExportFunction("__host_error", h.hostError). ExportFunction("__host_error_len", h.hostErrorLen). - Instantiate(ctx) + Instantiate(ctx, r) } // hostCall is the WebAssembly function export "__host_call", which initiates a host using the callHandler using @@ -392,7 +395,7 @@ func requireReadString(ctx context.Context, mem api.Memory, fieldName string, of func requireRead(ctx context.Context, mem api.Memory, fieldName string, offset, byteCount uint32) []byte { buf, ok := mem.Read(ctx, offset, byteCount) if !ok { - panic(fmt.Errorf("out of range reading %s", fieldName)) + panic(fmt.Errorf("out of memory reading %s", fieldName)) } return buf } diff --git a/go.mod b/go.mod index 1cf74a2..dcf5458 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.17 require ( github.com/Workiva/go-datastructures v1.0.53 - github.com/bytecodealliance/wasmtime-go v0.36.0 - github.com/tetratelabs/wazero v0.0.0-20220529032218-029a79476b4f + github.com/bytecodealliance/wasmtime-go v0.38.1 + github.com/tetratelabs/wazero v0.0.0-20220714084325-040736caac8f github.com/wasmerio/wasmer-go v1.0.4 ) diff --git a/go.sum b/go.sum index 824333d..a4f10ed 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= -github.com/bytecodealliance/wasmtime-go v0.36.0 h1:B6thr7RMM9xQmouBtUqm1RpkJjuLS37m6nxX+iwsQSc= -github.com/bytecodealliance/wasmtime-go v0.36.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= +github.com/bytecodealliance/wasmtime-go v0.38.1 h1:eqrJmy1nR/uyxZC4OydXWpvGeEHzprW1Fao6eXvNnEE= +github.com/bytecodealliance/wasmtime-go v0.38.1/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= @@ -10,8 +10,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tetratelabs/wazero v0.0.0-20220529032218-029a79476b4f h1:bN4C2nSpz/ND03EbZoV+3xR8Ivc5rV6FBpoErU2uU14= -github.com/tetratelabs/wazero v0.0.0-20220529032218-029a79476b4f/go.mod h1:Y4X/zO4sC2dJjZG9GDYNRbJGogfqFYJY/BbyKlOxXGI= +github.com/tetratelabs/wazero v0.0.0-20220714084325-040736caac8f h1:MmGwq39JVO05i+4oj7TyZPJLMC5Sn+d2qqyywKVHEDc= +github.com/tetratelabs/wazero v0.0.0-20220714084325-040736caac8f/go.mod h1:Y4X/zO4sC2dJjZG9GDYNRbJGogfqFYJY/BbyKlOxXGI= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs=