[JSC][x86] Drop support for x87 floating point
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 16:29:32 +0000 (16:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 16:29:32 +0000 (16:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194853

Patch by Xan Lopez <xan@igalia.com> on 2019-03-21
Reviewed by Don Olmstead.

Source/JavaScriptCore:

Require SSE2 throughout the codebase, and remove x87 support where
it was optionally available. SSE2 detection happens at compile
time through a static_assert.

* assembler/MacroAssemblerX86.h:
(JSC::MacroAssemblerX86::storeDouble):
(JSC::MacroAssemblerX86::moveDoubleToInts):
(JSC::MacroAssemblerX86::supportsFloatingPoint):
(JSC::MacroAssemblerX86::supportsFloatingPointTruncate):
(JSC::MacroAssemblerX86::supportsFloatingPointSqrt):
(JSC::MacroAssemblerX86::supportsFloatingPointAbs):
* assembler/MacroAssemblerX86Common.cpp:
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::moveDouble):
(JSC::MacroAssemblerX86Common::loadDouble):
(JSC::MacroAssemblerX86Common::loadFloat):
(JSC::MacroAssemblerX86Common::storeDouble):
(JSC::MacroAssemblerX86Common::storeFloat):
(JSC::MacroAssemblerX86Common::convertDoubleToFloat):
(JSC::MacroAssemblerX86Common::convertFloatToDouble):
(JSC::MacroAssemblerX86Common::addDouble):
(JSC::MacroAssemblerX86Common::addFloat):
(JSC::MacroAssemblerX86Common::divDouble):
(JSC::MacroAssemblerX86Common::divFloat):
(JSC::MacroAssemblerX86Common::subDouble):
(JSC::MacroAssemblerX86Common::subFloat):
(JSC::MacroAssemblerX86Common::mulDouble):
(JSC::MacroAssemblerX86Common::mulFloat):
(JSC::MacroAssemblerX86Common::convertInt32ToDouble):
(JSC::MacroAssemblerX86Common::convertInt32ToFloat):
(JSC::MacroAssemblerX86Common::branchDouble):
(JSC::MacroAssemblerX86Common::branchFloat):
(JSC::MacroAssemblerX86Common::compareDouble):
(JSC::MacroAssemblerX86Common::compareFloat):
(JSC::MacroAssemblerX86Common::branchTruncateDoubleToInt32):
(JSC::MacroAssemblerX86Common::truncateDoubleToInt32):
(JSC::MacroAssemblerX86Common::truncateFloatToInt32):
(JSC::MacroAssemblerX86Common::branchConvertDoubleToInt32):
(JSC::MacroAssemblerX86Common::branchDoubleNonZero):
(JSC::MacroAssemblerX86Common::branchDoubleZeroOrNaN):
(JSC::MacroAssemblerX86Common::lshiftPacked):
(JSC::MacroAssemblerX86Common::rshiftPacked):
(JSC::MacroAssemblerX86Common::orPacked):
(JSC::MacroAssemblerX86Common::move32ToFloat):
(JSC::MacroAssemblerX86Common::moveFloatTo32):
(JSC::MacroAssemblerX86Common::moveConditionallyDouble):
(JSC::MacroAssemblerX86Common::moveConditionallyFloat):
* offlineasm/x86.rb:
* runtime/MathCommon.cpp:
(JSC::operationMathPow):

Tools:

Force SSE2 on x86/32bit builds.

* Scripts/webkitdirs.pm:
(generateBuildSystemFromCMakeProject):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243293 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssemblerX86.h
Source/JavaScriptCore/assembler/MacroAssemblerX86Common.cpp
Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h
Source/JavaScriptCore/offlineasm/x86.rb
Source/JavaScriptCore/runtime/MathCommon.cpp
Tools/ChangeLog
Tools/Scripts/webkitdirs.pm

index 1be5bcc..834b4be 100644 (file)
@@ -1,3 +1,61 @@
+2019-03-21  Xan Lopez  <xan@igalia.com>
+
+        [JSC][x86] Drop support for x87 floating point
+        https://bugs.webkit.org/show_bug.cgi?id=194853
+
+        Reviewed by Don Olmstead.
+
+        Require SSE2 throughout the codebase, and remove x87 support where
+        it was optionally available. SSE2 detection happens at compile
+        time through a static_assert.
+
+        * assembler/MacroAssemblerX86.h:
+        (JSC::MacroAssemblerX86::storeDouble):
+        (JSC::MacroAssemblerX86::moveDoubleToInts):
+        (JSC::MacroAssemblerX86::supportsFloatingPoint):
+        (JSC::MacroAssemblerX86::supportsFloatingPointTruncate):
+        (JSC::MacroAssemblerX86::supportsFloatingPointSqrt):
+        (JSC::MacroAssemblerX86::supportsFloatingPointAbs):
+        * assembler/MacroAssemblerX86Common.cpp:
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::moveDouble):
+        (JSC::MacroAssemblerX86Common::loadDouble):
+        (JSC::MacroAssemblerX86Common::loadFloat):
+        (JSC::MacroAssemblerX86Common::storeDouble):
+        (JSC::MacroAssemblerX86Common::storeFloat):
+        (JSC::MacroAssemblerX86Common::convertDoubleToFloat):
+        (JSC::MacroAssemblerX86Common::convertFloatToDouble):
+        (JSC::MacroAssemblerX86Common::addDouble):
+        (JSC::MacroAssemblerX86Common::addFloat):
+        (JSC::MacroAssemblerX86Common::divDouble):
+        (JSC::MacroAssemblerX86Common::divFloat):
+        (JSC::MacroAssemblerX86Common::subDouble):
+        (JSC::MacroAssemblerX86Common::subFloat):
+        (JSC::MacroAssemblerX86Common::mulDouble):
+        (JSC::MacroAssemblerX86Common::mulFloat):
+        (JSC::MacroAssemblerX86Common::convertInt32ToDouble):
+        (JSC::MacroAssemblerX86Common::convertInt32ToFloat):
+        (JSC::MacroAssemblerX86Common::branchDouble):
+        (JSC::MacroAssemblerX86Common::branchFloat):
+        (JSC::MacroAssemblerX86Common::compareDouble):
+        (JSC::MacroAssemblerX86Common::compareFloat):
+        (JSC::MacroAssemblerX86Common::branchTruncateDoubleToInt32):
+        (JSC::MacroAssemblerX86Common::truncateDoubleToInt32):
+        (JSC::MacroAssemblerX86Common::truncateFloatToInt32):
+        (JSC::MacroAssemblerX86Common::branchConvertDoubleToInt32):
+        (JSC::MacroAssemblerX86Common::branchDoubleNonZero):
+        (JSC::MacroAssemblerX86Common::branchDoubleZeroOrNaN):
+        (JSC::MacroAssemblerX86Common::lshiftPacked):
+        (JSC::MacroAssemblerX86Common::rshiftPacked):
+        (JSC::MacroAssemblerX86Common::orPacked):
+        (JSC::MacroAssemblerX86Common::move32ToFloat):
+        (JSC::MacroAssemblerX86Common::moveFloatTo32):
+        (JSC::MacroAssemblerX86Common::moveConditionallyDouble):
+        (JSC::MacroAssemblerX86Common::moveConditionallyFloat):
+        * offlineasm/x86.rb:
+        * runtime/MathCommon.cpp:
+        (JSC::operationMathPow):
+
 2019-03-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GLIB] User data not correctly passed to callback of functions and constructors with no parameters
