diff options
Diffstat (limited to 'test/codegen/stack.go')
| -rw-r--r-- | test/codegen/stack.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/codegen/stack.go b/test/codegen/stack.go index 65c9868d67..4e45d68f38 100644 --- a/test/codegen/stack.go +++ b/test/codegen/stack.go @@ -6,7 +6,10 @@ package codegen -import "runtime" +import ( + "runtime" + "unsafe" +) // This file contains code generation tests related to the use of the // stack. @@ -128,6 +131,29 @@ func spillSlotReuse() { getp2()[nopInt()] = 0 } +// Check that no stack frame space is needed for simple slice initialization with underlying structure. +type mySlice struct { + array unsafe.Pointer + len int + cap int +} + +// amd64:"TEXT\t.*, [$]0-" +func sliceInit(base uintptr) []uintptr { + const ptrSize = 8 + size := uintptr(4096) + bitmapSize := size / ptrSize / 8 + elements := int(bitmapSize / ptrSize) + var sl mySlice + sl = mySlice{ + unsafe.Pointer(base + size - bitmapSize), + elements, + elements, + } + // amd64:-"POPQ",-"SP" + return *(*[]uintptr)(unsafe.Pointer(&sl)) +} + //go:noinline func nopInt() int { return 0 |
