mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: make maxOffAddr reflect the actual address space upper bound
Currently maxOffAddr is defined in terms of the whole 64-bit address space, assuming that it's all supported, by using ^uintptr(0) as the maximal address in the offset space. In reality, the maximal address in the offset space is (1<<heapAddrBits)-1 because we don't have more than that actually available to us on a given platform. On most platforms this is fine, because arenaBaseOffset is just connecting two segments of address space, but on AIX we use it as an actual offset for the starting address of the available address space, which is limited. This means using ^uintptr(0) as the maximal address in the offset address space causes wrap-around, especially when we just want to represent a range approximately like [addr, infinity), which today we do by using maxOffAddr. To fix this, we define maxOffAddr more appropriately, in terms of (1<<heapAddrBits)-1. This change also redefines arenaBaseOffset to not be the negation of the virtual address corresponding to address zero in the virtual address space, but instead directly as the virtual address corresponding to zero. This matches the existing documentation more closely and makes the logic around arenaBaseOffset decidedly simpler, especially when trying to reason about its use on AIX. Fixes #38966. Change-Id: I1336e5036a39de846f64cc2d253e8536dee57611 Reviewed-on: https://go-review.googlesource.com/c/go/+/233497 Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
364a05e2fe
commit
796786cd0c
5 changed files with 20 additions and 36 deletions
|
|
@ -576,13 +576,13 @@ func (sc spanClass) noscan() bool {
|
|||
//
|
||||
//go:nosplit
|
||||
func arenaIndex(p uintptr) arenaIdx {
|
||||
return arenaIdx((p + arenaBaseOffset) / heapArenaBytes)
|
||||
return arenaIdx((p - arenaBaseOffset) / heapArenaBytes)
|
||||
}
|
||||
|
||||
// arenaBase returns the low address of the region covered by heap
|
||||
// arena i.
|
||||
func arenaBase(i arenaIdx) uintptr {
|
||||
return uintptr(i)*heapArenaBytes - arenaBaseOffset
|
||||
return uintptr(i)*heapArenaBytes + arenaBaseOffset
|
||||
}
|
||||
|
||||
type arenaIdx uint
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue