// on a 32-bit architecture, it may get allocated unaligned
// space.
g := escape(new(GCController)).(*GCController)
+ g.gcControllerState.test = true // Mark it as a test copy.
g.init(int32(gcPercent))
return g
}
// If this is zero, no fractional workers are needed.
fractionalUtilizationGoal float64
+ // test indicates that this is a test-only copy of gcControllerState.
+ test bool
+
_ cpu.CacheLinePad
}
//
// mheap_.lock must be held or the world must be stopped.
func (c *gcControllerState) commit(triggerRatio float64) {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
// Compute the next GC goal, which is when the allocated heap
// has grown by GOGC/100 over the heap marked by the last
//
// mheap_.lock must be held or the world must be stopped.
func (c *gcControllerState) effectiveGrowthRatio() float64 {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
egogc := float64(atomic.Load64(&c.heapGoal)-c.heapMarked) / float64(c.heapMarked)
if egogc < 0 {
//
// The world must be stopped, or mheap_.lock must be held.
func (c *gcControllerState) setGCPercent(in int32) int32 {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
out := c.gcPercent
if in < 0 {