Skip to content
  • fpizlo@apple.com's avatar
    DFG should optimize typedArray.byteLength · c09dc63d
    fpizlo@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=119909
    
    Source/JavaScriptCore: 
    
    Reviewed by Oliver Hunt.
            
    This adds typedArray.byteLength inlining to the DFG, and does so without changing
    the IR: byteLength is turned into GetArrayLength followed by BitLShift. This is
    legal since the byteLength of a typed array cannot exceed
    numeric_limits<int32_t>::max().
    
    * bytecode/SpeculatedType.cpp:
    (JSC::typedArrayTypeFromSpeculation):
    * bytecode/SpeculatedType.h:
    * dfg/DFGArrayMode.cpp:
    (JSC::DFG::toArrayType):
    * dfg/DFGArrayMode.h:
    * dfg/DFGFixupPhase.cpp:
    (JSC::DFG::FixupPhase::fixupNode):
    (JSC::DFG::FixupPhase::attemptToMakeGetArrayLength):
    (JSC::DFG::FixupPhase::attemptToMakeGetByteLength):
    (JSC::DFG::FixupPhase::convertToGetArrayLength):
    (JSC::DFG::FixupPhase::prependGetArrayLength):
    * dfg/DFGGraph.h:
    (JSC::DFG::Graph::constantRegisterForConstant):
    (JSC::DFG::Graph::convertToConstant):
    * runtime/TypedArrayType.h:
    (JSC::logElementSize):
    (JSC::elementSize):
    
    LayoutTests: 
    
    Reviewed by Oliver Hunt.
            
    Convert two of the tyepd array tests to use byteLength instead of length.
    These tests show speed-ups around 2.5x-5x.
    
    * fast/js/regress/Int16Array-bubble-sort-with-byteLength-expected.txt: Added.
    * fast/js/regress/Int16Array-bubble-sort-with-byteLength.html: Added.
    * fast/js/regress/Int8Array-load-with-byteLength-expected.txt: Added.
    * fast/js/regress/Int8Array-load-with-byteLength.html: Added.
    * fast/js/regress/script-tests/Int16Array-bubble-sort-with-byteLength.js: Added.
    (bubbleSort):
    (myRandom):
    (validateSort):
    * fast/js/regress/script-tests/Int8Array-load-with-byteLength.js: Added.
    (adler32):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154218 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    c09dc63d