Ignore:
Timestamp:
Aug 19, 2013, 4:16:01 PM (12 years ago)
Author:
[email protected]
Message:

DFG should inline typedArray.byteOffset
https://bugs.webkit.org/show_bug.cgi?id=119962

Source/JavaScriptCore:

Reviewed by Oliver Hunt.

This adds a new node, GetTypedArrayByteOffset, which inlines
typedArray.byteOffset.

Also, I improved a bunch of the clobbering logic related to typed arrays
and clobbering in general. For example, PutByOffset/PutStructure are not
clobber-world so they can be handled by most default cases in CSE. Also,
It's better to use the 'Class_field' notation for typed arrays now that
they no longer involve magical descriptor thingies.

  • bytecode/SpeculatedType.h:
  • dfg/DFGAbstractHeap.h:
  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::::executeEffects):

  • dfg/DFGArrayMode.h:

(JSC::DFG::neverNeedsStorage):

  • dfg/DFGCSEPhase.cpp:

(JSC::DFG::CSEPhase::getByValLoadElimination):
(JSC::DFG::CSEPhase::getByOffsetLoadElimination):
(JSC::DFG::CSEPhase::getPropertyStorageLoadElimination):
(JSC::DFG::CSEPhase::checkArrayElimination):
(JSC::DFG::CSEPhase::getIndexedPropertyStorageLoadElimination):
(JSC::DFG::CSEPhase::getTypedArrayByteOffsetLoadElimination):
(JSC::DFG::CSEPhase::performNodeCSE):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::attemptToMakeGetTypedArrayByteLength):
(JSC::DFG::FixupPhase::convertToGetArrayLength):
(JSC::DFG::FixupPhase::attemptToMakeGetTypedArrayByteOffset):

  • dfg/DFGNodeType.h:
  • dfg/DFGPredictionPropagationPhase.cpp:

(JSC::DFG::PredictionPropagationPhase::propagate):

  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGTypeCheckHoistingPhase.cpp:

(JSC::DFG::TypeCheckHoistingPhase::identifyRedundantStructureChecks):

  • runtime/ArrayBuffer.h:

(JSC::ArrayBuffer::offsetOfData):

  • runtime/Butterfly.h:

(JSC::Butterfly::offsetOfArrayBuffer):

  • runtime/IndexingHeader.h:

(JSC::IndexingHeader::offsetOfArrayBuffer):

LayoutTests:

Reviewed by Oliver Hunt.

  • fast/js/dfg-byteOffset-neuter.html: Added.
  • fast/js/dfg-byteOffset-neuter-expected.txt: Added.
  • fast/js/regress/ArrayBuffer-Int32Array-byteOffset-expected.txt: Added.
  • fast/js/regress/ArrayBuffer-Int32Array-byteOffset.html: Added.
  • fast/js/regress/script-tests/ArrayBuffer-Int32Array-byteOffset.js: Added.
  • fast/js/script-tests/dfg-byteOffset-neuter.js: Added.

(foo):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp

    r153292 r154305  
    397397                return 0;
    398398            }
    399             case PutStructure:
    400             case PutByOffset:
    401                 // GetByVal currently always speculates that it's accessing an
    402                 // array with an integer index, which means that it's impossible
    403                 // for a structure change or a put to property storage to affect
    404                 // the GetByVal.
    405                 break;
    406399            default:
    407400                if (m_graph.clobbersWorld(node))
     
    635628                break;
    636629               
    637             case PutStructure:
    638                 // Changing the structure cannot change the outcome of a property get.
    639                 break;
    640                
    641630            case PutByVal:
    642631            case PutByValAlias:
     
    725714                return 0;
    726715               
    727             case PutByOffset:
    728             case PutStructure:
    729                 // Changing the structure or putting to the storage cannot
    730                 // change the property storage pointer.
    731                 break;
    732                
    733716            case PutByVal:
    734717            case PutByValAlias:
     
    764747
    765748            switch (node->op()) {
    766             case PutByOffset:
    767             case PutStructure:
    768                 // Changing the structure or putting to the storage cannot
    769                 // change the property storage pointer.
    770                 break;
    771                
    772749            case CheckArray:
    773750                if (node->child1() == child1 && node->arrayMode() == arrayMode)
     
    804781            }
    805782
    806             case PutByOffset:
    807             case PutStructure:
    808                 // Changing the structure or putting to the storage cannot
    809                 // change the property storage pointer.
    810                 break;
    811                
     783            default:
     784                if (m_graph.clobbersWorld(node))
     785                    return 0;
     786                break;
     787            }
     788        }
     789        return 0;
     790    }
     791   
     792    Node* getTypedArrayByteOffsetLoadElimination(Node* child1)
     793    {
     794        for (unsigned i = m_indexInBlock; i--;) {
     795            Node* node = m_currentBlock->at(i);
     796            if (node == child1)
     797                break;
     798
     799            switch (node->op()) {
     800            case GetTypedArrayByteOffset: {
     801                if (node->child1() == child1)
     802                    return node;
     803                break;
     804            }
     805
    812806            default:
    813807                if (m_graph.clobbersWorld(node))
     
    13441338            break;
    13451339        }
     1340           
     1341        case GetTypedArrayByteOffset: {
     1342            if (cseMode == StoreElimination)
     1343                break;
     1344            setReplacement(getTypedArrayByteOffsetLoadElimination(node->child1().node()));
     1345            break;
     1346        }
    13461347
    13471348        case GetButterfly:
Note: See TracChangeset for help on using the changeset viewer.