Ignore:
Timestamp:
Jan 30, 2011, 3:07:11 PM (14 years ago)
Author:
[email protected]
Message:

2011-01-30 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Filter all Heap collection through a common reset function, in
preparation for adding features triggered by collection.
https://bugs.webkit.org/show_bug.cgi?id=53396


SunSpider reports no change.

  • runtime/Heap.cpp: (JSC::Heap::reportExtraMemoryCostSlowCase): When we're over the extraCost limit, just call collectAllGarbage() instead of rolling our own special way of resetting the heap. In theory, this may be slower in some cases, but it also fixes cases of pathological heap growth that we've seen, where the only objects being allocated are temporary and huge (<rdar://problem/8885843>).

(JSC::Heap::allocate):
(JSC::Heap::collectAllGarbage): Use the shared reset function.

(JSC::Heap::reset):

  • runtime/Heap.h: Carved a new shared reset function out of the old collectAllGarbage.
File:
1 edited

Legend:

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

    r77081 r77094  
    9191    // collecting more frequently as long as it stays alive.
    9292
    93     if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2) {
    94         JAVASCRIPTCORE_GC_BEGIN();
    95 
    96         markRoots();
    97 
    98         JAVASCRIPTCORE_GC_MARKED();
    99 
    100         m_markedSpace.reset();
    101         m_extraCost = 0;
    102 
    103         JAVASCRIPTCORE_GC_END();
    104 
    105         (*m_activityCallback)();
    106     }
     93    if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2)
     94        collectAllGarbage();
    10795    m_extraCost += cost;
    10896}
     
    124112    void* result = m_markedSpace.allocate(s);
    125113    m_operationInProgress = NoOperation;
    126 
    127114    if (!result) {
    128         JAVASCRIPTCORE_GC_BEGIN();
    129 
    130         markRoots();
    131 
    132         JAVASCRIPTCORE_GC_MARKED();
    133 
    134         m_markedSpace.reset();
    135         m_extraCost = 0;
    136 
    137         JAVASCRIPTCORE_GC_END();
    138 
    139         (*m_activityCallback)();
     115        reset(DoNotSweep);
    140116
    141117        m_operationInProgress = Allocation;
     
    143119        m_operationInProgress = NoOperation;
    144120    }
     121
    145122    ASSERT(result);
    146123    return result;
     
    390367void Heap::collectAllGarbage()
    391368{
     369    reset(DoSweep);
     370}
     371
     372void Heap::reset(SweepToggle sweepToggle)
     373{
    392374    ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
    393375    JAVASCRIPTCORE_GC_BEGIN();
     
    398380
    399381    m_markedSpace.reset();
    400     m_markedSpace.sweep();
    401382    m_extraCost = 0;
    402383
     384    if (sweepToggle == DoSweep)
     385        m_markedSpace.sweep();
     386
    403387    JAVASCRIPTCORE_GC_END();
    404388
Note: See TracChangeset for help on using the changeset viewer.