From ab9db51e1cf651c0d6d5b56dfd0d9d452f176726 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 16 Mar 2017 15:02:02 -0400 Subject: [PATCH] runtime: rename mspan.stackfreelist -> manualFreeList We're going to use this free list for other types of manually-managed memory in the heap. For #19325. Change-Id: Ib7e682295133eabfddf3a84f44db43d937bfdd9c Reviewed-on: https://go-review.googlesource.com/38575 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Rick Hudson --- src/runtime/mheap.go | 9 +++++---- src/runtime/stack.go | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 30ec7ab4d9..80349a9731 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -174,9 +174,10 @@ type mspan struct { prev *mspan // previous span in list, or nil if none list *mSpanList // For debugging. TODO: Remove. - startAddr uintptr // address of first byte of span aka s.base() - npages uintptr // number of pages in span - stackfreelist gclinkptr // list of free stacks, avoids overloading freelist + startAddr uintptr // address of first byte of span aka s.base() + npages uintptr // number of pages in span + + manualFreeList gclinkptr // list of free objects in _MSpanManual spans // freeindex is the slot index between 0 and nelems at which to begin scanning // for the next free object in this span. @@ -672,7 +673,7 @@ func (h *mheap) allocStack(npage uintptr) *mspan { s := h.allocSpanLocked(npage) if s != nil { s.state = _MSpanManual - s.stackfreelist = 0 + s.manualFreeList = 0 s.allocCount = 0 s.sizeclass = 0 s.nelems = 0 diff --git a/src/runtime/stack.go b/src/runtime/stack.go index b8397279a9..9e00edde61 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -193,24 +193,24 @@ func stackpoolalloc(order uint8) gclinkptr { if s.allocCount != 0 { throw("bad allocCount") } - if s.stackfreelist.ptr() != nil { - throw("bad stackfreelist") + if s.manualFreeList.ptr() != nil { + throw("bad manualFreeList") } s.elemsize = _FixedStack << order for i := uintptr(0); i < _StackCacheSize; i += s.elemsize { x := gclinkptr(s.base() + i) - x.ptr().next = s.stackfreelist - s.stackfreelist = x + x.ptr().next = s.manualFreeList + s.manualFreeList = x } list.insert(s) } - x := s.stackfreelist + x := s.manualFreeList if x.ptr() == nil { throw("span has no free stacks") } - s.stackfreelist = x.ptr().next + s.manualFreeList = x.ptr().next s.allocCount++ - if s.stackfreelist.ptr() == nil { + if s.manualFreeList.ptr() == nil { // all stacks in s are allocated. list.remove(s) } @@ -223,12 +223,12 @@ func stackpoolfree(x gclinkptr, order uint8) { if s.state != _MSpanManual { throw("freeing stack not in a stack span") } - if s.stackfreelist.ptr() == nil { + if s.manualFreeList.ptr() == nil { // s will now have a free stack stackpool[order].insert(s) } - x.ptr().next = s.stackfreelist - s.stackfreelist = x + x.ptr().next = s.manualFreeList + s.manualFreeList = x s.allocCount-- if gcphase == _GCoff && s.allocCount == 0 { // Span is completely free. Return it to the heap @@ -247,7 +247,7 @@ func stackpoolfree(x gclinkptr, order uint8) { // // By not freeing, we prevent step #4 until GC is done. stackpool[order].remove(s) - s.stackfreelist = 0 + s.manualFreeList = 0 mheap_.freeStack(s) } } @@ -1165,7 +1165,7 @@ func freeStackSpans() { next := s.next if s.allocCount == 0 { list.remove(s) - s.stackfreelist = 0 + s.manualFreeList = 0 mheap_.freeStack(s) } s = next -- 2.48.1