]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: add mp parameter for getMCache
authorLeonard Wang <wangdeyu0907@gmail.com>
Sat, 11 Sep 2021 12:53:24 +0000 (20:53 +0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 28 Sep 2021 18:43:19 +0000 (18:43 +0000)
Since all callers of getMCache appear to have mp available,
we pass the mp to getMCache, and reduce one call to getg.
And after modification, getMCache is also inlined.

Change-Id: Ib7880c118336acc026ecd7c60c5a88722c3ddfc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/349329
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Carlos Amedee <carlos@golang.org>

src/runtime/malloc.go
src/runtime/mcache.go

index f8d5d48a28d7c8f7c1e35ebc013f93a166bbb42b..7affe244a25442dd307c3672bb6116da60d746b3 100644 (file)
@@ -972,7 +972,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
 
        shouldhelpgc := false
        dataSize := size
-       c := getMCache()
+       c := getMCache(mp)
        if c == nil {
                throw("mallocgc called without a P or outside bootstrapping")
        }
@@ -1247,7 +1247,7 @@ func reflect_unsafe_NewArray(typ *_type, n int) unsafe.Pointer {
 }
 
 func profilealloc(mp *m, x unsafe.Pointer, size uintptr) {
-       c := getMCache()
+       c := getMCache(mp)
        if c == nil {
                throw("profilealloc called without a P or outside bootstrapping")
        }
index a9e959109abaab7f4e624fe7fcc857f7572efcff..21c36ca7505892cb9664dfc02025a5df20d8015b 100644 (file)
@@ -122,9 +122,9 @@ func freemcache(c *mcache) {
 //
 // 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 {
+func getMCache(mp *m) *mcache {
        // Grab the mcache, since that's where stats live.
-       pp := getg().m.p.ptr()
+       pp := mp.p.ptr()
        var c *mcache
        if pp == nil {
                // We will be called without a P while bootstrapping,