Skip to content

Commit 75a19db

Browse files
mknyszekgopherbot
authored andcommitted
runtime: use memclrNoHeapPointers to clear inline mark bits
Clearing the inline mark bits with memclrNoHeapPointers is slightly better than having the compiler insert, e.g. duffzero, since it can take advantage of wider SIMD instructions. duffzero is likely going away, but we know things the compiler doesn't, such as the fact that this memory is nicely aligned. In this particular case, memclrNoHeapPointers does a better job. For #73581. Change-Id: I3918096929acfe6efe6f469fb089ebe04b4acff5 Reviewed-on: https://go-review.googlesource.com/c/go/+/687938 Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Michael Knyszek <[email protected]>
1 parent 6d4a91c commit 75a19db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/runtime/mgcmark_greenteagc.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ func (imb *spanInlineMarkBits) init(class spanClass, needzero bool) {
132132
throw("runtime: span inline mark bits nil?")
133133
}
134134
if needzero {
135-
*imb = spanInlineMarkBits{}
135+
// Use memclrNoHeapPointers to avoid having the compiler make a worse
136+
// decision. We know that imb is both aligned and a nice power-of-two
137+
// size that works well for wider SIMD instructions. The compiler likely
138+
// has no idea that imb is aligned to 128 bytes.
139+
memclrNoHeapPointers(unsafe.Pointer(imb), unsafe.Sizeof(spanInlineMarkBits{}))
136140
}
137141
imb.class = class
138142
}

0 commit comments

Comments
 (0)