Skip to content

Commit 4ac4085

Browse files
committed
runtime: minor clarifications of markroot
This puts the _Root* indexes in a more friendly order and tweaks markrootSpans to use a for-range loop instead of its own indexing. Change-Id: I2c18d55c9a673ea396b6424d51ef4997a1a74825 Reviewed-on: https://go-review.googlesource.com/14548 Reviewed-by: Rick Hudson <[email protected]>
1 parent a1cad70 commit 4ac4085

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/runtime/mgc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ const (
126126
_DebugGC = 0
127127
_ConcurrentSweep = true
128128
_FinBlockSize = 4 * 1024
129+
129130
_RootData = 0
130131
_RootBss = 1
131132
_RootFinalizers = 2
132-
_RootSpans0 = 3
133+
_RootFlushCaches = 3
134+
_RootSpans0 = 4
133135
_RootSpansShards = 128
134-
_RootFlushCaches = _RootSpans0 + _RootSpansShards
135-
_RootCount = _RootFlushCaches + 1
136+
_RootCount = _RootSpans0 + _RootSpansShards
136137

137138
// sweepMinHeapDistance is a lower bound on the heap distance
138139
// (in bytes) reserved for concurrent sweeping between GC

src/runtime/mgcmark.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ func markrootSpans(gcw *gcWork, shard int) {
121121
sg := mheap_.sweepgen
122122
startSpan := shard * len(work.spans) / _RootSpansShards
123123
endSpan := (shard + 1) * len(work.spans) / _RootSpansShards
124-
for spanidx := startSpan; spanidx < endSpan; spanidx++ {
125-
s := work.spans[spanidx]
124+
for _, s := range work.spans[startSpan:endSpan] {
126125
if s.state != mSpanInUse {
127126
continue
128127
}

0 commit comments

Comments
 (0)