1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:34:42 -07:00

internal/cpu,runtime: call cpu.initialize before alginit

runtime.alginit needs runtime/support_{aes,ssse3,sse41} feature flag
to init aeshash function but internal/cpu.init not be called yet.
This CL will call internal/cpu.initialize before runtime.alginit, so
that we can move all cpu features related code to internal/cpu.

Change-Id: I00b8e403ace3553f8c707563d95f27dade0bc853
Reviewed-on: https://go-review.googlesource.com/104636
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Meng Zhuo 2018-04-10 22:33:03 +08:00 committed by Brad Fitzpatrick
parent 60fee0153f
commit 954f651ccc
6 changed files with 31 additions and 7 deletions

View File

@ -27,7 +27,7 @@ import (
// Do not instrument the following packages at all, // Do not instrument the following packages at all,
// at best instrumentation would cause infinite recursion. // at best instrumentation would cause infinite recursion.
var omit_pkgs = []string{"runtime/internal/atomic", "runtime/internal/sys", "runtime", "runtime/race", "runtime/msan"} var omit_pkgs = []string{"runtime/internal/atomic", "runtime/internal/sys", "runtime", "runtime/race", "runtime/msan", "internal/cpu"}
// Only insert racefuncenterfp/racefuncexit into the following packages. // Only insert racefuncenterfp/racefuncexit into the following packages.
// Memory accesses in the packages are either uninteresting or will cause false positives. // Memory accesses in the packages are either uninteresting or will cause false positives.

View File

@ -98,3 +98,10 @@ type s390x struct {
HasVX bool // vector facility. Note: the runtime sets this when it processes auxv records. HasVX bool // vector facility. Note: the runtime sets this when it processes auxv records.
_ [CacheLineSize]byte _ [CacheLineSize]byte
} }
// initialize examines the processor and sets the relevant variables above.
// This is called by the runtime package early in program initialization,
// before normal init functions are run.
func initialize() {
doinit()
}

View File

@ -42,7 +42,7 @@ const (
hwcap_ASIMDFHM = (1 << 23) hwcap_ASIMDFHM = (1 << 23)
) )
func init() { func doinit() {
// HWCAP feature bits // HWCAP feature bits
ARM64.HasFP = isSet(arm64_hwcap, hwcap_FP) ARM64.HasFP = isSet(arm64_hwcap, hwcap_FP)
ARM64.HasASIMD = isSet(arm64_hwcap, hwcap_ASIMD) ARM64.HasASIMD = isSet(arm64_hwcap, hwcap_ASIMD)

View File

@ -0,0 +1,13 @@
// 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.
// +build !386
// +build !amd64
// +build !amd64p32
// +build !arm64
package cpu
func doinit() {
}

View File

@ -14,7 +14,7 @@ func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
// xgetbv with ecx = 0 is implemented in cpu_x86.s. // xgetbv with ecx = 0 is implemented in cpu_x86.s.
func xgetbv() (eax, edx uint32) func xgetbv() (eax, edx uint32)
func init() { func doinit() {
maxID, _, _, _ := cpuid(0, 0) maxID, _, _, _ := cpuid(0, 0)
if maxID < 1 { if maxID < 1 {

View File

@ -466,6 +466,9 @@ const (
_GoidCacheBatch = 16 _GoidCacheBatch = 16
) )
//go:linkname internal_cpu_initialize internal/cpu.initialize
func internal_cpu_initialize()
// The bootstrap sequence is: // The bootstrap sequence is:
// //
// call osinit // call osinit
@ -489,6 +492,7 @@ func schedinit() {
stackinit() stackinit()
mallocinit() mallocinit()
mcommoninit(_g_.m) mcommoninit(_g_.m)
internal_cpu_initialize() // must run before alginit
alginit() // maps must not be used before this call alginit() // maps must not be used before this call
modulesinit() // provides activeModules modulesinit() // provides activeModules
typelinksinit() // uses maps, activeModules typelinksinit() // uses maps, activeModules