From 689fae2d7861fe14032762479011f9e48562e1e0 Mon Sep 17 00:00:00 2001 From: Gergely Brautigam Date: Wed, 28 Nov 2018 18:10:28 +0000 Subject: [PATCH] runtime: node ordering in mTreap; adjust code to reflect description. Adjust mTreap ordering logic to reflect the description of mTreap ordering. Before it was using unsafe.Pointer in order to gather the base address of a span. This has been changed to use base, which is the startAddress of a span as the description is telling us in mgclarge.go. Fixes: golang/go#28805 Change-Id: Ib3cd94a0757e23d135b5d41830f38fc08bcf16a3 GitHub-Last-Rev: 93f749b6700b1e179de16607a18395d5e162ecc1 GitHub-Pull-Request: golang/go#28973 Reviewed-on: https://go-review.googlesource.com/c/151499 Reviewed-by: Michael Knyszek Run-TryBot: Michael Knyszek --- src/runtime/mgclarge.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/mgclarge.go b/src/runtime/mgclarge.go index ab665615be..66259d4cdf 100644 --- a/src/runtime/mgclarge.go +++ b/src/runtime/mgclarge.go @@ -164,10 +164,10 @@ func (root *mTreap) insert(span *mspan) { pt = &t.right } else if t.npagesKey > npages { pt = &t.left - } else if uintptr(unsafe.Pointer(t.spanKey)) < uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() < span.base() { // t.npagesKey == npages, so sort on span addresses. pt = &t.right - } else if uintptr(unsafe.Pointer(t.spanKey)) > uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() > span.base() { pt = &t.left } else { throw("inserting span already in treap") @@ -271,9 +271,9 @@ func (root *mTreap) removeSpan(span *mspan) { t = t.right } else if t.npagesKey > npages { t = t.left - } else if uintptr(unsafe.Pointer(t.spanKey)) < uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() < span.base() { t = t.right - } else if uintptr(unsafe.Pointer(t.spanKey)) > uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() > span.base() { t = t.left } } -- 2.50.0