Ignore:
Timestamp:
May 3, 2012, 3:31:43 PM (13 years ago)
Author:
[email protected]
Message:

Heap::reportAbandonedObjectGraph should not hasten an allocation-triggered collection
https://bugs.webkit.org/show_bug.cgi?id=85543

Reviewed by Filip Pizlo.

Currently reportAbandonedObjectGraph causes the Heap to think it is closer to its
allocation limit for the current cycle, thus hastening an allocation-triggered collection.
In reality, it should just affect the opportunistic GC timer. We should track the bytes
we think have been abandoned and the bytes that have been allocated separately.

  • heap/Heap.cpp: Added a new field m_abandonedBytes to Heap to keep track of how much

we think we've abandoned.
(JSC::Heap::Heap):
(JSC::Heap::reportAbandonedObjectGraph):
(JSC):
(JSC::Heap::didAbandon): Added this function for reportAbandonedObjectGraph to call
rather than didAllocate. Works the same as didAllocate, but modifies bytes abandoned rather
than bytes allocated. Also notifies the timer, summing the two values together.
(JSC::Heap::collect):
(JSC::Heap::didAllocate): Now adds the bytes allocated and bytes abandoned when reporting
to GCActivityCallback.

  • heap/Heap.h:

(Heap):

File:
1 edited

Legend:

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

    r115915 r116025  
    317317    , m_bytesAllocatedLimit(m_minBytesPerCycle)
    318318    , m_bytesAllocated(0)
     319    , m_bytesAbandoned(0)
    319320    , m_operationInProgress(NoOperation)
    320321    , m_objectSpace(this)
     
    402403    // be more profitable. Since allocation is the trigger for collection,
    403404    // we hasten the next collection by pretending that we've allocated more memory.
    404     didAllocate(abandonedBytes);
     405    didAbandon(abandonedBytes);
     406}
     407
     408void Heap::didAbandon(size_t bytes)
     409{
     410    m_activityCallback->didAllocate(m_bytesAllocated + m_bytesAbandoned);
     411    m_bytesAbandoned += bytes;
    405412}
    406413
     
    729736{
    730737    SamplingRegion samplingRegion("Garbage Collection");
     738    fprintf(stdout, "running collection\n");
    731739   
    732740    GCPHASE(Collect);
     
    786794        m_objectSpace.shrink();
    787795        m_weakSet.shrink();
     796        m_bytesAbandoned = 0;
    788797    }
    789798
     
    827836void Heap::didAllocate(size_t bytes)
    828837{
    829     m_activityCallback->didAllocate(m_bytesAllocated);
     838    m_activityCallback->didAllocate(m_bytesAllocated + m_bytesAbandoned);
    830839    m_bytesAllocated += bytes;
    831840}
Note: See TracChangeset for help on using the changeset viewer.