OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/x64/assembler-x64.h" |
| 6 |
| 7 #if V8_OS_MACOSX |
| 8 #include <sys/sysctl.h> |
| 9 #endif |
6 | 10 |
7 #if V8_TARGET_ARCH_X64 | 11 #if V8_TARGET_ARCH_X64 |
8 | 12 |
9 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
10 #include "src/macro-assembler.h" | 14 #include "src/macro-assembler.h" |
11 #include "src/serialize.h" | 15 #include "src/v8.h" |
12 | 16 |
13 namespace v8 { | 17 namespace v8 { |
14 namespace internal { | 18 namespace internal { |
15 | 19 |
16 // ----------------------------------------------------------------------------- | 20 // ----------------------------------------------------------------------------- |
17 // Implementation of CpuFeatures | 21 // Implementation of CpuFeatures |
18 | 22 |
| 23 namespace { |
| 24 |
| 25 bool EnableAVX() { |
| 26 #if V8_OS_MACOSX |
| 27 // Mac OS X 10.9 has a bug where AVX transitions were indeed being caused by |
| 28 // ISRs, so we detect Mac OS X 10.9 here and disable AVX in that case. |
| 29 char buffer[128]; |
| 30 size_t buffer_size = arraysize(buffer); |
| 31 int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; |
| 32 if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) { |
| 33 V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version"); |
| 34 } |
| 35 // The buffer now contains a string of the form XX.YY.ZZ, where |
| 36 // XX is the major kernel version component. 13.x.x (Mavericks) is |
| 37 // affected by this bug, so disable AVX there. |
| 38 if (memcmp(buffer, "13.", 3) == 0) return false; |
| 39 #endif // V8_OS_MACOSX |
| 40 return FLAG_enable_avx; |
| 41 } |
| 42 |
| 43 } // namespace |
| 44 |
| 45 |
19 void CpuFeatures::ProbeImpl(bool cross_compile) { | 46 void CpuFeatures::ProbeImpl(bool cross_compile) { |
20 base::CPU cpu; | 47 base::CPU cpu; |
21 CHECK(cpu.has_sse2()); // SSE2 support is mandatory. | 48 CHECK(cpu.has_sse2()); // SSE2 support is mandatory. |
22 CHECK(cpu.has_cmov()); // CMOV support is mandatory. | 49 CHECK(cpu.has_cmov()); // CMOV support is mandatory. |
23 | 50 |
24 // Only use statically determined features for cross compile (snapshot). | 51 // Only use statically determined features for cross compile (snapshot). |
25 if (cross_compile) return; | 52 if (cross_compile) return; |
26 | 53 |
27 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; | 54 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; |
28 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; | 55 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; |
29 // SAHF is not generally available in long mode. | 56 // SAHF is not generally available in long mode. |
30 if (cpu.has_sahf() && FLAG_enable_sahf) supported_ |= 1u << SAHF; | 57 if (cpu.has_sahf() && FLAG_enable_sahf) supported_ |= 1u << SAHF; |
31 if (cpu.has_avx() && FLAG_enable_avx) supported_ |= 1u << AVX; | 58 if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX; |
32 if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3; | 59 if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3; |
33 } | 60 } |
34 | 61 |
35 | 62 |
36 void CpuFeatures::PrintTarget() { } | 63 void CpuFeatures::PrintTarget() { } |
37 void CpuFeatures::PrintFeatures() { | 64 void CpuFeatures::PrintFeatures() { |
38 printf("SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d\n", | 65 printf("SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d\n", |
39 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), | 66 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), |
40 CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX), | 67 CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX), |
41 CpuFeatures::IsSupported(FMA3)); | 68 CpuFeatures::IsSupported(FMA3)); |
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3350 | 3377 |
3351 | 3378 |
3352 bool RelocInfo::IsInConstantPool() { | 3379 bool RelocInfo::IsInConstantPool() { |
3353 return false; | 3380 return false; |
3354 } | 3381 } |
3355 | 3382 |
3356 | 3383 |
3357 } } // namespace v8::internal | 3384 } } // namespace v8::internal |
3358 | 3385 |
3359 #endif // V8_TARGET_ARCH_X64 | 3386 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |