diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 572f62c2f9..195a56963d 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1777,10 +1777,12 @@ func FrameStartLine(f *Frame) int { // PersistentAlloc allocates some memory that lives outside the Go heap. // This memory will never be freed; use sparingly. -func PersistentAlloc(n uintptr) unsafe.Pointer { - return persistentalloc(n, 0, &memstats.other_sys) +func PersistentAlloc(n, align uintptr) unsafe.Pointer { + return persistentalloc(n, align, &memstats.other_sys) } +const TagAlign = tagAlign + // FPCallers works like Callers and uses frame pointer unwinding to populate // pcBuf with the return addresses of the physical frames on the stack. func FPCallers(pcBuf []uintptr) int { diff --git a/src/runtime/lfstack.go b/src/runtime/lfstack.go index cbec6e8447..8946c80348 100644 --- a/src/runtime/lfstack.go +++ b/src/runtime/lfstack.go @@ -24,10 +24,6 @@ type lfstack uint64 func (head *lfstack) push(node *lfnode) { node.pushcnt++ new := lfstackPack(node, node.pushcnt) - if node1 := lfstackUnpack(new); node1 != node { - print("runtime: lfstack.push invalid packing: node=", node, " cnt=", hex(node.pushcnt), " packed=", hex(new), " -> node=", node1, "\n") - throw("lfstack.push") - } for { old := atomic.Load64((*uint64)(head)) node.next = old @@ -61,15 +57,11 @@ func lfnodeValidate(node *lfnode) { if base, _, _ := findObject(uintptr(unsafe.Pointer(node)), 0, 0); base != 0 { throw("lfstack node allocated from the heap") } - if lfstackUnpack(lfstackPack(node, ^uintptr(0))) != node { - printlock() - println("runtime: bad lfnode address", hex(uintptr(unsafe.Pointer(node)))) - throw("bad lfnode address") - } + lfstackPack(node, ^uintptr(0)) } func lfstackPack(node *lfnode, cnt uintptr) uint64 { - return uint64(taggedPointerPack(unsafe.Pointer(node), cnt)) + return uint64(taggedPointerPack(unsafe.Pointer(node), cnt&(1< ptr=", t.pointer(), " tag=", hex(t.tag()), "\n") + throw("taggedPointerPack") } - return taggedPointer(uint64(uintptr(ptr))<<(64-addrBits) | uint64(tag&(1<> tagBits << 3)) + return unsafe.Pointer(uintptr(int64(tp) >> tagBits << tagAlignBits)) } if GOOS == "aix" { - return unsafe.Pointer(uintptr((tp >> aixTagBits << 3) | 0xa<<56)) + return unsafe.Pointer(uintptr((tp >> aixTagBits << tagAlignBits) | 0xa<<56)) } if GOARCH == "riscv64" { - return unsafe.Pointer(uintptr(tp >> riscv64TagBits << 3)) + return unsafe.Pointer(uintptr(tp >> riscv64TagBits << tagAlignBits)) } - return unsafe.Pointer(uintptr(tp >> tagBits << 3)) + return unsafe.Pointer(uintptr(tp >> tagBits << tagAlignBits)) } // Tag returns the tag from a taggedPointer.