Skip to content

Commit 27f49b7

Browse files
deps: updates TinyGo to v0.28.1 (#28)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
1 parent ae25bc5 commit 27f49b7

File tree

31 files changed

+84
-105
lines changed

31 files changed

+84
-105
lines changed

.github/workflows/commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
go-version: # Note: Go only supports 2 versions: https://go.dev/doc/devel/release#policy
5353
- "1.20"
5454
tinygo-version: # Note: TinyGo only supports latest: https://github.com/tinygo-org/tinygo/releases
55-
- "0.27.0" # Latest
55+
- "0.28.1" # Latest
5656

5757
steps:
5858
- uses: actions/checkout@v3

.github/workflows/testdata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
go-version: # Note: Go only supports 2 versions: https://go.dev/doc/devel/release#policy
3030
- "1.20"
3131
tinygo-version: # Note: TinyGo only supports latest: https://github.com/tinygo-org/tinygo/releases
32-
- "0.27.0" # Latest
32+
- "0.28.1" # Latest
3333

3434
steps:
3535
- uses: actions/checkout@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func handleRequest(req api.Request, resp api.Response) (next bool, reqCtx uint32
4040
}
4141
```
4242

43-
If you make changes, you can rebuild it like so:
43+
If you make changes, you can rebuild this with TinyGo v0.28 or higher like so:
4444
```sh
4545
tinygo build -o examples/router/main.wasm -scheduler=none --no-debug -target=wasi examples/router/main.go
4646
```

examples/router/main.wasm

473 Bytes
Binary file not shown.

examples/wasi/main.wasm

996 Bytes
Binary file not shown.

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
module github.com/http-wasm/http-wasm-guest-tinygo
22

3-
// TinyGo 0.27 doesn't fully support Go 1.20, but it supports what we need.
4-
// Particularly, unsafe.SliceData, unsafe.StringData were added to TinyGo 0.27.
5-
// See https://github.com/tinygo-org/tinygo/commit/c43958972c3ffcd51e65414a346e53779edb9f97
63
go 1.20

handler/body.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ func (b wasmBody) Read(bytes []byte) (size uint32, eof bool) {
4545
return // invalid, but prevent crashing.
4646
}
4747

48-
size, eof = read(b, uintptr(ptr), limit)
48+
size, eof = read(b, ptr, limit)
4949
runtime.KeepAlive(bytes) // keep bytes alive until ptr is no longer needed.
5050
return
5151
}
5252

53-
func read(b wasmBody, ptr uintptr, limit imports.BufLimit) (size uint32, eof bool) {
53+
func read(b wasmBody, ptr uint32, limit imports.BufLimit) (size uint32, eof bool) {
5454
eofLen := imports.ReadBody(imports.BodyKind(b), ptr, limit)
5555
eof = (eofLen >> 32) == 1
5656
size = uint32(eofLen)
@@ -64,7 +64,7 @@ func (b wasmBody) Write(bytes []byte) {
6464
return
6565
}
6666

67-
imports.WriteBody(imports.BodyKind(b), uintptr(ptr), size)
67+
imports.WriteBody(imports.BodyKind(b), ptr, size)
6868
runtime.KeepAlive(bytes) // keep bytes alive until ptr is no longer needed.
6969
}
7070

@@ -75,6 +75,6 @@ func (b wasmBody) WriteString(s string) {
7575
return
7676
}
7777

78-
imports.WriteBody(imports.BodyKind(b), uintptr(ptr), size)
78+
imports.WriteBody(imports.BodyKind(b), ptr, size)
7979
runtime.KeepAlive(s) // keep s alive until ptr is no longer needed.
8080
}

handler/header.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func (w wasmHeader) Names() (names []string) {
3131
}
3232
// Otherwise, we have to allocate a new buffer for the large entry.
3333
buf := make([]byte, size)
34-
ptr := unsafe.Pointer(unsafe.SliceData(buf))
35-
_ = imports.GetHeaderNames(imports.HeaderKind(w), uintptr(ptr), size)
34+
ptr := uint32(uintptr(unsafe.Pointer(unsafe.SliceData(buf))))
35+
_ = imports.GetHeaderNames(imports.HeaderKind(w), ptr, size)
3636
names = mem.GetNULTerminated(buf)
3737
runtime.KeepAlive(buf) // keep buf alive until ptr is no longer needed.
3838
return
@@ -51,7 +51,7 @@ func (w wasmHeader) Get(name string) (value string, ok bool) {
5151
// GetAll implements the same method as documented on api.Request.
5252
func (w wasmHeader) GetAll(name string) (names []string) {
5353
namePtr, nameSize := mem.StringToPtr(name)
54-
countLen := imports.GetHeaderValues(imports.HeaderKind(w), uintptr(namePtr), nameSize, mem.ReadBufPtr, mem.ReadBufLimit)
54+
countLen := imports.GetHeaderValues(imports.HeaderKind(w), namePtr, nameSize, mem.ReadBufPtr, mem.ReadBufLimit)
5555
runtime.KeepAlive(name) // keep name alive until ptr is no longer needed.
5656
if countLen == 0 {
5757
return
@@ -66,8 +66,8 @@ func (w wasmHeader) GetAll(name string) (names []string) {
6666
}
6767
// Otherwise, we have to allocate a new buffer for the large entry.
6868
buf := make([]byte, size)
69-
ptr := unsafe.Pointer(unsafe.SliceData(buf))
70-
_ = imports.GetHeaderValues(imports.HeaderKind(w), uintptr(namePtr), nameSize, uintptr(ptr), size)
69+
ptr := uint32(uintptr(unsafe.Pointer(unsafe.SliceData(buf))))
70+
_ = imports.GetHeaderValues(imports.HeaderKind(w), namePtr, nameSize, ptr, size)
7171
names = mem.GetNULTerminated(buf)
7272
runtime.KeepAlive(name) // keep name alive until ptr is no longer needed.
7373
runtime.KeepAlive(buf) // keep buf alive until ptr is no longer needed.
@@ -78,7 +78,7 @@ func (w wasmHeader) GetAll(name string) (names []string) {
7878
func (w wasmHeader) Set(name, value string) {
7979
namePtr, nameSize := mem.StringToPtr(name)
8080
valuePtr, valueSize := mem.StringToPtr(value)
81-
imports.SetHeaderValue(imports.HeaderKind(w), uintptr(namePtr), nameSize, uintptr(valuePtr), valueSize)
81+
imports.SetHeaderValue(imports.HeaderKind(w), namePtr, nameSize, valuePtr, valueSize)
8282
runtime.KeepAlive(name) // keep name alive until ptr is no longer needed.
8383
runtime.KeepAlive(value) // keep value alive until ptr is no longer needed.
8484
}
@@ -87,14 +87,14 @@ func (w wasmHeader) Set(name, value string) {
8787
func (w wasmHeader) Add(name, value string) {
8888
namePtr, nameSize := mem.StringToPtr(name)
8989
valuePtr, valueSize := mem.StringToPtr(value)
90-
imports.AddHeaderValue(imports.HeaderKind(w), uintptr(namePtr), nameSize, uintptr(valuePtr), valueSize)
90+
imports.AddHeaderValue(imports.HeaderKind(w), namePtr, nameSize, valuePtr, valueSize)
9191
runtime.KeepAlive(name) // keep name alive until ptr is no longer needed.
9292
runtime.KeepAlive(value) // keep value alive until ptr is no longer needed.
9393
}
9494

9595
// Remove implements the same method as documented on api.Request.
9696
func (w wasmHeader) Remove(name string) {
9797
namePtr, nameSize := mem.StringToPtr(name)
98-
imports.RemoveHeader(imports.HeaderKind(w), uintptr(namePtr), nameSize)
98+
imports.RemoveHeader(imports.HeaderKind(w), namePtr, nameSize)
9999
runtime.KeepAlive(name) // keep name alive until ptr is no longer needed.
100100
}

handler/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ func (wasmHost) Log(level api.LogLevel, message string) {
3838
return // don't incur host call overhead
3939
}
4040
ptr, size := mem.StringToPtr(message)
41-
imports.Log(level, uintptr(ptr), size)
41+
imports.Log(level, ptr, size)
4242
runtime.KeepAlive(message) // keep message alive until ptr is no longer needed.
4343
}

handler/internal/imports/host.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,63 +111,63 @@ func EnableFeatures(features api.Features) api.Features {
111111
return enableFeatures(features)
112112
}
113113

114-
func GetConfig(ptr uintptr, limit BufLimit) (len uint32) {
114+
func GetConfig(ptr uint32, limit BufLimit) (len uint32) {
115115
return getConfig(ptr, limit)
116116
}
117117

118118
func LogEnabled(level api.LogLevel) uint32 {
119119
return logEnabled(level)
120120
}
121121

122-
func Log(level api.LogLevel, ptr uintptr, size uint32) {
122+
func Log(level api.LogLevel, ptr, size uint32) {
123123
log(level, ptr, size)
124124
}
125125

126-
func GetMethod(ptr uintptr, limit BufLimit) (len uint32) {
126+
func GetMethod(ptr uint32, limit BufLimit) (len uint32) {
127127
return getMethod(ptr, limit)
128128
}
129129

130-
func SetMethod(ptr uintptr, size uint32) {
130+
func SetMethod(ptr, size uint32) {
131131
setMethod(ptr, size)
132132
}
133133

134-
func GetURI(ptr uintptr, limit BufLimit) (len uint32) {
134+
func GetURI(ptr uint32, limit BufLimit) (len uint32) {
135135
return getURI(ptr, limit)
136136
}
137137

138-
func SetURI(ptr uintptr, size uint32) {
138+
func SetURI(ptr, size uint32) {
139139
setURI(ptr, size)
140140
}
141141

142-
func GetProtocolVersion(ptr uintptr, limit BufLimit) (len uint32) {
142+
func GetProtocolVersion(ptr uint32, limit BufLimit) (len uint32) {
143143
return getProtocolVersion(ptr, limit)
144144
}
145145

146-
func GetHeaderNames(kind HeaderKind, ptr uintptr, limit BufLimit) CountLen {
146+
func GetHeaderNames(kind HeaderKind, ptr uint32, limit BufLimit) CountLen {
147147
return getHeaderNames(kind, ptr, limit)
148148
}
149149

150-
func GetHeaderValues(kind HeaderKind, namePtr uintptr, nameSize uint32, bufPtr uintptr, bufLimit BufLimit) CountLen {
150+
func GetHeaderValues(kind HeaderKind, namePtr, nameSize uint32, bufPtr uint32, bufLimit BufLimit) CountLen {
151151
return getHeaderValues(kind, namePtr, nameSize, bufPtr, bufLimit)
152152
}
153153

154-
func SetHeaderValue(kind HeaderKind, namePtr uintptr, nameSize uint32, valuePtr uintptr, valueSize uint32) {
154+
func SetHeaderValue(kind HeaderKind, namePtr, nameSize uint32, valuePtr uint32, valueSize uint32) {
155155
setHeaderValue(kind, namePtr, nameSize, valuePtr, valueSize)
156156
}
157157

158-
func AddHeaderValue(kind HeaderKind, namePtr uintptr, nameSize uint32, valuePtr uintptr, valueSize uint32) {
158+
func AddHeaderValue(kind HeaderKind, namePtr, nameSize uint32, valuePtr uint32, valueSize uint32) {
159159
addHeaderValue(kind, namePtr, nameSize, valuePtr, valueSize)
160160
}
161161

162-
func RemoveHeader(kind HeaderKind, namePtr uintptr, nameSize uint32) {
162+
func RemoveHeader(kind HeaderKind, namePtr, nameSize uint32) {
163163
removeHeader(kind, namePtr, nameSize)
164164
}
165165

166-
func ReadBody(kind BodyKind, bufPtr uintptr, bufLimit BufLimit) EOFLen {
166+
func ReadBody(kind BodyKind, bufPtr uint32, bufLimit BufLimit) EOFLen {
167167
return readBody(kind, bufPtr, bufLimit)
168168
}
169169

170-
func WriteBody(kind BodyKind, bufPtr uintptr, bufSize uint32) {
170+
func WriteBody(kind BodyKind, bufPtr uint32, bufSize uint32) {
171171
writeBody(kind, bufPtr, bufSize)
172172
}
173173

0 commit comments

Comments
 (0)