WebKit Bugzilla
Attachment 369092 Details for
Bug 196488
: [CMake] Detect SSE2 at compile time
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Detect SSE2 with CMake
cmake-sse2.diff (text/plain), 11.21 KB, created by
Xan Lopez
on 2019-05-05 09:23:25 PDT
(
hide
)
Description:
Detect SSE2 with CMake
Filename:
MIME Type:
Creator:
Xan Lopez
Created:
2019-05-05 09:23:25 PDT
Size:
11.21 KB
patch
obsolete
>From d3e81df99ac41d7b0d3cf9ff1626135fb72d4b52 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Xan=20L=C3=B3pez?= <xan@igalia.com> >Date: Tue, 2 Apr 2019 12:44:07 +0200 >Subject: [PATCH] [CMake] Detect SSE2 at compile time > https://bugs.webkit.org/show_bug.cgi?id=196488 > >Reviewed by NOBODY (OOPS!). > >.: > >* Source/cmake/FindSSE2.cmake: Added. >* Source/cmake/WebKitCompilerFlags.cmake: Detect SSE2 support and >add SSE2 to the global compiler flags. > >Source/JavaScriptCore: > >* assembler/MacroAssemblerX86Common.cpp: Remove unnecessary (and >incorrect) static_assert. >(JSC::MacroAssemblerX86Common::collectCPUFeatures): >* assembler/MacroAssemblerX86Common.h: Remove SSE2 flags. > >Tools: > >* Scripts/webkitdirs.pm: >(generateBuildSystemFromCMakeProject): Do not add SSE2 flags here >for x86 builds. This is now handled in WebKitCompilerFlags.cmake. >--- > ChangeLog | 11 ++++ > Source/JavaScriptCore/ChangeLog | 12 ++++ > .../assembler/MacroAssemblerX86Common.cpp | 7 --- > .../assembler/MacroAssemblerX86Common.h | 30 --------- > Source/cmake/FindSSE2.cmake | 61 +++++++++++++++++++ > Source/cmake/WebKitCompilerFlags.cmake | 9 +++ > Tools/ChangeLog | 11 ++++ > Tools/Scripts/webkitdirs.pm | 9 --- > 8 files changed, 104 insertions(+), 46 deletions(-) > create mode 100644 Source/cmake/FindSSE2.cmake > >diff --git a/ChangeLog b/ChangeLog >index 4921060bf4a..7d258a4b11d 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,14 @@ >+2019-05-03 Xan López <xan@igalia.com> >+ >+ [CMake] Detect SSE2 at compile time >+ https://bugs.webkit.org/show_bug.cgi?id=196488 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/cmake/FindSSE2.cmake: Added. >+ * Source/cmake/WebKitCompilerFlags.cmake: Detect SSE2 support and >+ add SSE2 to the global compiler flags. >+ > 2019-05-03 Basuke Suzuki <Basuke.Suzuki@sony.com> > > [WinCairo] Implement and enable RemoteInspector Server. >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 7d960395584..3ec2de4f8ab 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,15 @@ >+2019-05-03 Xan López <xan@igalia.com> >+ >+ [CMake] Detect SSE2 at compile time >+ https://bugs.webkit.org/show_bug.cgi?id=196488 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * assembler/MacroAssemblerX86Common.cpp: Remove unnecessary (and >+ incorrect) static_assert. >+ (JSC::MacroAssemblerX86Common::collectCPUFeatures): >+ * assembler/MacroAssemblerX86Common.h: Remove SSE2 flags. >+ > 2019-05-04 Tadeu Zagallo <tzagallo@apple.com> > > TypedArrays should not store properties that are canonical numeric indices >diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp >index 31753589df7..8c752c0d030 100644 >--- a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp >+++ b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp >@@ -168,11 +168,6 @@ static_assert(PROBE_OFFSETOF_REG(cpu.fprs, X86Registers::xmm15) == PROBE_CPU_XMM > static_assert(sizeof(Probe::State) == PROBE_SIZE, "Probe::State::size's matches ctiMasmProbeTrampoline"); > static_assert((PROBE_EXECUTOR_OFFSET + PTR_SIZE) <= (PROBE_SIZE + OUT_SIZE), "Must have room after ProbeContext to stash the probe handler"); > >-#if CPU(X86) >-// SSE2 is a hard requirement on x86. >-static_assert(isSSE2Present(), "SSE2 support is required in JavaScriptCore"); >-#endif >- > #undef PROBE_OFFSETOF > > #if CPU(X86) >@@ -792,7 +787,6 @@ void MacroAssemblerX86Common::collectCPUFeatures() > std::call_once(onceKey, [] { > { > CPUID cpuid = getCPUID(0x1); >- s_sse2CheckState = (cpuid[3] & (1 << 26)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear; > s_sse4_1CheckState = (cpuid[2] & (1 << 19)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear; > s_sse4_2CheckState = (cpuid[2] & (1 << 20)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear; > s_popcntCheckState = (cpuid[2] & (1 << 23)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear; >@@ -809,7 +803,6 @@ void MacroAssemblerX86Common::collectCPUFeatures() > }); > } > >-MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse2CheckState = CPUIDCheckState::NotChecked; > MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse4_1CheckState = CPUIDCheckState::NotChecked; > MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse4_2CheckState = CPUIDCheckState::NotChecked; > MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_avxCheckState = CPUIDCheckState::NotChecked; >diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h >index 097bcb0bb86..ff097290ef3 100644 >--- a/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h >+++ b/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h >@@ -4197,41 +4197,11 @@ private: > } > #endif > >-#if CPU(X86) >-#if OS(MAC_OS_X) >- >- // All X86 Macs are guaranteed to support at least SSE2, >- static bool isSSE2Present() >- { >- return true; >- } >- >-#else // OS(MAC_OS_X) >- static bool isSSE2Present() >- { >- if (s_sse2CheckState == CPUIDCheckState::NotChecked) >- collectCPUFeatures(); >- return s_sse2CheckState == CPUIDCheckState::Set; >- } >- >-#endif // OS(MAC_OS_X) >-#elif !defined(NDEBUG) // CPU(X86) >- >- // On x86-64 we should never be checking for SSE2 in a non-debug build, >- // but non debug add this method to keep the asserts above happy. >- static bool isSSE2Present() >- { >- return true; >- } >- >-#endif >- > using CPUID = std::array<unsigned, 4>; > static CPUID getCPUID(unsigned level); > static CPUID getCPUIDEx(unsigned level, unsigned count); > JS_EXPORT_PRIVATE static void collectCPUFeatures(); > >- JS_EXPORT_PRIVATE static CPUIDCheckState s_sse2CheckState; > JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_1CheckState; > JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_2CheckState; > JS_EXPORT_PRIVATE static CPUIDCheckState s_avxCheckState; >diff --git a/Source/cmake/FindSSE2.cmake b/Source/cmake/FindSSE2.cmake >new file mode 100644 >index 00000000000..6af14e5a148 >--- /dev/null >+++ b/Source/cmake/FindSSE2.cmake >@@ -0,0 +1,61 @@ >+################################# >+# Check for the presence of SSE2. >+# >+# Once done, this will define: >+# - SSE2_SUPPORT_FOUND - the system supports (at least) SSE2. >+# >+# Copyright (c) 2014, Pablo Fernandez Alcantarilla, Jesus Nuevo >+# Copyright (c) 2019, Igalia S.L. >+# >+# Redistribution and use in source and binary forms, with or without modification, >+# are permitted provided that the following conditions are met: >+# >+# * Redistributions of source code must retain the above copyright notice, >+# this list of conditions and the following disclaimer. >+# >+# * Redistributions in binary form must reproduce the above copyright notice, >+# this list of conditions and the following disclaimer in the documentation >+# and/or other materials provided with the distribution. >+# >+# * Neither the name of the copyright holders nor the names of its contributors >+# may be used to endorse or promote products derived from this software without >+# specific prior written permission. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY >+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT >+# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, >+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED >+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY >+# WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+set(SSE2_SUPPORT_FOUND FALSE) >+ >+macro(CHECK_FOR_SSE2) >+ include(CheckCXXSourceRuns) >+ >+ check_cxx_source_runs(" >+ #include <emmintrin.h> >+ int main () >+ { >+ __m128d a, b; >+ double vals[2] = {0}; >+ a = _mm_loadu_pd (vals); >+ b = _mm_add_pd (a,a); >+ _mm_storeu_pd (vals,b); >+ return(0); >+ }" >+ HAVE_SSE2_EXTENSIONS) >+ >+ if (COMPILER_IS_GCC_OR_CLANG OR (MSVC AND NOT CMAKE_CL_64)) >+ if (HAVE_SSE2_EXTENSIONS) >+ set(SSE2_SUPPORT_FOUND TRUE) >+ message(STATUS "Found SSE2 extensions.") >+ endif () >+ endif () >+ >+endmacro(CHECK_FOR_SSE2) >+ >+CHECK_FOR_SSE2() >diff --git a/Source/cmake/WebKitCompilerFlags.cmake b/Source/cmake/WebKitCompilerFlags.cmake >index f56a47bbe4b..16b12f07440 100644 >--- a/Source/cmake/WebKitCompilerFlags.cmake >+++ b/Source/cmake/WebKitCompilerFlags.cmake >@@ -144,6 +144,15 @@ if (COMPILER_IS_GCC_OR_CLANG) > if (CMAKE_COMPILER_IS_GNUCXX) > WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-expansion-to-defined) > endif () >+ >+ # Force SSE2 fp on x86 builds. >+ if (WTF_CPU_X86) >+ WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-msse2 -mfpmath=sse) >+ include(FindSSE2) >+ if (NOT SSE2_SUPPORT_FOUND) >+ message(FATAL_ERROR "SSE2 support is required to compile WebKit") >+ endif () >+ endif () > endif () > > if (COMPILER_IS_GCC_OR_CLANG AND NOT MSVC) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 806e0b1b8ca..a0e9846147a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,14 @@ >+2019-05-03 Xan López <xan@igalia.com> >+ >+ [CMake] Detect SSE2 at compile time >+ https://bugs.webkit.org/show_bug.cgi?id=196488 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/webkitdirs.pm: >+ (generateBuildSystemFromCMakeProject): Do not add SSE2 flags here >+ for x86 builds. This is now handled in WebKitCompilerFlags.cmake. >+ > 2019-05-04 Alex Christensen <achristensen@webkit.org> > > Revert r244953 and r244954 because they broke internal builds. >diff --git a/Tools/Scripts/webkitdirs.pm b/Tools/Scripts/webkitdirs.pm >index b1168fe55bf..6f3109827a4 100755 >--- a/Tools/Scripts/webkitdirs.pm >+++ b/Tools/Scripts/webkitdirs.pm >@@ -2218,15 +2218,6 @@ sub generateBuildSystemFromCMakeProject > my $cmakeSourceDir = isCygwin() ? windowsSourceDir() : sourceDir(); > push @args, '"' . $cmakeSourceDir . '"'; > >- # Compiler options to keep floating point values consistent >- # between 32-bit and 64-bit architectures. This makes us use SSE >- # when our architecture is 32-bit ('i686') or when it's not but >- # the user has requested a 32-bit build. >- if ((architecture() eq "i686" || (architecture() eq "x86_64" && shouldBuild32Bit())) && !isCrossCompilation() && !isAnyWindows()) { >- $ENV{'CFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CFLAGS'} || ""); >- $ENV{'CXXFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CXXFLAGS'} || ""); >- } >- > # We call system("cmake @args") instead of system("cmake", @args) so that @args is > # parsed for shell metacharacters. > my $wrapper = join(" ", wrapperPrefixIfNeeded()) . " "; >-- >2.21.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 196488
:
366483
|
366485
|
366492
|
368924
|
368925
|
368926
|
369023
|
369092
|
369093
|
369115
|
369118
|
369473
|
369476
|
369481