mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix race instrumentation of append
typedslicecopy is another write barrier that is not understood by racewalk. It seems quite complex to handle it in the compiler, so instead just instrument it in runtime. Update #9796 Change-Id: I0eb6abf3a2cd2491a338fab5f7da22f01bf7e89b Reviewed-on: https://go-review.googlesource.com/4370 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
c1bbf0a2ea
commit
ed8cc5cf9b
3 changed files with 103 additions and 0 deletions
|
|
@ -328,6 +328,13 @@ func typedslicecopy(typ *_type, dst, src slice) int {
|
|||
dstp := unsafe.Pointer(dst.array)
|
||||
srcp := unsafe.Pointer(src.array)
|
||||
|
||||
if raceenabled {
|
||||
callerpc := getcallerpc(unsafe.Pointer(&typ))
|
||||
pc := funcPC(slicecopy)
|
||||
racewriterangepc(dstp, uintptr(n)*typ.size, callerpc, pc)
|
||||
racereadrangepc(srcp, uintptr(n)*typ.size, callerpc, pc)
|
||||
}
|
||||
|
||||
if !needwb() {
|
||||
memmove(dstp, srcp, uintptr(n)*typ.size)
|
||||
return int(n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue