| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 31 // OF THE POSSIBILITY OF SUCH DAMAGE. | 31 // OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | 32 |
| 33 // The original source code covered by the above license above has been modified | 33 // The original source code covered by the above license above has been modified |
| 34 // significantly by Google Inc. | 34 // significantly by Google Inc. |
| 35 // Copyright 2012 the V8 project authors. All rights reserved. | 35 // Copyright 2012 the V8 project authors. All rights reserved. |
| 36 | 36 |
| 37 #include "src/v8.h" | 37 #include "src/ia32/assembler-ia32.h" |
| 38 |
| 39 #if V8_OS_MACOSX |
| 40 #include <sys/sysctl.h> |
| 41 #endif |
| 38 | 42 |
| 39 #if V8_TARGET_ARCH_IA32 | 43 #if V8_TARGET_ARCH_IA32 |
| 40 | 44 |
| 41 #include "src/base/bits.h" | 45 #include "src/base/bits.h" |
| 42 #include "src/base/cpu.h" | 46 #include "src/base/cpu.h" |
| 43 #include "src/disassembler.h" | 47 #include "src/disassembler.h" |
| 44 #include "src/macro-assembler.h" | 48 #include "src/macro-assembler.h" |
| 45 #include "src/serialize.h" | 49 #include "src/v8.h" |
| 46 | 50 |
| 47 namespace v8 { | 51 namespace v8 { |
| 48 namespace internal { | 52 namespace internal { |
| 49 | 53 |
| 50 // ----------------------------------------------------------------------------- | 54 // ----------------------------------------------------------------------------- |
| 51 // Implementation of CpuFeatures | 55 // Implementation of CpuFeatures |
| 52 | 56 |
| 57 namespace { |
| 58 |
| 59 bool EnableAVX() { |
| 60 #if V8_OS_MACOSX |
| 61 // Mac OS X 10.9 has a bug where AVX transitions were indeed being caused by |
| 62 // ISRs, so we detect Mac OS X 10.9 here and disable AVX in that case. |
| 63 char buffer[128]; |
| 64 size_t buffer_size = arraysize(buffer); |
| 65 int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; |
| 66 if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) { |
| 67 V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version"); |
| 68 } |
| 69 // The buffer now contains a string of the form XX.YY.ZZ, where |
| 70 // XX is the major kernel version component. 13.x.x (Mavericks) is |
| 71 // affected by this bug, so disable AVX there. |
| 72 if (memcmp(buffer, "13.", 3) == 0) return false; |
| 73 #endif // V8_OS_MACOSX |
| 74 return FLAG_enable_avx; |
| 75 } |
| 76 |
| 77 } // namespace |
| 78 |
| 79 |
| 53 void CpuFeatures::ProbeImpl(bool cross_compile) { | 80 void CpuFeatures::ProbeImpl(bool cross_compile) { |
| 54 base::CPU cpu; | 81 base::CPU cpu; |
| 55 CHECK(cpu.has_sse2()); // SSE2 support is mandatory. | 82 CHECK(cpu.has_sse2()); // SSE2 support is mandatory. |
| 56 CHECK(cpu.has_cmov()); // CMOV support is mandatory. | 83 CHECK(cpu.has_cmov()); // CMOV support is mandatory. |
| 57 | 84 |
| 58 // Only use statically determined features for cross compile (snapshot). | 85 // Only use statically determined features for cross compile (snapshot). |
| 59 if (cross_compile) return; | 86 if (cross_compile) return; |
| 60 | 87 |
| 61 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; | 88 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; |
| 62 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; | 89 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; |
| 63 if (cpu.has_avx() && FLAG_enable_avx) supported_ |= 1u << AVX; | 90 if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX; |
| 64 if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3; | 91 if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3; |
| 65 } | 92 } |
| 66 | 93 |
| 67 | 94 |
| 68 void CpuFeatures::PrintTarget() { } | 95 void CpuFeatures::PrintTarget() { } |
| 69 void CpuFeatures::PrintFeatures() { | 96 void CpuFeatures::PrintFeatures() { |
| 70 printf("SSE3=%d SSE4_1=%d AVX=%d FMA3=%d\n", CpuFeatures::IsSupported(SSE3), | 97 printf("SSE3=%d SSE4_1=%d AVX=%d FMA3=%d\n", CpuFeatures::IsSupported(SSE3), |
| 71 CpuFeatures::IsSupported(SSE4_1), CpuFeatures::IsSupported(AVX), | 98 CpuFeatures::IsSupported(SSE4_1), CpuFeatures::IsSupported(AVX), |
| 72 CpuFeatures::IsSupported(FMA3)); | 99 CpuFeatures::IsSupported(FMA3)); |
| 73 } | 100 } |
| (...skipping 2671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2745 fprintf(coverage_log, "%s\n", file_line); | 2772 fprintf(coverage_log, "%s\n", file_line); |
| 2746 fflush(coverage_log); | 2773 fflush(coverage_log); |
| 2747 } | 2774 } |
| 2748 } | 2775 } |
| 2749 | 2776 |
| 2750 #endif | 2777 #endif |
| 2751 | 2778 |
| 2752 } } // namespace v8::internal | 2779 } } // namespace v8::internal |
| 2753 | 2780 |
| 2754 #endif // V8_TARGET_ARCH_IA32 | 2781 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |