Skip to content

Commit

Permalink
Merge r181570 - [ARM] Enable generating idiv instructions if it is su…
Browse files Browse the repository at this point in the history
…pported

https://bugs.webkit.org/show_bug.cgi?id=142725

Reviewed by Michael Saboff.

Source/JavaScriptCore:

* assembler/ARMAssembler.h: Added sdiv and udiv implementation for ARM Traditional instruction set.
(JSC::ARMAssembler::sdiv):
(JSC::ARMAssembler::udiv):
* assembler/ARMv7Assembler.h: Use HAVE(ARM_IDIV_INSTRUCTIONS) instead of CPU(APPLE_ARMV7S).
* assembler/AbstractMacroAssembler.h:
(JSC::isARMv7IDIVSupported):
(JSC::optimizeForARMv7IDIVSupported):
(JSC::isARMv7s): Renamed to isARMv7IDIVSupported().
(JSC::optimizeForARMv7s): Renamed to optimizeForARMv7IDIVSupported().
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithDiv):
(JSC::DFG::SpeculativeJIT::compileArithMod):

Source/WTF:

* wtf/Platform.h: Set HAVE_ARM_IDIV_INSTRUCTIONS based on GCC macro too.
  • Loading branch information
ossy-szeged authored and carlosgcampos committed Mar 17, 2015
1 parent 0160b44 commit d906c79
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 11 deletions.
22 changes: 22 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,25 @@
2015-03-16 Csaba Osztrogonác <ossy@webkit.org>

[ARM] Enable generating idiv instructions if it is supported
https://bugs.webkit.org/show_bug.cgi?id=142725

Reviewed by Michael Saboff.

* assembler/ARMAssembler.h: Added sdiv and udiv implementation for ARM Traditional instruction set.
(JSC::ARMAssembler::sdiv):
(JSC::ARMAssembler::udiv):
* assembler/ARMv7Assembler.h: Use HAVE(ARM_IDIV_INSTRUCTIONS) instead of CPU(APPLE_ARMV7S).
* assembler/AbstractMacroAssembler.h:
(JSC::isARMv7IDIVSupported):
(JSC::optimizeForARMv7IDIVSupported):
(JSC::isARMv7s): Renamed to isARMv7IDIVSupported().
(JSC::optimizeForARMv7s): Renamed to optimizeForARMv7IDIVSupported().
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithDiv):
(JSC::DFG::SpeculativeJIT::compileArithMod):

2015-03-13 Filip Pizlo <fpizlo@apple.com>

Object allocation sinking phase shouldn't re-decorate previously sunken allocations on each fixpoint operation
Expand Down
24 changes: 24 additions & 0 deletions Source/JavaScriptCore/assembler/ARMAssembler.h
Expand Up @@ -216,6 +216,10 @@ namespace JSC {
#endif
NOP = 0xe1a00000,
DMB_SY = 0xf57ff05f,
#if HAVE(ARM_IDIV_INSTRUCTIONS)
SDIV = 0x0710f010,
UDIV = 0x0730f010,
#endif
};

