⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 155376 in webkit


Ignore:
Timestamp:
Sep 9, 2013, 1:21:27 PM (13 years ago)
Author:
Lucas Forschler
Message:

Rollout 155365.

Location:
branches/safari-534.59-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-534.59-branch/Source/JavaScriptCore/ChangeLog

    r155365 r155376  
    1 2013-09-09  Lucas Forschler  <lforschler@apple.com>
    2 
    3         Merge fix for <rdar:/problem/14909253>
    4    
    5     2013-09-09  Filip Pizlo  <fpizlo@apple.com>
    6    
    7             * runtime/ArrayPrototype.cpp:
    8             (JSC::arrayProtoFuncSort):
    9             * runtime/JSArray.cpp:
    10             (JSC::JSArray::sortNumeric):
    11             (JSC::JSArray::sort):
    12             (JSC::JSArray::compactForSorting):
    13             * runtime/JSArray.h:
    14             (JSC::JSArray::hasSparseMap):
    15 
    1612013-03-14  Lucas Forschler  <lforschler@apple.com>
    172
  • branches/safari-534.59-branch/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r155365 r155376  
    539539    CallType callType = getCallData(function, callData);
    540540
    541     if (thisObj->classInfo() == &JSArray::s_info && !asArray(thisObj)->hasSparseMap()) {
     541    if (thisObj->classInfo() == &JSArray::s_info) {
    542542        if (isNumericCompareFunction(exec, callType, callData))
    543543            asArray(thisObj)->sortNumeric(exec, function, callType, callData);
  • branches/safari-534.59-branch/Source/JavaScriptCore/runtime/JSArray.cpp

    r155365 r155376  
    965965
    966966    unsigned lengthNotIncludingUndefined = compactForSorting();
    967    
    968     ASSERT(!storage->m_sparseValueMap);
     967    if (storage->m_sparseValueMap) {
     968        throwOutOfMemoryError(exec);
     969        return;
     970    }
    969971
    970972    if (!lengthNotIncludingUndefined)
     
    996998
    997999    unsigned lengthNotIncludingUndefined = compactForSorting();
    998     ASSERT(!storage->m_sparseValueMap);
     1000    if (storage->m_sparseValueMap) {
     1001        throwOutOfMemoryError(exec);
     1002        return;
     1003    }
    9991004
    10001005    if (!lengthNotIncludingUndefined)
     
    11501155
    11511156    unsigned usedVectorLength = min(storage->m_length, m_vectorLength);
    1152     unsigned nodeCount = usedVectorLength;
     1157    unsigned nodeCount = usedVectorLength + (storage->m_sparseValueMap ? storage->m_sparseValueMap->size() : 0);
    11531158
    11541159    if (!nodeCount)
     
    11781183    // Iterate over the array, ignoring missing values, counting undefined ones, and inserting all other ones into the tree.
    11791184    for (; numDefined < usedVectorLength; ++numDefined) {
    1180         if (numDefined >= m_vectorLength)
    1181             break;
    11821185        JSValue v = storage->m_vector[numDefined].get();
    11831186        if (!v || v.isUndefined())
     
    11871190    }
    11881191    for (unsigned i = numDefined; i < usedVectorLength; ++i) {
    1189         if (i >= m_vectorLength)
    1190             break;
    11911192        JSValue v = storage->m_vector[i].get();
    11921193        if (v) {
     
    12031204    unsigned newUsedVectorLength = numDefined + numUndefined;
    12041205
    1205     ASSERT(!storage->m_sparseValueMap);
    1206    
    1207     // The array size may have changed.  Figure out the new bounds.
    1208     unsigned newestUsedVectorLength = min(m_storage->m_length, m_vectorLength);
    1209    
    1210     unsigned elementsToExtractThreshold = min(min(newestUsedVectorLength, numDefined), static_cast<unsigned>(tree.abstractor().m_nodes.size()));
    1211     unsigned undefinedElementsThreshold = min(newestUsedVectorLength, newUsedVectorLength);
    1212     unsigned clearElementsThreshold = min(newestUsedVectorLength, usedVectorLength);     
    1213    
     1206    if (SparseArrayValueMap* map = storage->m_sparseValueMap) {
     1207        newUsedVectorLength += map->size();
     1208        if (newUsedVectorLength > m_vectorLength) {
     1209            // Check that it is possible to allocate an array large enough to hold all the entries.
     1210            if ((newUsedVectorLength > MAX_STORAGE_VECTOR_LENGTH) || !increaseVectorLength(newUsedVectorLength)) {
     1211                throwOutOfMemoryError(exec);
     1212                return;
     1213            }
     1214        }
     1215       
     1216        storage = m_storage;
     1217
     1218        SparseArrayValueMap::iterator end = map->end();
     1219        for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) {
     1220            tree.abstractor().m_nodes[numDefined].value = it->second.get();
     1221            tree.insert(numDefined);
     1222            ++numDefined;
     1223        }
     1224
     1225        delete map;
     1226        storage->m_sparseValueMap = 0;
     1227    }
     1228
     1229    ASSERT(tree.abstractor().m_nodes.size() >= numDefined);
     1230
     1231    // FIXME: If the compare function changed the length of the array, the following might be
     1232    // modifying the vector incorrectly.
     1233
    12141234    // Copy the values back into m_storage.
    12151235    AVLTree<AVLTreeAbstractorForArrayCompare, 44>::Iterator iter;
    12161236    iter.start_iter_least(tree);
    12171237    JSGlobalData& globalData = exec->globalData();
    1218     for (unsigned i = 0; i < elementsToExtractThreshold; ++i) {
     1238    for (unsigned i = 0; i < numDefined; ++i) {
    12191239        storage->m_vector[i].set(globalData, this, tree.abstractor().m_nodes[*iter].value);
    12201240        ++iter;
     
    12221242
    12231243    // Put undefined values back in.
    1224     for (unsigned i = elementsToExtractThreshold; i < undefinedElementsThreshold; ++i)
     1244    for (unsigned i = numDefined; i < newUsedVectorLength; ++i)
    12251245        storage->m_vector[i].setUndefined();
    12261246
    12271247    // Ensure that unused values in the vector are zeroed out.
    1228     for (unsigned i = undefinedElementsThreshold; i < clearElementsThreshold; ++i)
     1248    for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i)
    12291249        storage->m_vector[i].clear();
    12301250
     
    12991319    unsigned newUsedVectorLength = numDefined + numUndefined;
    13001320
    1301     ASSERT(!storage->m_sparseValueMap);
     1321    if (SparseArrayValueMap* map = storage->m_sparseValueMap) {
     1322        newUsedVectorLength += map->size();
     1323        if (newUsedVectorLength > m_vectorLength) {
     1324            // Check that it is possible to allocate an array large enough to hold all the entries - if not,
     1325            // exception is thrown by caller.
     1326            if ((newUsedVectorLength > MAX_STORAGE_VECTOR_LENGTH) || !increaseVectorLength(newUsedVectorLength))
     1327                return 0;
     1328
     1329            storage = m_storage;
     1330        }
     1331
     1332        SparseArrayValueMap::iterator end = map->end();
     1333        for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it)
     1334            storage->m_vector[numDefined++].setWithoutWriteBarrier(it->second.get());
     1335
     1336        delete map;
     1337        storage->m_sparseValueMap = 0;
     1338    }
    13021339
    13031340    for (unsigned i = numDefined; i < newUsedVectorLength; ++i)
  • branches/safari-534.59-branch/Source/JavaScriptCore/runtime/JSArray.h

    r155365 r155376  
    174174
    175175        static void visitChildren(JSCell*, SlotVisitor&);
    176        
    177         bool hasSparseMap()
    178         {
    179             return !!m_storage->m_sparseValueMap;
    180         }
    181176
    182177    protected:
Note: See TracChangeset for help on using the changeset viewer.