Ignore:
Timestamp:
Sep 8, 2013, 5:11:57 PM (12 years ago)
Author:
[email protected]
Message:

Calculating the size of the Heap should not require walking over it
https://bugs.webkit.org/show_bug.cgi?id=120910

Reviewed by Geoffrey Garen.

Currently Heap::size() is O(sizeof(Heap)). This is too expensive to
call during a collection. We should keep a count of visited and copied
bytes as each collection progresses so as to avoid re-walking the Heap
at the end of collection.

  • heap/GCThreadSharedData.cpp:

(JSC::GCThreadSharedData::childBytesVisited):
(JSC::GCThreadSharedData::childBytesCopied):

  • heap/GCThreadSharedData.h:
  • heap/Heap.cpp:

(JSC::Heap::Heap):
(JSC::Heap::markRoots):
(JSC::Heap::sizeAfterCollect):
(JSC::Heap::collect):

  • heap/Heap.h:
  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::reset):

  • heap/SlotVisitor.h:

(JSC::SlotVisitor::bytesVisited):
(JSC::SlotVisitor::bytesCopied):

  • heap/SlotVisitorInlines.h:

(JSC::SlotVisitor::internalAppend):
(JSC::SlotVisitor::copyLater):

File:
1 edited

Legend:

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

    r148696 r155317  
    5151    return result;
    5252}
     53
     54size_t GCThreadSharedData::childBytesVisited()
     55{       
     56    size_t result = 0;
     57    for (unsigned i = 0; i < m_gcThreads.size(); ++i)
     58        result += m_gcThreads[i]->slotVisitor()->bytesVisited();
     59    return result;
     60}
     61
     62size_t GCThreadSharedData::childBytesCopied()
     63{       
     64    size_t result = 0;
     65    for (unsigned i = 0; i < m_gcThreads.size(); ++i)
     66        result += m_gcThreads[i]->slotVisitor()->bytesCopied();
     67    return result;
     68}
    5369#endif
    5470
Note: See TracChangeset for help on using the changeset viewer.