Changeset 245127 in webkit


Ignore:
Timestamp:
May 9, 2019 3:43:43 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[CMake] Detect SSE2 at compile time
https://bugs.webkit.org/show_bug.cgi?id=196488

Patch by Xan López <Xan Lopez> on 2019-05-09
Reviewed by Carlos Garcia Campos.

.:

  • Source/cmake/DetectSSE2.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.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r245083 r245127  
     12019-05-09  Xan López  <xan@igalia.com>
     2
     3        [CMake] Detect SSE2 at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=196488
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * Source/cmake/DetectSSE2.cmake: Added.
     9        * Source/cmake/WebKitCompilerFlags.cmake: Detect SSE2 support and
     10        add SSE2 to the global compiler flags.
     11
    1122019-05-08  Don Olmstead  <don.olmstead@sony.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r245093 r245127  
     12019-05-09  Xan López  <xan@igalia.com>
     2
     3        [CMake] Detect SSE2 at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=196488
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * assembler/MacroAssemblerX86Common.cpp: Remove unnecessary (and
     9        incorrect) static_assert.
     10        (JSC::MacroAssemblerX86Common::collectCPUFeatures):
     11        * assembler/MacroAssemblerX86Common.h: Remove SSE2 flags.
     12
    1132019-05-08  Yusuke Suzuki  <ysuzuki@apple.com>
    214
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp

    r244138 r245127  
    168168static_assert(sizeof(Probe::State) == PROBE_SIZE, "Probe::State::size's matches ctiMasmProbeTrampoline");
    169169static_assert((PROBE_EXECUTOR_OFFSET + PTR_SIZE) <= (PROBE_SIZE + OUT_SIZE), "Must have room after ProbeContext to stash the probe handler");
    170 
    171 #if CPU(X86)
    172 // SSE2 is a hard requirement on x86.
    173 static_assert(isSSE2Present(), "SSE2 support is required in JavaScriptCore");
    174 #endif
    175170
    176171#undef PROBE_OFFSETOF
     
    793788        {
    794789            CPUID cpuid = getCPUID(0x1);
    795             s_sse2CheckState = (cpuid[3] & (1 << 26)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear;
    796790            s_sse4_1CheckState = (cpuid[2] & (1 << 19)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear;
    797791            s_sse4_2CheckState = (cpuid[2] & (1 << 20)) ? CPUIDCheckState::Set : CPUIDCheckState::Clear;
     
    810804}
    811805
    812 MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse2CheckState = CPUIDCheckState::NotChecked;
    813806MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse4_1CheckState = CPUIDCheckState::NotChecked;
    814807MacroAssemblerX86Common::CPUIDCheckState MacroAssemblerX86Common::s_sse4_2CheckState = CPUIDCheckState::NotChecked;
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r244138 r245127  
    41984198#endif
    41994199
    4200 #if CPU(X86)
    4201 #if OS(MAC_OS_X)
    4202 
    4203     // All X86 Macs are guaranteed to support at least SSE2,
    4204     static bool isSSE2Present()
    4205     {
    4206         return true;
    4207     }
    4208 
    4209 #else // OS(MAC_OS_X)
    4210     static bool isSSE2Present()
    4211     {
    4212         if (s_sse2CheckState == CPUIDCheckState::NotChecked)
    4213             collectCPUFeatures();
    4214         return s_sse2CheckState == CPUIDCheckState::Set;
    4215     }
    4216 
    4217 #endif // OS(MAC_OS_X)
    4218 #elif !defined(NDEBUG) // CPU(X86)
    4219 
    4220     // On x86-64 we should never be checking for SSE2 in a non-debug build,
    4221     // but non debug add this method to keep the asserts above happy.
    4222     static bool isSSE2Present()
    4223     {
    4224         return true;
    4225     }
    4226 
    4227 #endif
    4228 
    42294200    using CPUID = std::array<unsigned, 4>;
    42304201    static CPUID getCPUID(unsigned level);
     
    42324203    JS_EXPORT_PRIVATE static void collectCPUFeatures();
    42334204
    4234     JS_EXPORT_PRIVATE static CPUIDCheckState s_sse2CheckState;
    42354205    JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_1CheckState;
    42364206    JS_EXPORT_PRIVATE static CPUIDCheckState s_sse4_2CheckState;
  • trunk/Source/cmake/WebKitCompilerFlags.cmake

    r244895 r245127  
    144144    if (CMAKE_COMPILER_IS_GNUCXX)
    145145        WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-expansion-to-defined)
     146    endif ()
     147
     148    # Force SSE2 fp on x86 builds.
     149    if (WTF_CPU_X86 AND NOT CMAKE_CROSSCOMPILING)
     150        WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-msse2 -mfpmath=sse)
     151        include(DetectSSE2)
     152        if (NOT SSE2_SUPPORT_FOUND)
     153            message(FATAL_ERROR "SSE2 support is required to compile WebKit")
     154        endif ()
    146155    endif ()
    147156endif ()
  • trunk/Tools/ChangeLog

    r245095 r245127  
     12019-05-09  Xan López  <xan@igalia.com>
     2
     3        [CMake] Detect SSE2 at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=196488
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * Scripts/webkitdirs.pm:
     9        (generateBuildSystemFromCMakeProject): Do not add SSE2 flags here
     10        for x86 builds. This is now handled in WebKitCompilerFlags.cmake.
     11
    1122019-05-08  Adrian Perez de Castro  <aperez@igalia.com>
    213
  • trunk/Tools/Scripts/webkitdirs.pm

    r245087 r245127  
    22272227    push @args, '"' . $cmakeSourceDir . '"';
    22282228
    2229     # Compiler options to keep floating point values consistent
    2230     # between 32-bit and 64-bit architectures. This makes us use SSE
    2231     # when our architecture is 32-bit ('i686') or when it's not but
    2232     # the user has requested a 32-bit build.
    2233     if ((architecture() eq "i686" || (architecture() eq "x86_64" && shouldBuild32Bit())) && !isCrossCompilation() && !isAnyWindows()) {
    2234         $ENV{'CFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CFLAGS'} || "");
    2235         $ENV{'CXXFLAGS'} = "-march=pentium4 -msse2 -mfpmath=sse " . ($ENV{'CXXFLAGS'} || "");
    2236     }
    2237 
    22382229    # We call system("cmake @args") instead of system("cmake", @args) so that @args is
    22392230    # parsed for shell metacharacters.
Note: See TracChangeset for help on using the changeset viewer.