Skip to content

Commit f8a6d93

Browse files
committed
Optimized bitmask check in scanobject.
1 parent f903068 commit f8a6d93

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/runtime/mgcmark.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,15 +1623,9 @@ func scanobject(b uintptr, gcw *gcWork) {
16231623

16241624
// At this point we have extracted the next potential pointer.
16251625
// Quickly filter out nil and pointers back to the current object.
1626-
if obj != 0 && obj-b >= n {
1627-
if goexperiment.DeadlockGC {
1628-
// The GC will skip masked addresses if DeadlockGC is enabled.
1629-
if (uintptr(unsafe.Pointer(obj)) & gcBitMask) == gcBitMask {
1630-
// Skip masked pointers.
1631-
continue
1632-
}
1633-
}
1634-
1626+
// The GC will skip masked addresses if DeadlockGC is enabled.
1627+
if obj != 0 && obj-b >= n &&
1628+
(!goexperiment.DeadlockGC || obj <= gcUndoBitMask) {
16351629
// Test if obj points into the Go heap and, if so,
16361630
// mark the object.
16371631
//

0 commit comments

Comments
 (0)