diff options
| author | Keith Randall <khr@golang.org> | 2025-04-15 14:55:06 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-04-23 21:44:50 -0700 |
| commit | 9d0320de2574586f3b0610c1b5fd15b8f9c85dec (patch) | |
| tree | 4e9efc56ee44d4723283fb60e6b7664d865cfa4a /src/runtime/lfstack.go | |
| parent | 702f164ed1a4a64cfa60e10723b9b7344bd3f601 (diff) | |
| download | go-9d0320de2574586f3b0610c1b5fd15b8f9c85dec.tar.xz | |
runtime: align taggable pointers more so we can use low bits for tag
Currently we assume alignment to 8 bytes, so we can steal the low 3 bits.
This CL assumes alignment to 512 bytes, so we can steal the low 9 bits.
That's 6 extra bits!
Aligning to 512 bytes wastes a bit of space but it is not egregious.
Most of the objects that we make tagged pointers to are pretty big.
Update #49405
Change-Id: I66fc7784ac1be5f12f285de1d7851d5a6871fb75
Reviewed-on: https://go-review.googlesource.com/c/go/+/665815
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/lfstack.go')
| -rw-r--r-- | src/runtime/lfstack.go | 12 |
1 files changed, 2 insertions, 10 deletions
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<<tagBits-1))) } func lfstackUnpack(val uint64) *lfnode { |
