]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: clean up mheap.allocLarge
authorAustin Clements <austin@google.com>
Fri, 30 Jun 2017 20:51:07 +0000 (16:51 -0400)
committerAustin Clements <austin@google.com>
Mon, 3 Jul 2017 14:08:01 +0000 (14:08 +0000)
mheap.allocLarge just calls bestFitTreap and is the only caller of
bestFitTreap. Flatten these into a single function. Also fix their
comments: allocLarge claims to return exactly npages but can in fact
return a larger span, and h.freelarge is not in fact indexed by span
start address.

Change-Id: Ia20112bdc46643a501ea82ea77c58596bc96f125
Reviewed-on: https://go-review.googlesource.com/47315
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mheap.go

index 60676aba3ecf5196b6d0d60c8e47a5f5637fafe5..bf682ec97f93b4e6b3fae4225c62f51ac7037540 100644 (file)
@@ -857,16 +857,11 @@ func (h *mheap) isLargeSpan(npages uintptr) bool {
        return npages >= uintptr(len(h.free))
 }
 
-// Allocate a span of exactly npage pages from the treap of large spans.
+// allocLarge allocates a span of at least npage pages from the treap of large spans.
+// Returns nil if no such span currently exists.
 func (h *mheap) allocLarge(npage uintptr) *mspan {
-       return bestFitTreap(&h.freelarge, npage)
-}
-
-// Search treap for smallest span with >= npage pages.
-// If there are multiple smallest spans, select the one
-// with the earliest starting address.
-func bestFitTreap(treap *mTreap, npage uintptr) *mspan {
-       return treap.remove(npage)
+       // Search treap for smallest span with >= npage pages.
+       return h.freelarge.remove(npage)
 }
 
 // Try to add at least npage pages of memory to the heap,