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/CopiedSpace.h

    r161615 r162017  
    2929#include "CopiedAllocator.h"
    3030#include "HeapBlock.h"
     31#include "HeapOperation.h"
    3132#include "TinyBloomFilter.h"
    3233#include <wtf/Assertions.h>
     
    6364    void didStartFullCollection();
    6465
     66    template <HeapOperation collectionType>
    6567    void startedCopying();
     68    void startedEdenCopy();
     69    void startedFullCopy();
    6670    void doneCopying();
    6771    bool isInCopyPhase() { return m_inCopyingPhase; }
     
    96100
    97101    void doneFillingBlock(CopiedBlock*, CopiedBlock**);
    98     void recycleEvacuatedBlock(CopiedBlock*);
     102    void recycleEvacuatedBlock(CopiedBlock*, HeapOperation collectionType);
    99103    void recycleBorrowedBlock(CopiedBlock*);
    100104
     
    103107    CopiedAllocator m_allocator;
    104108
    105     TinyBloomFilter m_blockFilter;
    106109    HashSet<CopiedBlock*> m_blockSet;
    107110
    108111    SpinLock m_toSpaceLock;
    109112
    110     DoublyLinkedList<CopiedBlock>* m_toSpace;
    111     DoublyLinkedList<CopiedBlock>* m_fromSpace;
    112    
    113     DoublyLinkedList<CopiedBlock> m_blocks1;
    114     DoublyLinkedList<CopiedBlock> m_blocks2;
    115     DoublyLinkedList<CopiedBlock> m_oversizeBlocks;
     113    struct CopiedGeneration {
     114        CopiedGeneration()
     115            : toSpace(0)
     116            , fromSpace(0)
     117        {
     118        }
     119
     120        DoublyLinkedList<CopiedBlock>* toSpace;
     121        DoublyLinkedList<CopiedBlock>* fromSpace;
     122       
     123        DoublyLinkedList<CopiedBlock> blocks1;
     124        DoublyLinkedList<CopiedBlock> blocks2;
     125        DoublyLinkedList<CopiedBlock> oversizeBlocks;
     126
     127        TinyBloomFilter blockFilter;
     128    };
     129
     130    CopiedGeneration m_oldGen;
     131    CopiedGeneration m_newGen;
    116132   
    117133    bool m_inCopyingPhase;
Note: See TracChangeset for help on using the changeset viewer.