aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mcache.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2015-11-11 16:13:51 -0800
committerMatthew Dempsky <mdempsky@google.com>2015-11-12 00:34:58 +0000
commitc17c42e8a5232d7e56225caf9048cfa89f6923d0 (patch)
tree56397252fa1c17f3243e000fa497c97e207cde82 /src/runtime/mcache.go
parent58db5fc94d6038aa0308fc36c25b551a751260c2 (diff)
downloadgo-c17c42e8a5232d7e56225caf9048cfa89f6923d0.tar.xz
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>
Diffstat (limited to 'src/runtime/mcache.go')
-rw-r--r--src/runtime/mcache.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go
index 7424691b1f..4df1361833 100644
--- a/src/runtime/mcache.go
+++ b/src/runtime/mcache.go
@@ -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
}
}