From e4ac2d4acc8cb44df2107e3fa1067755feaaa005 Mon Sep 17 00:00:00 2001 From: Rick Hudson Date: Tue, 16 Feb 2016 17:16:43 -0500 Subject: [dev.garbage] runtime: replace ref with allocCount This is a renaming of the field ref to the more appropriate allocCount. The field holds the number of objects in the span that are currently allocated. Some throws strings were adjusted to more accurately convey the meaning of allocCount. Change-Id: I10daf44e3e9cc24a10912638c7de3c1984ef8efe Reviewed-on: https://go-review.googlesource.com/19518 Reviewed-by: Austin Clements --- src/runtime/mcentral.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/runtime/mcentral.go') diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go index 47d3ae2f81..5dafa28450 100644 --- a/src/runtime/mcentral.go +++ b/src/runtime/mcentral.go @@ -100,11 +100,11 @@ retry: // c is unlocked. havespan: cap := int32((s.npages << _PageShift) / s.elemsize) - n := cap - int32(s.ref) + n := cap - int32(s.allocCount) if n == 0 { - throw("empty span") + throw("span has no free objects") } - usedBytes := uintptr(s.ref) * s.elemsize + usedBytes := uintptr(s.allocCount) * s.elemsize if usedBytes > 0 { reimburseSweepCredit(usedBytes) } @@ -127,12 +127,12 @@ func (c *mcentral) uncacheSpan(s *mspan) { s.incache = false - if s.ref == 0 { - throw("uncaching full span") + if s.allocCount == 0 { + throw("uncaching span but s.allocCount == 0") } cap := int32((s.npages << _PageShift) / s.elemsize) - n := cap - int32(s.ref) + n := cap - int32(s.allocCount) if n > 0 { c.empty.remove(s) c.nonempty.insert(s) @@ -154,7 +154,7 @@ func (c *mcentral) freeSpan(s *mspan, n int32, start gclinkptr, end gclinkptr, p throw("freeSpan given cached span") } - s.ref -= uint16(n) + s.allocCount -= uint16(n) if preserve { // preserve is set only when called from MCentral_CacheSpan above, @@ -180,7 +180,7 @@ func (c *mcentral) freeSpan(s *mspan, n int32, start gclinkptr, end gclinkptr, p // lock of c above.) atomic.Store(&s.sweepgen, mheap_.sweepgen) - if s.ref != 0 { + if s.allocCount != 0 { unlock(&c.lock) return false } -- cgit v1.3