mirror of
https://github.com/golang/go
synced 2024-11-14 05:40:29 -07:00
runtime: rename shouldhelpgc to checkGCTrigger in mallocgc
shouldhelpgc is a very unhelpful name, because it has nothing to do with assists and solely to do with GC triggering. Name it checkGCTrigger instead, which is much clearer. Change-Id: Id38debd424ddb397376c0cea6e74b3fe94002f71 Reviewed-on: https://go-review.googlesource.com/c/go/+/617877 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
8df6413e11
commit
e750a0cdb3
@ -942,9 +942,9 @@ func nextFreeFast(s *mspan) gclinkptr {
|
|||||||
//
|
//
|
||||||
// Must run in a non-preemptible context since otherwise the owner of
|
// Must run in a non-preemptible context since otherwise the owner of
|
||||||
// c could change.
|
// c could change.
|
||||||
func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bool) {
|
func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, checkGCTrigger bool) {
|
||||||
s = c.alloc[spc]
|
s = c.alloc[spc]
|
||||||
shouldhelpgc = false
|
checkGCTrigger = false
|
||||||
freeIndex := s.nextFreeIndex()
|
freeIndex := s.nextFreeIndex()
|
||||||
if freeIndex == s.nelems {
|
if freeIndex == s.nelems {
|
||||||
// The span is full.
|
// The span is full.
|
||||||
@ -953,7 +953,7 @@ func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bo
|
|||||||
throw("s.allocCount != s.nelems && freeIndex == s.nelems")
|
throw("s.allocCount != s.nelems && freeIndex == s.nelems")
|
||||||
}
|
}
|
||||||
c.refill(spc)
|
c.refill(spc)
|
||||||
shouldhelpgc = true
|
checkGCTrigger = true
|
||||||
s = c.alloc[spc]
|
s = c.alloc[spc]
|
||||||
|
|
||||||
freeIndex = s.nextFreeIndex()
|
freeIndex = s.nextFreeIndex()
|
||||||
@ -1057,7 +1057,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
}
|
}
|
||||||
mp.mallocing = 1
|
mp.mallocing = 1
|
||||||
|
|
||||||
shouldhelpgc := false
|
checkGCTrigger := false
|
||||||
dataSize := userSize
|
dataSize := userSize
|
||||||
c := getMCache(mp)
|
c := getMCache(mp)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
@ -1140,7 +1140,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
span = c.alloc[tinySpanClass]
|
span = c.alloc[tinySpanClass]
|
||||||
v := nextFreeFast(span)
|
v := nextFreeFast(span)
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
v, span, shouldhelpgc = c.nextFree(tinySpanClass)
|
v, span, checkGCTrigger = c.nextFree(tinySpanClass)
|
||||||
}
|
}
|
||||||
x = unsafe.Pointer(v)
|
x = unsafe.Pointer(v)
|
||||||
(*[2]uint64)(x)[0] = 0
|
(*[2]uint64)(x)[0] = 0
|
||||||
@ -1169,7 +1169,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
span = c.alloc[spc]
|
span = c.alloc[spc]
|
||||||
v := nextFreeFast(span)
|
v := nextFreeFast(span)
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
v, span, shouldhelpgc = c.nextFree(spc)
|
v, span, checkGCTrigger = c.nextFree(spc)
|
||||||
}
|
}
|
||||||
x = unsafe.Pointer(v)
|
x = unsafe.Pointer(v)
|
||||||
if needzero && span.needzero != 0 {
|
if needzero && span.needzero != 0 {
|
||||||
@ -1182,7 +1182,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shouldhelpgc = true
|
checkGCTrigger = true
|
||||||
// For large allocations, keep track of zeroed state so that
|
// For large allocations, keep track of zeroed state so that
|
||||||
// bulk zeroing can be happen later in a preemptible context.
|
// bulk zeroing can be happen later in a preemptible context.
|
||||||
span = c.allocLarge(size, noscan)
|
span = c.allocLarge(size, noscan)
|
||||||
@ -1306,7 +1306,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldhelpgc {
|
if checkGCTrigger {
|
||||||
if t := (gcTrigger{kind: gcTriggerHeap}); t.test() {
|
if t := (gcTrigger{kind: gcTriggerHeap}); t.test() {
|
||||||
gcStart(t)
|
gcStart(t)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user