]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove duplicate cpu feature detection on x86
authorMartin Möhrmann <moehrmann@google.com>
Fri, 25 May 2018 12:01:25 +0000 (14:01 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 25 May 2018 13:14:07 +0000 (13:14 +0000)
This also allows the GODEBUGCPU options to change the
support_* runtime cpu feature variable values.

Change-Id: I884c5f03993afc7e3344ff2fd471a2c6cfde43d4
Reviewed-on: https://go-review.googlesource.com/114615
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_amd64p32.s
src/runtime/proc.go
src/runtime/runtime2.go

index 5ca26a2d5ffbb4d980c1d45a0d5bb74525218a84..a6a81c3f63d0ebd385329a45e9a7c66aff31aaeb 100644 (file)
@@ -164,42 +164,6 @@ notintel:
        TESTL   $(1<<23), DX // MMX
        JZ      bad_proc
 
-       TESTL   $(1<<26), DX // SSE2
-       SETNE   runtime·support_sse2(SB)
-
-       TESTL   $(1<<19), DI // SSE4.1
-       SETNE   runtime·support_sse41(SB)
-
-       TESTL   $(1<<23), DI // POPCNT
-       SETNE   runtime·support_popcnt(SB)
-
-       TESTL   $(1<<27), DI // OSXSAVE
-       SETNE   runtime·support_osxsave(SB)
-
-eax7:
-       // Load EAX=7/ECX=0 cpuid flags
-       CMPL    SI, $7
-       JLT     osavx
-       MOVL    $7, AX
-       MOVL    $0, CX
-       CPUID
-
-       TESTL   $(1<<9), BX // ERMS
-       SETNE   runtime·support_erms(SB)
-
-osavx:
-       // nacl does not support XGETBV to test
-       // for XMM and YMM OS support.
-#ifndef GOOS_nacl
-       CMPB    runtime·support_osxsave(SB), $1
-       JNE     nocpuinfo
-       MOVL    $0, CX
-       // For XGETBV, OSXSAVE bit is required and sufficient
-       XGETBV
-       ANDL    $6, AX
-       CMPL    AX, $6 // Check for OS support of XMM and YMM registers.
-#endif
-
 nocpuinfo:
        // if there is an _cgo_init, call it to let it
        // initialize and to set up GS.  if not,
index 214d1608d605f5b26d0c56d10149344935d60401..6902ce2c22c026ee570d07d8d9ac61d858510c02 100644 (file)
@@ -127,38 +127,6 @@ notintel:
        CPUID
        MOVL    AX, runtime·processorVersionInfo(SB)
 
-       TESTL   $(1<<26), DX // SSE2
-       SETNE   runtime·support_sse2(SB)
-
-       TESTL   $(1<<19), CX // SSE4.1
-       SETNE   runtime·support_sse41(SB)
-
-       TESTL   $(1<<23), CX // POPCNT
-       SETNE   runtime·support_popcnt(SB)
-
-       TESTL   $(1<<27), CX // OSXSAVE
-       SETNE   runtime·support_osxsave(SB)
-
-eax7:
-       // Load EAX=7/ECX=0 cpuid flags
-       CMPL    SI, $7
-       JLT     osavx
-       MOVL    $7, AX
-       MOVL    $0, CX
-       CPUID
-
-       TESTL   $(1<<9), BX // ERMS
-       SETNE   runtime·support_erms(SB)
-
-osavx:
-       CMPB    runtime·support_osxsave(SB), $1
-       JNE     nocpuinfo
-       MOVL    $0, CX
-       // For XGETBV, OSXSAVE bit is required and sufficient
-       XGETBV
-       ANDL    $6, AX
-       CMPL    AX, $6 // Check for OS support of XMM and YMM registers.
-
 nocpuinfo:
        // if there is an _cgo_init, call it.
        MOVQ    _cgo_init(SB), AX
index 9c0d788ea50de2e40edb68cf0927a4da38831035..49958d0c886b116b0a1077584904293bfa1a1417 100644 (file)
@@ -47,45 +47,7 @@ notintel:
        CPUID
        MOVL    AX, runtime·processorVersionInfo(SB)
 
-       TESTL   $(1<<26), DX // SSE2
-       SETNE   runtime·support_sse2(SB)
-
-       TESTL   $(1<<19), CX // SSE4.1
-       SETNE   runtime·support_sse41(SB)
-
-       TESTL   $(1<<23), CX // POPCNT
-       SETNE   runtime·support_popcnt(SB)
-
-       TESTL   $(1<<27), CX // OSXSAVE
-       SETNE   runtime·support_osxsave(SB)
-
-eax7:
-       // Load EAX=7/ECX=0 cpuid flags
-       CMPL    SI, $7
-       JLT     osavx
-       MOVL    $7, AX
-       MOVL    $0, CX
-       CPUID
-
-       TESTL   $(1<<9), BX // ERMS
-       SETNE   runtime·support_erms(SB)
-
-osavx:
-       // nacl does not support XGETBV to test
-       // for XMM and YMM OS support.
-#ifndef GOOS_nacl
-       CMPB    runtime·support_osxsave(SB), $1
-       JNE     nocpuinfo
-       MOVL    $0, CX
-       // For XGETBV, OSXSAVE bit is required and sufficient
-       XGETBV
-       ANDL    $6, AX
-       CMPL    AX, $6 // Check for OS support of XMM and YMM registers.
-#endif
-
 nocpuinfo:
-
-needtls:
        LEAL    runtime·m0+m_tls(SB), DI
        CALL    runtime·settls(SB)
 
index ba76f7c3e7b5aea3a9a2b41c00653157651a4a91..e312c575d0fb45783d7513113d993caa2f7a2490 100644 (file)
@@ -5,6 +5,7 @@
 package runtime
 
 import (
+       "internal/cpu"
        "runtime/internal/atomic"
        "runtime/internal/sys"
        "unsafe"
@@ -507,6 +508,11 @@ func cpuinit() {
        }
 
        internal_cpu_initialize(env)
+
+       support_erms = cpu.X86.HasERMS
+       support_popcnt = cpu.X86.HasPOPCNT
+       support_sse2 = cpu.X86.HasSSE2
+       support_sse41 = cpu.X86.HasSSE41
 }
 
 // The bootstrap sequence is:
index a8b0cd76acbbfcc1a93382a64b4f84b55f0c379b..1ac008382851ea375d6cb22f7d10a269da9fc379 100644 (file)
@@ -833,7 +833,7 @@ var (
        newprocs   int32
 
        // Information about what cpu features are available.
-       // Set on startup in asm_{386,amd64,amd64p32}.s.
+       // Set on startup in runtime.cpuinit.
        // Packages outside the runtime should not use these
        // as they are not an external api.
        // TODO: deprecate these; use internal/cpu directly.
@@ -841,7 +841,6 @@ var (
        isIntel              bool
        lfenceBeforeRdtsc    bool
        support_erms         bool
-       support_osxsave      bool
        support_popcnt       bool
        support_sse2         bool
        support_sse41        bool