Changeset 228728 in webkit


Ignore:
Timestamp:
Feb 19, 2018 9:01:57 PM (6 years ago)
Author:
Yusuke Suzuki
Message:

[FTL] Support ArrayPush for ArrayStorage
https://bugs.webkit.org/show_bug.cgi?id=182782

Reviewed by Saam Barati.

JSTests:

Existing array-push-multiple-storage.js covers ArrayPush(ArrayStorage) multiple arguments case.

  • stress/array-push-array-storage-beyond-int32.js: Added.

(shouldBe):
(test):

  • stress/array-push-array-storage.js: Added.

(shouldBe):
(test):

  • stress/array-push-multiple-array-storage-beyond-int32.js: Added.

(shouldBe):
(test):

  • stress/array-push-multiple-storage-continuous.js: Added.

(shouldBe):
(test):

Source/JavaScriptCore:

This patch adds support for ArrayPush(ArrayStorage). We just port ArrayPush(ArrayStorage) in DFG to FTL.

  • ftl/FTLAbstractHeapRepository.h:
  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileArrayPush):

Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r228727 r228728  
     12018-02-14  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [FTL] Support ArrayPush for ArrayStorage
     4        https://bugs.webkit.org/show_bug.cgi?id=182782
     5
     6        Reviewed by Saam Barati.
     7
     8        Existing array-push-multiple-storage.js covers ArrayPush(ArrayStorage) multiple arguments case.
     9
     10        * stress/array-push-array-storage-beyond-int32.js: Added.
     11        (shouldBe):
     12        (test):
     13        * stress/array-push-array-storage.js: Added.
     14        (shouldBe):
     15        (test):
     16        * stress/array-push-multiple-array-storage-beyond-int32.js: Added.
     17        (shouldBe):
     18        (test):
     19        * stress/array-push-multiple-storage-continuous.js: Added.
     20        (shouldBe):
     21        (test):
     22
    1232018-02-14  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Source/JavaScriptCore/ChangeLog

    r228727 r228728  
     12018-02-14  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [FTL] Support ArrayPush for ArrayStorage
     4        https://bugs.webkit.org/show_bug.cgi?id=182782
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch adds support for ArrayPush(ArrayStorage). We just port ArrayPush(ArrayStorage) in DFG to FTL.
     9
     10        * ftl/FTLAbstractHeapRepository.h:
     11        * ftl/FTLCapabilities.cpp:
     12        (JSC::FTL::canCompile):
     13        * ftl/FTLLowerDFGToB3.cpp:
     14        (JSC::FTL::DFG::LowerDFGToB3::compileArrayPush):
     15
    1162018-02-14  Yusuke Suzuki  <utatane.tea@gmail.com>
    217
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r228727 r228728  
    320320    case ArrayIndexOf:
    321321    case ArrayPop:
     322    case ArrayPush:
    322323    case ParseInt:
    323324    case AtomicsAdd:
     
    437438        break;
    438439    case PutByValWithThis:
    439         break;
    440     case ArrayPush:
    441         switch (node->arrayMode().type()) {
    442         case Array::Int32:
    443         case Array::Contiguous:
    444         case Array::Double:
    445             break;
    446         default:
    447             return CannotCompile;
    448         }
    449440        break;
    450441    default:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r228727 r228728  
    44684468                operation = m_out.operation(operationArrayPushDoubleMultiple);
    44694469            ValueFromBlock slowResult = m_out.anchor(vmCall(Int64, operation, m_callFrame, base, buffer, m_out.constInt32(elementCount)));
     4470            m_out.storePtr(m_out.constIntPtr(0), m_out.absolute(scratchBuffer->addressOfActiveLength()));
     4471            m_out.jump(continuation);
     4472
     4473            m_out.appendTo(continuation, lastNext);
     4474            setJSValue(m_out.phi(Int64, fastResult, slowResult));
     4475            return;
     4476        }
     4477
     4478        case Array::ArrayStorage: {
     4479            // This ensures that the result of ArrayPush is Int32 in AI.
     4480            int32_t largestPositiveInt32Length = 0x7fffffff - elementCount;
     4481
     4482            LValue prevLength = m_out.load32(storage, m_heaps.Butterfly_publicLength);
     4483            // Refuse to handle bizarre lengths.
     4484            speculate(Uncountable, noValue(), nullptr, m_out.above(prevLength, m_out.constInt32(largestPositiveInt32Length)));
     4485
     4486            if (elementCount == 1) {
     4487                Edge& element = m_graph.varArgChild(m_node, elementOffset);
     4488
     4489                LValue value = lowJSValue(element);
     4490
     4491                LBasicBlock fastPath = m_out.newBlock();
     4492                LBasicBlock slowPath = m_out.newBlock();
     4493                LBasicBlock continuation = m_out.newBlock();
     4494
     4495                m_out.branch(
     4496                    m_out.aboveOrEqual(
     4497                        prevLength, m_out.load32(storage, m_heaps.Butterfly_vectorLength)),
     4498                    rarely(slowPath), usually(fastPath));
     4499
     4500                LBasicBlock lastNext = m_out.appendTo(fastPath, slowPath);
     4501                m_out.store64(
     4502                    value, m_out.baseIndex(m_heaps.ArrayStorage_vector, storage, m_out.zeroExtPtr(prevLength)));
     4503                LValue newLength = m_out.add(prevLength, m_out.int32One);
     4504                m_out.store32(newLength, storage, m_heaps.Butterfly_publicLength);
     4505                m_out.store32(
     4506                    m_out.add(m_out.load32(storage, m_heaps.ArrayStorage_numValuesInVector), m_out.int32One),
     4507                    storage, m_heaps.ArrayStorage_numValuesInVector);
     4508
     4509                ValueFromBlock fastResult = m_out.anchor(boxInt32(newLength));
     4510                m_out.jump(continuation);
     4511
     4512                m_out.appendTo(slowPath, continuation);
     4513                ValueFromBlock slowResult = m_out.anchor(
     4514                    vmCall(Int64, m_out.operation(operationArrayPush), m_callFrame, value, base));
     4515                m_out.jump(continuation);
     4516
     4517                m_out.appendTo(continuation, lastNext);
     4518                setJSValue(m_out.phi(Int64, fastResult, slowResult));
     4519                return;
     4520            }
     4521
     4522            LValue newLength = m_out.add(prevLength, m_out.constInt32(elementCount));
     4523
     4524            LBasicBlock fastPath = m_out.newBlock();
     4525            LBasicBlock slowPath = m_out.newBlock();
     4526            LBasicBlock setup = m_out.newBlock();
     4527            LBasicBlock slowCallPath = m_out.newBlock();
     4528            LBasicBlock continuation = m_out.newBlock();
     4529
     4530            LValue beyondVectorLength = m_out.above(newLength, m_out.load32(storage, m_heaps.Butterfly_vectorLength));
     4531
     4532            m_out.branch(beyondVectorLength, rarely(slowPath), usually(fastPath));
     4533
     4534            LBasicBlock lastNext = m_out.appendTo(fastPath, slowPath);
     4535            m_out.store32(newLength, storage, m_heaps.Butterfly_publicLength);
     4536            m_out.store32(
     4537                m_out.add(m_out.load32(storage, m_heaps.ArrayStorage_numValuesInVector), m_out.constInt32(elementCount)),
     4538                storage, m_heaps.ArrayStorage_numValuesInVector);
     4539            ValueFromBlock fastBufferResult = m_out.anchor(m_out.baseIndex(storage, m_out.zeroExtPtr(prevLength), ScaleEight, ArrayStorage::vectorOffset()));
     4540            m_out.jump(setup);
     4541
     4542            m_out.appendTo(slowPath, setup);
     4543            size_t scratchSize = sizeof(EncodedJSValue) * elementCount;
     4544            ASSERT(scratchSize);
     4545            ScratchBuffer* scratchBuffer = vm().scratchBufferForSize(scratchSize);
     4546            m_out.storePtr(m_out.constIntPtr(scratchSize), m_out.absolute(scratchBuffer->addressOfActiveLength()));
     4547            ValueFromBlock slowBufferResult = m_out.anchor(m_out.constIntPtr(static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer())));
     4548            m_out.jump(setup);
     4549
     4550            m_out.appendTo(setup, slowCallPath);
     4551            LValue buffer = m_out.phi(pointerType(), fastBufferResult, slowBufferResult);
     4552            for (unsigned elementIndex = 0; elementIndex < elementCount; ++elementIndex) {
     4553                Edge& element = m_graph.varArgChild(m_node, elementIndex + elementOffset);
     4554
     4555                LValue value = lowJSValue(element);
     4556                m_out.store64(value, m_out.baseIndex(m_heaps.variables, buffer, m_out.constInt32(elementIndex), jsNumber(elementIndex)));
     4557            }
     4558            ValueFromBlock fastResult = m_out.anchor(boxInt32(newLength));
     4559
     4560            m_out.branch(beyondVectorLength, rarely(slowCallPath), usually(continuation));
     4561
     4562            m_out.appendTo(slowCallPath, continuation);
     4563            ValueFromBlock slowResult = m_out.anchor(vmCall(Int64, m_out.operation(operationArrayPushMultiple), m_callFrame, base, buffer, m_out.constInt32(elementCount)));
    44704564            m_out.storePtr(m_out.constIntPtr(0), m_out.absolute(scratchBuffer->addressOfActiveLength()));
    44714565            m_out.jump(continuation);
     
    1463614730                    m_out.constInt32(ArrayStorageShape)),
    1463714731                m_out.constInt32(SlowPutArrayStorageShape - ArrayStorageShape));
    14638             m_out.branch(isAnArrayStorageShape, usually(checkCase), usually(continuation));
     14732            m_out.branch(isAnArrayStorageShape, unsure(checkCase), unsure(continuation));
    1463914733
    1464014734            LBasicBlock lastNext = m_out.appendTo(checkCase, trueCase);
     
    1464714741                m_out.branch(
    1464814742                    m_out.testNonZero32(indexingType, m_out.constInt32(IsArray)),
    14649                     usually(trueCase), usually(continuation));
     14743                    unsure(trueCase), unsure(continuation));
    1465014744                break;
    1465114745
     
    1465414748                m_out.branch(
    1465514749                    m_out.testIsZero32(indexingType, m_out.constInt32(IsArray)),
    14656                     usually(trueCase), usually(continuation));
     14750                    unsure(trueCase), unsure(continuation));
    1465714751                break;
    1465814752
Note: See TracChangeset for help on using the changeset viewer.