Ignore:
Timestamp:
Sep 30, 2011, 3:23:33 PM (14 years ago)
Author:
[email protected]
Message:

2011-09-30 Oliver Hunt <[email protected]>

Need a sensible GGC policy

Reviewed by Geoff Garen.

This replaces the existing random collection policy
with a deterministic policy based on nursery size.

  • heap/AllocationSpace.cpp: (JSC::AllocationSpace::allocateSlowCase):
  • heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::markRoots): (JSC::Heap::collect):
  • heap/Heap.h:
  • heap/MarkedSpace.cpp: (JSC::MarkedSpace::MarkedSpace): (JSC::MarkedSpace::resetAllocator):
  • heap/MarkedSpace.h: (JSC::MarkedSpace::nurseryWaterMark): (JSC::MarkedSpace::allocate):
File:
1 edited

Legend:

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

    r96372 r96432  
    215215    : m_heapSize(heapSize)
    216216    , m_minBytesPerCycle(heapSizeForHint(heapSize))
     217    , m_lastFullGCSize(0)
    217218    , m_operationInProgress(NoOperation)
    218219    , m_objectSpace(this)
     
    454455}
    455456
    456 void Heap::markRoots()
    457 {
     457void Heap::markRoots(bool fullGC)
     458{
     459    UNUSED_PARAM(fullGC);
    458460    ASSERT(isValidThreadState(m_globalData));
    459461    if (m_operationInProgress != NoOperation)
     
    474476#if ENABLE(GGC)
    475477    MarkedBlock::DirtyCellVector dirtyCells;
    476     // Until we have a sensible policy we just random choose to perform
    477     // young generation collections 90% of the time.
    478     if (WTF::randomNumber() > 0.1)
     478    if (!fullGC)
    479479        m_objectSpace.gatherDirtyCells(dirtyCells);
    480480    else
     
    487487
    488488#if ENABLE(GGC)
    489     for (size_t i = 0; i < dirtyObjectCount; i++) {
     489    size_t dirtyCellCount = dirtyCells.size();
     490    for (size_t i = 0; i < dirtyCellCount; i++) {
    490491        heapRootVisitor.visitChildren(dirtyCells[i]);
    491492        visitor.drain();
     
    600601    ASSERT(m_isSafeToCollect);
    601602    JAVASCRIPTCORE_GC_BEGIN();
    602    
     603    bool fullGC = sweepToggle == DoSweep;
     604    if (!fullGC)
     605        fullGC = (capacity() > 4 * m_lastFullGCSize); 
    603606    canonicalizeCellLivenessData();
    604     markRoots();
     607
     608    markRoots(fullGC);
    605609
    606610    harvestWeakReferences();
     
    622626    // new bytes allocated) proportion, and seems to work well in benchmarks.
    623627    size_t proportionalBytes = 2 * size();
     628    if (fullGC)
     629        m_lastFullGCSize = proportionalBytes / 2;
     630   
    624631    m_objectSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));
    625632    JAVASCRIPTCORE_GC_END();
Note: See TracChangeset for help on using the changeset viewer.