Ignore:
Timestamp:
Aug 16, 2013, 10:50:48 PM (12 years ago)
Author:
[email protected]
Message:

DFG should optimize typedArray.byteLength
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):

File:
1 edited

Legend:

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

    r154127 r154218  
    485485}
    486486
     487Array::Type toArrayType(TypedArrayType type)
     488{
     489    switch (type) {
     490    case TypeInt8:
     491        return Array::Int8Array;
     492    case TypeInt16:
     493        return Array::Int16Array;
     494    case TypeInt32:
     495        return Array::Int32Array;
     496    case TypeUint8:
     497        return Array::Uint8Array;
     498    case TypeUint8Clamped:
     499        return Array::Uint8ClampedArray;
     500    case TypeUint16:
     501        return Array::Uint16Array;
     502    case TypeUint32:
     503        return Array::Uint32Array;
     504    case TypeFloat32:
     505        return Array::Float32Array;
     506    case TypeFloat64:
     507        return Array::Float64Array;
     508    default:
     509        return Array::Generic;
     510    }
     511}
     512
    487513void ArrayMode::dump(PrintStream& out) const
    488514{
Note: See TracChangeset for help on using the changeset viewer.