]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: node ordering in mTreap; adjust code to reflect description.
authorGergely Brautigam <skarlso777@gmail.com>
Wed, 28 Nov 2018 18:10:28 +0000 (18:10 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 29 Nov 2018 19:01:01 +0000 (19:01 +0000)
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 <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

src/runtime/mgclarge.go

index ab665615be5668802f45317683e9224a3086d9d2..66259d4cdfd81c101aed1d039340cd0f743bf28f 100644 (file)
@@ -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
                }
        }