Reviewers: Sven Panne,
Message:
PTAL
Description:
[x86] Disable AVX on Mac OS X 10.9.
Mac OS X 10.9 (Mavericks) has a bug that causes AVX transitions in ISRs,
so we better not use AVX there.
Please review this at https://codereview.chromium.org/826683003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+60, -6 lines):
M src/ia32/assembler-ia32.cc
M src/x64/assembler-x64.cc
Index: src/ia32/assembler-ia32.cc
diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc
index
2805fa0f9a8a7f84dc0c137f798ded16510893be..168a19644981172fc3268d9e87c38aa2dc13a177
100644
--- a/src/ia32/assembler-ia32.cc
+++ b/src/ia32/assembler-ia32.cc
@@ -34,7 +34,11 @@
// significantly by Google Inc.
// Copyright 2012 the V8 project authors. All rights reserved.
-#include "src/v8.h"
+#include "src/ia32/assembler-ia32.h"
+
+#if V8_OS_MACOSX
+#include <sys/sysctl.h>
+#endif
#if V8_TARGET_ARCH_IA32
@@ -42,7 +46,7 @@
#include "src/base/cpu.h"
#include "src/disassembler.h"
#include "src/macro-assembler.h"
-#include "src/serialize.h"
+#include "src/v8.h"
namespace v8 {
namespace internal {
@@ -50,6 +54,29 @@ namespace internal {
//
-----------------------------------------------------------------------------
// Implementation of CpuFeatures
+namespace {
+
+bool EnableAVX() {
+#if V8_OS_MACOSX
+ // Mac OS X 10.9 has a bug where AVX transitions were indeed being
caused by
+ // ISRs, so we detect Mac OS X 10.9 here and disable AVX in that case.
+ char buffer[128];
+ size_t buffer_size = arraysize(buffer);
+ int ctl_name[] = { CTL_KERN , KERN_OSRELEASE };
+ if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) {
+ V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version");
+ }
+ // The buffer now contains a string of the form XX.YY.ZZ, where
+ // XX is the major kernel version component. 13.x.x (Mavericks) is
+ // affected by this bug, so disable AVX there.
+ if (memcmp(buffer, "13.", 3) == 0) return false;
+#endif // V8_OS_MACOSX
+ return FLAG_enable_avx;
+}
+
+} // namespace
+
+
void CpuFeatures::ProbeImpl(bool cross_compile) {
base::CPU cpu;
CHECK(cpu.has_sse2()); // SSE2 support is mandatory.
@@ -60,7 +87,7 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1;
if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3;
- if (cpu.has_avx() && FLAG_enable_avx) supported_ |= 1u << AVX;
+ if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX;
if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3;
}
Index: src/x64/assembler-x64.cc
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index
469ebe9888f41efb06cdc04f07d199d7cc901e0b..fd722b23bd34fd86db481b1c694c6fa8e2a20804
100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/v8.h"
+#include "src/x64/assembler-x64.h"
+
+#if V8_OS_MACOSX
+#include <sys/sysctl.h>
+#endif
#if V8_TARGET_ARCH_X64
#include "src/base/bits.h"
#include "src/macro-assembler.h"
-#include "src/serialize.h"
+#include "src/v8.h"
namespace v8 {
namespace internal {
@@ -16,6 +20,29 @@ namespace internal {
//
-----------------------------------------------------------------------------
// Implementation of CpuFeatures
+namespace {
+
+bool EnableAVX() {
+#if V8_OS_MACOSX
+ // Mac OS X 10.9 has a bug where AVX transitions were indeed being
caused by
+ // ISRs, so we detect Mac OS X 10.9 here and disable AVX in that case.
+ char buffer[128];
+ size_t buffer_size = arraysize(buffer);
+ int ctl_name[] = { CTL_KERN , KERN_OSRELEASE };
+ if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) {
+ V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version");
+ }
+ // The buffer now contains a string of the form XX.YY.ZZ, where
+ // XX is the major kernel version component. 13.x.x (Mavericks) is
+ // affected by this bug, so disable AVX there.
+ if (memcmp(buffer, "13.", 3) == 0) return false;
+#endif // V8_OS_MACOSX
+ return FLAG_enable_avx;
+}
+
+} // namespace
+
+
void CpuFeatures::ProbeImpl(bool cross_compile) {
base::CPU cpu;
CHECK(cpu.has_sse2()); // SSE2 support is mandatory.
@@ -28,7 +55,7 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3;
// SAHF is not generally available in long mode.
if (cpu.has_sahf() && FLAG_enable_sahf) supported_ |= 1u << SAHF;
- if (cpu.has_avx() && FLAG_enable_avx) supported_ |= 1u << AVX;
+ if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX;
if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.