aboutsummaryrefslogtreecommitdiff
path: root/src/internal/runtime
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2024-09-17 15:42:26 -0400
committerGopher Robot <gobot@golang.org>2024-10-30 14:59:34 +0000
commit3a6795554daf96d4e01ab02f999a1ea7dde2660c (patch)
tree6b489a1f0f48b1193ff8d00712764d6281d7b179 /src/internal/runtime
parente25b913127ac8ba26c4ecc39288c7f8781f4ef5d (diff)
downloadgo-3a6795554daf96d4e01ab02f999a1ea7dde2660c.tar.xz
internal/runtime/maps: enable race for map functions in internal/runtime/maps
For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: Iebc7f5482299cb7c4ecccc4c2eb46b4bc42c5fc3 Reviewed-on: https://go-review.googlesource.com/c/go/+/616459 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/internal/runtime')
-rw-r--r--src/internal/runtime/maps/runtime_swiss.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/internal/runtime/maps/runtime_swiss.go b/src/internal/runtime/maps/runtime_swiss.go
index 1cf1dd21e5..b8bc8de0c3 100644
--- a/src/internal/runtime/maps/runtime_swiss.go
+++ b/src/internal/runtime/maps/runtime_swiss.go
@@ -10,7 +10,8 @@ import (
"internal/abi"
"internal/asan"
"internal/msan"
- //"internal/runtime/sys"
+ "internal/race"
+ "internal/runtime/sys"
"unsafe"
)
@@ -41,12 +42,12 @@ var zeroVal [abi.ZeroValSize]byte
//go:linkname runtime_mapaccess1 runtime.mapaccess1
func runtime_mapaccess1(typ *abi.SwissMapType, m *Map, key unsafe.Pointer) unsafe.Pointer {
// TODO: concurrent checks.
- //if raceenabled && m != nil {
- // callerpc := sys.GetCallerPC()
- // pc := abi.FuncPCABIInternal(mapaccess1)
- // racereadpc(unsafe.Pointer(m), callerpc, pc)
- // raceReadObjectPC(t.Key, key, callerpc, pc)
- //}
+ if race.Enabled && m != nil {
+ callerpc := sys.GetCallerPC()
+ pc := abi.FuncPCABIInternal(runtime_mapaccess1)
+ race.ReadPC(unsafe.Pointer(m), callerpc, pc)
+ race.ReadObjectPC(typ.Key, key, callerpc, pc)
+ }
if msan.Enabled && m != nil {
msan.Read(key, typ.Key.Size_)
}
@@ -107,12 +108,12 @@ func runtime_mapassign(typ *abi.SwissMapType, m *Map, key unsafe.Pointer) unsafe
if m == nil {
panic(errNilAssign)
}
- //if raceenabled {
- // callerpc := sys.GetCallerPC()
- // pc := abi.FuncPCABIInternal(mapassign)
- // racewritepc(unsafe.Pointer(m), callerpc, pc)
- // raceReadObjectPC(t.Key, key, callerpc, pc)
- //}
+ if race.Enabled {
+ callerpc := sys.GetCallerPC()
+ pc := abi.FuncPCABIInternal(runtime_mapassign)
+ race.WritePC(unsafe.Pointer(m), callerpc, pc)
+ race.ReadObjectPC(typ.Key, key, callerpc, pc)
+ }
if msan.Enabled {
msan.Read(key, typ.Key.Size_)
}