]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove unnecessary step from bulkBarrierPreWrite
authorAustin Clements <austin@google.com>
Mon, 24 Oct 2016 21:56:00 +0000 (17:56 -0400)
committerAustin Clements <austin@google.com>
Fri, 28 Oct 2016 21:23:42 +0000 (21:23 +0000)
Currently bulkBarrierPreWrite calls writebarrierptr_prewrite, but this
means that we check writeBarrier.needed twice and perform cgo checks
twice.

Change bulkBarrierPreWrite to call writebarrierptr_prewrite1 to skip
over these duplicate checks.

This may speed up bulkBarrierPreWrite slightly, but mostly this will
save us from running out of nosplit stack space on ppc64x in the near
future.

Updates #17503.

Change-Id: I1cea1a2207e884ab1a279c6a5e378dcdc048b63e
Reviewed-on: https://go-review.googlesource.com/31890
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbitmap.go

index 2d1910ec2e5e82d62642af05eecb5a99f559389c..ddbe3efc960beba9b33f7447f011b044aba5ec5b 100644 (file)
@@ -546,7 +546,7 @@ func (h heapBits) setCheckmarked(size uintptr) {
        atomic.Or8(h.bitp, bitScan<<(heapBitsShift+h.shift))
 }
 
-// bulkBarrierPreWrite executes writebarrierptr_prewrite
+// bulkBarrierPreWrite executes writebarrierptr_prewrite1
 // for every pointer slot in the memory range [src, src+size),
 // using pointer/scalar information from [dst, dst+size).
 // This executes the write barriers necessary before a memmove.
@@ -557,6 +557,8 @@ func (h heapBits) setCheckmarked(size uintptr) {
 // calling memmove(dst, src, size). This function is marked nosplit
 // to avoid being preempted; the GC must not stop the goroutine
 // between the memmove and the execution of the barriers.
+// The caller is also responsible for cgo pointer checks if this
+// may be writing Go pointers into non-Go memory.
 //
 // The pointer bitmap is not maintained for allocations containing
 // no pointers at all; any caller of bulkBarrierPreWrite must first
@@ -620,7 +622,7 @@ func bulkBarrierPreWrite(dst, src, size uintptr) {
                if h.isPointer() {
                        dstx := (*uintptr)(unsafe.Pointer(dst + i))
                        srcx := (*uintptr)(unsafe.Pointer(src + i))
-                       writebarrierptr_prewrite(dstx, *srcx)
+                       writebarrierptr_prewrite1(dstx, *srcx)
                }
                h = h.next()
        }
@@ -652,7 +654,7 @@ func bulkBarrierBitmap(dst, src, size, maskOffset uintptr, bits *uint8) {
                if *bits&mask != 0 {
                        dstx := (*uintptr)(unsafe.Pointer(dst + i))
                        srcx := (*uintptr)(unsafe.Pointer(src + i))
-                       writebarrierptr_prewrite(dstx, *srcx)
+                       writebarrierptr_prewrite1(dstx, *srcx)
                }
                mask <<= 1
        }