enum {
Expand Down Expand Up @@ -477,6 +481,26 @@ namespace JSC {
m_buffer.putInt(toARMWord(cc) | MULL | RN(rdhi) | RD(rdlo) | RS(rn) | RM(rm));
}

#if HAVE(ARM_IDIV_INSTRUCTIONS)
template<int datasize>
void sdiv(int rd, int rn, int rm, Condition cc = AL)
{
static_assert(datasize == 32, "sdiv datasize must be 32 for armv7s");
ASSERT(rd != ARMRegisters::pc);
ASSERT(rn != ARMRegisters::pc);
ASSERT(rm != ARMRegisters::pc);
m_buffer.putInt(toARMWord(cc) | SDIV | RN(rd) | RM(rn) | RS(rm));
}

void udiv(int rd, int rn, int rm, Condition cc = AL)
{
ASSERT(rd != ARMRegisters::pc);
ASSERT(rn != ARMRegisters::pc);
ASSERT(rm != ARMRegisters::pc);
m_buffer.putInt(toARMWord(cc) | UDIV | RN(rd) | RM(rn) | RS(rm));
}
#endif

void vmov_f64(int dd, int dm, Condition cc = AL)
{
emitDoublePrecisionInstruction(toARMWord(cc) | VMOV_F64, dd, 0, dm);
Expand Down
6 changes: 3 additions & 3 deletions Source/JavaScriptCore/assembler/ARMv7Assembler.h
Expand Up @@ -708,7 +708,7 @@ class ARMv7Assembler {
OP_ROR_reg_T2 = 0xFA60,
OP_CLZ = 0xFAB0,
OP_SMULL_T1 = 0xFB80,
#if CPU(APPLE_ARMV7S)
#if HAVE(ARM_IDIV_INSTRUCTIONS)
OP_SDIV_T1 = 0xFB90,
OP_UDIV_T1 = 0xFBB0,
#endif
Expand Down Expand Up @@ -1499,7 +1499,7 @@ class ARMv7Assembler {
m_formatter.twoWordOp16Imm16(OP_PUSH_T2, registerList);
}

#if CPU(APPLE_ARMV7S)
#if HAVE(ARM_IDIV_INSTRUCTIONS)
template<int datasize>
ALWAYS_INLINE void sdiv(RegisterID rd, RegisterID rn, RegisterID rm)
{
Expand Down Expand Up @@ -1847,7 +1847,7 @@ class ARMv7Assembler {
m_formatter.twoWordOp12Reg40Imm3Reg4Imm20Imm5(OP_UBFX_T1, rd, rn, (lsb & 0x1c) << 10, (lsb & 0x3) << 6, (width - 1) & 0x1f);
}

#if CPU(APPLE_ARMV7S)
#if HAVE(ARM_IDIV_INSTRUCTIONS)
ALWAYS_INLINE void udiv(RegisterID rd, RegisterID rn, RegisterID rm)
{
ASSERT(!BadReg(rd));
Expand Down
8 changes: 4 additions & 4 deletions Source/JavaScriptCore/assembler/AbstractMacroAssembler.h
Expand Up @@ -39,9 +39,9 @@

namespace JSC {

inline bool isARMv7s()
inline bool isARMv7IDIVSupported()
{
#if CPU(APPLE_ARMV7S)
#if HAVE(ARM_IDIV_INSTRUCTIONS)
return true;
#else
return false;
Expand All @@ -66,9 +66,9 @@ inline bool isX86()
#endif
}

inline bool optimizeForARMv7s()
inline bool optimizeForARMv7IDIVSupported()
{
return isARMv7s() && Options::enableArchitectureSpecificOptimizations();
return isARMv7IDIVSupported() && Options::enableArchitectureSpecificOptimizations();
}

inline bool optimizeForARM64()
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Expand Up @@ -271,7 +271,7 @@ class FixupPhase : public Phase {
case ArithMod: {
if (Node::shouldSpeculateInt32OrBooleanForArithmetic(node->child1().node(), node->child2().node())
&& node->canSpeculateInt32(FixupPass)) {
if (optimizeForX86() || optimizeForARM64() || optimizeForARMv7s()) {
if (optimizeForX86() || optimizeForARM64() || optimizeForARMv7IDIVSupported()) {
fixIntOrBooleanEdge(node->child1());
fixIntOrBooleanEdge(node->child2());
if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
Expand Down
6 changes: 3 additions & 3 deletions Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Expand Up @@ -3218,7 +3218,7 @@ void SpeculativeJIT::compileArithDiv(Node* node)

done.link(&m_jit);
int32Result(eax.gpr(), node);
#elif CPU(APPLE_ARMV7S) || CPU(ARM64)
#elif HAVE(ARM_IDIV_INSTRUCTIONS) || CPU(ARM64)
SpeculateInt32Operand op1(this, node->child1());
SpeculateInt32Operand op2(this, node->child2());
GPRReg op1GPR = op1.gpr();
Expand Down Expand Up @@ -3471,7 +3471,7 @@ void SpeculativeJIT::compileArithMod(Node* node)
done.link(&m_jit);
int32Result(edx.gpr(), node);

#elif CPU(ARM64) || CPU(APPLE_ARMV7S)
#elif HAVE(ARM_IDIV_INSTRUCTIONS) || CPU(ARM64)
GPRTemporary temp(this);
GPRTemporary quotientThenRemainder(this);
GPRTemporary multiplyAnswer(this);
Expand All @@ -3496,7 +3496,7 @@ void SpeculativeJIT::compileArithMod(Node* node)
// arithMode() == Arith::Unchecked?
// https://bugs.webkit.org/show_bug.cgi?id=126444
speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchMul32(JITCompiler::Overflow, quotientThenRemainderGPR, divisorGPR, multiplyAnswerGPR));
#if CPU(APPLE_ARMV7S)
#if HAVE(ARM_IDIV_INSTRUCTIONS)
m_jit.assembler().sub(quotientThenRemainderGPR, dividendGPR, multiplyAnswerGPR);
#else
m_jit.assembler().sub<32>(quotientThenRemainderGPR, dividendGPR, multiplyAnswerGPR);
Expand Down
9 changes: 9 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,12 @@
2015-03-16 Csaba Osztrogonác <ossy@webkit.org>

[ARM] Enable generating idiv instructions if it is supported
https://bugs.webkit.org/show_bug.cgi?id=142725

Reviewed by Michael Saboff.

* wtf/Platform.h: Set HAVE_ARM_IDIV_INSTRUCTIONS based on GCC macro too.

2015-03-16 Max Stepin <maxstepin@gmail.com>

Add APNG support
Expand Down
4 changes: 4 additions & 0 deletions Source/WTF/wtf/Platform.h
Expand Up @@ -334,6 +334,10 @@
#define WTF_CPU_APPLE_ARMV7S 1
#endif

#if defined(__ARM_ARCH_EXT_IDIV__) || CPU(APPLE_ARMV7S)
#define HAVE_ARM_IDIV_INSTRUCTIONS 1
#endif

#endif /* ARM */

#if CPU(ARM) || CPU(MIPS) || CPU(SH4)
Expand Down

0 comments on commit d906c79

Please sign in to comment.