mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: rewrite lots of foo_Bar(f, ...) into f.bar(...)
Applies to types fixAlloc, mCache, mCentral, mHeap, mSpan, and mSpanList. Two special cases: 1. mHeap_Scavenge() previously didn't take an *mheap parameter, so it was specially handled in this CL. 2. mHeap_Free() would have collided with mheap's "free" field, so it's been renamed to (*mheap).freeSpan to parallel its underlying (*mheap).freeSpanLocked method. Change-Id: I325938554cca432c166fe9d9d689af2bbd68de4b Reviewed-on: https://go-review.googlesource.com/16221 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
58db5fc94d
commit
c17c42e8a5
11 changed files with 158 additions and 162 deletions
|
|
@ -63,7 +63,7 @@ var emptymspan mspan
|
|||
|
||||
func allocmcache() *mcache {
|
||||
lock(&mheap_.lock)
|
||||
c := (*mcache)(fixAlloc_Alloc(&mheap_.cachealloc))
|
||||
c := (*mcache)(mheap_.cachealloc.alloc())
|
||||
unlock(&mheap_.lock)
|
||||
memclr(unsafe.Pointer(c), unsafe.Sizeof(*c))
|
||||
for i := 0; i < _NumSizeClasses; i++ {
|
||||
|
|
@ -75,7 +75,7 @@ func allocmcache() *mcache {
|
|||
|
||||
func freemcache(c *mcache) {
|
||||
systemstack(func() {
|
||||
mCache_ReleaseAll(c)
|
||||
c.releaseAll()
|
||||
stackcache_clear(c)
|
||||
|
||||
// NOTE(rsc,rlh): If gcworkbuffree comes back, we need to coordinate
|
||||
|
|
@ -85,14 +85,14 @@ func freemcache(c *mcache) {
|
|||
|
||||
lock(&mheap_.lock)
|
||||
purgecachedstats(c)
|
||||
fixAlloc_Free(&mheap_.cachealloc, unsafe.Pointer(c))
|
||||
mheap_.cachealloc.free(unsafe.Pointer(c))
|
||||
unlock(&mheap_.lock)
|
||||
})
|
||||
}
|
||||
|
||||
// Gets a span that has a free object in it and assigns it
|
||||
// to be the cached span for the given sizeclass. Returns this span.
|
||||
func mCache_Refill(c *mcache, sizeclass int32) *mspan {
|
||||
func (c *mcache) refill(sizeclass int32) *mspan {
|
||||
_g_ := getg()
|
||||
|
||||
_g_.m.locks++
|
||||
|
|
@ -106,7 +106,7 @@ func mCache_Refill(c *mcache, sizeclass int32) *mspan {
|
|||
}
|
||||
|
||||
// Get a new cached span from the central lists.
|
||||
s = mCentral_CacheSpan(&mheap_.central[sizeclass].mcentral)
|
||||
s = mheap_.central[sizeclass].mcentral.cacheSpan()
|
||||
if s == nil {
|
||||
throw("out of memory")
|
||||
}
|
||||
|
|
@ -119,11 +119,11 @@ func mCache_Refill(c *mcache, sizeclass int32) *mspan {
|
|||
return s
|
||||
}
|
||||
|
||||
func mCache_ReleaseAll(c *mcache) {
|
||||
func (c *mcache) releaseAll() {
|
||||
for i := 0; i < _NumSizeClasses; i++ {
|
||||
s := c.alloc[i]
|
||||
if s != &emptymspan {
|
||||
mCentral_UncacheSpan(&mheap_.central[i].mcentral, s)
|
||||
mheap_.central[i].mcentral.uncacheSpan(s)
|
||||
c.alloc[i] = &emptymspan
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue