]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - heap/ConservativeRoots.h
JavaScriptCore-1218.34.tar.gz
[apple/javascriptcore.git] / heap / ConservativeRoots.h
index d078606843132bec3203dd680bc57f32e608e38a..219bdcc8e0162a8242cc3ebc4a01aaa3314eb61b 100644 (file)
 
 namespace JSC {
 
-class JSCell;
+class DFGCodeBlocks;
 class Heap;
-
-// May contain duplicates.
+class JITStubRoutineSet;
+class JSCell;
 
 class ConservativeRoots {
 public:
-    ConservativeRoots(Heap*);
+    ConservativeRoots(const MarkedBlockSet*, CopiedSpace*);
     ~ConservativeRoots();
 
-    void add(void*);
     void add(void* begin, void* end);
+    void add(void* begin, void* end, JITStubRoutineSet&);
+    void add(void* begin, void* end, JITStubRoutineSet&, DFGCodeBlocks&);
     
     size_t size();
     JSCell** roots();
@@ -52,40 +53,22 @@ private:
     static const size_t inlineCapacity = 128;
     static const size_t nonInlineCapacity = 8192 / sizeof(JSCell*);
     
+    template<typename MarkHook>
+    void genericAddPointer(void*, TinyBloomFilter, MarkHook&);
+
+    template<typename MarkHook>
+    void genericAddSpan(void*, void* end, MarkHook&);
+    
     void grow();
 
-    Heap* m_heap;
     JSCell** m_roots;
     size_t m_size;
     size_t m_capacity;
+    const MarkedBlockSet* m_blocks;
+    CopiedSpace* m_copiedSpace;
     JSCell* m_inlineRoots[inlineCapacity];
 };
 
-inline ConservativeRoots::ConservativeRoots(Heap* heap)
-    : m_heap(heap)
-    , m_roots(m_inlineRoots)
-    , m_size(0)
-    , m_capacity(inlineCapacity)
-{
-}
-
-inline ConservativeRoots::~ConservativeRoots()
-{
-    if (m_roots != m_inlineRoots)
-        OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*));
-}
-
-inline void ConservativeRoots::add(void* p)
-{
-    if (!m_heap->contains(p))
-        return;
-
-    if (m_size == m_capacity)
-        grow();
-
-    m_roots[m_size++] = reinterpret_cast<JSCell*>(p);
-}
-
 inline size_t ConservativeRoots::size()
 {
     return m_size;