aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgcscavenge.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-04-28 21:30:57 +0000
committerMichael Knyszek <mknyszek@google.com>2020-05-08 16:32:03 +0000
commitea5f9b666ccf7affca596be3ab0dc523ca4444fb (patch)
tree5fa08a27635a5d1a65384d071c16229c4fd200c8 /src/runtime/mgcscavenge.go
parentd69509ff995bf3b92246365980e3d27eaf720e6a (diff)
downloadgo-ea5f9b666ccf7affca596be3ab0dc523ca4444fb.tar.gz
go-ea5f9b666ccf7affca596be3ab0dc523ca4444fb.zip
runtime: use offAddr in more parts of the runtime
This change uses the new offAddr type in more parts of the runtime where we've been implicitly switching from the default address space to a contiguous view. The purpose of offAddr is to represent addresses in the contiguous view of the address space, and to make direct computations between real addresses and offset addresses impossible. This change thus improves readability in the runtime. Updates #35788. Change-Id: I4e1c5fed3ed68aa12f49a42b82eb3f46aba82fc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/230718 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/mgcscavenge.go')
-rw-r--r--src/runtime/mgcscavenge.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go
index 4dacfa0a5c..b74da1057a 100644
--- a/src/runtime/mgcscavenge.go
+++ b/src/runtime/mgcscavenge.go
@@ -452,8 +452,8 @@ func (s *pageAlloc) scavengeStartGen() {
s.inUse.cloneInto(&s.scav.inUse)
// Pick the new starting address for the scavenger cycle.
- var startAddr uintptr
- if s.scav.scavLWM < s.scav.freeHWM {
+ var startAddr offAddr
+ if s.scav.scavLWM.lessThan(s.scav.freeHWM) {
// The "free" high watermark exceeds the "scavenged" low watermark,
// so there are free scavengable pages in parts of the address space
// that the scavenger already searched, the high watermark being the
@@ -467,7 +467,7 @@ func (s *pageAlloc) scavengeStartGen() {
// scavenging from where we were.
startAddr = s.scav.scavLWM
}
- s.scav.inUse.removeGreaterEqual(startAddr)
+ s.scav.inUse.removeGreaterEqual(startAddr.addr())
// reservationBytes may be zero if s.inUse.totalBytes is small, or if
// scavengeReservationShards is large. This case is fine as the scavenger
@@ -478,8 +478,8 @@ func (s *pageAlloc) scavengeStartGen() {
s.scav.reservationBytes = alignUp(s.inUse.totalBytes, pallocChunkBytes) / scavengeReservationShards
s.scav.gen++
s.scav.released = 0
- s.scav.freeHWM = 0
- s.scav.scavLWM = maxSearchAddr
+ s.scav.freeHWM = minOffAddr
+ s.scav.scavLWM = maxOffAddr
}
// scavengeReserve reserves a contiguous range of the address space
@@ -698,8 +698,8 @@ func (s *pageAlloc) scavengeRangeLocked(ci chunkIdx, base, npages uint) uintptr
addr := chunkBase(ci) + uintptr(base)*pageSize
// Update the scavenge low watermark.
- if addr < s.scav.scavLWM {
- s.scav.scavLWM = addr
+ if oAddr := (offAddr{addr}); oAddr.lessThan(s.scav.scavLWM) {
+ s.scav.scavLWM = oAddr
}
// Only perform the actual scavenging if we're not in a test.