mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: introduce, use funcPC to convert Go func to PC
This removes the ** unsafe hack. Real bug fixed at chan.go:101. LGTM=dave, r, iant R=golang-codereviews, dave, r, iant CC=dvyukov, golang-codereviews, khr https://golang.org/cl/140870044
This commit is contained in:
parent
2c780a35b9
commit
0e07f1c99f
9 changed files with 33 additions and 72 deletions
|
|
@ -48,9 +48,7 @@ func growslice(t *slicetype, old sliceStruct, n int64) sliceStruct {
|
|||
|
||||
if raceenabled {
|
||||
callerpc := getcallerpc(unsafe.Pointer(&t))
|
||||
fn := growslice
|
||||
pc := **(**uintptr)(unsafe.Pointer(&fn))
|
||||
racereadrangepc(old.array, old.len*int(t.elem.size), callerpc, pc)
|
||||
racereadrangepc(old.array, old.len*int(t.elem.size), callerpc, funcPC(growslice))
|
||||
}
|
||||
|
||||
et := t.elem
|
||||
|
|
@ -105,8 +103,7 @@ func slicecopy(to sliceStruct, fm sliceStruct, width uintptr) int {
|
|||
|
||||
if raceenabled {
|
||||
callerpc := getcallerpc(unsafe.Pointer(&to))
|
||||
fn := slicecopy
|
||||
pc := **(**uintptr)(unsafe.Pointer(&fn))
|
||||
pc := funcPC(slicecopy)
|
||||
racewriterangepc(to.array, n*int(width), callerpc, pc)
|
||||
racereadrangepc(fm.array, n*int(width), callerpc, pc)
|
||||
}
|
||||
|
|
@ -133,8 +130,7 @@ func slicestringcopy(to []byte, fm string) int {
|
|||
|
||||
if raceenabled {
|
||||
callerpc := getcallerpc(unsafe.Pointer(&to))
|
||||
fn := slicestringcopy
|
||||
pc := **(**uintptr)(unsafe.Pointer(&fn))
|
||||
pc := funcPC(slicestringcopy)
|
||||
racewriterangepc(unsafe.Pointer(&to[0]), n, callerpc, pc)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue