Ignore:
Timestamp:
Sep 17, 2013, 6:06:49 PM (12 years ago)
Author:
[email protected]
Message:

Use CheckStructure for checking the types of typed arrays whenever possible
https://bugs.webkit.org/show_bug.cgi?id=121514

Reviewed by Oliver Hunt.

  • bytecode/ArrayProfile.cpp:

(JSC::ArrayProfile::computeUpdatedPrediction):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::fromObserved):
(JSC::DFG::ArrayMode::refine):
(JSC::DFG::ArrayMode::originalArrayStructure):
(JSC::DFG::arrayClassToString):

  • dfg/DFGArrayMode.h:

(JSC::DFG::ArrayMode::ArrayMode):
(JSC::DFG::ArrayMode::arrayModesWithIndexingShape):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::isOriginalTypedArrayStructure):

File:
1 edited

Legend:

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

    r155497 r156017  
    3737ArrayMode ArrayMode::fromObserved(const ConcurrentJITLocker& locker, ArrayProfile* profile, Array::Action action, bool makeSafe)
    3838{
     39    Array::Class nonArray;
     40    if (profile->usesOriginalArrayStructures(locker))
     41        nonArray = Array::OriginalNonArray;
     42    else
     43        nonArray = Array::NonArray;
     44   
    3945    ArrayModes observed = profile->observedArrayModes(locker);
    4046    switch (observed) {
     
    4349    case asArrayModes(NonArray):
    4450        if (action == Array::Write && !profile->mayInterceptIndexedAccesses(locker))
    45             return ArrayMode(Array::Undecided, Array::NonArray, Array::OutOfBounds, Array::Convert);
    46         return ArrayMode(Array::SelectUsingPredictions);
     51            return ArrayMode(Array::Undecided, nonArray, Array::OutOfBounds, Array::Convert);
     52        return ArrayMode(Array::SelectUsingPredictions, nonArray);
    4753
    4854    case asArrayModes(ArrayWithUndecided):
     
    5763
    5864    case asArrayModes(NonArrayWithInt32):
    59         return ArrayMode(Array::Int32, Array::NonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     65        return ArrayMode(Array::Int32, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    6066    case asArrayModes(ArrayWithInt32):
    6167        return ArrayMode(Array::Int32, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);
     
    6470
    6571    case asArrayModes(NonArrayWithDouble):
    66         return ArrayMode(Array::Double, Array::NonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     72        return ArrayMode(Array::Double, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    6773    case asArrayModes(ArrayWithDouble):
    6874        return ArrayMode(Array::Double, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);
     
    7177
    7278    case asArrayModes(NonArrayWithContiguous):
    73         return ArrayMode(Array::Contiguous, Array::NonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     79        return ArrayMode(Array::Contiguous, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    7480    case asArrayModes(ArrayWithContiguous):
    7581        return ArrayMode(Array::Contiguous, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);
     
    7884
    7985    case asArrayModes(NonArrayWithArrayStorage):
    80         return ArrayMode(Array::ArrayStorage, Array::NonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     86        return ArrayMode(Array::ArrayStorage, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    8187    case asArrayModes(NonArrayWithSlowPutArrayStorage):
    8288    case asArrayModes(NonArrayWithArrayStorage) | asArrayModes(NonArrayWithSlowPutArrayStorage):
    83         return ArrayMode(Array::SlowPutArrayStorage, Array::NonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
     89        return ArrayMode(Array::SlowPutArrayStorage, nonArray, Array::AsIs).withProfile(locker, profile, makeSafe);
    8490    case asArrayModes(ArrayWithArrayStorage):
    8591        return ArrayMode(Array::ArrayStorage, Array::Array, Array::AsIs).withProfile(locker, profile, makeSafe);
     
    118124            arrayClass = Array::Array;
    119125        else if (hasSeenNonArray(observed))
    120             arrayClass = Array::NonArray;
     126            arrayClass = nonArray;
    121127        else
    122128            arrayClass = Array::PossiblyArray;
     
    185191       
    186192        if (isStringSpeculation(base))
    187             return ArrayMode(Array::String);
     193            return withType(Array::String);
    188194       
    189195        if (isArgumentsSpeculation(base))
    190             return ArrayMode(Array::Arguments);
     196            return withType(Array::Arguments);
    191197       
    192198        if (isInt8ArraySpeculation(base))
    193             return ArrayMode(Array::Int8Array);
     199            return withType(Array::Int8Array);
    194200       
    195201        if (isInt16ArraySpeculation(base))
    196             return ArrayMode(Array::Int16Array);
     202            return withType(Array::Int16Array);
    197203       
    198204        if (isInt32ArraySpeculation(base))
    199             return ArrayMode(Array::Int32Array);
     205            return withType(Array::Int32Array);
    200206       
    201207        if (isUint8ArraySpeculation(base))
    202             return ArrayMode(Array::Uint8Array);
     208            return withType(Array::Uint8Array);
    203209       
    204210        if (isUint8ClampedArraySpeculation(base))
    205             return ArrayMode(Array::Uint8ClampedArray);
     211            return withType(Array::Uint8ClampedArray);
    206212       
    207213        if (isUint16ArraySpeculation(base))
    208             return ArrayMode(Array::Uint16Array);
     214            return withType(Array::Uint16Array);
    209215       
    210216        if (isUint32ArraySpeculation(base))
    211             return ArrayMode(Array::Uint32Array);
     217            return withType(Array::Uint32Array);
    212218       
    213219        if (isFloat32ArraySpeculation(base))
    214             return ArrayMode(Array::Float32Array);
     220            return withType(Array::Float32Array);
    215221       
    216222        if (isFloat64ArraySpeculation(base))
    217             return ArrayMode(Array::Float64Array);
     223            return withType(Array::Float64Array);
    218224
    219225        return ArrayMode(Array::Generic);
     
    226232Structure* ArrayMode::originalArrayStructure(Graph& graph, const CodeOrigin& codeOrigin) const
    227233{
    228     if (!isJSArrayWithOriginalStructure())
    229         return 0;
    230    
    231234    JSGlobalObject* globalObject = graph.globalObjectFor(codeOrigin);
    232235   
    233     switch (type()) {
    234     case Array::Int32:
    235         return globalObject->originalArrayStructureForIndexingType(ArrayWithInt32);
    236     case Array::Double:
    237         return globalObject->originalArrayStructureForIndexingType(ArrayWithDouble);
    238     case Array::Contiguous:
    239         return globalObject->originalArrayStructureForIndexingType(ArrayWithContiguous);
    240     case Array::ArrayStorage:
    241         return globalObject->originalArrayStructureForIndexingType(ArrayWithArrayStorage);
    242     default:
    243         CRASH();
     236    switch (arrayClass()) {
     237    case Array::OriginalArray: {
     238        switch (type()) {
     239        case Array::Int32:
     240            return globalObject->originalArrayStructureForIndexingType(ArrayWithInt32);
     241        case Array::Double:
     242            return globalObject->originalArrayStructureForIndexingType(ArrayWithDouble);
     243        case Array::Contiguous:
     244            return globalObject->originalArrayStructureForIndexingType(ArrayWithContiguous);
     245        case Array::ArrayStorage:
     246            return globalObject->originalArrayStructureForIndexingType(ArrayWithArrayStorage);
     247        default:
     248            CRASH();
     249            return 0;
     250        }
     251    }
     252       
     253    case Array::OriginalNonArray: {
     254        TypedArrayType type = typedArrayType();
     255        if (type == NotTypedArray)
     256            return 0;
     257       
     258        return globalObject->typedArrayStructure(type);
     259    }
     260       
     261    default:
    244262        return 0;
    245263    }
     
    422440    case Array::NonArray:
    423441        return "NonArray";
     442    case Array::OriginalNonArray:
     443        return "OriginalNonArray";
    424444    case Array::PossiblyArray:
    425445        return "PossiblyArray";
Note: See TracChangeset for help on using the changeset viewer.