diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2020-07-14 20:27:27 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2020-10-22 15:25:33 +0000 |
| commit | b4a06b20897fe7ea3be715cb51040a2ccc52c15b (patch) | |
| tree | 409e48b86b6579a3abe8bd60fd25b7af727f11f3 /src/runtime/export_test.go | |
| parent | de74ea5d740ccc69dbb146578dc8a965351a3d6b (diff) | |
| download | go-b4a06b20897fe7ea3be715cb51040a2ccc52c15b.tar.xz | |
runtime: define the AddrRange used for testing in terms of addrRange
Currently the AddrRange used for testing is defined separately from
addrRange in the runtime, making it difficult to test it as well as
addrRanges. Redefine AddrRange in terms of addrRange instead.
For #40191.
Change-Id: I3aa5b8df3e4c9a3c494b46ab802dd574b2488141
Reviewed-on: https://go-review.googlesource.com/c/go/+/242677
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
| -rw-r--r-- | src/runtime/export_test.go | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index f2fa11dc98..25b251f4ba 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -749,10 +749,7 @@ func (p *PageAlloc) Scavenge(nbytes uintptr, mayUnlock bool) (r uintptr) { func (p *PageAlloc) InUse() []AddrRange { ranges := make([]AddrRange, 0, len(p.inUse.ranges)) for _, r := range p.inUse.ranges { - ranges = append(ranges, AddrRange{ - Base: r.base.addr(), - Limit: r.limit.addr(), - }) + ranges = append(ranges, AddrRange{r}) } return ranges } @@ -763,10 +760,29 @@ func (p *PageAlloc) PallocData(i ChunkIdx) *PallocData { return (*PallocData)((*pageAlloc)(p).tryChunkOf(ci)) } -// AddrRange represents a range over addresses. -// Specifically, it represents the range [Base, Limit). +// AddrRange is a wrapper around addrRange for testing. type AddrRange struct { - Base, Limit uintptr + addrRange +} + +// MakeAddrRange creates a new address range. +func MakeAddrRange(base, limit uintptr) AddrRange { + return AddrRange{makeAddrRange(base, limit)} +} + +// Base returns the virtual base address of the address range. +func (a AddrRange) Base() uintptr { + return a.addrRange.base.addr() +} + +// Base returns the virtual address of the limit of the address range. +func (a AddrRange) Limit() uintptr { + return a.addrRange.limit.addr() +} + +// Equals returns true if the two address ranges are exactly equal. +func (a AddrRange) Equals(b AddrRange) bool { + return a == b } // BitRange represents a range over a bitmap. |
