Ignore:
Timestamp:
May 23, 2012, 1:47:46 PM (13 years ago)
Author:
[email protected]
Message:

Refactored heap tear-down to use normal value semantics (i.e., destructors)
https://bugs.webkit.org/show_bug.cgi?id=87302

Reviewed by Oliver Hunt.

This is a step toward incremental DOM finalization.

  • heap/CopiedSpace.cpp:

(JSC::CopiedSpace::~CopiedSpace):

  • heap/CopiedSpace.h:

(CopiedSpace): Just use our destructor, instead of relying on the heap
to send us a special message at a special time.

  • heap/Heap.cpp:

(JSC::Heap::Heap): Use OwnPtr for m_markListSet because this is not Sparta.

(JSC::Heap::~Heap): No need for delete or freeAllBlocks because normal
destructors do this work automatically now.

(JSC::Heap::lastChanceToFinalize): Just call lastChanceToFinalize on our
sub-objects, and assume it does the right thing. This improves encapsulation,
so we can add items requiring finalization to our sub-objects.

  • heap/Heap.h: Moved m_blockAllocator to get the right destruction order.
  • heap/MarkedSpace.cpp:

(Take):
(JSC):
(JSC::Take::Take):
(JSC::Take::operator()):
(JSC::Take::returnValue): Moved to the top of the file so it can be used
in another function.

(JSC::MarkedSpace::~MarkedSpace): Delete all outstanding memory, like a good
destructor should.

(JSC::MarkedSpace::lastChanceToFinalize): Moved some code here from the heap,
since it pertains to our internal implementation details.

  • heap/MarkedSpace.h:

(MarkedSpace):

  • heap/WeakBlock.cpp:

(JSC::WeakBlock::lastChanceToFinalize):

  • heap/WeakBlock.h:

(WeakBlock):

  • heap/WeakSet.cpp:

(JSC::WeakSet::lastChanceToFinalize):

  • heap/WeakSet.h:

(WeakSet): Stop using a special freeAllBlocks() callback and just implement
lastChanceToFinalize.

File:
1 edited

Legend:

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

    r118210 r118238  
    245245    , m_objectSpace(this)
    246246    , m_storageSpace(this)
    247     , m_markListSet(0)
    248247    , m_activityCallback(DefaultGCActivityCallback::create(this))
    249248    , m_machineThreads(this)
     
    262261Heap::~Heap()
    263262{
    264     delete m_markListSet;
    265 
    266     m_objectSpace.freeAllBlocks();
    267     m_storageSpace.freeAllBlocks();
    268 
    269     ASSERT(!size());
    270     ASSERT(!capacity());
    271263}
    272264
     
    287279        WTFLogAlways("ERROR: JavaScriptCore heap deallocated while %ld values were still protected", static_cast<unsigned long>(size));
    288280
    289     m_weakSet.finalizeAll();
    290     m_objectSpace.canonicalizeCellLivenessData();
    291     m_objectSpace.clearMarks();
    292     m_objectSpace.sweep();
    293     m_globalData->smallStrings.finalizeSmallStrings();
     281    m_weakSet.lastChanceToFinalize();
     282    m_objectSpace.lastChanceToFinalize();
    294283
    295284#if ENABLE(SIMPLE_HEAP_PROFILING)
Note: See TracChangeset for help on using the changeset viewer.