Index: src/base/cpu.cc |
diff --git a/src/base/cpu.cc b/src/base/cpu.cc |
index 5bc8b13a97ba2fb9ca2094e32b43d288cf3b0157..7fde50cccd7f994456292300c176553f3bd663f9 100644 |
--- a/src/base/cpu.cc |
+++ b/src/base/cpu.cc |
@@ -64,6 +64,19 @@ static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { |
#endif // !V8_LIBC_MSVCRT |
+static V8_INLINE bool avx_os_support() { |
Benedikt Meurer
2014/11/25 17:32:42
That does not belong here. The CPU class should on
|
+#if !V8_LIBC_MSVCRT |
+ unsigned int eax, edx; |
+ unsigned int ecx = 0; |
+ __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(ecx)); |
+ return (eax & 0x6) == 0x6; |
+#else |
+ uint64_t xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK); |
+ return (xcrFeatureMask & 0x6) == 0x6; |
+#endif |
+} |
+ |
+ |
#elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 \ |
|| V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 |
@@ -291,32 +304,35 @@ static bool HasListItem(const char* list, const char* item) { |
#endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
-CPU::CPU() : stepping_(0), |
- model_(0), |
- ext_model_(0), |
- family_(0), |
- ext_family_(0), |
- type_(0), |
- implementer_(0), |
- architecture_(0), |
- part_(0), |
- has_fpu_(false), |
- has_cmov_(false), |
- has_sahf_(false), |
- has_mmx_(false), |
- has_sse_(false), |
- has_sse2_(false), |
- has_sse3_(false), |
- has_ssse3_(false), |
- has_sse41_(false), |
- has_sse42_(false), |
- has_idiva_(false), |
- has_neon_(false), |
- has_thumb2_(false), |
- has_vfp_(false), |
- has_vfp3_(false), |
- has_vfp3_d32_(false), |
- is_fp64_mode_(false) { |
+CPU::CPU() |
+ : stepping_(0), |
+ model_(0), |
+ ext_model_(0), |
+ family_(0), |
+ ext_family_(0), |
+ type_(0), |
+ implementer_(0), |
+ architecture_(0), |
+ part_(0), |
+ has_fpu_(false), |
+ has_cmov_(false), |
+ has_sahf_(false), |
+ has_mmx_(false), |
+ has_sse_(false), |
+ has_sse2_(false), |
+ has_sse3_(false), |
+ has_ssse3_(false), |
+ has_sse41_(false), |
+ has_sse42_(false), |
+ has_avx_(false), |
+ has_fma3_(false), |
+ has_idiva_(false), |
+ has_neon_(false), |
+ has_thumb2_(false), |
+ has_vfp_(false), |
+ has_vfp3_(false), |
+ has_vfp3_d32_(false), |
+ is_fp64_mode_(false) { |
memcpy(vendor_, "Unknown", 8); |
#if V8_OS_NACL |
// Portable host shouldn't do feature detection. |
@@ -356,6 +372,8 @@ CPU::CPU() : stepping_(0), |
has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; |
has_sse41_ = (cpu_info[2] & 0x00080000) != 0; |
has_sse42_ = (cpu_info[2] & 0x00100000) != 0; |
+ has_avx_ = ((cpu_info[2] & 0x18000000) == 0x18000000) && avx_os_support(); |
Benedikt Meurer
2014/11/25 17:32:42
As mentioned above, remove the avx_os_support here
|
+ if (has_avx_) has_fma3_ = (cpu_info[2] & 0x00001000) != 0; |
} |
#if V8_HOST_ARCH_IA32 |