Ignore:
Timestamp:
Jan 8, 2014, 7:49:38 PM (11 years ago)
Author:
[email protected]
Message:

Marking should be generational
https://bugs.webkit.org/show_bug.cgi?id=126552

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Re-marking the same objects over and over is a waste of effort. This patch implements
the sticky mark bit algorithm (along with our already-present write barriers) to reduce
overhead during garbage collection caused by rescanning objects.

There are now two collection modes, EdenCollection and FullCollection. EdenCollections
only visit new objects or objects that were added to the remembered set by a write barrier.
FullCollections are normal collections that visit all objects regardless of their
generation.

In this patch EdenCollections do not do anything in CopiedSpace. This will be fixed in
https://bugs.webkit.org/show_bug.cgi?id=126555.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::visitAggregate):

  • bytecode/CodeBlock.h:

(JSC::CodeBlockSet::mark):

  • dfg/DFGOperations.cpp:
  • heap/CodeBlockSet.cpp:

(JSC::CodeBlockSet::add):
(JSC::CodeBlockSet::traceMarked):
(JSC::CodeBlockSet::rememberCurrentlyExecutingCodeBlocks):

  • heap/CodeBlockSet.h:
  • heap/CopiedBlockInlines.h:

(JSC::CopiedBlock::reportLiveBytes):

  • heap/CopiedSpace.cpp:

(JSC::CopiedSpace::didStartFullCollection):

  • heap/CopiedSpace.h:

(JSC::CopiedSpace::heap):

  • heap/Heap.cpp:

(JSC::Heap::Heap):
(JSC::Heap::didAbandon):
(JSC::Heap::markRoots):
(JSC::Heap::copyBackingStores):
(JSC::Heap::addToRememberedSet):
(JSC::Heap::collectAllGarbage):
(JSC::Heap::collect):
(JSC::Heap::didAllocate):
(JSC::Heap::writeBarrier):

  • heap/Heap.h:

(JSC::Heap::isInRememberedSet):
(JSC::Heap::operationInProgress):
(JSC::Heap::shouldCollect):
(JSC::Heap::isCollecting):
(JSC::Heap::isWriteBarrierEnabled):
(JSC::Heap::writeBarrier):

  • heap/HeapOperation.h:
  • heap/MarkStack.cpp:

(JSC::MarkStackArray::~MarkStackArray):
(JSC::MarkStackArray::clear):
(JSC::MarkStackArray::fillVector):

  • heap/MarkStack.h:
  • heap/MarkedAllocator.cpp:

(JSC::isListPagedOut):
(JSC::MarkedAllocator::isPagedOut):
(JSC::MarkedAllocator::tryAllocateHelper):
(JSC::MarkedAllocator::addBlock):
(JSC::MarkedAllocator::removeBlock):
(JSC::MarkedAllocator::reset):

  • heap/MarkedAllocator.h:

(JSC::MarkedAllocator::MarkedAllocator):

  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::clearRememberedSet):
(JSC::MarkedBlock::clearMarksWithCollectionType):
(JSC::MarkedBlock::lastChanceToFinalize):

  • heap/MarkedBlock.h: Changed atomSize to 16 bytes because we have no objects smaller

than 16 bytes. This is also to pay for the additional Bitmap for the remembered set.
(JSC::MarkedBlock::didConsumeEmptyFreeList):
(JSC::MarkedBlock::setRemembered):
(JSC::MarkedBlock::clearRemembered):
(JSC::MarkedBlock::atomicClearRemembered):
(JSC::MarkedBlock::isRemembered):

  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::~MarkedSpace):
(JSC::MarkedSpace::resetAllocators):
(JSC::MarkedSpace::visitWeakSets):
(JSC::MarkedSpace::reapWeakSets):
(JSC::VerifyMarked::operator()):
(JSC::MarkedSpace::clearMarks):

  • heap/MarkedSpace.h:

(JSC::ClearMarks::operator()):
(JSC::ClearRememberedSet::operator()):
(JSC::MarkedSpace::didAllocateInBlock):
(JSC::MarkedSpace::clearRememberedSet):

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::~SlotVisitor):
(JSC::SlotVisitor::clearMarkStack):

  • heap/SlotVisitor.h:

(JSC::SlotVisitor::markStack):
(JSC::SlotVisitor::sharedData):

  • heap/SlotVisitorInlines.h:

(JSC::SlotVisitor::internalAppend):
(JSC::SlotVisitor::unconditionallyAppend):
(JSC::SlotVisitor::copyLater):
(JSC::SlotVisitor::reportExtraMemoryUsage):
(JSC::SlotVisitor::heap):

  • jit/Repatch.cpp:
  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::visitChildren):

  • runtime/JSPropertyNameIterator.h:

(JSC::StructureRareData::setEnumerationCache):

  • runtime/JSString.cpp:

(JSC::JSString::visitChildren):

  • runtime/StructureRareDataInlines.h:

(JSC::StructureRareData::setPreviousID):
(JSC::StructureRareData::setObjectToStringValue):

  • runtime/WeakMapData.cpp:

(JSC::WeakMapData::visitChildren):

Source/WTF:

  • wtf/Bitmap.h:

(WTF::WordType>::count): Added a cast that became necessary when Bitmap
is used with smaller types than int32_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/MarkStack.cpp

    r140195 r161540  
    5858MarkStackArray::~MarkStackArray()
    5959{
    60     ASSERT(m_numberOfSegments == 1 && m_segments.size() == 1);
     60    ASSERT(m_numberOfSegments == 1);
     61    ASSERT(m_segments.size() == 1);
    6162    m_blockAllocator.deallocate(MarkStackSegment::destroy(m_segments.removeHead()));
     63    m_numberOfSegments--;
     64    ASSERT(!m_numberOfSegments);
     65    ASSERT(!m_segments.size());
     66}
     67
     68void MarkStackArray::clear()
     69{
     70    if (!m_segments.head())
     71        return;
     72    MarkStackSegment* next;
     73    for (MarkStackSegment* current = m_segments.head(); current->next(); current = next) {
     74        next = current->next();
     75        m_segments.remove(current);
     76        m_blockAllocator.deallocate(MarkStackSegment::destroy(current));
     77    }
     78    m_top = 0;
     79    m_numberOfSegments = 1;
     80#if !ASSERT_DISABLED
     81    m_segments.head()->m_top = 0;
     82#endif
    6283}
    6384
     
    168189}
    169190
     191void MarkStackArray::fillVector(Vector<const JSCell*>& vector)
     192{
     193    ASSERT(vector.size() == size());
     194
     195    MarkStackSegment* currentSegment = m_segments.head();
     196    if (!currentSegment)
     197        return;
     198
     199    unsigned count = 0;
     200    for (unsigned i = 0; i < m_top; ++i) {
     201        ASSERT(currentSegment->data()[i]);
     202        vector[count++] = currentSegment->data()[i];
     203    }
     204
     205    currentSegment = currentSegment->next();
     206    while (currentSegment) {
     207        for (unsigned i = 0; i < s_segmentCapacity; ++i) {
     208            ASSERT(currentSegment->data()[i]);
     209            vector[count++] = currentSegment->data()[i];
     210        }
     211        currentSegment = currentSegment->next();
     212    }
     213}
     214
    170215} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.