Skip to content

Commit 0c6296a

Browse files
mknyszekgopherbot
authored andcommitted
runtime: have mergeInlineMarkBits also clear the inline mark bits
This is conceptually simpler, as the sweeper doesn't have to worry about clearing them separately. It also doesn't have a use for them. This will also be useful to avoiding unnecessary zeroing in initInlineMarkBits at allocation time. Currently, because it's used in both span allocation and at sweep time, we cannot blindly trust needzero. This change also renames mergeInlineMarkBits to moveInlineMarkBits to make this change in semantics clearer from the name. For #73581. Change-Id: Ib154738a945633b7ff5b2ae27235baa310400139 Reviewed-on: https://go-review.googlesource.com/c/go/+/687936 Auto-Submit: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 397d211 commit 0c6296a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/runtime/mgcmark_greenteagc.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ func (s *mspan) initInlineMarkBits() {
183183
s.inlineMarkBits().init(s.spanclass)
184184
}
185185

186-
// mergeInlineMarks merges the span's inline mark bits into dst.
186+
// moveInlineMarks merges the span's inline mark bits into dst and clears them.
187187
//
188188
// gcUsesSpanInlineMarkBits(s.elemsize) must be true.
189-
func (s *mspan) mergeInlineMarks(dst *gcBits) {
189+
func (s *mspan) moveInlineMarks(dst *gcBits) {
190190
if doubleCheckGreenTea && !gcUsesSpanInlineMarkBits(s.elemsize) {
191191
throw("expected span with inline mark bits")
192192
}
@@ -203,6 +203,9 @@ func (s *mspan) mergeInlineMarks(dst *gcBits) {
203203
if doubleCheckGreenTea && !s.spanclass.noscan() && imb.marks != imb.scans {
204204
throw("marks don't match scans for span with pointer")
205205
}
206+
207+
// Reset the inline mark bits.
208+
imb.init(s.spanclass)
206209
}
207210

208211
// inlineMarkBits returns the inline mark bits for the span.

src/runtime/mgcmark_nogreenteagc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func tryDeferToSpanScan(p uintptr, gcw *gcWork) bool {
2424
func (s *mspan) initInlineMarkBits() {
2525
}
2626

27-
func (s *mspan) mergeInlineMarks(to *gcBits) {
27+
func (s *mspan) moveInlineMarks(to *gcBits) {
2828
throw("unimplemented")
2929
}
3030

src/runtime/mgcsweep.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
650650
}
651651
}
652652

653-
// Copy over the inline mark bits if necessary.
653+
// Copy over and clear the inline mark bits if necessary.
654654
if gcUsesSpanInlineMarkBits(s.elemsize) {
655-
s.mergeInlineMarks(s.gcmarkBits)
655+
s.moveInlineMarks(s.gcmarkBits)
656656
}
657657

658658
// Check for zombie objects.
@@ -704,11 +704,6 @@ func (sl *sweepLocked) sweep(preserve bool) bool {
704704
// Initialize alloc bits cache.
705705
s.refillAllocCache(0)
706706

707-
// Reset the object queue, if we have one.
708-
if gcUsesSpanInlineMarkBits(s.elemsize) {
709-
s.initInlineMarkBits()
710-
}
711-
712707
// The span must be in our exclusive ownership until we update sweepgen,
713708
// check for potential races.
714709
if state := s.state.get(); state != mSpanInUse || s.sweepgen != sweepgen-1 {

0 commit comments

Comments
 (0)