Revert tinygo reflect.SliceHeader specialization (#2210)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
This commit is contained in:
2
.github/workflows/commit.yaml
vendored
2
.github/workflows/commit.yaml
vendored
@@ -163,7 +163,7 @@ jobs:
|
||||
go-version: "1.22"
|
||||
- uses: acifani/setup-tinygo@v2
|
||||
with:
|
||||
tinygo-version: "0.31.2"
|
||||
tinygo-version: "0.32.0"
|
||||
- run: tinygo build ./cmd/wazero
|
||||
- run: tinygo build -size short -target pico -stack-size=8kb ./cmd/wazero
|
||||
|
||||
|
||||
4
.github/workflows/examples.yaml
vendored
4
.github/workflows/examples.yaml
vendored
@@ -17,7 +17,7 @@ on:
|
||||
|
||||
env:
|
||||
EMSDK_VERSION: "3.1.40"
|
||||
TINYGO_VERSION: "0.31.0"
|
||||
TINYGO_VERSION: "0.32.0"
|
||||
ZIG_VERSION: "0.11.0"
|
||||
|
||||
concurrency:
|
||||
@@ -84,6 +84,7 @@ jobs:
|
||||
|
||||
- name: Build TinyGo examples
|
||||
run: make build.examples.tinygo
|
||||
if: matrix.go-version != '1.20' # fails with TinyGo v0.32.0
|
||||
|
||||
- name: Build AssemblyScript examples
|
||||
run: make build.examples.as
|
||||
@@ -105,6 +106,7 @@ jobs:
|
||||
|
||||
- name: Build bench cases
|
||||
run: make build.bench
|
||||
if: matrix.go-version != '1.20' # fails with TinyGo v0.32.0
|
||||
|
||||
- name: Run example tests
|
||||
run: make test.examples
|
||||
|
||||
2
.github/workflows/integration.yaml
vendored
2
.github/workflows/integration.yaml
vendored
@@ -19,7 +19,7 @@ defaults:
|
||||
|
||||
env: # Update this prior to requiring a higher minor version in go.mod
|
||||
GO_VERSION: "1.22"
|
||||
TINYGO_VERSION: "0.31.0"
|
||||
TINYGO_VERSION: "0.32.0"
|
||||
ZIG_VERSION: "0.11.0"
|
||||
BINARYEN_VERSION: "116"
|
||||
STDLIB_TESTS: "internal/integration_test/stdlibs"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
//go:build !tinygo
|
||||
|
||||
package amd64
|
||||
|
||||
import "reflect"
|
||||
|
||||
// setSliceLimits sets both Cap and Len for the given reflected slice.
|
||||
func setSliceLimits(s *reflect.SliceHeader, limit uintptr) {
|
||||
s.Len = int(limit)
|
||||
s.Cap = int(limit)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
//go:build tinygo
|
||||
|
||||
package amd64
|
||||
|
||||
import "reflect"
|
||||
|
||||
// setSliceLimits sets both Cap and Len for the given reflected slice.
|
||||
func setSliceLimits(s *reflect.SliceHeader, limit uintptr) {
|
||||
s.Len = limit
|
||||
s.Len = limit
|
||||
}
|
||||
@@ -9,12 +9,13 @@ import (
|
||||
)
|
||||
|
||||
func stackView(rbp, top uintptr) []byte {
|
||||
l := int(top - rbp)
|
||||
var stackBuf []byte
|
||||
{
|
||||
// TODO: use unsafe.Slice after floor version is set to Go 1.20.
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&stackBuf))
|
||||
hdr.Data = rbp
|
||||
setSliceLimits(hdr, top-rbp)
|
||||
hdr.Len = l
|
||||
hdr.Cap = l
|
||||
}
|
||||
return stackBuf
|
||||
}
|
||||
@@ -72,7 +73,7 @@ func GoCallStackView(stackPointerBeforeGoCall *uint64) []uint64 {
|
||||
// | SizeInBytes |
|
||||
// +-----------------+ <---- stackPointerBeforeGoCall
|
||||
// (low address)
|
||||
data := unsafe.Pointer(uintptr(unsafe.Pointer(stackPointerBeforeGoCall)) + 8)
|
||||
data := unsafe.Add(unsafe.Pointer(stackPointerBeforeGoCall), 8)
|
||||
size := *stackPointerBeforeGoCall / 8
|
||||
return unsafe.Slice((*uint64)(data), int(size))
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ func UnwindStack(sp, _, top uintptr, returnAddresses []uintptr) []uintptr {
|
||||
|
||||
var stackBuf []byte
|
||||
{
|
||||
// TODO: use unsafe.Slice after floor version is set to Go 1.20.
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&stackBuf))
|
||||
hdr.Data = sp
|
||||
hdr.Len = l
|
||||
|
||||
@@ -556,7 +556,8 @@ func (c *callEngine) cloneStack(l uintptr) (newSP, newFP, newTop uintptr, newSta
|
||||
{
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&prevStackAligned))
|
||||
sh.Data = c.stackTop - relSp
|
||||
setSliceLimits(sh, relSp, relSp)
|
||||
sh.Len = int(relSp)
|
||||
sh.Cap = int(relSp)
|
||||
}
|
||||
newTop = alignedStackTop(newStack)
|
||||
{
|
||||
@@ -564,7 +565,8 @@ func (c *callEngine) cloneStack(l uintptr) (newSP, newFP, newTop uintptr, newSta
|
||||
newFP = newTop - relFp
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&newStackAligned))
|
||||
sh.Data = newSP
|
||||
setSliceLimits(sh, relSp, relSp)
|
||||
sh.Len = int(relSp)
|
||||
sh.Cap = int(relSp)
|
||||
}
|
||||
copy(newStackAligned, prevStackAligned)
|
||||
return
|
||||
|
||||
@@ -189,7 +189,6 @@ func TestCompiledModule_functionIndexOf(t *testing.T) {
|
||||
const executableAddr = 0xaaaa
|
||||
var executable []byte
|
||||
{
|
||||
// TODO: use unsafe.Slice after floor version is set to Go 1.20.
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&executable))
|
||||
hdr.Data = executableAddr
|
||||
hdr.Len = 0xffff
|
||||
|
||||
@@ -53,7 +53,8 @@ func hostModuleListenersSliceFromOpaque(opaqueBegin uintptr) []experimental.Func
|
||||
var ret []experimental.FunctionListener
|
||||
sh = (*reflect.SliceHeader)(unsafe.Pointer(&ret))
|
||||
sh.Data = uintptr(b)
|
||||
setSliceLimits(sh, uintptr(l), uintptr(c))
|
||||
sh.Len = int(l)
|
||||
sh.Cap = int(c)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
//go:build !tinygo
|
||||
|
||||
package wazevo
|
||||
|
||||
import "reflect"
|
||||
|
||||
// setSliceLimits sets both Cap and Len for the given reflected slice.
|
||||
func setSliceLimits(s *reflect.SliceHeader, l, c uintptr) {
|
||||
s.Len = int(l)
|
||||
s.Cap = int(c)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
//go:build tinygo
|
||||
|
||||
package wazevo
|
||||
|
||||
import "reflect"
|
||||
|
||||
// setSliceLimits sets both Cap and Len for the given reflected slice.
|
||||
func setSliceLimits(s *reflect.SliceHeader, l, c uintptr) {
|
||||
s.Len = l
|
||||
s.Cap = c
|
||||
}
|
||||
@@ -22,7 +22,6 @@ func main() {}
|
||||
//
|
||||
//export require_no_diff
|
||||
func require_no_diff(binaryPtr uintptr, binarySize int, checkMemory bool, checkLogging bool) {
|
||||
// TODO: use unsafe.Slice after flooring Go 1.20.
|
||||
var wasmBin []byte
|
||||
wasmHdr := (*reflect.SliceHeader)(unsafe.Pointer(&wasmBin))
|
||||
wasmHdr.Data = binaryPtr
|
||||
@@ -51,7 +50,6 @@ func require_no_diff(binaryPtr uintptr, binarySize int, checkMemory bool, checkL
|
||||
//
|
||||
//export validate
|
||||
func validate(binaryPtr uintptr, binarySize int) {
|
||||
// TODO: use unsafe.Slice after flooring Go 1.20.
|
||||
var wasmBin []byte
|
||||
wasmHdr := (*reflect.SliceHeader)(unsafe.Pointer(&wasmBin))
|
||||
wasmHdr.Data = binaryPtr
|
||||
|
||||
Reference in New Issue
Block a user