]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - heap/MarkStack.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / heap / MarkStack.cpp
index 39907c715edc56c928a9cc51157cda93224482ca..da6ef94723d0b5e7604a10ea9b7f7b5ef25f4e38 100644 (file)
 
 #include "config.h"
 #include "MarkStack.h"
-#include "MarkStackInlines.h"
-
-#include "ConservativeRoots.h"
-#include "CopiedSpace.h"
-#include "CopiedSpaceInlines.h"
-#include "Heap.h"
-#include "JSArray.h"
-#include "JSCell.h"
-#include "JSObject.h"
-
-#include "SlotVisitorInlines.h"
-#include "Structure.h"
-#include "WriteBarrier.h"
-#include <wtf/Atomics.h>
-#include <wtf/DataLog.h>
-#include <wtf/MainThread.h>
 
-namespace JSC {
-
-COMPILE_ASSERT(MarkStackSegment::blockSize == WeakBlock::blockSize, blockSizeMatch);
-
-MarkStackArray::MarkStackArray(BlockAllocator& blockAllocator)
-    : m_blockAllocator(blockAllocator)
-    , m_top(0)
-    , m_numberOfSegments(0)
-{
-    m_segments.push(MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>()));
-    m_numberOfSegments++;
-}
+#include "JSCInlines.h"
 
-MarkStackArray::~MarkStackArray()
-{
-    ASSERT(m_numberOfSegments == 1 && m_segments.size() == 1);
-    m_blockAllocator.deallocate(MarkStackSegment::destroy(m_segments.removeHead()));
-}
-
-void MarkStackArray::expand()
-{
-    ASSERT(m_segments.head()->m_top == s_segmentCapacity);
-    
-    MarkStackSegment* nextSegment = MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>());
-    m_numberOfSegments++;
-    
-#if !ASSERT_DISABLED
-    nextSegment->m_top = 0;
-#endif
-
-    m_segments.push(nextSegment);
-    setTopForEmptySegment();
-    validatePrevious();
-}
+namespace JSC {
 
-bool MarkStackArray::refill()
+MarkStackArray::MarkStackArray()
+    : GCSegmentedArray<const JSCell*>()
 {
-    validatePrevious();
-    if (top())
-        return true;
-    m_blockAllocator.deallocate(MarkStackSegment::destroy(m_segments.removeHead()));
-    ASSERT(m_numberOfSegments > 1);
-    m_numberOfSegments--;
-    setTopForFullSegment();
-    validatePrevious();
-    return true;
 }
 
 void MarkStackArray::donateSomeCellsTo(MarkStackArray& other)
@@ -112,11 +57,11 @@ void MarkStackArray::donateSomeCellsTo(MarkStackArray& other)
 
     // Remove our head and the head of the other list before we start moving segments around.
     // We'll add them back on once we're done donating.
-    MarkStackSegment* myHead = m_segments.removeHead();
-    MarkStackSegment* otherHead = other.m_segments.removeHead();
+    GCArraySegment<const JSCell*>* myHead = m_segments.removeHead();
+    GCArraySegment<const JSCell*>* otherHead = other.m_segments.removeHead();
 
     while (segmentsToDonate--) {
-        MarkStackSegment* current = m_segments.removeHead();
+        GCArraySegment<const JSCell*>* current = m_segments.removeHead();
         ASSERT(current);
         ASSERT(m_numberOfSegments > 1);
         other.m_segments.push(current);
@@ -144,8 +89,8 @@ void MarkStackArray::stealSomeCellsFrom(MarkStackArray& other, size_t idleThread
     // If other has an entire segment, steal it and return.
     if (other.m_numberOfSegments > 1) {
         // Move the heads of the lists aside. We'll push them back on after.
-        MarkStackSegment* otherHead = other.m_segments.removeHead();
-        MarkStackSegment* myHead = m_segments.removeHead();
+        GCArraySegment<const JSCell*>* otherHead = other.m_segments.removeHead();
+        GCArraySegment<const JSCell*>* myHead = m_segments.removeHead();
 
         ASSERT(other.m_segments.head()->m_top == s_segmentCapacity);