Changeset 162866 in webkit


Ignore:
Timestamp:
Jan 27, 2014, 1:52:39 PM (12 years ago)
Author:
fpizlo@apple.com
Message:

FTL should support NewArrayWithSize
https://bugs.webkit.org/show_bug.cgi?id=127698

Reviewed by Mark Hahnenberg.

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileNewArrayWithSize):

  • tests/stress/new-array-storage-array-with-size.js: Added.

(foo):
(test):

  • tests/stress/new-array-with-size-with-bad-time.js: Added.

(foo):

  • tests/stress/new-contiguous-array-with-size.js: Added.

(foo):
(test):

  • tests/stress/new-double-array-with-size.js: Added.

(foo):
(test):

  • tests/stress/new-int32-array-with-size.js: Added.

(foo):
(test):

  • tests/stress/new-undecided-array-with-size.js: Added.

(foo):
(test):

Location:
branches/jsCStack/Source/JavaScriptCore
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/jsCStack/Source/JavaScriptCore/ChangeLog

    r162861 r162866  
     12014-01-27  Filip Pizlo  <fpizlo@apple.com>
     2
     3        FTL should support NewArrayWithSize
     4        https://bugs.webkit.org/show_bug.cgi?id=127698
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        * ftl/FTLCapabilities.cpp:
     9        (JSC::FTL::canCompile):
     10        * ftl/FTLLowerDFGToLLVM.cpp:
     11        (JSC::FTL::LowerDFGToLLVM::compileNode):
     12        (JSC::FTL::LowerDFGToLLVM::compileNewArrayWithSize):
     13        * tests/stress/new-array-storage-array-with-size.js: Added.
     14        (foo):
     15        (test):
     16        * tests/stress/new-array-with-size-with-bad-time.js: Added.
     17        (foo):
     18        * tests/stress/new-contiguous-array-with-size.js: Added.
     19        (foo):
     20        (test):
     21        * tests/stress/new-double-array-with-size.js: Added.
     22        (foo):
     23        (test):
     24        * tests/stress/new-int32-array-with-size.js: Added.
     25        (foo):
     26        (test):
     27        * tests/stress/new-undecided-array-with-size.js: Added.
     28        (foo):
     29        (test):
     30
    1312014-01-27  Michael Saboff  <msaboff@apple.com>
    232
  • branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r162717 r162866  
    131131    case ToString:
    132132    case MakeRope:
     133    case NewArrayWithSize:
    133134        // These are OK.
    134135        break;
  • branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r162854 r162866  
    423423        case NewArrayBuffer:
    424424            compileNewArrayBuffer();
     425            break;
     426        case NewArrayWithSize:
     427            compileNewArrayWithSize();
    425428            break;
    426429        case AllocatePropertyStorage:
     
    22382241    }
    22392242   
     2243    void compileNewArrayWithSize()
     2244    {
     2245        LValue publicLength = lowInt32(m_node->child1());
     2246       
     2247        JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->codeOrigin);
     2248        Structure* structure = globalObject->arrayStructureForIndexingTypeDuringAllocation(
     2249            m_node->indexingType());
     2250       
     2251        if (!globalObject->isHavingABadTime() && !hasArrayStorage(m_node->indexingType())) {
     2252            ASSERT(
     2253                hasUndecided(structure->indexingType())
     2254                || hasInt32(structure->indexingType())
     2255                || hasDouble(structure->indexingType())
     2256                || hasContiguous(structure->indexingType()));
     2257
     2258            LBasicBlock fastCase = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize fast case"));
     2259            LBasicBlock largeCase = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize large case"));
     2260            LBasicBlock failCase = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize fail case"));
     2261            LBasicBlock slowCase = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize slow case"));
     2262            LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize continuation"));
     2263           
     2264            m_out.branch(
     2265                m_out.aboveOrEqual(publicLength, m_out.constInt32(MIN_SPARSE_ARRAY_INDEX)),
     2266                largeCase, fastCase);
     2267
     2268            LBasicBlock lastNext = m_out.appendTo(fastCase, largeCase);
     2269           
     2270            // We don't round up to BASE_VECTOR_LEN for new Array(blah).
     2271            LValue vectorLength = publicLength;
     2272           
     2273            LValue payloadSize =
     2274                m_out.shl(m_out.zeroExt(vectorLength, m_out.intPtr), m_out.constIntPtr(3));
     2275           
     2276            LValue butterflySize = m_out.add(
     2277                payloadSize, m_out.constIntPtr(sizeof(IndexingHeader)));
     2278           
     2279            LValue endOfStorage = allocateBasicStorageAndGetEnd(butterflySize, failCase);
     2280           
     2281            LValue butterfly = m_out.sub(endOfStorage, payloadSize);
     2282           
     2283            LValue object = allocateObject<JSArray>(
     2284                m_out.constIntPtr(structure), butterfly, failCase);
     2285           
     2286            m_out.store32(publicLength, butterfly, m_heaps.Butterfly_publicLength);
     2287            m_out.store32(vectorLength, butterfly, m_heaps.Butterfly_vectorLength);
     2288           
     2289            if (hasDouble(m_node->indexingType())) {
     2290                LBasicBlock initLoop = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize double init loop"));
     2291                LBasicBlock initDone = FTL_NEW_BLOCK(m_out, ("NewArrayWithSize double init done"));
     2292               
     2293                ValueFromBlock originalIndex = m_out.anchor(vectorLength);
     2294                ValueFromBlock originalPointer = m_out.anchor(butterfly);
     2295                m_out.branch(m_out.notZero32(vectorLength), initLoop, initDone);
     2296               
     2297                LBasicBlock initLastNext = m_out.appendTo(initLoop, initDone);
     2298                LValue index = m_out.phi(m_out.int32, originalIndex);
     2299                LValue pointer = m_out.phi(m_out.intPtr, originalPointer);
     2300               
     2301                m_out.store64(
     2302                    m_out.constInt64(bitwise_cast<int64_t>(QNaN)),
     2303                    TypedPointer(m_heaps.indexedDoubleProperties.atAnyIndex(), pointer));
     2304               
     2305                LValue nextIndex = m_out.sub(index, m_out.int32One);
     2306                addIncoming(index, m_out.anchor(nextIndex));
     2307                addIncoming(pointer, m_out.anchor(m_out.add(pointer, m_out.intPtrEight)));
     2308                m_out.branch(m_out.notZero32(nextIndex), initLoop, initDone);
     2309               
     2310                m_out.appendTo(initDone, initLastNext);
     2311            }
     2312           
     2313            ValueFromBlock fastResult = m_out.anchor(object);
     2314            m_out.jump(continuation);
     2315           
     2316            m_out.appendTo(largeCase, failCase);
     2317            ValueFromBlock largeStructure = m_out.anchor(m_out.constIntPtr(
     2318                globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithArrayStorage)));
     2319            m_out.jump(slowCase);
     2320           
     2321            m_out.appendTo(failCase, slowCase);
     2322            ValueFromBlock failStructure = m_out.anchor(m_out.constIntPtr(structure));
     2323            m_out.jump(slowCase);
     2324           
     2325            m_out.appendTo(slowCase, continuation);
     2326            LValue structureValue = m_out.phi(
     2327                m_out.intPtr, largeStructure, failStructure);
     2328            ValueFromBlock slowResult = m_out.anchor(vmCall(
     2329                m_out.operation(operationNewArrayWithSize),
     2330                m_callFrame, structureValue, publicLength));
     2331            m_out.jump(continuation);
     2332           
     2333            m_out.appendTo(continuation, lastNext);
     2334            setJSValue(m_out.phi(m_out.intPtr, fastResult, slowResult));
     2335            return;
     2336        }
     2337       
     2338        LValue structureValue = m_out.select(
     2339            m_out.aboveOrEqual(publicLength, m_out.constInt32(MIN_SPARSE_ARRAY_INDEX)),
     2340            m_out.constIntPtr(
     2341                globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithArrayStorage)),
     2342            m_out.constIntPtr(structure));
     2343        setJSValue(vmCall(m_out.operation(operationNewArrayWithSize), m_callFrame, structureValue, publicLength));
     2344    }
     2345   
    22402346    void compileAllocatePropertyStorage()
    22412347    {
Note: See TracChangeset for help on using the changeset viewer.