index 72def72..e4baced 100644 (file)
@@ -140,7 +140,6 @@ public:
 
     void storeDouble(FPRegisterID src, TrustedImmPtr address)
     {
-        ASSERT(isSSE2Present());
         ASSERT(address.m_value);
         m_assembler.movsd_rm(src, address.asPtr());
     }
@@ -173,7 +172,6 @@ public:
     
     void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2)
     {
-        ASSERT(isSSE2Present());
         m_assembler.pextrw_irr(3, src, dest1);
         m_assembler.pextrw_irr(2, src, dest2);
         lshift32(TrustedImm32(16), dest1);
@@ -294,10 +292,10 @@ public:
         return DataLabelPtr(this);
     }
 
-    static bool supportsFloatingPoint() { return isSSE2Present(); }
-    static bool supportsFloatingPointTruncate() { return isSSE2Present(); }
-    static bool supportsFloatingPointSqrt() { return isSSE2Present(); }
-    static bool supportsFloatingPointAbs() { return isSSE2Present(); }
+    static bool supportsFloatingPoint() { return true; }
+    static bool supportsFloatingPointTruncate() { return true; }
+    static bool supportsFloatingPointSqrt() { return true; }
+    static bool supportsFloatingPointAbs() { return true; }
 
     template<PtrTag resultTag, PtrTag locationTag>
     static FunctionPtr<resultTag> readCallTarget(CodeLocationCall<locationTag> call)
index 8b148cf..3175358 100644 (file)
@@ -168,6 +168,11 @@ 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)
index 8fe9ea7..097bcb0 100644 (file)
@@ -1451,11 +1451,8 @@ public:
 
     // Floating-point operation:
     //
-    // Presently only supports SSE, not x87 floating point.
-
     void moveDouble(FPRegisterID src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         if (src != dest)
             m_assembler.movaps_rr(src, dest);
     }
@@ -1463,7 +1460,6 @@ public:
     void loadDouble(TrustedImmPtr address, FPRegisterID dest)
     {
 #if CPU(X86)
-        ASSERT(isSSE2Present());
         m_assembler.movsd_mr(address.asPtr(), dest);
 #else
         move(address, scratchRegister());
@@ -1473,20 +1469,17 @@ public:
 
     void loadDouble(ImplicitAddress address, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movsd_mr(address.offset, address.base, dest);
     }
 
     void loadDouble(BaseIndex address, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movsd_mr(address.offset, address.base, address.index, address.scale, dest);
     }
 
     void loadFloat(TrustedImmPtr address, FPRegisterID dest)
     {
 #if CPU(X86)
-        ASSERT(isSSE2Present());
         m_assembler.movss_mr(address.asPtr(), dest);
 #else
         move(address, scratchRegister());
@@ -1496,61 +1489,51 @@ public:
 
     void loadFloat(ImplicitAddress address, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movss_mr(address.offset, address.base, dest);
     }
 
     void loadFloat(BaseIndex address, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movss_mr(address.offset, address.base, address.index, address.scale, dest);
     }
 
     void storeDouble(FPRegisterID src, ImplicitAddress address)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movsd_rm(src, address.offset, address.base);
     }
     
     void storeDouble(FPRegisterID src, BaseIndex address)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movsd_rm(src, address.offset, address.base, address.index, address.scale);
     }
 
     void storeFloat(FPRegisterID src, ImplicitAddress address)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movss_rm(src, address.offset, address.base);
     }
 
     void storeFloat(FPRegisterID src, BaseIndex address)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movss_rm(src, address.offset, address.base, address.index, address.scale);
     }
     
     void convertDoubleToFloat(FPRegisterID src, FPRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsd2ss_rr(src, dst);
     }
 
     void convertDoubleToFloat(Address address, FPRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsd2ss_mr(address.offset, address.base, dst);
     }
 
     void convertFloatToDouble(FPRegisterID src, FPRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtss2sd_rr(src, dst);
     }
 
     void convertFloatToDouble(Address address, FPRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtss2sd_mr(address.offset, address.base, dst);
     }
 
