Skip to content

Commit

Permalink
enabling race
Browse files Browse the repository at this point in the history
Change-Id: Ib5d608f37142697b8bc484c3bf6f5cae84b583ff
  • Loading branch information
mauri870 committed Nov 22, 2023
1 parent f2440c1 commit 4cc18df
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/runtime/race.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ var __tsan_report_count byte
//go:cgo_import_static __tsan_go_atomic64_exchange
//go:cgo_import_static __tsan_go_atomic32_fetch_add
//go:cgo_import_static __tsan_go_atomic64_fetch_add
//go:cgo_import_static __tsan_go_atomic32_fetch_and
//go:cgo_import_static __tsan_go_atomic64_fetch_and
//go:cgo_import_static __tsan_go_atomic32_fetch_or
//go:cgo_import_static __tsan_go_atomic64_fetch_or
//go:cgo_import_static __tsan_go_atomic32_compare_exchange
//go:cgo_import_static __tsan_go_atomic64_compare_exchange

Expand Down Expand Up @@ -642,6 +646,36 @@ func abigen_sync_atomic_AddUint64(addr *uint64, delta uint64) (new uint64)
//go:linkname abigen_sync_atomic_AddUintptr sync/atomic.AddUintptr
func abigen_sync_atomic_AddUintptr(addr *uintptr, delta uintptr) (new uintptr)

//go:linkname abigen_sync_atomic_AndInt32 sync/atomic.AndInt32
func abigen_sync_atomic_AndInt32(addr *int32, mask int32) (old int32)

//go:linkname abigen_sync_atomic_AndUint32 sync/atomic.AndUint32
func abigen_sync_atomic_AndUint32(addr *uint32, mask uint32) (old uint32)

//go:linkname abigen_sync_atomic_AndInt64 sync/atomic.AndInt64
func abigen_sync_atomic_AndInt64(addr *int64, mask int64) (old int64)

//go:linkname abigen_sync_atomic_AndUint64 sync/atomic.AndUint64
func abigen_sync_atomic_AndUint64(addr *uint64, mask uint64) (old uint64)

//go:linkname abigen_sync_atomic_AndUintptr sync/atomic.AndUintptr
func abigen_sync_atomic_AndUintptr(addr *uintptr, mask uintptr) (old uintptr)

//go:linkname abigen_sync_atomic_OrInt32 sync/atomic.OrInt32
func abigen_sync_atomic_OrInt32(addr *int32, mask int32) (old int32)

//go:linkname abigen_sync_atomic_OrUint32 sync/atomic.OrUint32
func abigen_sync_atomic_OrUint32(addr *uint32, mask uint32) (old uint32)

//go:linkname abigen_sync_atomic_OrInt64 sync/atomic.OrInt64
func abigen_sync_atomic_OrInt64(addr *int64, mask int64) (old int64)

//go:linkname abigen_sync_atomic_OrUint64 sync/atomic.OrUint64
func abigen_sync_atomic_OrUint64(addr *uint64, mask uint64) (old uint64)

//go:linkname abigen_sync_atomic_OrUintptr sync/atomic.OrUintptr
func abigen_sync_atomic_OrUintptr(addr *uintptr, mask uintptr) (old uintptr)

//go:linkname abigen_sync_atomic_CompareAndSwapInt32 sync/atomic.CompareAndSwapInt32
func abigen_sync_atomic_CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)

Expand Down
50 changes: 50 additions & 0 deletions src/runtime/race_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,56 @@ TEXT sync∕atomic·AddUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AddInt64(SB)

// And
TEXT sync∕atomic·AndInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVQ $__tsan_go_atomic32_fetch_and(SB), AX
CALL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVQ $__tsan_go_atomic64_fetch_and(SB), AX
CALL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·AndInt32(SB)

TEXT sync∕atomic·AndUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

TEXT sync∕atomic·AndUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

