Ignore:
Timestamp:
Jan 14, 2014, 3:03:01 PM (11 years ago)
Author:
[email protected]
Message:

Copying should be generational
https://bugs.webkit.org/show_bug.cgi?id=126555

Reviewed by Geoffrey Garen.

This patch adds support for copying to our generational collector. Eden collections
always trigger copying. Full collections use our normal fragmentation-based heuristics.

The way this works is that the CopiedSpace now has the notion of an old generation set of CopiedBlocks
and a new generation of CopiedBlocks. During each mutator cycle new CopiedSpace allocations reside
in the new generation. When a collection occurs, those blocks are moved to the old generation.

One key thing to remember is that both new and old generation objects in the MarkedSpace can
refer to old or new generation allocations in CopiedSpace. This is why we must fire write barriers
when assigning to an old (MarkedSpace) object's Butterfly.

  • heap/CopiedAllocator.h:

(JSC::CopiedAllocator::tryAllocateDuringCopying):

  • heap/CopiedBlock.h:

(JSC::CopiedBlock::CopiedBlock):
(JSC::CopiedBlock::didEvacuateBytes):
(JSC::CopiedBlock::isOld):
(JSC::CopiedBlock::didPromote):

  • heap/CopiedBlockInlines.h:

(JSC::CopiedBlock::reportLiveBytes):
(JSC::CopiedBlock::reportLiveBytesDuringCopying):

  • heap/CopiedSpace.cpp:

(JSC::CopiedSpace::CopiedSpace):
(JSC::CopiedSpace::~CopiedSpace):
(JSC::CopiedSpace::init):
(JSC::CopiedSpace::tryAllocateOversize):
(JSC::CopiedSpace::tryReallocateOversize):
(JSC::CopiedSpace::doneFillingBlock):
(JSC::CopiedSpace::didStartFullCollection):
(JSC::CopiedSpace::doneCopying):
(JSC::CopiedSpace::size):
(JSC::CopiedSpace::capacity):
(JSC::CopiedSpace::isPagedOut):

  • heap/CopiedSpace.h:

(JSC::CopiedSpace::CopiedGeneration::CopiedGeneration):

  • heap/CopiedSpaceInlines.h:

(JSC::CopiedSpace::contains):
(JSC::CopiedSpace::recycleEvacuatedBlock):
(JSC::CopiedSpace::allocateBlock):
(JSC::CopiedSpace::startedCopying):

  • heap/CopyVisitor.cpp:

(JSC::CopyVisitor::copyFromShared):

  • heap/CopyVisitorInlines.h:

(JSC::CopyVisitor::allocateNewSpace):
(JSC::CopyVisitor::allocateNewSpaceSlow):

  • heap/GCThreadSharedData.cpp:

(JSC::GCThreadSharedData::didStartCopying):

  • heap/Heap.cpp:

(JSC::Heap::copyBackingStores):

  • heap/SlotVisitorInlines.h:

(JSC::SlotVisitor::copyLater):

  • heap/TinyBloomFilter.h:

(JSC::TinyBloomFilter::add):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/CopiedBlockInlines.h

    r161615 r162017  
    2727#define CopiedBlockInlines_h
    2828
     29#include "ClassInfo.h"
    2930#include "CopiedBlock.h"
    3031#include "Heap.h"
     32#include "MarkedBlock.h"
    3133
    3234namespace JSC {
    3335   
    34 inline void CopiedBlock::reportLiveBytes(JSCell* owner, CopyToken token, unsigned bytes)
     36inline bool CopiedBlock::shouldReportLiveBytes(SpinLockHolder&, JSCell* owner)
    3537{
    36 #if ENABLE(PARALLEL_GC)
    37     SpinLockHolder locker(&m_workListLock);
    38 #endif
     38    // We want to add to live bytes if the owner isn't part of the remembered set or
     39    // if this block was allocated during the last cycle.
     40    // If we always added live bytes we would double count for elements in the remembered
     41    // set across collections.
     42    // If we didn't always add live bytes to new blocks, we'd get too few.
     43    bool ownerIsRemembered = MarkedBlock::blockFor(owner)->isRemembered(owner);
     44    return !ownerIsRemembered || !m_isOld;
     45}
     46
     47inline void CopiedBlock::reportLiveBytes(SpinLockHolder&, JSCell* owner, CopyToken token, unsigned bytes)
     48{
     49    checkConsistency();
    3950#ifndef NDEBUG
    40     checkConsistency();
    4151    m_liveObjects++;
    4252#endif
    4353    m_liveBytes += bytes;
     54    checkConsistency();
     55    ASSERT(m_liveBytes <= CopiedBlock::blockSize);
    4456
    4557    if (isPinned())
     
    5769}
    5870
     71inline void CopiedBlock::reportLiveBytesDuringCopying(unsigned bytes)
     72{
     73    checkConsistency();
     74    // This doesn't need to be locked because the thread that calls this function owns the current block.
     75    m_isOld = true;
     76#ifndef NDEBUG
     77    m_liveObjects++;
     78#endif
     79    m_liveBytes += bytes;
     80    checkConsistency();
     81    ASSERT(m_liveBytes <= CopiedBlock::blockSize);
     82}
     83
    5984} // namespace JSC
    6085
Note: See TracChangeset for help on using the changeset viewer.