Use FastMalloc (bmalloc) instead of BlockAllocator for GC pages
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jan 2015 19:20:06 +0000 (19:20 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jan 2015 19:20:06 +0000 (19:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140900

Reviewed by Mark Hahnenberg.

Re-landing just the GCArraySegment piece of this patch.

* heap/CodeBlockSet.cpp:
(JSC::CodeBlockSet::CodeBlockSet):
* heap/CodeBlockSet.h:
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::GCSegmentedArray):
(JSC::GCSegmentedArray<T>::~GCSegmentedArray):
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::refill):
(JSC::GCArraySegment<T>::create):
(JSC::GCArraySegment<T>::destroy):
* heap/GCThreadSharedData.cpp:
(JSC::GCThreadSharedData::GCThreadSharedData):
* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/MarkStack.cpp:
(JSC::MarkStackArray::MarkStackArray):
* heap/MarkStack.h:
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179348 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/CodeBlockSet.cpp
Source/JavaScriptCore/heap/CodeBlockSet.h
Source/JavaScriptCore/heap/GCSegmentedArray.h
Source/JavaScriptCore/heap/GCSegmentedArrayInlines.h
Source/JavaScriptCore/heap/GCThreadSharedData.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/MarkStack.cpp
Source/JavaScriptCore/heap/MarkStack.h
Source/JavaScriptCore/heap/SlotVisitor.cpp

index b39e60d..6b19d2c 100644 (file)
@@ -1,3 +1,35 @@
+2015-01-28  Geoffrey Garen  <ggaren@apple.com>
+
+        Use FastMalloc (bmalloc) instead of BlockAllocator for GC pages
+        https://bugs.webkit.org/show_bug.cgi?id=140900
+
+        Reviewed by Mark Hahnenberg.
+
+        Re-landing just the GCArraySegment piece of this patch.
+
+        * heap/CodeBlockSet.cpp:
+        (JSC::CodeBlockSet::CodeBlockSet):
+        * heap/CodeBlockSet.h:
+        * heap/GCSegmentedArray.h:
+        (JSC::GCArraySegment::GCArraySegment):
+        * heap/GCSegmentedArrayInlines.h:
+        (JSC::GCSegmentedArray<T>::GCSegmentedArray):
+        (JSC::GCSegmentedArray<T>::~GCSegmentedArray):
+        (JSC::GCSegmentedArray<T>::clear):
+        (JSC::GCSegmentedArray<T>::expand):
+        (JSC::GCSegmentedArray<T>::refill):
+        (JSC::GCArraySegment<T>::create):
+        (JSC::GCArraySegment<T>::destroy):
+        * heap/GCThreadSharedData.cpp:
+        (JSC::GCThreadSharedData::GCThreadSharedData):
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        * heap/MarkStack.cpp:
+        (JSC::MarkStackArray::MarkStackArray):
+        * heap/MarkStack.h:
+        * heap/SlotVisitor.cpp:
+        (JSC::SlotVisitor::SlotVisitor):
+
 2015-01-29  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Move HAVE_DTRACE definition back to Platform.h
