diff options
author | Martin Möhrmann <moehrmann@google.com> | 2018-07-28 10:56:48 +0200 |
---|---|---|
committer | Martin Möhrmann <moehrmann@google.com> | 2018-08-24 07:29:52 +0000 |
commit | c15c04d9e85a6a2c46ae57cb830192e0eee276dc (patch) | |
tree | 83dd5c15182196d11597cfad6823987138297c70 /src/runtime/cpuflags.go | |
parent | d8cf1514cadb512de6972e760ccef76452e3a67c (diff) | |
download | go-c15c04d9e85a6a2c46ae57cb830192e0eee276dc.tar.gz go-c15c04d9e85a6a2c46ae57cb830192e0eee276dc.zip |
runtime: use internal/cpu variables in assembler code
Using internal/cpu variables has the benefit of avoiding false sharing
(as those are padded) and allows memory and cache usage for these variables
to be shared by multiple packages.
Change-Id: I2bf68d03091bf52b466cf689230d5d25d5950037
Reviewed-on: https://go-review.googlesource.com/126599
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/cpuflags.go')
-rw-r--r-- | src/runtime/cpuflags.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/runtime/cpuflags.go b/src/runtime/cpuflags.go new file mode 100644 index 0000000000..dee6116a90 --- /dev/null +++ b/src/runtime/cpuflags.go @@ -0,0 +1,17 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import ( + "internal/cpu" + "unsafe" +) + +// Offsets into internal/cpu records for use in assembly. +const ( + offset_x86_HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2) + offset_x86_HasERMS = unsafe.Offsetof(cpu.X86.HasERMS) + offset_x86_HasSSE2 = unsafe.Offsetof(cpu.X86.HasSSE2) +) |