aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race_amd64.s
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-04-11 14:20:54 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-23 07:43:18 +0000
commitab3f1a23b6c29a110423d6fd6bf2b01fa62a6fb2 (patch)
tree38e2a45179cd9748a8bad2099f32fbe3dc9a2e37 /src/runtime/race_amd64.s
parentc824420d4744bd3e11128c000d88c24859602d46 (diff)
downloadgo-ab3f1a23b6c29a110423d6fd6bf2b01fa62a6fb2.tar.gz
go-ab3f1a23b6c29a110423d6fd6bf2b01fa62a6fb2.zip
runtime: add race detector support for new timers
Since the new timers run on g0, which does not have a race context, we add a race context field to the P, and use that for timer functions. This works since all timer functions are in the standard library. Updates #27707 Change-Id: I8a5b727b4ddc8ca6fc60eb6d6f5e9819245e395b Reviewed-on: https://go-review.googlesource.com/c/go/+/171882 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/race_amd64.s')
-rw-r--r--src/runtime/race_amd64.s18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/runtime/race_amd64.s b/src/runtime/race_amd64.s
index 4ed9533bfb..758d543203 100644
--- a/src/runtime/race_amd64.s
+++ b/src/runtime/race_amd64.s
@@ -416,9 +416,11 @@ rest:
// Set g = g0.
get_tls(R12)
MOVQ g(R12), R13
- MOVQ g_m(R13), R13
- MOVQ m_g0(R13), R14
- MOVQ R14, g(R12) // g = m->g0
+ MOVQ g_m(R13), R14
+ MOVQ m_g0(R14), R15
+ CMPQ R13, R15
+ JEQ noswitch // branch if already on g0
+ MOVQ R15, g(R12) // g = m->g0
PUSHQ RARG1 // func arg
PUSHQ RARG0 // func arg
CALL runtime·racecallback(SB)
@@ -430,6 +432,7 @@ rest:
MOVQ g_m(R13), R13
MOVQ m_curg(R13), R14
MOVQ R14, g(R12) // g = m->curg
+ret:
// Restore callee-saved registers.
POPQ R15
POPQ R14
@@ -440,3 +443,12 @@ rest:
POPQ BP
POPQ BX
RET
+
+noswitch:
+ // already on g0
+ PUSHQ RARG1 // func arg
+ PUSHQ RARG0 // func arg
+ CALL runtime·racecallback(SB)
+ POPQ R12
+ POPQ R12
+ JMP ret