Ignore:
Timestamp:
Jun 8, 2011, 2:39:27 PM (14 years ago)
Author:
[email protected]
Message:

2011-06-08 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Took some responsibilities away from NewSpace
https://bugs.webkit.org/show_bug.cgi?id=62325


NewSpace is basically just an allocator now.


Heap acts as a controller, responsible for managing the set of all
MarkedBlocks.


This is in preparation for moving parts of the controller logic into
separate helper classes that can act on arbitrary sets of MarkedBlocks
that may or may not be in NewSpace.

  • heap/Heap.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocate): (JSC::Heap::markRoots): (JSC::Heap::clearMarks): (JSC::Heap::sweep): (JSC::Heap::objectCount): (JSC::Heap::size): (JSC::Heap::capacity): (JSC::Heap::collect): (JSC::Heap::resetAllocator): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlocks): (JSC::Heap::shrink): Moved the set of MarkedBlocks from NewSpace to Heap, along with all functions that operate on the set of MarkedBlocks. Also moved responsibility for deciding whether to allocate a new MarkedBlock, and for allocating it.
  • heap/Heap.h: (JSC::Heap::contains): (JSC::Heap::forEach): Ditto.
  • heap/NewSpace.cpp: (JSC::NewSpace::addBlock): (JSC::NewSpace::removeBlock): (JSC::NewSpace::resetAllocator):
  • heap/NewSpace.h: (JSC::NewSpace::waterMark): (JSC::NewSpace::allocate): Ditto.
File:
1 edited

Legend:

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

    r88379 r88389  
    5959
    6060        NewSpace(Heap*);
    61         void destroy();
    62 
    63         size_t highWaterMark();
    64         void setHighWaterMark(size_t);
    6561
    6662        SizeClass& sizeClassFor(size_t);
    6763        void* allocate(SizeClass&);
    6864
    69         void clearMarks();
    70         void markRoots();
     65        void addBlock(SizeClass&, MarkedBlock*);
     66        void removeBlock(MarkedBlock*);
     67
     68        size_t waterMark();
     69        size_t highWaterMark();
     70        void setHighWaterMark(size_t);
     71
    7172        void resetAllocator();
    72         void sweep();
    73         void shrink();
    74 
    75         size_t size() const;
    76         size_t capacity() const;
    77         size_t objectCount() const;
    78 
    79         bool contains(const void*);
    80 
    81         template<typename Functor> void forEach(Functor&);
    8273
    8374    private:
     
    9283        static const size_t impreciseCount = impreciseCutoff / impreciseStep - 1;
    9384
    94         typedef HashSet<MarkedBlock*>::iterator BlockIterator;
    95 
    96         MarkedBlock* allocateBlock(SizeClass&);
    97         void freeBlocks(DoublyLinkedList<MarkedBlock>&);
    98 
    99         void clearMarks(MarkedBlock*);
    100 
    10185        SizeClass m_preciseSizeClasses[preciseCount];
    10286        SizeClass m_impreciseSizeClasses[impreciseCount];
    103         HashSet<MarkedBlock*> m_blocks;
    10487        size_t m_waterMark;
    10588        size_t m_highWaterMark;
     
    10790    };
    10891
    109     inline bool NewSpace::contains(const void* x)
     92    inline size_t NewSpace::waterMark()
    11093    {
    111         if (!MarkedBlock::isAtomAligned(x))
    112             return false;
    113 
    114         MarkedBlock* block = MarkedBlock::blockFor(x);
    115         if (!block || !m_blocks.contains(block))
    116             return false;
    117            
    118         return true;
    119     }
    120 
    121     template <typename Functor> inline void NewSpace::forEach(Functor& functor)
    122     {
    123         BlockIterator end = m_blocks.end();
    124         for (BlockIterator it = m_blocks.begin(); it != end; ++it)
    125             (*it)->forEach(functor);
     94        return m_waterMark;
    12695    }
    12796
     
    153122        }
    154123
    155         if (m_waterMark < m_highWaterMark)
    156             return allocateBlock(sizeClass)->allocate();
    157 
    158124        return 0;
    159125    }
Note: See TracChangeset for help on using the changeset viewer.