Skip to content

Revert tinygo reflect.SliceHeader specialization #2210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk how we feel about skipping building tests with Go 1.20 + TinyGo v0.32.0, as that seems to be an unsupported combination.


- name: Build AssemblyScript examples
run: make build.examples.as
Expand All @@ -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 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 0 additions & 11 deletions internal/engine/wazevo/backend/isa/amd64/reflect.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/engine/wazevo/backend/isa/amd64/reflect_tinygo.go

This file was deleted.

7 changes: 4 additions & 3 deletions internal/engine/wazevo/backend/isa/amd64/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
}
Expand Down
1 change: 0 additions & 1 deletion internal/engine/wazevo/backend/isa/arm64/unwind_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions internal/engine/wazevo/call_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,17 @@ 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)
{
newSP = newTop - relSp
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
Expand Down
1 change: 0 additions & 1 deletion internal/engine/wazevo/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion internal/engine/wazevo/hostmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
11 changes: 0 additions & 11 deletions internal/engine/wazevo/reflect.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/engine/wazevo/reflect_tinygo.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/integration_test/fuzz/wazerolib/extern.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading