Skip to content

Commit

Permalink
deps: updates wazero to 1.0.0-pre.7 (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Jan 18, 2023
1 parent f7d9444 commit e0c3a93
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 59 deletions.
8 changes: 4 additions & 4 deletions examples/helloworld/greeting/greet_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/host-functions/greeting/greet_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/known-types/known/known_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/wasi/cat/cat_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions gen/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (gg *Generator) genHostFunctions(g *protogen.GeneratedFile, f *fileInfo) {
g.QualifiedGoIdent(wazeroAPIPackage.Ident("Module")),
))
g.P("offset, size := uint32(stack[0]), uint32(stack[1])")
g.P("buf, err := ", g.QualifiedGoIdent(pluginWasmPackage.Ident("ReadMemory")), "(ctx, m, offset, size)")
g.P("buf, err := ", g.QualifiedGoIdent(pluginWasmPackage.Ident("ReadMemory")), "(m.Memory(), offset, size)")
g.P(errorHandling)

g.P("var request ", g.QualifiedGoIdent(method.Input.GoIdent))
Expand Down Expand Up @@ -315,8 +315,8 @@ func genPluginMethod(g *protogen.GeneratedFile, f *fileInfo, method *protogen.Me
defer p.free.Call(ctx, dataPtr)
// The pointer is a linear memory offset, which is where we write the name.
if !p.module.Memory().Write(ctx, uint32(dataPtr), data) {
return response, fmt.Errorf("Memory.Write(%d, %d) out of range of memory size %d", dataPtr, dataSize, p.module.Memory().Size(ctx))
if !p.module.Memory().Write(uint32(dataPtr), data) {
return response, fmt.Errorf("Memory.Write(%d, %d) out of range of memory size %d", dataPtr, dataSize, p.module.Memory().Size())
}
}
`)
Expand All @@ -329,10 +329,10 @@ func genPluginMethod(g *protogen.GeneratedFile, f *fileInfo, method *protogen.Me
resSize := uint32(ptrSize[0])
// The pointer is a linear memory offset, which is where we write the name.
bytes, ok := p.module.Memory().Read(ctx, resPtr, resSize)
bytes, ok := p.module.Memory().Read(resPtr, resSize)
if !ok {
return response, fmt.Errorf("Memory.Read(%d, %d) out of range of memory size %d",
resPtr, resSize, p.module.Memory().Size(ctx))
resPtr, resSize, p.module.Memory().Size())
}
if err = response.UnmarshalVT(bytes); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/planetscale/vtprotobuf v0.3.0
github.com/stretchr/testify v1.7.1
github.com/tetratelabs/wazero v1.0.0-pre.4
github.com/tetratelabs/wazero v1.0.0-pre.7
google.golang.org/protobuf v1.28.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tetratelabs/wazero v1.0.0-pre.4 h1:RBJQT5OzmORkSp6MmZDWoFEr0zXjk4pmvMKAdeUnsaI=
github.com/tetratelabs/wazero v1.0.0-pre.4/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
github.com/tetratelabs/wazero v1.0.0-pre.7 h1:WI5N14XxoXw+ZWhcjSazJ6rEowhJbH/x8hglxC5gN7k=
github.com/tetratelabs/wazero v1.0.0-pre.7/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
16 changes: 8 additions & 8 deletions tests/fields/proto/fields_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/host-functions/proto/host_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/import/proto/bar/bar_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/import/proto/foo/foo_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tests/well-known/proto/known_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions wasm/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/tetratelabs/wazero/api"
)

func ReadMemory(ctx context.Context, m api.Module, offset, size uint32) ([]byte, error) {
buf, ok := m.Memory().Read(ctx, offset, size)
func ReadMemory(mem api.Memory, offset, size uint32) ([]byte, error) {
buf, ok := mem.Read(offset, size)
if !ok {
return nil, fmt.Errorf("Memory.Read(%d, %d) out of range", offset, size)
}
Expand All @@ -38,9 +38,9 @@ func WriteMemory(ctx context.Context, m api.Module, data []byte) (uint64, error)
dataPtr := results[0]

// The pointer is a linear memory offset, which is where we write the name.
if !m.Memory().Write(ctx, uint32(dataPtr), data) {
if !m.Memory().Write(uint32(dataPtr), data) {
return 0, fmt.Errorf("Memory.Write(%d, %d) out of range of memory size %d",
dataPtr, len(data), m.Memory().Size(ctx))
dataPtr, len(data), m.Memory().Size())
}

return dataPtr, nil
Expand Down

0 comments on commit e0c3a93

Please sign in to comment.