mirror of
https://github.com/golang/go
synced 2024-11-14 05:40:29 -07:00
runtime: execute publicationBarrier in noscan case for delayed zeroing
This is a peace-of-mind change to make sure that delayed-zeroed memory (in the large alloc case) is globally visible from the moment the allocation is published back to the caller. The way it's written right now is good enough for the garbage collector (we already have a publication barrier for a nil span.largeType, so the GC will ignore the noscan span) but this might matter for user code on weak memory architectures. Change-Id: I06ac9b95863074e5f09382629083b19bfa87fdb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/619036 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
a1c4fb4361
commit
acd072a078
@ -1581,15 +1581,14 @@ func mallocgcLarge(size uintptr, typ *_type, needzero bool) (unsafe.Pointer, uin
|
||||
memclrNoHeapPointersChunked(size, x) // This is a possible preemption point: see #47302
|
||||
|
||||
// Finish storing the type information for this case.
|
||||
if !noscan {
|
||||
mp := acquirem()
|
||||
if !noscan {
|
||||
getMCache(mp).scanAlloc += heapSetTypeLarge(uintptr(x), size, typ, span)
|
||||
|
||||
// Publish the type information with the zeroed memory.
|
||||
}
|
||||
// Publish the object with the now-zeroed memory.
|
||||
publicationBarrier()
|
||||
releasem(mp)
|
||||
}
|
||||
}
|
||||
return x, size
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user