"funcPC",
"getArgInfoFast",
"getm",
+ "getMCache",
"isDirectIface",
"itabHashFunc",
"noescape",
shouldhelpgc := false
dataSize := size
c := getMCache()
+ if c == nil {
+ throw("mallocgc called without a P or outside bootstrapping")
+ }
var span *mspan
var x unsafe.Pointer
noscan := typ == nil || typ.ptrdata == 0
}
func profilealloc(mp *m, x unsafe.Pointer, size uintptr) {
- getMCache().nextSample = nextSample()
+ c := getMCache()
+ if c == nil {
+ throw("profilealloc called without a P or outside bootstrapping")
+ }
+ c.nextSample = nextSample()
mProf_Malloc(x, size)
}
// getMCache is a convenience function which tries to obtain an mcache.
//
-// Must be running with a P when called (so the caller must be in a
-// non-preemptible state) or must be called during bootstrapping.
+// Returns nil if we're not bootstrapping or we don't have a P. The caller's
+// P must not change, so we must be in a non-preemptible state.
func getMCache() *mcache {
// Grab the mcache, since that's where stats live.
pp := getg().m.p.ptr()
// mcache0 is cleared when bootstrapping is complete,
// by procresize.
c = mcache0
- if c == nil {
- throw("getMCache called with no P or outside bootstrapping")
- }
} else {
c = pp.mcache
}
// Update consistent accounting too.
c := getMCache()
+ if c == nil {
+ throw("scavengeRangeLocked called without a P or outside bootstrapping")
+ }
stats := memstats.heapStats.acquire(c)
atomic.Xaddint64(&stats.committed, -nbytes)
atomic.Xaddint64(&stats.released, nbytes)
}
// Update consistent stats.
c := getMCache()
+ if c == nil {
+ // TODO(mknyszek): Remove this and handle this case to fix #42339.
+ throw("allocSpan called without P or outside bootstrapping")
+ }
stats := memstats.heapStats.acquire(c)
atomic.Xaddint64(&stats.committed, int64(scav))
atomic.Xaddint64(&stats.released, -int64(scav))
// just add directly to heap_released.
atomic.Xadd64(&memstats.heap_released, int64(asize))
c := getMCache()
+ if c == nil {
+ // TODO(mknyszek): Remove this and handle this case to fix #42339.
+ throw("grow called without P or outside bootstrapping")
+ }
stats := memstats.heapStats.acquire(c)
atomic.Xaddint64(&stats.released, int64(asize))
memstats.heapStats.release(c)
}
// Update consistent stats.
c := getMCache()
+ if c == nil {
+ // TODO(mknyszek): Remove this and handle this case to fix #42339.
+ throw("freeSpanLocked called without P or outside bootstrapping")
+ }
stats := memstats.heapStats.acquire(c)
switch typ {
case spanAllocHeap: