Unreviewed, rolling out r149349 and r149354.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 20:18:46 +0000 (20:18 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 20:18:46 +0000 (20:18 +0000)
http://trac.webkit.org/changeset/149349
http://trac.webkit.org/changeset/149354
https://bugs.webkit.org/show_bug.cgi?id=115444

 The Thumb version of compileSoftModulo make invalid use of
registers (Requested by benjaminp on #webkit).

Source/JavaScriptCore:

* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.xcodeproj/project.pbxproj:
* assembler/ARMv7Assembler.h:
(ARMv7Assembler):
* assembler/AbstractMacroAssembler.h:
(JSC::isARMv7s):
(JSC):
* assembler/MacroAssemblerARMv7.cpp: Removed.
* assembler/MacroAssemblerARMv7.h:
(MacroAssemblerARMv7):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileSoftModulo):
(DFG):
(JSC::DFG::SpeculativeJIT::compileIntegerArithDivForARMv7s):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
(SpeculativeJIT):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):

Source/WTF:

* wtf/Platform.h:

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

16 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/assembler/ARMv7Assembler.h
Source/JavaScriptCore/assembler/AbstractMacroAssembler.h
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.cpp [deleted file]
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/dfg/DFGOperations.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h

index e6a50df4c7056f60c4f9a5e6aea988427db21ab1..9a0c1ee57cc0376f2c3436f2fe86fcfb77f9e987 100644 (file)
@@ -517,7 +517,6 @@ if (WTF_CPU_ARM)
         assembler/ARMAssembler.cpp
         assembler/ARMv7Assembler.cpp
         assembler/MacroAssemblerARM.cpp
-        assembler/MacroAssemblerARMv7.cpp
     )
 elseif (WTF_CPU_MIPS)
 elseif (WTF_CPU_X86)
index c844b130bef5890d3dc24767d8e6d0d84bc03d23..d2d6c908e77e29cd34f1142080f555a9a688d834 100644 (file)
@@ -1,3 +1,38 @@
+2013-04-30  Commit Queue  <rniwa@webkit.org>
+
+        Unreviewed, rolling out r149349 and r149354.
+        http://trac.webkit.org/changeset/149349
+        http://trac.webkit.org/changeset/149354
+        https://bugs.webkit.org/show_bug.cgi?id=115444
+
+         The Thumb version of compileSoftModulo make invalid use of
+        registers (Requested by benjaminp on #webkit).
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * assembler/ARMv7Assembler.h:
+        (ARMv7Assembler):
+        * assembler/AbstractMacroAssembler.h:
+        (JSC::isARMv7s):
+        (JSC):
+        * assembler/MacroAssemblerARMv7.cpp: Removed.
+        * assembler/MacroAssemblerARMv7.h:
+        (MacroAssemblerARMv7):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        * dfg/DFGOperations.cpp:
+        * dfg/DFGOperations.h:
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileSoftModulo):
+        (DFG):
+        (JSC::DFG::SpeculativeJIT::compileIntegerArithDivForARMv7s):
+        * dfg/DFGSpeculativeJIT.h:
+        (JSC::DFG::SpeculativeJIT::callOperation):
+        (SpeculativeJIT):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+
 2013-04-30  Zalan Bujtas  <zalan@apple.com>
 
         Animations fail to start on http://www.google.com/insidesearch/howsearchworks/thestory/
index feb4d0b37ba51a46ffd88920bf057b1f5e381332..1021f092211c8cad98a0a96c4eab226acba70a9f 100644 (file)
@@ -73,7 +73,6 @@ javascriptcore_sources += \
        Source/JavaScriptCore/assembler/MacroAssembler.h \
        Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp \
        Source/JavaScriptCore/assembler/MacroAssemblerARM.h \
-       Source/JavaScriptCore/assembler/MacroAssemblerARMv7.cpp \
        Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h \
        Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h \
        Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h \
index 25efbc459d8299667506793148d71ae9222e2e4c..47aa4e6d80f91b0b5868f9ea3c886fb054e5192e 100644 (file)
                86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */; };
                86C568E111A213EE0007F7F0 /* MacroAssemblerMIPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */; settings = {ATTRIBUTES = (Private, ); }; };
                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C568DF11A213EE0007F7F0 /* MIPSAssembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               86C568E4FB92867A16FD1002 /* MacroAssemblerARMv7.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C568E3FB92867A16FD1002 /* MacroAssemblerARMv7.cpp */; };
                86CA032E1038E8440028A609 /* Executable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CA032D1038E8440028A609 /* Executable.cpp */; };
                86CAFEE31035DDE60028A609 /* Executable.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CAFEE21035DDE60028A609 /* Executable.h */; settings = {ATTRIBUTES = (Private, ); }; };
                86CC85A10EE79A4700288682 /* JITInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CC85A00EE79A4700288682 /* JITInlines.h */; };
                86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM.cpp; sourceTree = "<group>"; };
                86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerMIPS.h; sourceTree = "<group>"; };
                86C568DF11A213EE0007F7F0 /* MIPSAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIPSAssembler.h; sourceTree = "<group>"; };
-               86C568E3FB92867A16FD1002 /* MacroAssemblerARMv7.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARMv7.cpp; sourceTree = "<group>"; };
                86CA032D1038E8440028A609 /* Executable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Executable.cpp; sourceTree = "<group>"; };
                86CAFEE21035DDE60028A609 /* Executable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Executable.h; sourceTree = "<group>"; };
                86CC85A00EE79A4700288682 /* JITInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITInlines.h; sourceTree = "<group>"; };
                                86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */,
                                86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */,
                                86D3B2C210156BDE002865E7 /* MacroAssemblerARM.h */,
-                               86C568E3FB92867A16FD1002 /* MacroAssemblerARMv7.cpp */,
                                86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */,
                                863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */,
                                86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */,
                                14B723B212D7DA46003BD5ED /* MachineStackMarker.cpp in Sources */,
                                0FEB3ECF16237F6C00AB67AD /* MacroAssembler.cpp in Sources */,
                                86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
-                               86C568E4FB92867A16FD1002 /* MacroAssemblerARMv7.cpp in Sources */,
                                86AE64A8135E5E1C00963012 /* MacroAssemblerSH4.cpp in Sources */,
                                C2B916C514DA040C00CBAC86 /* MarkedAllocator.cpp in Sources */,
                                142D6F0813539A2800B02E86 /* MarkedBlock.cpp in Sources */,
index 079b509553ac6f1eefc0751e782605344c4836a7..28989549d454dd334bda154f22d1f902edc18e0a 100644 (file)
@@ -661,8 +661,10 @@ private:
         OP_ROR_reg_T2   = 0xFA60,
         OP_CLZ          = 0xFAB0,
         OP_SMULL_T1     = 0xFB80,
+#if CPU(APPLE_ARMV7S)
         OP_SDIV_T1      = 0xFB90,
         OP_UDIV_T1      = 0xFBB0,
+#endif
     } OpcodeID1;
 
     typedef enum {
@@ -1405,6 +1407,7 @@ public:
         m_formatter.twoWordOp12Reg4FourFours(OP_ROR_reg_T2, rn, FourFours(0xf, rd, 0, rm));
     }
 
+#if CPU(APPLE_ARMV7S)
     ALWAYS_INLINE void sdiv(RegisterID rd, RegisterID rn, RegisterID rm)
     {
         ASSERT(!BadReg(rd));
@@ -1412,6 +1415,7 @@ public:
         ASSERT(!BadReg(rm));
         m_formatter.twoWordOp12Reg4FourFours(OP_SDIV_T1, rn, FourFours(0xf, rd, 0xf, rm));
     }
+#endif
 
     ALWAYS_INLINE void smull(RegisterID rdLo, RegisterID rdHi, RegisterID rn, RegisterID rm)
     {
@@ -1749,6 +1753,7 @@ public:
         m_formatter.twoWordOp12Reg40Imm3Reg4Imm20Imm5(OP_UBFX_T1, rd, rn, (lsb & 0x1c) << 10, (lsb & 0x3) << 6, (width - 1) & 0x1f);
     }
 
+#if CPU(APPLE_ARMV7S)
     ALWAYS_INLINE void udiv(RegisterID rd, RegisterID rn, RegisterID rm)
     {
         ASSERT(!BadReg(rd));
@@ -1756,6 +1761,7 @@ public:
         ASSERT(!BadReg(rm));
         m_formatter.twoWordOp12Reg4FourFours(OP_UDIV_T1, rn, FourFours(0xf, rd, 0xf, rm));
     }
+#endif
 
     void vadd(FPDoubleRegisterID rd, FPDoubleRegisterID rn, FPDoubleRegisterID rm)
     {
index 755e54ff112a87b336c1e41449a8fa0e94eca78f..68fd804ecc825c892d92e787d7d3797bfa282528 100644 (file)
 
 namespace JSC {
 
+inline bool isARMv7s()
+{
+#if CPU(APPLE_ARMV7S)
+    return true;
+#else
+    return false;
+#endif
+}
+
 inline bool isX86()
 {
 #if CPU(X86_64) || CPU(X86)
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.cpp b/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.cpp
deleted file mode 100644 (file)
index 2ed5fc2..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED 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.
- */
-
-#include "config.h"
-
-#if ENABLE(ASSEMBLER) && CPU(ARM_THUMB2)
-
-#include "MacroAssemblerARMv7.h"
-
-#if OS(QNX)
-#include <sys/syspage.h>
-#endif
-
-namespace JSC {
-
-#if OS(QNX)
-
-static bool isIntegerDivSupported()
-{
-#ifdef ARM_CPU_FLAG_IDIV
-    return !!(SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_IDIV);
-#else
-    return false;
-#endif
-}
-
-const bool MacroAssemblerARMv7::s_isIntegerDivSupported = isIntegerDivSupported();
-
-#endif // OS(QNX)
-
-}
-
-#endif // ENABLE(ASSEMBLER) && CPU(ARM_THUMB2)
index 1b074854e8c2c23ec23a9a5323d5af2b575c9f0e..b1bc417296686c6ea14beb4b8b0abbec2e24a2c1 100644 (file)
@@ -793,19 +793,8 @@ public:
     }
 #endif
 
-    // Integer operations.
-    static bool supportsIntegerDiv()
-    {
-#if CPU(APPLE_ARMV7S)
-        return true;
-#elif OS(QNX)
-        return s_isIntegerDivSupported;
-#else
-        return false;
-#endif
-    }
+    // Floating-point operations:
 
-    // Floating-point operations.
     static bool supportsFloatingPoint() { return true; }
     static bool supportsFloatingPointTruncate() { return true; }
     static bool supportsFloatingPointSqrt() { return true; }
@@ -1918,10 +1907,6 @@ private:
     }
 
     bool m_makeJumpPatchable;
-
-#if OS(QNX)
-    static const bool s_isIntegerDivSupported;
-#endif
 };
 
 } // namespace JSC
index 20c66070968f9d1176d7f3a3e180fd4f730c73b2..c9a58d66986384ffa018867a657ec57b6d37dc0f 100644 (file)
@@ -214,14 +214,7 @@ private:
         case ArithDiv: {
             if (Node::shouldSpeculateIntegerForArithmetic(node->child1().node(), node->child2().node())
                 && node->canSpeculateInteger()) {
-#if CPU(X86) || CPU(X86_64)
-                const bool cpuSupportsIntegerDiv = true;
-#elif CPU(ARM_THUMB2)
-                const bool cpuSupportsIntegerDiv = MacroAssembler::supportsIntegerDiv();
-#else
-                const bool cpuSupportsIntegerDiv = false;
-#endif
-                if (cpuSupportsIntegerDiv) {
+                if (isX86() || isARMv7s()) {
                     setUseKindAndUnboxIfProfitable<Int32Use>(node->child1());
                     setUseKindAndUnboxIfProfitable<Int32Use>(node->child2());
                     break;
index 32c8fe7aae4db39b35114718d77956a824e0d8a5..310f244ef5c193bf2e2b8679efd78c8ab8c5f445 100644 (file)
@@ -45,7 +45,6 @@
 #include "ObjectConstructor.h"
 #include "Operations.h"
 #include "StringConstructor.h"
-#include <stdlib.h>
 #include <wtf/InlineASM.h>
 
 #if ENABLE(JIT)
@@ -1601,11 +1600,6 @@ JSCell* DFG_OPERATION operationMakeRope3(ExecState* exec, JSString* a, JSString*
     return JSRopeString::create(vm, a, b, c);
 }
 
-int32_t DFG_OPERATION operationModOnInts(int32_t a, int32_t b)
-{
-    return a % b;
-}
-
 double DFG_OPERATION operationFModOnInts(int32_t a, int32_t b)
 {
     return fmod(a, b);
index fb9873cee1b49c7dd3944aeecabf881202963c25..c314e8eb39752fc1d94c04adc7a33bbc70efb5e4 100644 (file)
@@ -97,7 +97,6 @@ typedef double DFG_OPERATION (*D_DFGOperation_DD)(double, double);
 typedef double DFG_OPERATION (*D_DFGOperation_ZZ)(int32_t, int32_t);
 typedef double DFG_OPERATION (*D_DFGOperation_EJ)(ExecState*, EncodedJSValue);
 typedef int32_t DFG_OPERATION (*Z_DFGOperation_D)(double);
-typedef int32_t DFG_OPERATION (*Z_DFGOperation_ZZ)(int32_t, int32_t);
 typedef size_t DFG_OPERATION (*S_DFGOperation_ECC)(ExecState*, JSCell*, JSCell*);
 typedef size_t DFG_OPERATION (*S_DFGOperation_EJ)(ExecState*, EncodedJSValue);
 typedef size_t DFG_OPERATION (*S_DFGOperation_EJJ)(ExecState*, EncodedJSValue, EncodedJSValue);
@@ -209,7 +208,6 @@ EncodedJSValue DFG_OPERATION operationGetInlinedArgumentByVal(ExecState*, int32_
 EncodedJSValue DFG_OPERATION operationGetArgumentByVal(ExecState*, int32_t, int32_t) WTF_INTERNAL;
 JSCell* DFG_OPERATION operationNewFunction(ExecState*, JSCell*) WTF_INTERNAL;
 JSCell* DFG_OPERATION operationNewFunctionExpression(ExecState*, JSCell*) WTF_INTERNAL;
-int32_t DFG_OPERATION operationModOnInts(int32_t, int32_t) WTF_INTERNAL;
 double DFG_OPERATION operationFModOnInts(int32_t, int32_t) WTF_INTERNAL;
 size_t DFG_OPERATION operationIsObject(ExecState*, EncodedJSValue) WTF_INTERNAL;
 size_t DFG_OPERATION operationIsFunction(EncodedJSValue) WTF_INTERNAL;
index 3b2985fd36217d79235a9ab21080e388d1a73367..4337e80f59b71d275db509db5a71bd110901ca59 100644 (file)
@@ -2877,12 +2877,12 @@ void SpeculativeJIT::compileInstanceOf(Node* node)
 #endif
 }
 
-#if CPU(X86) || CPU(X86_64)
 void SpeculativeJIT::compileSoftModulo(Node* node)
 {
     // In the fast path, the dividend value could be the final result
     // (in case of |dividend| < |divisor|), so we speculate it as strict int32.
     SpeculateStrictInt32Operand op1(this, node->child1());
+#if CPU(X86) || CPU(X86_64)
     if (isInt32Constant(node->child2().node())) {
         int32_t divisor = valueOfInt32Constant(node->child2().node());
         if (divisor) {
@@ -2922,9 +2922,36 @@ void SpeculativeJIT::compileSoftModulo(Node* node)
             return;
         }
     }
+#elif CPU(APPLE_ARMV7S) || CPU(ARM_THUMB2)
+    if (isInt32Constant(node->child2().node())) {
+        int32_t divisor = valueOfInt32Constant(node->child2().node());
+        if (divisor > 0 && hasOneBitSet(divisor)) { // If power of 2 then just mask
+            GPRReg dividendGPR = op1.gpr();
+            GPRTemporary result(this);
+            GPRReg resultGPR = result.gpr();
 
-    SpeculateIntegerOperand op2(this, node->child2());
+            m_jit.assembler().cmp(dividendGPR, ARMThumbImmediate::makeEncodedImm(0));
+            m_jit.assembler().it(ARMv7Assembler::ConditionLT, false);
+            m_jit.assembler().neg(resultGPR, dividendGPR);
+            m_jit.assembler().mov(resultGPR, dividendGPR);
+            m_jit.and32(TrustedImm32(divisor - 1), resultGPR);
+            m_jit.assembler().it(ARMv7Assembler::ConditionLT);
+            m_jit.assembler().neg(resultGPR, resultGPR);
 
+            if (!nodeCanIgnoreNegativeZero(node->arithNodeFlags())) {
+                // Check that we're not about to create negative zero.
+                JITCompiler::Jump numeratorPositive = m_jit.branch32(JITCompiler::GreaterThanOrEqual, dividendGPR, TrustedImm32(0));
+                speculationCheck(NegativeZero, JSValueRegs(), 0, m_jit.branchTest32(JITCompiler::Zero, resultGPR));
+                numeratorPositive.link(&m_jit);
+            }
+            integerResult(resultGPR, node);
+            return;
+        }
+    }
+#endif
+
+    SpeculateIntegerOperand op2(this, node->child2());
+#if CPU(X86) || CPU(X86_64)
     GPRTemporary eax(this, X86Registers::eax);
     GPRTemporary edx(this, X86Registers::edx);
     GPRReg op1GPR = op1.gpr();
@@ -2989,87 +3016,43 @@ void SpeculativeJIT::compileSoftModulo(Node* node)
     
     if (op1SaveGPR != op1GPR)
         unlock(op1SaveGPR);
-
+            
     integerResult(edx.gpr(), node);
-}
-#elif CPU(ARM_THUMB2)
-void SpeculativeJIT::compileSoftModulo(Node* node)
-{
-    // In the fast path, the dividend value could be the final result
-    // (in case of |dividend| < |divisor|), so we speculate it as strict int32.
-    SpeculateStrictInt32Operand op1(this, node->child1());
-    if (isInt32Constant(node->child2().node())) {
-        int32_t divisor = valueOfInt32Constant(node->child2().node());
-        if (divisor > 0 && hasOneBitSet(divisor)) { // If power of 2 then just mask
-            GPRReg dividendGPR = op1.gpr();
-            GPRTemporary result(this);
-            GPRReg resultGPR = result.gpr();
-
-            m_jit.assembler().cmp(dividendGPR, ARMThumbImmediate::makeEncodedImm(0));
-            m_jit.assembler().it(ARMv7Assembler::ConditionLT, false);
-            m_jit.assembler().neg(resultGPR, dividendGPR);
-            m_jit.assembler().mov(resultGPR, dividendGPR);
-            m_jit.and32(TrustedImm32(divisor - 1), resultGPR);
-            m_jit.assembler().it(ARMv7Assembler::ConditionLT);
-            m_jit.assembler().neg(resultGPR, resultGPR);
-
-            if (!nodeCanIgnoreNegativeZero(node->arithNodeFlags())) {
-                // Check that we're not about to create negative zero.
-                JITCompiler::Jump numeratorPositive = m_jit.branch32(JITCompiler::GreaterThanOrEqual, dividendGPR, TrustedImm32(0));
-                speculationCheck(NegativeZero, JSValueRegs(), 0, m_jit.branchTest32(JITCompiler::Zero, resultGPR));
-                numeratorPositive.link(&m_jit);
-            }
-            integerResult(resultGPR, node);
-            return;
-        }
-    }
-
-    SpeculateIntegerOperand op2(this, node->child2());
 
+#elif CPU(APPLE_ARMV7S)
+    GPRTemporary temp(this);
+    GPRTemporary quotientThenRemainder(this);
+    GPRTemporary multiplyAnswer(this);
     GPRReg dividendGPR = op1.gpr();
     GPRReg divisorGPR = op2.gpr();
+    GPRReg quotientThenRemainderGPR = quotientThenRemainder.gpr();
+    GPRReg multiplyAnswerGPR = multiplyAnswer.gpr();
 
-    GPRResult result(this);
-    GPRReg resultGPR = result.gpr();
-
-    if (MacroAssembler::supportsIntegerDiv()) {
-        GPRTemporary multiplyAnswer(this);
-        GPRReg multiplyAnswerGPR = multiplyAnswer.gpr();
-        m_jit.assembler().sdiv(resultGPR, dividendGPR, divisorGPR);
-        speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchMul32(JITCompiler::Overflow, resultGPR, divisorGPR, multiplyAnswerGPR));
-        m_jit.assembler().sub(resultGPR, dividendGPR, multiplyAnswerGPR);
-    } else {
-        flushRegisters();
-        callOperation(operationModOnInts, resultGPR, dividendGPR, divisorGPR);
-    }
+    m_jit.assembler().sdiv(quotientThenRemainderGPR, dividendGPR, divisorGPR);
+    speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchMul32(JITCompiler::Overflow, quotientThenRemainderGPR, divisorGPR, multiplyAnswerGPR));
+    m_jit.assembler().sub(quotientThenRemainderGPR, dividendGPR, multiplyAnswerGPR);
 
     // If the user cares about negative zero, then speculate that we're not about
     // to produce negative zero.
     if (!nodeCanIgnoreNegativeZero(node->arithNodeFlags())) {
         // Check that we're not about to create negative zero.
         JITCompiler::Jump numeratorPositive = m_jit.branch32(JITCompiler::GreaterThanOrEqual, dividendGPR, TrustedImm32(0));
-        speculationCheck(NegativeZero, JSValueRegs(), 0, m_jit.branchTest32(JITCompiler::Zero, resultGPR));
+        speculationCheck(NegativeZero, JSValueRegs(), 0, m_jit.branchTest32(JITCompiler::Zero, quotientThenRemainderGPR));
         numeratorPositive.link(&m_jit);
     }
 
-    integerResult(resultGPR, node);
-}
-#else // CPU type without integer division
-void SpeculativeJIT::compileSoftModulo(Node* node)
-{
-    SpeculateStrictInt32Operand op1(this, node->child1());
-    SpeculateIntegerOperand op2(this, node->child2());
-
+    integerResult(quotientThenRemainderGPR, node);
+#else // not architecture that can do integer division
     // Do this the *safest* way possible: call out to a C function that will do the modulo,
     // and then attempt to convert back.
-    GPRReg dividendGPR = op1.gpr();
-    GPRReg divisorGPR = op2.gpr();
-
+    GPRReg op1GPR = op1.gpr();
+    GPRReg op2GPR = op2.gpr();
+    
     FPRResult result(this);
-
+    
     flushRegisters();
-    callOperation(operationFModOnInts, result.fpr(), dividendGPR, divisorGPR);
-
+    callOperation(operationFModOnInts, result.fpr(), op1GPR, op2GPR);
+    
     FPRTemporary scratch(this);
     GPRTemporary intResult(this);
     JITCompiler::JumpList failureCases;
@@ -3077,14 +3060,14 @@ void SpeculativeJIT::compileSoftModulo(Node* node)
     speculationCheck(Overflow, JSValueRegs(), 0, failureCases);
     if (!nodeCanIgnoreNegativeZero(node->arithNodeFlags())) {
         // Check that we're not about to create negative zero.
-        JITCompiler::Jump numeratorPositive = m_jit.branch32(JITCompiler::GreaterThanOrEqual, dividendGPR, TrustedImm32(0));
+        JITCompiler::Jump numeratorPositive = m_jit.branch32(JITCompiler::GreaterThanOrEqual, op1GPR, TrustedImm32(0));
         speculationCheck(NegativeZero, JSValueRegs(), 0, m_jit.branchTest32(JITCompiler::Zero, intResult.gpr()));
         numeratorPositive.link(&m_jit);
     }
-
+    
     integerResult(intResult.gpr(), node);
+#endif // CPU(X86) || CPU(X86_64)
 }
-#endif
 
 void SpeculativeJIT::compileAdd(Node* node)
 {
@@ -3493,8 +3476,8 @@ void SpeculativeJIT::compileIntegerArithDivForX86(Node* node)
             
     integerResult(eax.gpr(), node);
 }
-#elif ENABLE(ARM_INTEGER_DIV)
-void SpeculativeJIT::compileIntegerArithDivForARM(Node* node)
+#elif CPU(APPLE_ARMV7S)
+void SpeculativeJIT::compileIntegerArithDivForARMv7s(Node* node)
 {
     SpeculateIntegerOperand op1(this, node->child1());
     SpeculateIntegerOperand op2(this, node->child2());
index ca75826569f1f3e168bcfe51488c09701b67067e..6d1defa315fe0fb89bb5c9c041f179be28348373 100644 (file)
@@ -1110,13 +1110,6 @@ public:
         m_jit.zeroExtend32ToPtr(GPRInfo::returnValueGPR, result);
         return call;
     }
-    JITCompiler::Call callOperation(Z_DFGOperation_ZZ operation, GPRReg result, GPRReg arg1, GPRReg arg2)
-    {
-        m_jit.setupArguments(arg1, arg2);
-        JITCompiler::Call call = m_jit.appendCall(operation);
-        m_jit.zeroExtend32ToPtr(GPRInfo::returnValueGPR, result);
-        return call;
-    }
     JITCompiler::Call callOperation(J_DFGOperation_EGriJsgI operation, GPRReg result, GPRReg arg1, GPRReg arg2, Identifier* identifier)
     {
         m_jit.setupArgumentsWithExecState(arg1, arg2, TrustedImmPtr(identifier));
@@ -1322,13 +1315,6 @@ public:
         m_jit.zeroExtend32ToPtr(GPRInfo::returnValueGPR, result);
         return call;
     }
-    JITCompiler::Call callOperation(Z_DFGOperation_ZZ operation, GPRReg result, GPRReg arg1, GPRReg arg2)
-    {
-        m_jit.setupArguments(arg1, arg2);
-        JITCompiler::Call call = m_jit.appendCall(operation);
-        m_jit.zeroExtend32ToPtr(GPRInfo::returnValueGPR, result);
-        return call;
-    }
     JITCompiler::Call callOperation(J_DFGOperation_E operation, GPRReg resultTag, GPRReg resultPayload)
     {
         m_jit.setupArgumentsExecState();
@@ -1985,8 +1971,8 @@ public:
     void compileArithIMul(Node*);
 #if CPU(X86) || CPU(X86_64)
     void compileIntegerArithDivForX86(Node*);
-#elif ENABLE(ARM_INTEGER_DIV)
-    void compileIntegerArithDivForARM(Node*);
+#elif CPU(APPLE_ARMV7S)
+    void compileIntegerArithDivForARMv7s(Node*);
 #endif
     void compileArithMod(Node*);
     void compileSoftModulo(Node*);
index c89f431abb41dbd8d71fc484e50987dba9bd256d..3595753c114580ef8006f79a9cbce13357e2865b 100644 (file)
@@ -2253,9 +2253,8 @@ void SpeculativeJIT::compile(Node* node)
         case Int32Use: {
 #if CPU(X86)
             compileIntegerArithDivForX86(node);
-#elif ENABLE(ARM_INTEGER_DIV)
-            ASSERT(MacroAssembler::supportsIntegerDiv());
-            compileIntegerArithDivForARM(node);
+#elif CPU(APPLE_ARMV7S)
+            compileIntegerArithDivForARMv7s(node);
 #else // CPU type without integer divide
             RELEASE_ASSERT_NOT_REACHED(); // should have been coverted into a double divide.
 #endif
index 91dc36a831a437eb0f0176f631ddf5ae89b8bab9..97892031cbf9d1f5b64b1e85f3e72da582adf286 100644 (file)
@@ -1,3 +1,15 @@
+2013-04-30  Commit Queue  <rniwa@webkit.org>
+
+        Unreviewed, rolling out r149349 and r149354.
+        http://trac.webkit.org/changeset/149349
+        http://trac.webkit.org/changeset/149354
+        https://bugs.webkit.org/show_bug.cgi?id=115444
+
+         The Thumb version of compileSoftModulo make invalid use of
+        registers (Requested by benjaminp on #webkit).
+
+        * wtf/Platform.h:
+
 2013-04-30  Darin Adler  <darin@apple.com>
 
         [Mac] Make adoptNS faster on platforms without garbage collection by skipping a CFRetain/NSRelease pair
index e9071d36d7424b8108d570b211252b672bdc585a..0e1130873cd25db7497d006798ab66cc54430f58 100644 (file)
 #define ENABLE_COMPARE_AND_SWAP 1
 #endif
 
-#if CPU(APPLE_ARMV7S) || (CPU(ARM_THUMB2) && OS(QNX))
-#define ENABLE_ARM_INTEGER_DIV 1
-#endif
-
 #define ENABLE_OBJECT_MARK_LOGGING 0
 
 #if !defined(ENABLE_PARALLEL_GC) && !ENABLE(OBJECT_MARK_LOGGING) && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(BLACKBERRY) || PLATFORM(GTK)) && ENABLE(COMPARE_AND_SWAP)