From: Michael Anthony Knyszek Date: Thu, 3 Oct 2024 18:18:11 +0000 (+0000) Subject: runtime: use wb flag instead of gcphase for allocate-black check X-Git-Tag: go1.24rc1~672 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d8997c8c1fd2b666b1f145b8006e6a7871e48f45;p=gostls13.git runtime: use wb flag instead of gcphase for allocate-black check This is an allocator microoptimization. There's no reason to check gcphase in general, since it's mostly for debugging anyway. writeBarrier.enabled is set in all the same cases here, and we force one fewer cache line (probably) to be touched during malloc. Conceptually, it also makes a bit more sense. The allocate-black policy is partly informed by the write barrier design. Change-Id: Ia5ff593d64c29cf7f4d1bced3204056566444a98 Reviewed-on: https://go-review.googlesource.com/c/go/+/617875 Reviewed-by: Keith Randall Auto-Submit: Michael Knyszek LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 4fda8a3c23..d376a4a26a 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -1224,7 +1224,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { // All slots hold nil so no scanning is needed. // This may be racing with GC so do it atomically if there can be // a race marking the bit. - if gcphase != _GCoff { + if writeBarrier.enabled { gcmarknewobject(span, uintptr(x)) }