Ignore:
Timestamp:
Dec 9, 2010, 10:27:13 AM (14 years ago)
Author:
[email protected]
Message:

2010-12-09 Michael Saboff <[email protected]>

Reviewed by Geoffrey Garen.

Addressed the "FIXME" issues in array sort for toString() methods that
mutate the array in either size or contents. The change is to mark
the temporary array contents so that they are not garbage collected
and to make sure the array is large enough to hold the contents
of the sorted temporary vector.
https://bugs.webkit.org/show_bug.cgi?id=50718

  • runtime/Collector.cpp: (JSC::Heap::addTempSortVector): (JSC::Heap::removeTempSortVector): (JSC::Heap::markTempSortVectors): (JSC::Heap::markRoots):
  • runtime/Collector.h:
  • runtime/JSArray.cpp: (JSC::JSArray::sort):
  • runtime/JSValue.h:

2010-12-09 Michael Saboff <[email protected]>

Reviewed by Geoffrey Garen.

New test to verify that arrays sort per the standard even it
there is an override for toString() that modifies the array.
https://bugs.webkit.org/show_bug.cgi?id=50718

  • fast/js/array-sort-modifying-tostring-expected.txt: Added.
  • fast/js/array-sort-modifying-tostring.html: Added.
  • fast/js/script-tests/array-sort-modifying-tostring.js: Added. (do_gc): (Item): (toString_Mutate): (test):
File:
1 edited

Legend:

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

    r73545 r73623  
    961961}
    962962
     963void Heap::pushTempSortVector(Vector<ValueStringPair>* tempVector)
     964{
     965    m_tempSortingVectors.append(tempVector);
     966}
     967
     968void Heap::popTempSortVector(Vector<ValueStringPair>* tempVector)
     969{
     970    ASSERT_UNUSED(tempVector, tempVector == m_tempSortingVectors.last());
     971    m_tempSortingVectors.removeLast();
     972}
     973   
     974void Heap::markTempSortVectors(MarkStack& markStack)
     975{
     976    typedef Vector<Vector<ValueStringPair>* > VectorOfValueStringVectors;
     977
     978    VectorOfValueStringVectors::iterator end = m_tempSortingVectors.end();
     979    for (VectorOfValueStringVectors::iterator it = m_tempSortingVectors.begin(); it != end; ++it) {
     980        Vector<ValueStringPair>* tempSortingVector = *it;
     981
     982        Vector<ValueStringPair>::iterator vectorEnd = tempSortingVector->end();
     983        for (Vector<ValueStringPair>::iterator vectorIt = tempSortingVector->begin(); vectorIt != vectorEnd; ++vectorIt)
     984            if (vectorIt->first)
     985                markStack.append(vectorIt->first);
     986        markStack.drain();
     987    }
     988}
     989   
    963990void Heap::clearMarkBits()
    964991{
     
    10481075    // Mark explicitly registered roots.
    10491076    markProtectedObjects(markStack);
     1077   
     1078    // Mark temporary vector for Array sorting
     1079    markTempSortVectors(markStack);
    10501080
    10511081    // Mark misc. other roots.
Note: See TracChangeset for help on using the changeset viewer.