@@ -1564,7 +1547,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddsd_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op1 == dest)
                 m_assembler.addsd_rr(op2, dest);
             else {
@@ -1584,7 +1566,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddsd_mr(op1.offset, op1.base, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.addsd_mr(op1.offset, op1.base, dest);
                 return;
@@ -1605,7 +1586,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddsd_mr(op1.offset, op1.base, op1.index, op1.scale, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.addsd_mr(op1.offset, op1.base, op1.index, op1.scale, dest);
                 return;
@@ -1630,7 +1610,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddss_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op1 == dest)
                 m_assembler.addss_rr(op2, dest);
             else {
@@ -1645,7 +1624,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddss_mr(op1.offset, op1.base, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.addss_mr(op1.offset, op1.base, dest);
                 return;
@@ -1666,7 +1644,6 @@ public:
         if (supportsAVX())
             m_assembler.vaddss_mr(op1.offset, op1.base, op1.index, op1.scale, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.addss_mr(op1.offset, op1.base, op1.index, op1.scale, dest);
                 return;
@@ -1678,7 +1655,6 @@ public:
 
     void divDouble(FPRegisterID src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.divsd_rr(src, dest);
     }
 
@@ -1693,19 +1669,16 @@ public:
 
     void divDouble(Address src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.divsd_mr(src.offset, src.base, dest);
     }
 
     void divFloat(FPRegisterID src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.divss_rr(src, dest);
     }
 
     void divFloat(Address src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.divss_mr(src.offset, src.base, dest);
     }
 
@@ -1719,8 +1692,6 @@ public:
         if (supportsAVX())
             m_assembler.vsubsd_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
-
             // B := A - B is invalid.
             ASSERT(op1 == dest || op2 != dest);
             moveDouble(op1, dest);
@@ -1763,7 +1734,6 @@ public:
         if (supportsAVX())
             m_assembler.vsubss_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             // B := A - B is invalid.
             ASSERT(op1 == dest || op2 != dest);
             moveDouble(op1, dest);
@@ -1806,7 +1776,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulsd_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op1 == dest)
                 m_assembler.mulsd_rr(op2, dest);
             else {
@@ -1826,7 +1795,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulsd_mr(op1.offset, op1.base, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.mulsd_mr(op1.offset, op1.base, dest);
                 return;
@@ -1846,7 +1814,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulsd_mr(op1.offset, op1.base, op1.index, op1.scale, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.mulsd_mr(op1.offset, op1.base, op1.index, op1.scale, dest);
                 return;
@@ -1871,7 +1838,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulss_rr(op1, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op1 == dest)
                 m_assembler.mulss_rr(op2, dest);
             else {
@@ -1886,7 +1852,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulss_mr(op1.offset, op1.base, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.mulss_mr(op1.offset, op1.base, dest);
                 return;
@@ -1906,7 +1871,6 @@ public:
         if (supportsAVX())
             m_assembler.vmulss_mr(op1.offset, op1.base, op1.index, op1.scale, op2, dest);
         else {
-            ASSERT(isSSE2Present());
             if (op2 == dest) {
                 m_assembler.mulss_mr(op1.offset, op1.base, op1.index, op1.scale, dest);
                 return;
@@ -2009,32 +1973,26 @@ public:
 
     void convertInt32ToDouble(RegisterID src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsi2sd_rr(src, dest);
     }
 
     void convertInt32ToDouble(Address src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsi2sd_mr(src.offset, src.base, dest);
     }
 
     void convertInt32ToFloat(RegisterID src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsi2ss_rr(src, dest);
     }
 
     void convertInt32ToFloat(Address src, FPRegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvtsi2ss_mr(src.offset, src.base, dest);
     }
 
     Jump branchDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right)
     {
-        ASSERT(isSSE2Present());
-
         if (cond & DoubleConditionBitInvert)
             m_assembler.ucomisd_rr(left, right);
         else
@@ -2044,8 +2002,6 @@ public:
 
     Jump branchFloat(DoubleCondition cond, FPRegisterID left, FPRegisterID right)
     {
-        ASSERT(isSSE2Present());
-
         if (cond & DoubleConditionBitInvert)
             m_assembler.ucomiss_rr(left, right);
         else
@@ -2055,7 +2011,6 @@ public:
 
     void compareDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
         floatingPointCompare(cond, left, right, dest, [this] (FPRegisterID arg1, FPRegisterID arg2) {
             m_assembler.ucomisd_rr(arg1, arg2);
         });
@@ -2063,7 +2018,6 @@ public:
 
     void compareFloat(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
         floatingPointCompare(cond, left, right, dest, [this] (FPRegisterID arg1, FPRegisterID arg2) {
             m_assembler.ucomiss_rr(arg1, arg2);
         });
@@ -2076,20 +2030,17 @@ public:
     enum BranchTruncateType { BranchIfTruncateFailed, BranchIfTruncateSuccessful };
     Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvttsd2si_rr(src, dest);
         return branch32(branchType ? NotEqual : Equal, dest, TrustedImm32(0x80000000));
     }
 
     void truncateDoubleToInt32(FPRegisterID src, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvttsd2si_rr(src, dest);
     }
 
     void truncateFloatToInt32(FPRegisterID src, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvttss2si_rr(src, dest);
     }
 
@@ -2099,7 +2050,6 @@ public:
     // (specifically, in this case, 0).
     void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID fpTemp, bool negZeroCheck = true)
     {
-        ASSERT(isSSE2Present());
         m_assembler.cvttsd2si_rr(src, dest);
 
         // If the result is zero, it might have been -0.0, and the double comparison won't catch this!
@@ -2129,45 +2079,38 @@ public:
 
     Jump branchDoubleNonZero(FPRegisterID reg, FPRegisterID scratch)
     {
-        ASSERT(isSSE2Present());
         m_assembler.xorpd_rr(scratch, scratch);
         return branchDouble(DoubleNotEqual, reg, scratch);
     }
 
     Jump branchDoubleZeroOrNaN(FPRegisterID reg, FPRegisterID scratch)
     {
-        ASSERT(isSSE2Present());
         m_assembler.xorpd_rr(scratch, scratch);
         return branchDouble(DoubleEqualOrUnordered, reg, scratch);
     }
 
     void lshiftPacked(TrustedImm32 imm, XMMRegisterID reg)
     {
-        ASSERT(isSSE2Present());
         m_assembler.psllq_i8r(imm.m_value, reg);
     }
 
     void rshiftPacked(TrustedImm32 imm, XMMRegisterID reg)
     {
-        ASSERT(isSSE2Present());
         m_assembler.psrlq_i8r(imm.m_value, reg);
     }
 
     void orPacked(XMMRegisterID src, XMMRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.por_rr(src, dst);
     }
 
     void move32ToFloat(RegisterID src, XMMRegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movd_rr(src, dst);
     }
 
     void moveFloatTo32(XMMRegisterID src, RegisterID dst)
     {
-        ASSERT(isSSE2Present());
         m_assembler.movd_rr(src, dst);
     }
 
@@ -2252,8 +2195,6 @@ public:
 
     void moveConditionallyDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID src, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
-
         if (cond & DoubleConditionBitInvert)
             m_assembler.ucomisd_rr(left, right);
         else
@@ -2263,8 +2204,6 @@ public:
 
     void moveConditionallyDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID thenCase, RegisterID elseCase, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
-
         if (thenCase != dest && elseCase != dest) {
             move(elseCase, dest);
             elseCase = dest;
@@ -2287,8 +2226,6 @@ public:
 
     void moveConditionallyFloat(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID src, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
-
         if (cond & DoubleConditionBitInvert)
             m_assembler.ucomiss_rr(left, right);
         else
@@ -2298,8 +2235,6 @@ public:
 
     void moveConditionallyFloat(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID thenCase, RegisterID elseCase, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
-
         if (thenCase != dest && elseCase != dest) {
             move(elseCase, dest);
             elseCase = dest;
@@ -2384,8 +2319,6 @@ public:
 
     void moveConditionallyDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID src, RegisterID dest)
     {
-        ASSERT(isSSE2Present());
-
         if (cond & DoubleConditionBitInvert)
             m_assembler.ucomisd_rr(left, right);
         else
index 62aa35a..7969964 100644 (file)
@@ -110,21 +110,6 @@ def isWin
     end
 end
 
-def useX87
-    case $activeBackend
-    when "X86"
-        true
-    when "X86_WIN"
-        true
-    when "X86_64"
-        false
-    when "X86_64_WIN"
-        false
-    else
-        raise "bad value for $activeBackend: #{$activeBackend}"
-    end
-end
-
 def isMSVC
     $options.has_key?(:assembler) && $options[:assembler] == "MASM"
 end
@@ -341,7 +326,6 @@ end
 class FPRegisterID
     def x86Operand(kind)
         raise unless kind == :double
-        raise if useX87
         case name
         when "ft0", "fa0", "fr"
             register("xmm0")
@@ -359,23 +343,6 @@ class FPRegisterID
             raise "Bad register #{name} for X86 at #{codeOriginString}"
         end
     end
-    def x87DefaultStackPosition
-        case name
-        when "ft0", "fr"
-            0
-        when "ft1"
-            1
-        when "ft2", "ft3", "ft4", "ft5"
-            raise "Unimplemented register #{name} for X86 at #{codeOriginString}"
-        else
-            raise "Bad register #{name} for X86 at #{codeOriginString}"
-        end
-    end
-    def x87Operand(offset)
-        raise unless useX87
-        raise unless offset == 0 or offset == 1
-        "#{register("st")}(#{x87DefaultStackPosition + offset})"
-    end
     def x86CallOperand(kind)
         "#{callPrefix}#{x86Operand(kind)}"
     end
@@ -561,7 +528,7 @@ class Instruction
         when :quad
             isX64 ? "q" : raise
         when :double
-            not useX87 ? "sd" : raise
+            "sd"
         else
             raise
         end
@@ -633,17 +600,13 @@ class Instruction
     end
     
     def handleX86DoubleBranch(branchOpcode, mode)
-        if useX87
-            handleX87Compare(mode)
+        case mode
+        when :normal
+            $asm.puts "ucomisd #{orderOperands(operands[1].x86Operand(:double), operands[0].x86Operand(:double))}"
+        when :reverse
+            $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
         else
-            case mode
-            when :normal
-                $asm.puts "ucomisd #{orderOperands(operands[1].x86Operand(:double), operands[0].x86Operand(:double))}"
-            when :reverse
-                $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
-            else
-                raise mode.inspect
-            end
+            raise mode.inspect
         end
         $asm.puts "#{branchOpcode} #{operands[2].asmLabel}"
     end
@@ -861,43 +824,6 @@ class Instruction
         end
     end
 
-    def handleX87Compare(mode)
-        floatingPointCompareImplicitOperand = getImplicitOperandString
-        case mode
-        when :normal
-            if (operands[0].x87DefaultStackPosition == 0)
-                $asm.puts "fucomi #{floatingPointCompareImplicitOperand}#{operands[1].x87Operand(0)}"
-            else
-                $asm.puts "fld #{operands[0].x87Operand(0)}"
-                $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[1].x87Operand(1)}"
-            end
-        when :reverse
-            if (operands[1].x87DefaultStackPosition == 0)
-                $asm.puts "fucomi #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(0)}"
-            else
-                $asm.puts "fld #{operands[1].x87Operand(0)}"
-                $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
-            end
-        else
-            raise mode.inspect
-        end
-    end
-
-    def handleX87BinOp(opcode, opcodereverse)
-        if (operands[1].x87DefaultStackPosition == 0)
-            $asm.puts "#{opcode} #{orderOperands(operands[0].x87Operand(0), register("st"))}"
-        elsif (operands[0].x87DefaultStackPosition == 0)
-            if !isIntelSyntax
-                $asm.puts "#{opcodereverse} #{register("st")}, #{operands[1].x87Operand(0)}"
-            else
-                $asm.puts "#{opcode} #{operands[1].x87Operand(0)}, #{register("st")}"
-            end
-        else
-            $asm.puts "fld #{operands[0].x87Operand(0)}"
-            $asm.puts "#{opcodereverse}p #{orderOperands(register("st"), operands[1].x87Operand(1))}"
-        end
-    end
-
     def lowerX86
         raise unless $activeBackend == "X86"
         lowerX86Common
@@ -1039,89 +965,25 @@ class Instruction
         when "storeb"
             $asm.puts "mov#{x86Suffix(:byte)} #{x86Operands(:byte, :byte)}"
         when "loadd"
-            if useX87
-                if !isIntelSyntax
-                    $asm.puts "fldl #{operands[0].x86Operand(:double)}"
-                else
-                    $asm.puts "fld #{operands[0].x86Operand(:double)}"
-                end
-                $asm.puts "fstp #{operands[1].x87Operand(1)}"
-            else
-                $asm.puts "movsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "movsd #{x86Operands(:double, :double)}"
         when "moved"
-            if useX87
-                if (operands[0].x87DefaultStackPosition == 0)
-                    $asm.puts "fst #{operands[1].x87Operand(0)}"
-                else
-                    $asm.puts "fld #{operands[0].x87Operand(0)}"
-                    $asm.puts "fstp #{operands[1].x87Operand(1)}"
-                end
-            else
-                $asm.puts "movsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "movsd #{x86Operands(:double, :double)}"
         when "stored"
-            if useX87
-                if (operands[0].x87DefaultStackPosition == 0)
-                    $asm.puts "fst#{x86Suffix(:int)} #{operands[1].x86Operand(:double)}"
-                else
-                    $asm.puts "fld #{operands[0].x87Operand(0)}"
-                    if !isIntelSyntax
-                        $asm.puts "fstpl #{operands[1].x86Operand(:double)}"
-                    else
-                        $asm.puts "fstp #{operands[1].x86Operand(:double)}"
-                    end
-                end
-            else
-                $asm.puts "movsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "movsd #{x86Operands(:double, :double)}"
         when "addd"
-            if useX87
-                handleX87BinOp("fadd", "fadd")
-            else
-                $asm.puts "addsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "addsd #{x86Operands(:double, :double)}"
         when "muld"
-            if useX87
-                handleX87BinOp("fmul", "fmul")
-            else
-                $asm.puts "mulsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "mulsd #{x86Operands(:double, :double)}"
         when "subd"
-            if useX87
-                handleX87BinOp("fsub", "fsubr")
-            else
-                $asm.puts "subsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "subsd #{x86Operands(:double, :double)}"
         when "divd"
-            if useX87
-                handleX87BinOp("fdiv", "fdivr")
-            else
-                $asm.puts "divsd #{x86Operands(:double, :double)}"
-            end
+            $asm.puts "divsd #{x86Operands(:double, :double)}"
         when "sqrtd"
-            if useX87
-                $asm.puts "fld #{operands[0].x87Operand(0)}"
-                $asm.puts "fsqrtl"
-                $asm.puts "fstp #{operands[1].x87Operand(1)}"
-            else
-                $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
-            end
+            $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
         when "ci2d"
-            if useX87
-                sp = RegisterID.new(nil, "sp")
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(operands[0].x86Operand(:int), offsetRegister(-4, sp.x86Operand(:ptr)))}"
-                $asm.puts "fild#{x86Suffix(:ptr)} #{getSizeString(:ptr)}#{offsetRegister(-4, sp.x86Operand(:ptr))}"
-                $asm.puts "fstp #{operands[1].x87Operand(1)}"
-            else
-                $asm.puts "cvtsi2sd #{orderOperands(operands[0].x86Operand(:int), operands[1].x86Operand(:double))}"
-            end
+            $asm.puts "cvtsi2sd #{orderOperands(operands[0].x86Operand(:int), operands[1].x86Operand(:double))}"
         when "bdeq"
-            if useX87
-                handleX87Compare(:normal)
-            else
-                $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
-            end
+            $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
             if operands[0] == operands[1]
                 # This is just a jump ordered, which is a jnp.
                 $asm.puts "jnp #{operands[2].asmLabel}"
@@ -1144,11 +1006,7 @@ class Instruction
         when "bdequn"
             handleX86DoubleBranch("je", :normal)
         when "bdnequn"
-            if useX87
-                handleX87Compare(:normal)
-            else
-                $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
-            end
+            $asm.puts "ucomisd #{orderOperands(operands[0].x86Operand(:double), operands[1].x86Operand(:double))}"
             if operands[0] == operands[1]
                 # This is just a jump unordered, which is a jp.
                 $asm.puts "jp #{operands[2].asmLabel}"
@@ -1170,48 +1028,21 @@ class Instruction
         when "bdltequn"
             handleX86DoubleBranch("jbe", :normal)
         when "btd2i"
-            # FIXME: unused and unimplemented for x87
-            raise if useX87
             $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
             $asm.puts "cmpl $0x80000000 #{operands[1].x86Operand(:int)}"
             $asm.puts "je #{operands[2].asmLabel}"
         when "td2i"
-            # FIXME: unused and unimplemented for x87
-            raise if useX87
             $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
         when "bcd2i"
-            if useX87
-                floatingPointCompareImplicitOperand = getImplicitOperandString
-                sp = RegisterID.new(nil, "sp")
-                if (operands[0].x87DefaultStackPosition == 0)
-                    $asm.puts "fistl -4(#{sp.x86Operand(:ptr)})"
-                else
-                    $asm.puts "fld #{operands[0].x87Operand(0)}"
-                    $asm.puts "fistp#{x86Suffix(:ptr)} #{getSizeString(:ptr)}#{offsetRegister(-4, sp.x86Operand(:ptr))}"
-                end
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(offsetRegister(-4, sp.x86Operand(:ptr)), operands[1].x86Operand(:int))}"
-                $asm.puts "test#{x86Suffix(:int)} #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
-                $asm.puts "je #{operands[2].asmLabel}"
-                $asm.puts "fild#{x86Suffix(:int)} #{getSizeString(:int)}#{offsetRegister(-4, sp.x86Operand(:ptr))}"
-                $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
-                $asm.puts "jp #{operands[2].asmLabel}"
-                $asm.puts "jne #{operands[2].asmLabel}"
-            else
-                $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
-                $asm.puts "test#{x86Suffix(:int)} #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
-                $asm.puts "je #{operands[2].asmLabel}"
-                $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7"
-                $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7"
-                $asm.puts "jp #{operands[2].asmLabel}"
-                $asm.puts "jne #{operands[2].asmLabel}"
-            end
+            $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
+            $asm.puts "test#{x86Suffix(:int)} #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
+            $asm.puts "je #{operands[2].asmLabel}"
+            $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7"
+            $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7"
+            $asm.puts "jp #{operands[2].asmLabel}"
+            $asm.puts "jne #{operands[2].asmLabel}"
         when "movdz"
-            if useX87
-                $asm.puts "fldzl"
-                $asm.puts "fstp #{operands[0].x87Operand(1)}"
-            else
-                $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
-            end
+            $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
         when "pop"
             operands.each {
                 | op |
@@ -1391,12 +1222,6 @@ class Instruction
         when "break"
             $asm.puts "int #{const(3)}"
         when "call"
-            if useX87
-                2.times {
-                    | offset |
-                    $asm.puts "ffree #{register("st")}(#{offset})"
-                }
-            end
             op = operands[0].x86CallOperand(:ptr)
             if operands[0].is_a? LabelReference
                 operands[0].used
@@ -1517,68 +1342,30 @@ class Instruction
         when "idivi"
             $asm.puts "idiv#{x86Suffix(:int)} #{operands[0].x86Operand(:int)}"
         when "fii2d"
-            if useX87
-                sp = RegisterID.new(nil, "sp")
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(operands[0].x86Operand(:int), offsetRegister(-8, sp.x86Operand(:ptr)))}"
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(operands[1].x86Operand(:int), offsetRegister(-4, sp.x86Operand(:ptr)))}"
-                $asm.puts "fld#{x86Suffix(:ptr)} #{getSizeString(:double)}#{offsetRegister(-8, sp.x86Operand(:ptr))}"
-                $asm.puts "fstp #{operands[2].x87Operand(1)}"
-            else
-                $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}"
-                $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7"
-                $asm.puts "psllq $32, %xmm7"
-                $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}"
-            end
+            $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}"
+            $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7"
+            $asm.puts "psllq $32, %xmm7"
+            $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}"
         when "fd2ii"
-            if useX87
-                sp = RegisterID.new(nil, "sp")
-                if (operands[0].x87DefaultStackPosition == 0)
-                    $asm.puts "fst#{x86Suffix(:ptr)} #{getSizeString(:double)}#{offsetRegister(-8, sp.x86Operand(:ptr))}"
-                else
-                    $asm.puts "fld #{operands[0].x87Operand(0)}"
-                    $asm.puts "fstpl -8(#{sp.x86Operand(:ptr)})"
-                end
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(offsetRegister(-8, sp.x86Operand(:ptr)), operands[1].x86Operand(:int))}"
-                $asm.puts "mov#{x86Suffix(:int)} #{orderOperands(offsetRegister(-4, sp.x86Operand(:ptr)), operands[2].x86Operand(:int))}"
-            else
-                $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
-                $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7"
-                $asm.puts "psrlq $32, %xmm7"
-                $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}"
-            end
+            $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
+            $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7"
+            $asm.puts "psrlq $32, %xmm7"
+            $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}"
         when "fq2d"
-            if useX87
-                sp = RegisterID.new(nil, "sp")
-                $asm.puts "movq #{operands[0].x86Operand(:quad)}, -8(#{sp.x86Operand(:ptr)})"
-                $asm.puts "fldl -8(#{sp.x86Operand(:ptr)})"
-                $asm.puts "fstp #{operands[1].x87Operand(1)}"
+            if !isIntelSyntax
+                $asm.puts "movq #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}"
             else
-                if !isIntelSyntax
-                    $asm.puts "movq #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}"
-                else
-                    # MASM does not accept register operands with movq.
-                    # Debugging shows that movd actually moves a qword when using MASM.
-                    $asm.puts "movd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:quad)}"
-                end
+                # MASM does not accept register operands with movq.
+                # Debugging shows that movd actually moves a qword when using MASM.
+                $asm.puts "movd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:quad)}"
             end
         when "fd2q"
-            if useX87
-                sp = RegisterID.new(nil, "sp")
-                if (operands[0].x87DefaultStackPosition == 0)
-                    $asm.puts "fst#{x86Suffix(:int)} #{getSizeString(:int)}#{offsetRegister(-8, sp.x86Operand(:ptr))}"
-                else
-                    $asm.puts "fld #{operands[0].x87Operand(0)}"
-                    $asm.puts "fstpl -8(#{sp.x86Operand(:ptr)})"
-                end
-                $asm.puts "movq -8(#{sp.x86Operand(:ptr)}), #{operands[1].x86Operand(:quad)}"
+            if !isIntelSyntax
+                $asm.puts "movq #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}"
             else
-                if !isIntelSyntax
-                    $asm.puts "movq #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}"
-                else
-                    # MASM does not accept register operands with movq.
-                    # Debugging shows that movd actually moves a qword when using MASM.
-                    $asm.puts "movd #{operands[1].x86Operand(:quad)}, #{operands[0].x86Operand(:double)}"
-                end
+                # MASM does not accept register operands with movq.
+                # Debugging shows that movd actually moves a qword when using MASM.
+                $asm.puts "movd #{operands[1].x86Operand(:quad)}, #{operands[0].x86Operand(:double)}"
             end
         when "bo"
             $asm.puts "jo #{operands[0].asmLabel}"
index abe26cc..e2b761f 100644 (file)
@@ -437,20 +437,8 @@ double JIT_OPERATION operationMathPow(double x, double y)
     int32_t yAsInt = y;
     if (static_cast<double>(yAsInt) == y && yAsInt >= 0 && yAsInt <= maxExponentForIntegerMathPow) {
         // If the exponent is a small positive int32 integer, we do a fast exponentiation
-
-        // Do not use x87 values for accumulation. x87 values has 80bit precision.
-        // The result produced by x87's 80bit double precision differs from the one calculated with SSE2 in DFG.
-        // Using volatile double is workaround for this problem. By specifying volatile, we expect that `result` and `xd`
-        // are stored in the stack. And at that time, we expect that they are rounded by fst/fstp[1, 2].
-        // [1]: https://gcc.gnu.org/wiki/x87note
-        // [2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
-#if !CPU(X86) || (defined(__SSE2_MATH__) && defined(__SSE2__))
-        typedef double DoubleValue;
-#else
-        typedef volatile double DoubleValue;
-#endif
-        DoubleValue result = 1;
-        DoubleValue xd = x;
+        double result = 1;
+        double xd = x;
         while (yAsInt) {
             if (yAsInt & 1)
                 result *= xd;
index bc72a56..ed5d9d9 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-21  Xan Lopez  <xan@igalia.com>
+
+        [JSC][x86] Drop support for x87 floating point
+        https://bugs.webkit.org/show_bug.cgi?id=194853
+
+        Reviewed by Don Olmstead.
+
+        Force SSE2 on x86/32bit builds.
+
+        * Scripts/webkitdirs.pm:
+        (generateBuildSystemFromCMakeProject):
+
 2019-03-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GLIB] User data not correctly passed to callback of functions and constructors with no parameters
index d52b351..3d597f2 100755 (executable)
@@ -2277,7 +2277,9 @@ sub generateBuildSystemFromCMakeProject
     push @args, '"' . $cmakeSourceDir . '"';
 
     # Compiler options to keep floating point values consistent
-    # between 32-bit and 64-bit architectures.
+    # 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'} || "");