From 05bcc2fbc62cd4ce5cf0c97a8d5eb42a4a5eb323 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Wed, 7 Jan 2015 13:10:44 +0100 Subject: [PATCH] [x86] Blacklist AVX for all Mac OS versions up to 10.9. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/808333005 Cr-Commit-Position: refs/heads/master@{#25969} --- src/ia32/assembler-ia32.cc | 13 ++++++++----- src/x64/assembler-x64.cc | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index 168a196..86a77f9 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -58,8 +58,8 @@ 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. + // Mac OS X up to 10.9 has a bug where AVX transitions were indeed being + // caused by ISRs, so we detect that here and disable AVX in that case. char buffer[128]; size_t buffer_size = arraysize(buffer); int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; @@ -67,9 +67,12 @@ bool EnableAVX() { 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; + // XX is the major kernel version component. + char* period_pos = strchr(buffer, '.'); + DCHECK_NOT_NULL(period_pos); + *period_pos = '\0'; + long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT + if (kernel_version_major <= 13) return false; #endif // V8_OS_MACOSX return FLAG_enable_avx; } diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index fd722b2..96422f6 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -24,8 +24,8 @@ 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. + // Mac OS X up to 10.9 has a bug where AVX transitions were indeed being + // caused by ISRs, so we detect that here and disable AVX in that case. char buffer[128]; size_t buffer_size = arraysize(buffer); int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; @@ -33,9 +33,12 @@ bool EnableAVX() { 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; + // XX is the major kernel version component. + char* period_pos = strchr(buffer, '.'); + DCHECK_NOT_NULL(period_pos); + *period_pos = '\0'; + long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT + if (kernel_version_major <= 13) return false; #endif // V8_OS_MACOSX return FLAG_enable_avx; } -- 2.7.4