Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (153189 => 153190)
--- trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:01:20 UTC (rev 153189)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:01:22 UTC (rev 153190)
@@ -1,5 +1,23 @@
2013-05-27 Filip Pizlo <[email protected]>
+ fourthTier: FTL should support ArithMod
+ https://bugs.webkit.org/show_bug.cgi?id=116792
+
+ Reviewed by Oliver Hunt.
+
+ * ftl/FTLAbbreviations.h:
+ (JSC::FTL::buildFRem):
+ * ftl/FTLCapabilities.cpp:
+ (JSC::FTL::canCompile):
+ * ftl/FTLLowerDFGToLLVM.cpp:
+ (JSC::FTL::LowerDFGToLLVM::compileNode):
+ (JSC::FTL::LowerDFGToLLVM::compileArithMod):
+ (LowerDFGToLLVM):
+ * ftl/FTLOutput.h:
+ (JSC::FTL::Output::doubleRem):
+
+2013-05-27 Filip Pizlo <[email protected]>
+
It should be possible to record heap operations (both FastMalloc and JSC GC)
https://bugs.webkit.org/show_bug.cgi?id=116848
Modified: trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h (153189 => 153190)
--- trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h 2013-07-25 04:01:20 UTC (rev 153189)
+++ trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h 2013-07-25 04:01:22 UTC (rev 153190)
@@ -177,6 +177,7 @@
static inline LValue buildFSub(LBuilder builder, LValue left, LValue right) { return LLVMBuildFSub(builder, left, right, ""); }
static inline LValue buildFMul(LBuilder builder, LValue left, LValue right) { return LLVMBuildFMul(builder, left, right, ""); }
static inline LValue buildFDiv(LBuilder builder, LValue left, LValue right) { return LLVMBuildFDiv(builder, left, right, ""); }
+static inline LValue buildFRem(LBuilder builder, LValue left, LValue right) { return LLVMBuildFRem(builder, left, right, ""); }
static inline LValue buildFNeg(LBuilder builder, LValue value) { return LLVMBuildFNeg(builder, value, ""); }
static inline LValue buildAnd(LBuilder builder, LValue left, LValue right) { return LLVMBuildAnd(builder, left, right, ""); }
static inline LValue buildOr(LBuilder builder, LValue left, LValue right) { return LLVMBuildOr(builder, left, right, ""); }
Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (153189 => 153190)
--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2013-07-25 04:01:20 UTC (rev 153189)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2013-07-25 04:01:22 UTC (rev 153190)
@@ -67,6 +67,7 @@
case ArithSub:
case ArithMul:
case ArithDiv:
+ case ArithMod:
case ArithNegate:
case UInt32ToNumber:
case Int32ToDouble:
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (153189 => 153190)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2013-07-25 04:01:20 UTC (rev 153189)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2013-07-25 04:01:22 UTC (rev 153190)
@@ -311,6 +311,9 @@
case ArithDiv:
compileArithDiv();
break;
+ case ArithMod:
+ compileArithMod();
+ break;
case ArithNegate:
compileArithNegate();
break;
@@ -785,6 +788,97 @@
}
}
+ void compileArithMod()
+ {
+ switch (m_node->binaryUseKind()) {
+ case Int32Use: {
+ LValue numerator = lowInt32(m_node->child1());
+ LValue denominator = lowInt32(m_node->child2());
+
+ LBasicBlock unsafeDenominator = FTL_NEW_BLOCK(m_out, ("ArithMod unsafe denominator"));
+ LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ArithMod continuation"));
+ LBasicBlock done = FTL_NEW_BLOCK(m_out, ("ArithMod done"));
+
+ Vector<ValueFromBlock, 3> results;
+
+ LValue adjustedDenominator = m_out.add(denominator, m_out.int32One);
+
+ m_out.branch(m_out.above(adjustedDenominator, m_out.int32One), continuation, unsafeDenominator);
+
+ LBasicBlock lastNext = m_out.appendTo(unsafeDenominator, continuation);
+
+ LValue neg2ToThe31 = m_out.constInt32(-2147483647-1);
+
+ // FIXME: -2^31 / -1 will actually yield negative zero, so we could have a
+ // separate case for that. But it probably doesn't matter so much.
+ if (nodeUsedAsNumber(m_node->arithNodeFlags())) {
+ speculate(Overflow, noValue(), 0, m_out.isZero32(denominator));
+ speculate(Overflow, noValue(), 0, m_out.equal(numerator, neg2ToThe31));
+ m_out.jump(continuation);
+ } else {
+ // This is the case where we convert the result to an int after we're done. So,
+ // if the denominator is zero, then the result should be result should be zero.
+ // If the denominator is not zero (i.e. it's -1 because we're guarded by the
+ // check above) and the numerator is -2^31 then the result should be -2^31.
+
+ LBasicBlock modByZero = FTL_NEW_BLOCK(m_out, ("ArithMod modulo by zero"));
+ LBasicBlock notModByZero = FTL_NEW_BLOCK(m_out, ("ArithMod not modulo by zero"));
+ LBasicBlock neg2ToThe31ByNeg1 = FTL_NEW_BLOCK(m_out, ("ArithMod -2^31/-1"));
+
+ m_out.branch(m_out.isZero32(denominator), modByZero, notModByZero);
+
+ m_out.appendTo(modByZero, notModByZero);
+ results.append(m_out.anchor(m_out.int32Zero));
+ m_out.jump(done);
+
+ m_out.appendTo(notModByZero, neg2ToThe31ByNeg1);
+ m_out.branch(m_out.equal(numerator, neg2ToThe31), neg2ToThe31ByNeg1, continuation);
+
+ m_out.appendTo(neg2ToThe31ByNeg1, continuation);
+ results.append(m_out.anchor(m_out.int32Zero));
+ m_out.jump(done);
+ }
+
+ m_out.appendTo(continuation, done);
+
+ if (!nodeCanIgnoreNegativeZero(m_node->arithNodeFlags())) {
+ LBasicBlock zeroNumerator = FTL_NEW_BLOCK(m_out, ("ArithMod zero numerator"));
+ LBasicBlock numeratorContinuation = FTL_NEW_BLOCK(m_out, ("ArithMod numerator continuation"));
+
+ m_out.branch(m_out.isZero32(numerator), zeroNumerator, numeratorContinuation);
+
+ LBasicBlock innerLastNext = m_out.appendTo(zeroNumerator, numeratorContinuation);
+
+ speculate(
+ NegativeZero, noValue(), 0, m_out.lessThan(denominator, m_out.int32Zero));
+
+ m_out.jump(numeratorContinuation);
+
+ m_out.appendTo(numeratorContinuation, innerLastNext);
+ }
+
+ results.append(m_out.anchor(m_out.rem(numerator, denominator)));
+ m_out.jump(done);
+
+ m_out.appendTo(done, lastNext);
+
+ m_int32Values.add(m_node, m_out.phi(m_out.int32, results));
+ break;
+ }
+
+ case NumberUse: {
+ m_doubleValues.add(
+ m_node,
+ m_out.doubleRem(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
+ break;
+ }
+
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
void compileArithNegate()
{
switch (m_node->child1().useKind()) {
Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.h (153189 => 153190)
--- trunk/Source/_javascript_Core/ftl/FTLOutput.h 2013-07-25 04:01:20 UTC (rev 153189)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.h 2013-07-25 04:01:22 UTC (rev 153190)
@@ -141,6 +141,7 @@
LValue doubleSub(LValue left, LValue right) { return buildFSub(m_builder, left, right); }
LValue doubleMul(LValue left, LValue right) { return buildFMul(m_builder, left, right); }
LValue doubleDiv(LValue left, LValue right) { return buildFDiv(m_builder, left, right); }
+ LValue doubleRem(LValue left, LValue right) { return buildFRem(m_builder, left, right); }
LValue doubleNeg(LValue value) { return buildFNeg(m_builder, value); }
LValue bitAnd(LValue left, LValue right) { return buildAnd(m_builder, left, right); }