Commit ab9db51e authored by Austin Clements's avatar Austin Clements

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 <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent 8fbaa4f7
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment