Skip to content

Commit

Permalink
runtime: add arg maps for sync/atomic functions in ARM64 race mode
Browse files Browse the repository at this point in the history
In race mode, these functions are defined and declared in
different packages, which therefore don't have implicit arg maps.
When they are defer'd, and the stack needs to move, the runtime
fails with missing stack maps. This CL adds arg maps (FUNCDATA)
to them.

Updates #28848

Change-Id: I0271563b7e78e7797ce2990c303dced957efaa86
Reviewed-on: https://go-review.googlesource.com/c/150457
Run-TryBot: Cherry Zhang <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
cherrymui committed Nov 21, 2018
1 parent a0edb0c commit ae65615
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/runtime/race_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -192,69 +192,86 @@ TEXT runtime·racefuncexit(SB), NOSPLIT, $0-0

// Load
TEXT sync∕atomic·LoadInt32(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic32_load(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·LoadInt64(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic64_load(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·LoadUint32(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·LoadInt32(SB)

TEXT sync∕atomic·LoadUint64(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·LoadInt64(SB)

TEXT sync∕atomic·LoadUintptr(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·LoadInt64(SB)

TEXT sync∕atomic·LoadPointer(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·LoadInt64(SB)

// Store
TEXT sync∕atomic·StoreInt32(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic32_store(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·StoreInt64(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic64_store(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·StoreUint32(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·StoreInt32(SB)

TEXT sync∕atomic·StoreUint64(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·StoreInt64(SB)

TEXT sync∕atomic·StoreUintptr(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·StoreInt64(SB)

// Swap
TEXT sync∕atomic·SwapInt32(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic32_exchange(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·SwapInt64(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic64_exchange(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·SwapUint32(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·SwapInt32(SB)

TEXT sync∕atomic·SwapUint64(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·SwapInt64(SB)

TEXT sync∕atomic·SwapUintptr(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·SwapInt64(SB)

// Add
TEXT sync∕atomic·AddInt32(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic32_fetch_add(SB), R9
BL racecallatomic<>(SB)
MOVW add+8(FP), R0 // convert fetch_add to add_fetch
Expand All @@ -264,6 +281,7 @@ TEXT sync∕atomic·AddInt32(SB), NOSPLIT, $0
RET

TEXT sync∕atomic·AddInt64(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic64_fetch_add(SB), R9
BL racecallatomic<>(SB)
MOVD add+8(FP), R0 // convert fetch_add to add_fetch
Expand All @@ -273,32 +291,40 @@ TEXT sync∕atomic·AddInt64(SB), NOSPLIT, $0
RET

TEXT sync∕atomic·AddUint32(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·AddInt32(SB)

TEXT sync∕atomic·AddUint64(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·AddInt64(SB)

TEXT sync∕atomic·AddUintptr(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·AddInt64(SB)

// CompareAndSwap
TEXT sync∕atomic·CompareAndSwapInt32(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic32_compare_exchange(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·CompareAndSwapInt64(SB), NOSPLIT, $0
GO_ARGS
MOVD $__tsan_go_atomic64_compare_exchange(SB), R9
BL racecallatomic<>(SB)
RET

TEXT sync∕atomic·CompareAndSwapUint32(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·CompareAndSwapInt32(SB)

TEXT sync∕atomic·CompareAndSwapUint64(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·CompareAndSwapInt64(SB)

TEXT sync∕atomic·CompareAndSwapUintptr(SB), NOSPLIT, $0
GO_ARGS
JMP sync∕atomic·CompareAndSwapInt64(SB)

// Generic atomic operation implementation.
Expand Down

0 comments on commit ae65615

Please sign in to comment.