index 2a818f0..eae1aac 100644 (file)
@@ -35,8 +35,8 @@ namespace JSC {
 
 static const bool verbose = false;
 
-CodeBlockSet::CodeBlockSet(BlockAllocator& blockAllocator)
-    : m_currentlyExecuting(blockAllocator)
+CodeBlockSet::CodeBlockSet()
+    : m_currentlyExecuting()
 {
 }
 
index e00cefe..d248337 100644 (file)
@@ -36,7 +36,6 @@
 
 namespace JSC {
 
-class BlockAllocator;
 class CodeBlock;
 class Heap;
 class JSCell;
@@ -50,7 +49,7 @@ class CodeBlockSet {
     WTF_MAKE_NONCOPYABLE(CodeBlockSet);
 
 public:
-    CodeBlockSet(BlockAllocator&);
+    CodeBlockSet();
     ~CodeBlockSet();
     
     // Add a CodeBlock. This is only called by CodeBlock constructors.
index 8faf16b..8aeba10 100644 (file)
 #ifndef GCSegmentedArray_h
 #define GCSegmentedArray_h
 
-#include "HeapBlock.h"
+#include <wtf/DoublyLinkedList.h>
 #include <wtf/Vector.h>
 
 namespace JSC {
 
-class BlockAllocator;
-class DeadBlock;
-
 template <typename T>
-class GCArraySegment : public HeapBlock<GCArraySegment<T>> {
+class GCArraySegment : public DoublyLinkedListNode<GCArraySegment<T>> {
+    friend class WTF::DoublyLinkedListNode<GCArraySegment<T>>;
 public:
-    GCArraySegment(Region* region)
-        : HeapBlock<GCArraySegment>(region)
+    GCArraySegment()
+        : DoublyLinkedListNode<GCArraySegment<T>>()
 #if !ASSERT_DISABLED
         , m_top(0)
 #endif
     {
     }
 
-    static GCArraySegment* create(DeadBlock*);
+    static GCArraySegment* create();
+    static void destroy(GCArraySegment*);
 
     T* data()
     {
@@ -54,6 +53,8 @@ public:
 
     static const size_t blockSize = 4 * KB;
 
+    GCArraySegment* m_prev;
+    GCArraySegment* m_next;
 #if !ASSERT_DISABLED
     size_t m_top;
 #endif
@@ -66,7 +67,7 @@ class GCSegmentedArray {
     friend class GCSegmentedArrayIterator<T>;
     friend class GCSegmentedArrayIterator<const T>;
 public:
-    GCSegmentedArray(BlockAllocator&);
+    GCSegmentedArray();
     ~GCSegmentedArray();
 
     void append(T);
@@ -101,7 +102,6 @@ protected:
     void validatePrevious();
 
     DoublyLinkedList<GCArraySegment<T>> m_segments;
-    BlockAllocator& m_blockAllocator;
 
     JS_EXPORT_PRIVATE static const size_t s_segmentCapacity = CapacityFromSize<GCArraySegment<T>::blockSize>::value;
     size_t m_top;
index e2eff4d..88e43cc 100644 (file)
 #ifndef GCSegmentedArrayInlines_h
 #define GCSegmentedArrayInlines_h
 
-#include "BlockAllocator.h"
 #include "GCSegmentedArray.h"
 
 namespace JSC {
 
 template <typename T>
-GCSegmentedArray<T>::GCSegmentedArray(BlockAllocator& blockAllocator)
-    : m_blockAllocator(blockAllocator)
-    , m_top(0)
+GCSegmentedArray<T>::GCSegmentedArray()
+    : m_top(0)
     , m_numberOfSegments(0)
 {
-    m_segments.push(GCArraySegment<T>::create(m_blockAllocator.allocate<GCArraySegment<T>>()));
+    m_segments.push(GCArraySegment<T>::create());
     m_numberOfSegments++;
 }
 
@@ -46,7 +44,7 @@ GCSegmentedArray<T>::~GCSegmentedArray()
 {
     ASSERT(m_numberOfSegments == 1);
     ASSERT(m_segments.size() == 1);
-    m_blockAllocator.deallocate(GCArraySegment<T>::destroy(m_segments.removeHead()));
+    GCArraySegment<T>::destroy(m_segments.removeHead());
     m_numberOfSegments--;
     ASSERT(!m_numberOfSegments);
     ASSERT(!m_segments.size());
@@ -61,7 +59,7 @@ void GCSegmentedArray<T>::clear()
     for (GCArraySegment<T>* current = m_segments.head(); current->next(); current = next) {
         next = current->next();
         m_segments.remove(current);
-        m_blockAllocator.deallocate(GCArraySegment<T>::destroy(current));
+        GCArraySegment<T>::destroy(current);
     }
     m_top = 0;
     m_numberOfSegments = 1;
@@ -75,7 +73,7 @@ void GCSegmentedArray<T>::expand()
 {
     ASSERT(m_segments.head()->m_top == s_segmentCapacity);
     
-    GCArraySegment<T>* nextSegment = GCArraySegment<T>::create(m_blockAllocator.allocate<GCArraySegment<T>>());
+    GCArraySegment<T>* nextSegment = GCArraySegment<T>::create();
     m_numberOfSegments++;
     
 #if !ASSERT_DISABLED
@@ -93,7 +91,7 @@ bool GCSegmentedArray<T>::refill()
     validatePrevious();
     if (top())
         return true;
-    m_blockAllocator.deallocate(GCArraySegment<T>::destroy(m_segments.removeHead()));
+    GCArraySegment<T>::destroy(m_segments.removeHead());
     ASSERT(m_numberOfSegments > 1);
     m_numberOfSegments--;
     setTopForFullSegment();
@@ -127,9 +125,16 @@ void GCSegmentedArray<T>::fillVector(Vector<T>& vector)
 }
 
 template <typename T>
-inline GCArraySegment<T>* GCArraySegment<T>::create(DeadBlock* block)
+inline GCArraySegment<T>* GCArraySegment<T>::create()
 {
-    return new (NotNull, block) GCArraySegment<T>(block->region());
+    return new (NotNull, fastMalloc(blockSize)) GCArraySegment<T>();
+}
+
+template <typename T>
+inline void GCArraySegment<T>::destroy(GCArraySegment* segment)
+{
+    segment->~GCArraySegment();
+    fastFree(segment);
 }
 
 template <typename T>
index 27e59e8..c8847aa 100644 (file)
@@ -73,7 +73,7 @@ GCThreadSharedData::GCThreadSharedData(VM* vm)
     : m_vm(vm)
     , m_copiedSpace(&vm->heap.m_storageSpace)
     , m_shouldHashCons(false)
-    , m_sharedMarkStack(vm->heap.blockAllocator())
+    , m_sharedMarkStack()
     , m_numberOfActiveParallelMarkers(0)
     , m_parallelMarkersShouldExit(false)
     , m_copyIndex(0)
index 3758dd3..38df707 100644 (file)
@@ -317,7 +317,7 @@ Heap::Heap(VM* vm, HeapType heapType)
     , m_slotVisitor(m_sharedData)
     , m_copyVisitor(m_sharedData)
     , m_handleSet(vm)
-    , m_codeBlocks(m_blockAllocator)
+    , m_codeBlocks()
     , m_isSafeToCollect(false)
     , m_writeBarrierBuffer(256)
     , m_vm(vm)
index 66201f4..da6ef94 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace JSC {
 
-MarkStackArray::MarkStackArray(BlockAllocator& blockAllocator)
-    : GCSegmentedArray<const JSCell*>(blockAllocator)
+MarkStackArray::MarkStackArray()
+    : GCSegmentedArray<const JSCell*>()
 {
 }
 
index 17a6019..04f19c6 100644 (file)
@@ -34,7 +34,7 @@ class JSCell;
 
 class MarkStackArray : public GCSegmentedArray<const JSCell*> {
 public:
-    MarkStackArray(BlockAllocator&);
+    MarkStackArray();
 
     void donateSomeCellsTo(MarkStackArray& other);
     void stealSomeCellsFrom(MarkStackArray& other, size_t idleThreadCount);
index d45c381..4de4966 100644 (file)
@@ -17,7 +17,7 @@
 namespace JSC {
 
 SlotVisitor::SlotVisitor(GCThreadSharedData& shared)
-    : m_stack(shared.m_vm->heap.blockAllocator())
+    : m_stack()
     , m_bytesVisited(0)
     , m_bytesCopied(0)
     , m_visitCount(0)