Commit d8256824 authored by Austin Clements's avatar Austin Clements

runtime: remove unnecessary step from bulkBarrierPreWrite

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/31890Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent 70c107c6
...@@ -546,7 +546,7 @@ func (h heapBits) setCheckmarked(size uintptr) { ...@@ -546,7 +546,7 @@ func (h heapBits) setCheckmarked(size uintptr) {
atomic.Or8(h.bitp, bitScan<<(heapBitsShift+h.shift)) 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), // for every pointer slot in the memory range [src, src+size),
// using pointer/scalar information from [dst, dst+size). // using pointer/scalar information from [dst, dst+size).
// This executes the write barriers necessary before a memmove. // This executes the write barriers necessary before a memmove.
...@@ -557,6 +557,8 @@ func (h heapBits) setCheckmarked(size uintptr) { ...@@ -557,6 +557,8 @@ func (h heapBits) setCheckmarked(size uintptr) {
// calling memmove(dst, src, size). This function is marked nosplit // calling memmove(dst, src, size). This function is marked nosplit
// to avoid being preempted; the GC must not stop the goroutine // to avoid being preempted; the GC must not stop the goroutine
// between the memmove and the execution of the barriers. // 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 // The pointer bitmap is not maintained for allocations containing
// no pointers at all; any caller of bulkBarrierPreWrite must first // no pointers at all; any caller of bulkBarrierPreWrite must first
...@@ -620,7 +622,7 @@ func bulkBarrierPreWrite(dst, src, size uintptr) { ...@@ -620,7 +622,7 @@ func bulkBarrierPreWrite(dst, src, size uintptr) {
if h.isPointer() { if h.isPointer() {
dstx := (*uintptr)(unsafe.Pointer(dst + i)) dstx := (*uintptr)(unsafe.Pointer(dst + i))
srcx := (*uintptr)(unsafe.Pointer(src + i)) srcx := (*uintptr)(unsafe.Pointer(src + i))
writebarrierptr_prewrite(dstx, *srcx) writebarrierptr_prewrite1(dstx, *srcx)
} }
h = h.next() h = h.next()
} }
...@@ -652,7 +654,7 @@ func bulkBarrierBitmap(dst, src, size, maskOffset uintptr, bits *uint8) { ...@@ -652,7 +654,7 @@ func bulkBarrierBitmap(dst, src, size, maskOffset uintptr, bits *uint8) {
if *bits&mask != 0 { if *bits&mask != 0 {
dstx := (*uintptr)(unsafe.Pointer(dst + i)) dstx := (*uintptr)(unsafe.Pointer(dst + i))
srcx := (*uintptr)(unsafe.Pointer(src + i)) srcx := (*uintptr)(unsafe.Pointer(src + i))
writebarrierptr_prewrite(dstx, *srcx) writebarrierptr_prewrite1(dstx, *srcx)
} }
mask <<= 1 mask <<= 1
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment