From f8d0d4fd59b6cb6f875eac7753f036b10a28f995 Mon Sep 17 00:00:00 2001 From: Rick Hudson Date: Mon, 14 Mar 2016 12:02:02 -0400 Subject: [dev.garbage] runtime: cleanup and optimize span.base() Prior to this CL the base of a span was calculated in various places using shifts or calls to base(). This CL now always calls base() which has been optimized to calculate the base of the span when the span is initialized and store that value in the span structure. Change-Id: I661f2bfa21e3748a249cdf049ef9062db6e78100 Reviewed-on: https://go-review.googlesource.com/20703 Reviewed-by: Austin Clements --- src/runtime/malloc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 2da13f2073..31335dae80 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -711,7 +711,7 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { s = largeAlloc(size, flags) }) s.freeindex = 1 - x = unsafe.Pointer(uintptr(s.start << pageShift)) + x = unsafe.Pointer(s.base()) size = s.elemsize } @@ -833,7 +833,7 @@ func largeAlloc(size uintptr, flag uint32) *mspan { if s == nil { throw("out of memory") } - s.limit = uintptr(s.start)<<_PageShift + size + s.limit = s.base() + size heapBitsForSpan(s.base()).initSpan(s) return s } -- cgit v1.3-5-g9baa