]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add a couple of writeBarrier.needed checks
authorIan Lance Taylor <iant@golang.org>
Wed, 8 Apr 2020 04:47:13 +0000 (21:47 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 8 Apr 2020 20:43:02 +0000 (20:43 +0000)
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>
src/runtime/mbarrier.go

index 941324782c66aaa01fb868ec061da8ea07f74ab5..264376da9b4afa56e3f36b134493529e440ea256 100644 (file)
@@ -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)