Ignore:
Timestamp:
Nov 9, 2012, 9:58:19 AM (13 years ago)
Author:
[email protected]
Message:

MarkStackArray should use the BlockAllocator instead of the MarkStackSegmentAllocator
https://bugs.webkit.org/show_bug.cgi?id=101642

Reviewed by Filip Pizlo.

MarkStackSegmentAllocator is like a miniature version of the BlockAllocator. Now that the BlockAllocator has support
for a variety of block sizes, we should get rid of the MarkStackSegmentAllocator in favor of the BlockAllocator.

  • heap/BlockAllocator.h: Add new specializations of regionSetFor for the new MarkStackSegments.

(JSC):
(JSC::MarkStackSegment):

  • heap/GCThreadSharedData.cpp:

(JSC::GCThreadSharedData::GCThreadSharedData):
(JSC::GCThreadSharedData::reset):

  • heap/GCThreadSharedData.h:

(GCThreadSharedData):

  • heap/MarkStack.cpp:

(JSC::MarkStackArray::MarkStackArray): We now have a doubly linked list of MarkStackSegments, so we need to refactor
all the places that used the old custom tail/previous logic.
(JSC::MarkStackArray::~MarkStackArray):
(JSC::MarkStackArray::expand):
(JSC::MarkStackArray::refill):
(JSC::MarkStackArray::donateSomeCellsTo): Refactor to use the new linked list.
(JSC::MarkStackArray::stealSomeCellsFrom): Ditto.

  • heap/MarkStack.h:

(JSC):
(MarkStackSegment):
(JSC::MarkStackSegment::MarkStackSegment):
(JSC::MarkStackSegment::sizeFromCapacity):
(MarkStackArray):

  • heap/MarkStackInlines.h:

(JSC::MarkStackSegment::create):
(JSC):
(JSC::MarkStackArray::postIncTop):
(JSC::MarkStackArray::preDecTop):
(JSC::MarkStackArray::setTopForFullSegment):
(JSC::MarkStackArray::setTopForEmptySegment):
(JSC::MarkStackArray::top):
(JSC::MarkStackArray::validatePrevious):
(JSC::MarkStackArray::append):
(JSC::MarkStackArray::removeLast):
(JSC::MarkStackArray::isEmpty):
(JSC::MarkStackArray::size):

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::SlotVisitor):

File:
1 edited

Legend:

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

    r128084 r134080  
    5151#endif
    5252
     53#include "HeapBlock.h"
    5354#include <wtf/StdLibExtras.h>
    54 #include <wtf/TCSpinLock.h>
    5555
    5656namespace JSC {
    5757
     58class BlockAllocator;
     59class DeadBlock;
    5860class JSCell;
    5961
    60 struct MarkStackSegment {
    61     MarkStackSegment* m_previous;
     62class MarkStackSegment : public HeapBlock<MarkStackSegment> {
     63public:
     64    MarkStackSegment(Region* region)
     65        : HeapBlock<MarkStackSegment>(region)
    6266#if !ASSERT_DISABLED
    63     size_t m_top;
     67        , m_top(0)
    6468#endif
    65        
     69    {
     70    }
     71
     72    static MarkStackSegment* create(DeadBlock*);
     73
    6674    const JSCell** data()
    6775    {
     
    7886        return sizeof(MarkStackSegment) + capacity * sizeof(const JSCell*);
    7987    }
    80 };
    8188
    82 class MarkStackSegmentAllocator {
    83 public:
    84     MarkStackSegmentAllocator();
    85     ~MarkStackSegmentAllocator();
    86    
    87     MarkStackSegment* allocate();
    88     void release(MarkStackSegment*);
    89    
    90     void shrinkReserve();
    91    
    92 private:
    93     SpinLock m_lock;
    94     MarkStackSegment* m_nextFreeSegment;
     89    static const size_t blockSize = 4 * KB;
     90
     91#if !ASSERT_DISABLED
     92    size_t m_top;
     93#endif
    9594};
    9695
    9796class MarkStackArray {
    9897public:
    99     MarkStackArray(MarkStackSegmentAllocator&);
     98    MarkStackArray(BlockAllocator&);
    10099    ~MarkStackArray();
    101100
     
    123122    void validatePrevious();
    124123
    125     MarkStackSegment* m_topSegment;
    126     MarkStackSegmentAllocator& m_allocator;
     124    DoublyLinkedList<MarkStackSegment> m_segments;
     125    BlockAllocator& m_blockAllocator;
    127126
    128127    size_t m_segmentCapacity;
    129128    size_t m_top;
    130     size_t m_numberOfPreviousSegments;
     129    size_t m_numberOfSegments;
    131130   
    132131};
Note: See TracChangeset for help on using the changeset viewer.