Ignore:
Timestamp:
Jan 23, 2018, 12:39:34 PM (7 years ago)
Author:
[email protected]
Message:

Re-arrange TypedArray JSTypes to match the order of the TypedArrayType enum list.
https://bugs.webkit.org/show_bug.cgi?id=181976
<rdar://problem/36766936>

Reviewed by Filip Pizlo.

  1. The order of TypedArray JSTypes now matches the order the TypedArrayType enum list. I also added static asserts in TypedArrayType.h to enforce this.

Also redefined FOR_EACH_TYPED_ARRAY_TYPE() in terms of

  1. Define 4 new values:
    1. FirstTypedArrayType
    2. LastTypedArrayType
    3. NumberOfTypedArrayTypesExcludingDataView
    4. NumberOfTypedArrayTypes

Use these everywhere where we iterate or bisect the TypedArray JSTypes.

  1. Removed NUMBER_OF_TYPED_ARRAY_TYPES, and use NumberOfTypedArrayTypes instead.
  1. Simplify the code that converts between TypedArrayType and JSType.

Changed typedArrayTypeForType() to be the mirror image of typeForTypedArrayType().
Previously, typedArrayTypeForType() converts DataViewType to NotTypedArray
instead of TypeDataView. Now, it converts to TypeDataView.

This does not result in any change of behavior because typedArrayTypeForType()
is only called in Structure::hasIndexingHeader(), and its result is passed to
isTypedView(), which handles TypeDataView correctly.

  1. Also fixed a bug in SpeculativeJIT::compileGetTypedArrayByteOffset(). If the vector is null, we can skip the rest of the checks. While the current code does not result in incorrect behavior, it is inefficient, and communicates wrong information to the reader i.e. implying that there's something in the dataGPR when there's not. The dataGPR should also be null in this case.
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::handleConstantInternalFunction):

  • dfg/DFGSpeculativeJIT.cpp:

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

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::isTypedArrayView):

  • ftl/FTLOSRExit.cpp:
  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::visitChildren):

  • runtime/JSType.h:
  • runtime/TypedArrayType.cpp:

(JSC::typeForTypedArrayType): Deleted.

  • runtime/TypedArrayType.h:

(JSC::typedArrayTypeForType):
(JSC::typeForTypedArrayType):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r226940 r227434  
    15391539    loadb JSCell::m_type[t0], t2
    15401540    subi FirstArrayType, t2
    1541     bia t2, LastArrayType - FirstArrayType, .opGetByValSlow
     1541    biaeq t2, NumberOfTypedArrayTypesExcludingDataView, .opGetByValSlow
    15421542   
    15431543    # Sweet, now we know that we have a typed array. Do some basic things now.
     
    15451545    biaeq t1, JSArrayBufferView::m_length[t0], .opGetByValSlow
    15461546   
    1547     # Now bisect through the various types. Note that we can treat Uint8ArrayType and
    1548     # Uint8ClampedArrayType the same.
    1549     bia t2, Uint8ClampedArrayType - FirstArrayType, .opGetByValAboveUint8ClampedArray
    1550    
    1551     # We have one of Int8ArrayType .. Uint8ClampedArrayType.
    1552     bia t2, Int16ArrayType - FirstArrayType, .opGetByValInt32ArrayOrUint8Array
    1553    
    1554     # We have one of Int8ArrayType or Int16ArrayType
    1555     bineq t2, Int8ArrayType - FirstArrayType, .opGetByValInt16Array
    1556    
     1547    # Now bisect through the various types:
     1548    #    Int8ArrayType,
     1549    #    Uint8ArrayType,
     1550    #    Uint8ClampedArrayType,
     1551    #    Int16ArrayType,
     1552    #    Uint16ArrayType,
     1553    #    Int32ArrayType,
     1554    #    Uint32ArrayType,
     1555    #    Float32ArrayType,
     1556    #    Float64ArrayType,
     1557
     1558    bia t2, Uint16ArrayType - FirstArrayType, .opGetByValAboveUint16Array
     1559
     1560    # We have one of Int8ArrayType .. Uint16ArrayType.
     1561    bia t2, Uint8ClampedArrayType - FirstArrayType, .opGetByValInt16ArrayOrUint16Array
     1562
     1563    # We have one of Int8ArrayType ... Uint8ClampedArrayType
     1564    bineq t2, Int8ArrayType - FirstArrayType, .opGetByValUint8ArrayOrUint8ClampedArray
     1565
    15571566    # We have Int8ArrayType
    15581567    loadbs [t3, t1], t0
    15591568    finishIntGetByVal(t0, t1)
    15601569
    1561 .opGetByValInt16Array:
     1570.opGetByValUint8ArrayOrUint8ClampedArray:
     1571    # We have either Uint8ArrayType or Uint8ClampedArrayType. They behave the same so that's cool.
     1572    loadb [t3, t1], t0
     1573    finishIntGetByVal(t0, t1)
     1574
     1575.opGetByValInt16ArrayOrUint16Array:
     1576    # We have either Int16ArrayType or Uint16ClampedArrayType.
     1577    bieq t2, Uint16ArrayType - FirstArrayType, .opGetByValUint16Array
     1578
     1579    # We have Int16ArrayType.
    15621580    loadhs [t3, t1, 2], t0
    15631581    finishIntGetByVal(t0, t1)
    15641582
    1565 .opGetByValInt32ArrayOrUint8Array:
    1566     # We have one of Int16Array, Uint8Array, or Uint8ClampedArray.
    1567     bieq t2, Int32ArrayType - FirstArrayType, .opGetByValInt32Array
    1568    
    1569     # We have either Uint8Array or Uint8ClampedArray. They behave the same so that's cool.
    1570     loadb [t3, t1], t0
    1571     finishIntGetByVal(t0, t1)
    1572 
    1573 .opGetByValInt32Array:
    1574     loadi [t3, t1, 4], t0
    1575     finishIntGetByVal(t0, t1)
    1576 
    1577 .opGetByValAboveUint8ClampedArray:
    1578     # We have one of Uint16ArrayType .. Float64ArrayType.
    1579     bia t2, Uint32ArrayType - FirstArrayType, .opGetByValAboveUint32Array
    1580    
    1581     # We have either Uint16ArrayType or Uint32ArrayType.
    1582     bieq t2, Uint32ArrayType - FirstArrayType, .opGetByValUint32Array
    1583 
     1583.opGetByValUint16Array:
    15841584    # We have Uint16ArrayType.
    15851585    loadh [t3, t1, 2], t0
    15861586    finishIntGetByVal(t0, t1)
    15871587
     1588.opGetByValAboveUint16Array:
     1589    # We have one of Int32ArrayType .. Float64ArrayType.
     1590    bia t2, Uint32ArrayType - FirstArrayType, .opGetByValFloat32ArrayOrFloat64Array
     1591
     1592    # We have either Int32ArrayType or Uint32ArrayType
     1593    bineq t2, Int32ArrayType - FirstArrayType, .opGetByValUint32Array
     1594
     1595    # We have Int32ArrayType
     1596    loadi [t3, t1, 4], t0
     1597    finishIntGetByVal(t0, t1)
     1598
    15881599.opGetByValUint32Array:
     1600    # We have Uint32ArrayType.
    15891601    # This is the hardest part because of large unsigned values.
    15901602    loadi [t3, t1, 4], t0
     
    15921604    finishIntGetByVal(t0, t1)
    15931605
    1594 .opGetByValAboveUint32Array:
     1606.opGetByValFloat32ArrayOrFloat64Array:
    15951607    # We have one of Float32ArrayType or Float64ArrayType. Sadly, we cannot handle Float32Array
    15961608    # inline yet. That would require some offlineasm changes.
Note: See TracChangeset for help on using the changeset viewer.