Ignore:
Timestamp:
Jan 8, 2010, 5:02:38 PM (15 years ago)
Author:
[email protected]
Message:

2010-01-08 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Memory use grows grows possibly unbounded in this JavaScript Array test case
https://bugs.webkit.org/show_bug.cgi?id=31675

This fixes one observed bug in this test case, which is that
arrays don't report extra cost for the sparse value maps.

SunSpider reports a small speedup.

  • runtime/JSArray.cpp: (JSC::JSArray::putSlowCase): Report extra memory cost for the sparse value map.
  • runtime/JSArray.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSArray.cpp

    r52956 r53025  
    330330
    331331        // We miss some cases where we could compact the storage, such as a large array that is being filled from the end
    332         // (which will only be compacted as we reach indices that are less than cutoff) - but this makes the check much faster.
     332        // (which will only be compacted as we reach indices that are less than MIN_SPARSE_ARRAY_INDEX) - but this makes the check much faster.
    333333        if ((i > MAX_STORAGE_VECTOR_INDEX) || !isDenseEnoughForVector(i + 1, storage->m_numValuesInVector + 1)) {
    334334            if (!map) {
     
    336336                storage->m_sparseValueMap = map;
    337337            }
    338             map->set(i, value);
     338
     339            pair<SparseArrayValueMap::iterator, bool> result = map->add(i, value);
     340            if (!result.second) { // pre-existing entry
     341                result.first->second = value;
     342                return;
     343            }
     344
     345            size_t capacity = map->capacity();
     346            if (capacity != storage->reportedMapCapacity) {
     347                Heap::heap(this)->reportExtraMemoryCost((capacity - storage->reportedMapCapacity) * (sizeof(unsigned) + sizeof(JSValue)));
     348                storage->reportedMapCapacity = capacity;
     349            }
    339350            return;
    340351        }
Note: See TracChangeset for help on using the changeset viewer.