mirror of
https://github.com/golang/go
synced 2024-11-17 09:04:44 -07:00
runtime: add a couple of writeBarrier.needed checks
Make typedmemmove, typedmemclr, typedmemclrpartial look more like other callers of bulkBarrierPreWrite. Change-Id: Ic47030d88bf07d290f91198b7810ffc16d9769e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/227541 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
f4827240db
commit
a59465b545
@ -157,7 +157,7 @@ func typedmemmove(typ *_type, dst, src unsafe.Pointer) {
|
||||
if dst == src {
|
||||
return
|
||||
}
|
||||
if typ.ptrdata != 0 {
|
||||
if writeBarrier.needed && typ.ptrdata != 0 {
|
||||
bulkBarrierPreWrite(uintptr(dst), uintptr(src), typ.ptrdata)
|
||||
}
|
||||
// There's a race here: if some other goroutine can write to
|
||||
@ -333,7 +333,7 @@ func reflect_typedslicecopy(elemType *_type, dst, src slice) int {
|
||||
//
|
||||
//go:nosplit
|
||||
func typedmemclr(typ *_type, ptr unsafe.Pointer) {
|
||||
if typ.ptrdata != 0 {
|
||||
if writeBarrier.needed && typ.ptrdata != 0 {
|
||||
bulkBarrierPreWrite(uintptr(ptr), 0, typ.ptrdata)
|
||||
}
|
||||
memclrNoHeapPointers(ptr, typ.size)
|
||||
@ -346,7 +346,7 @@ func reflect_typedmemclr(typ *_type, ptr unsafe.Pointer) {
|
||||
|
||||
//go:linkname reflect_typedmemclrpartial reflect.typedmemclrpartial
|
||||
func reflect_typedmemclrpartial(typ *_type, ptr unsafe.Pointer, off, size uintptr) {
|
||||
if typ.ptrdata != 0 {
|
||||
if writeBarrier.needed && typ.ptrdata != 0 {
|
||||
bulkBarrierPreWrite(uintptr(ptr), 0, size)
|
||||
}
|
||||
memclrNoHeapPointers(ptr, size)
|
||||
|
Loading…
Reference in New Issue
Block a user