From: Ian Lance Taylor Date: Wed, 8 Apr 2020 04:47:13 +0000 (-0700) Subject: runtime: add a couple of writeBarrier.needed checks X-Git-Tag: go1.15beta1~627 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a59465b545cd66e0796b5c7649a87a6f1b657cb4;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/runtime/mbarrier.go b/src/runtime/mbarrier.go index 941324782c..264376da9b 100644 --- a/src/runtime/mbarrier.go +++ b/src/runtime/mbarrier.go @@ -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)