1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:46:58 -07:00

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: 93f749b670
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>
This commit is contained in:
Gergely Brautigam 2018-11-28 18:10:28 +00:00 committed by Michael Knyszek
parent ec4de31c5c
commit 689fae2d78

View 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
}
}