From 4ff231bca1f9602e810b95cb75d7997329009e31 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 26 Oct 2015 17:53:22 -0700 Subject: runtime: eliminate some unnecessary uintptr conversions arena_{start,used,end} are already uintptr, so no need to convert them to uintptr, much less to convert them to unsafe.Pointer and then to uintptr. No binary change to pkg/linux_amd64/runtime.a. Change-Id: Ia4232ed2a724c44fde7eba403c5fe8e6dccaa879 Reviewed-on: https://go-review.googlesource.com/16339 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick --- src/runtime/malloc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index ae28a3c319..b86d41faac 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -388,7 +388,7 @@ func sysReserveHigh(n uintptr, reserved *bool) unsafe.Pointer { } func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { - if n > uintptr(h.arena_end)-uintptr(h.arena_used) { + if n > h.arena_end-h.arena_used { // We are in 32-bit mode, maybe we didn't use all possible address space yet. // Reserve some more space. p_size := round(n+_PageSize, 256<<20) @@ -420,7 +420,7 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { } } - if n <= uintptr(h.arena_end)-uintptr(h.arena_used) { + if n <= h.arena_end-h.arena_used { // Keep taking from our reservation. p := h.arena_used sysMap(unsafe.Pointer(p), n, h.arena_reserved, &memstats.heap_sys) @@ -438,7 +438,7 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { } // If using 64-bit, our reservation is all we have. - if uintptr(h.arena_end)-uintptr(h.arena_start) >= _MaxArena32 { + if h.arena_end-h.arena_start >= _MaxArena32 { return nil } @@ -451,7 +451,7 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { return nil } - if p < h.arena_start || uintptr(p)+p_size-uintptr(h.arena_start) >= _MaxArena32 { + if p < h.arena_start || uintptr(p)+p_size-h.arena_start >= _MaxArena32 { print("runtime: memory allocated by OS (", p, ") not in usable range [", hex(h.arena_start), ",", hex(h.arena_start+_MaxArena32), ")\n") sysFree(unsafe.Pointer(p), p_size, &memstats.heap_sys) return nil @@ -459,7 +459,7 @@ func mHeap_SysAlloc(h *mheap, n uintptr) unsafe.Pointer { p_end := p + p_size p += -p & (_PageSize - 1) - if uintptr(p)+n > uintptr(h.arena_used) { + if uintptr(p)+n > h.arena_used { mHeap_MapBits(h, p+n) mHeap_MapSpans(h, p+n) h.arena_used = p + n -- cgit v1.3