aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mkpreempt.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-02-25 20:30:37 -0500
committerCherry Zhang <cherryyz@google.com>2020-02-26 01:52:42 +0000
commitc46ffdd2eca339918ed30b6ba9d4715ba769d35d (patch)
tree02888c9df18e9afafd0a59ad94b63761a2a01ba8 /src/runtime/mkpreempt.go
parent089e482b3dd2026178c8ee5b90d9aadb6bf81239 (diff)
downloadgo-c46ffdd2eca339918ed30b6ba9d4715ba769d35d.tar.gz
go-c46ffdd2eca339918ed30b6ba9d4715ba769d35d.zip
runtime: guard VZEROUPPER on CPU feature
In CL 219131 we inserted a VZEROUPPER instruction on darwin/amd64. The instruction is not available on pre-AVX machines. Guard it with CPU feature. Fixes #37459. Change-Id: I9a064df277d091be4ee594eda5c7fd8ee323102b Reviewed-on: https://go-review.googlesource.com/c/go/+/221057 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/mkpreempt.go')
-rw-r--r--src/runtime/mkpreempt.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go
index 31b6f5cbac..c26406e55f 100644
--- a/src/runtime/mkpreempt.go
+++ b/src/runtime/mkpreempt.go
@@ -244,23 +244,26 @@ func genAMD64() {
// TODO: MXCSR register?
+ p("PUSHQ BP")
+ p("MOVQ SP, BP")
+ p("// Save flags before clobbering them")
+ p("PUSHFQ")
+ p("// obj doesn't understand ADD/SUB on SP, but does understand ADJSP")
+ p("ADJSP $%d", l.stack)
+ p("// But vet doesn't know ADJSP, so suppress vet stack checking")
+ p("NOP SP")
+
// Apparently, the signal handling code path in darwin kernel leaves
// the upper bits of Y registers in a dirty state, which causes
// many SSE operations (128-bit and narrower) become much slower.
// Clear the upper bits to get to a clean state. See issue #37174.
// It is safe here as Go code don't use the upper bits of Y registers.
p("#ifdef GOOS_darwin")
+ p("CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $0")
+ p("JE 2(PC)")
p("VZEROUPPER")
p("#endif")
- p("PUSHQ BP")
- p("MOVQ SP, BP")
- p("// Save flags before clobbering them")
- p("PUSHFQ")
- p("// obj doesn't understand ADD/SUB on SP, but does understand ADJSP")
- p("ADJSP $%d", l.stack)
- p("// But vet doesn't know ADJSP, so suppress vet stack checking")
- p("NOP SP")
l.save()
p("CALL ·asyncPreempt2(SB)")
l.restore()