// Or
TEXT sync∕atomic·OrInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVQ $__tsan_go_atomic32_fetch_or(SB), AX
CALL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVQ $__tsan_go_atomic64_fetch_or(SB), AX
CALL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·OrInt32(SB)

TEXT sync∕atomic·OrUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

TEXT sync∕atomic·OrUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

// CompareAndSwap
TEXT sync∕atomic·CompareAndSwapInt32(SB), NOSPLIT|NOFRAME, $0-17
GO_ARGS
Expand Down
50 changes: 50 additions & 0 deletions src/runtime/race_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,56 @@ TEXT sync∕atomic·AddUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AddInt64(SB)

// And
TEXT sync∕atomic·AndInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_and(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_and(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·AndInt32(SB)

TEXT sync∕atomic·AndUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

TEXT sync∕atomic·AndUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

// Or
TEXT sync∕atomic·OrInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_or(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_or(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·OrInt32(SB)

TEXT sync∕atomic·OrUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

TEXT sync∕atomic·OrUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

// CompareAndSwap
TEXT sync∕atomic·CompareAndSwapInt32(SB), NOSPLIT, $0-17
GO_ARGS
Expand Down
50 changes: 50 additions & 0 deletions src/runtime/race_ppc64le.s
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,56 @@ TEXT sync∕atomic·AddUintptr(SB), NOSPLIT, $0-24
GO_ARGS
BR sync∕atomic·AddInt64(SB)

// And
TEXT sync∕atomic·AndInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_and(SB), R8
BR racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_and(SB), R8
BR racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndUint32(SB), NOSPLIT, $0-20
GO_ARGS
BR sync∕atomic·AndInt32(SB)

TEXT sync∕atomic·AndUint64(SB), NOSPLIT, $0-24
GO_ARGS
BR sync∕atomic·AndInt64(SB)

TEXT sync∕atomic·AndUintptr(SB), NOSPLIT, $0-24
GO_ARGS
BR sync∕atomic·AndInt64(SB)

// Or
TEXT sync∕atomic·OrInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_or(SB), R8
BR racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_or(SB), R8
BR racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrUint32(SB), NOSPLIT, $0-20
GO_ARGS
BR sync∕atomic·OrInt32(SB)

TEXT sync∕atomic·OrUint64(SB), NOSPLIT, $0-24
GO_ARGS
BR sync∕atomic·OrInt64(SB)

TEXT sync∕atomic·OrUintptr(SB), NOSPLIT, $0-24
GO_ARGS
BR sync∕atomic·OrInt64(SB)

// CompareAndSwap in tsan
TEXT sync∕atomic·CompareAndSwapInt32(SB), NOSPLIT, $0-17
GO_ARGS
Expand Down
50 changes: 50 additions & 0 deletions src/runtime/race_s390x.s
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,56 @@ TEXT sync∕atomic·AddUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AddInt64(SB)

// And
TEXT sync∕atomic·AndInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_and(SB), R1
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_and(SB), R1
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·AndUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·AndInt32(SB)

TEXT sync∕atomic·AndUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

TEXT sync∕atomic·AndUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·AndInt64(SB)

// Or
TEXT sync∕atomic·OrInt32(SB), NOSPLIT|NOFRAME, $0-20
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_or(SB), R1
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrInt64(SB), NOSPLIT|NOFRAME, $0-24
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_or(SB), R1
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·OrUint32(SB), NOSPLIT, $0-20
GO_ARGS
JMP sync∕atomic·OrInt32(SB)

TEXT sync∕atomic·OrUint64(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

TEXT sync∕atomic·OrUintptr(SB), NOSPLIT, $0-24
GO_ARGS
JMP sync∕atomic·OrInt64(SB)

// CompareAndSwap

TEXT sync∕atomic·CompareAndSwapInt32(SB), NOSPLIT, $0-17
Expand Down

0 comments on commit 4cc18df

Please sign in to comment.