Diff
Modified: branches/jsCStack/Source/_javascript_Core/ChangeLog (163003 => 163004)
--- branches/jsCStack/Source/_javascript_Core/ChangeLog 2014-01-29 06:12:19 UTC (rev 163003)
+++ branches/jsCStack/Source/_javascript_Core/ChangeLog 2014-01-29 06:29:22 UTC (rev 163004)
@@ -1,5 +1,26 @@
2014-01-28 Filip Pizlo <fpi...@apple.com>
+ FTL should support ArrayPop
+ https://bugs.webkit.org/show_bug.cgi?id=127749
+
+ Reviewed by Geoffrey Garen.
+
+ * ftl/FTLCapabilities.cpp:
+ (JSC::FTL::canCompile):
+ * ftl/FTLIntrinsicRepository.h:
+ * ftl/FTLLowerDFGToLLVM.cpp:
+ (JSC::FTL::LowerDFGToLLVM::compileNode):
+ (JSC::FTL::LowerDFGToLLVM::compileArrayPush):
+ (JSC::FTL::LowerDFGToLLVM::compileArrayPop):
+ * tests/stress/array-pop-contiguous.js: Added.
+ (foo):
+ * tests/stress/array-pop-double.js: Added.
+ (foo):
+ * tests/stress/array-pop-int32.js: Added.
+ (foo):
+
+2014-01-28 Filip Pizlo <fpi...@apple.com>
+
DFG ArrayPop double array mishandles the NaN hole installation
https://bugs.webkit.org/show_bug.cgi?id=127813
Modified: branches/jsCStack/Source/_javascript_Core/ftl/FTLCapabilities.cpp (163003 => 163004)
--- branches/jsCStack/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2014-01-29 06:12:19 UTC (rev 163003)
+++ branches/jsCStack/Source/_javascript_Core/ftl/FTLCapabilities.cpp 2014-01-29 06:29:22 UTC (rev 163004)
@@ -202,6 +202,7 @@
}
break;
case ArrayPush:
+ case ArrayPop:
switch (node->arrayMode().type()) {
case Array::Int32:
case Array::Contiguous:
Modified: branches/jsCStack/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h (163003 => 163004)
--- branches/jsCStack/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h 2014-01-29 06:12:19 UTC (rev 163003)
+++ branches/jsCStack/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h 2014-01-29 06:29:22 UTC (rev 163004)
@@ -62,6 +62,7 @@
macro(C_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \
macro(I_JITOperation_EJss, functionType(intPtr, intPtr, intPtr)) \
macro(J_JITOperation_E, functionType(int64, intPtr)) \
+ macro(J_JITOperation_EA, functionType(int64, intPtr, intPtr)) \
macro(J_JITOperation_EAZ, functionType(int64, intPtr, intPtr, int32)) \
macro(J_JITOperation_EDA, functionType(int64, intPtr, doubleType, intPtr)) \
macro(J_JITOperation_EJA, functionType(int64, intPtr, int64, intPtr)) \
Modified: branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (163003 => 163004)
--- branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2014-01-29 06:12:19 UTC (rev 163003)
+++ branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2014-01-29 06:29:22 UTC (rev 163004)
@@ -419,6 +419,9 @@
case ArrayPush:
compileArrayPush();
break;
+ case ArrayPop:
+ compileArrayPop();
+ break;
case NewObject:
compileNewObject();
break;
@@ -2215,9 +2218,9 @@
LValue prevLength = m_out.load32(storage, m_heaps.Butterfly_publicLength);
- LBasicBlock fastPath = FTL_NEW_BLOCK(m_out, ("ArrayPush int32/contiguous fast path"));
- LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, ("ArrayPush int32/contiguous slow path"));
- LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ArrayPush int32/contiguous continuation"));
+ LBasicBlock fastPath = FTL_NEW_BLOCK(m_out, ("ArrayPush fast path"));
+ LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, ("ArrayPush slow path"));
+ LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ArrayPush continuation"));
m_out.branch(
m_out.aboveOrEqual(
@@ -2256,6 +2259,60 @@
}
}
+ void compileArrayPop()
+ {
+ LValue base = lowCell(m_node->child1());
+ LValue storage = lowStorage(m_node->child2());
+
+ switch (m_node->arrayMode().type()) {
+ case Array::Int32:
+ case Array::Double:
+ case Array::Contiguous: {
+ IndexedAbstractHeap& heap = m_heaps.forArrayType(m_node->arrayMode().type());
+
+ LBasicBlock fastCase = FTL_NEW_BLOCK(m_out, ("ArrayPop fast case"));
+ LBasicBlock slowCase = FTL_NEW_BLOCK(m_out, ("ArrayPop slow case"));
+ LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ArrayPop continuation"));
+
+ LValue prevLength = m_out.load32(storage, m_heaps.Butterfly_publicLength);
+
+ Vector<ValueFromBlock, 3> results;
+ results.append(m_out.anchor(m_out.constInt64(JSValue::encode(jsUndefined()))));
+ m_out.branch(m_out.isZero32(prevLength), continuation, fastCase);
+
+ LBasicBlock lastNext = m_out.appendTo(fastCase, slowCase);
+ LValue newLength = m_out.sub(prevLength, m_out.int32One);
+ m_out.store32(newLength, storage, m_heaps.Butterfly_publicLength);
+ TypedPointer pointer = m_out.baseIndex(
+ heap, storage, m_out.zeroExt(newLength, m_out.intPtr));
+ if (m_node->arrayMode().type() != Array::Double) {
+ LValue result = m_out.load64(pointer);
+ m_out.store64(m_out.int64Zero, pointer);
+ results.append(m_out.anchor(result));
+ m_out.branch(m_out.notZero64(result), continuation, slowCase);
+ } else {
+ LValue result = m_out.loadDouble(pointer);
+ m_out.store64(m_out.constInt64(bitwise_cast<int64_t>(QNaN)), pointer);
+ results.append(m_out.anchor(boxDouble(result)));
+ m_out.branch(m_out.doubleEqual(result, result), continuation, slowCase);
+ }
+
+ m_out.appendTo(slowCase, continuation);
+ results.append(m_out.anchor(vmCall(
+ m_out.operation(operationArrayPopAndRecoverLength), m_callFrame, base)));
+ m_out.jump(continuation);
+
+ m_out.appendTo(continuation, lastNext);
+ setJSValue(m_out.phi(m_out.int64, results));
+ return;
+ }
+
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ return;
+ }
+ }
+
void compileNewObject()
{
Structure* structure = m_node->structure();
Added: branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-contiguous.js (0 => 163004)
--- branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-contiguous.js (rev 0)
+++ branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-contiguous.js 2014-01-29 06:29:22 UTC (rev 163004)
@@ -0,0 +1,11 @@
+function foo(array) {
+ return [array.pop(), array.pop(), array.pop(), array.pop()];
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+ var result = foo(["foo", "bar", "baz"]);
+ if (result.toString() != "baz,bar,foo,")
+ throw "Error: bad result: " + result;
+}
Added: branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-double.js (0 => 163004)
--- branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-double.js (rev 0)
+++ branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-double.js 2014-01-29 06:29:22 UTC (rev 163004)
@@ -0,0 +1,11 @@
+function foo(array) {
+ return [array.pop(), array.pop(), array.pop(), array.pop()];
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+ var result = foo([1.5, 2.5, 3.5]);
+ if (result.toString() != "3.5,2.5,1.5,")
+ throw "Error: bad result: " + result;
+}
Added: branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-int32.js (0 => 163004)
--- branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-int32.js (rev 0)
+++ branches/jsCStack/Source/_javascript_Core/tests/stress/array-pop-int32.js 2014-01-29 06:29:22 UTC (rev 163004)
@@ -0,0 +1,11 @@
+function foo(array) {
+ return [array.pop(), array.pop(), array.pop(), array.pop()];
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+ var result = foo([1, 2, 3]);
+ if (result.toString() != "3,2,1,")
+ throw "Error: bad result: " + result;
+}