Remove bump allocator
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Sep 2011 17:41:51 +0000 (17:41 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Sep 2011 17:41:51 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68370

Reviewed by Sam Weinig.

Can't do anything with this allocator currently, and it's
increasing the complexity of the GC code.  Slight progression
on SunSpider, slight regression (undoing the original progression)
in V8.

* heap/Heap.cpp:
(JSC::Heap::collect):
* heap/Heap.h:
* heap/NewSpace.cpp:
(JSC::NewSpace::NewSpace):
* heap/NewSpace.h:
(JSC::NewSpace::allocate):
* runtime/JSObject.cpp:
(JSC::JSObject::allocatePropertyStorage):
* runtime/JSObject.h:
(JSC::JSObject::~JSObject):
(JSC::JSObject::visitChildrenDirect):
* runtime/StorageBarrier.h:
(JSC::StorageBarrier::set):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/NewSpace.cpp
Source/JavaScriptCore/heap/NewSpace.h
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/StorageBarrier.h

index 94cbf50..84f144c 100644 (file)
@@ -1,3 +1,30 @@
+2011-09-19  Oliver Hunt  <oliver@apple.com>
+
+        Remove bump allocator
+        https://bugs.webkit.org/show_bug.cgi?id=68370
+
+        Reviewed by Sam Weinig.
+
+        Can't do anything with this allocator currently, and it's
+        increasing the complexity of the GC code.  Slight progression
+        on SunSpider, slight regression (undoing the original progression)
+        in V8.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::collect):
+        * heap/Heap.h:
+        * heap/NewSpace.cpp:
+        (JSC::NewSpace::NewSpace):
+        * heap/NewSpace.h:
+        (JSC::NewSpace::allocate):
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::allocatePropertyStorage):
+        * runtime/JSObject.h:
+        (JSC::JSObject::~JSObject):
+        (JSC::JSObject::visitChildrenDirect):
+        * runtime/StorageBarrier.h:
+        (JSC::StorageBarrier::set):
+
 2011-09-19  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Fix distcheck build
index f642d27..4d2aa0c 100644 (file)
@@ -692,7 +692,6 @@ void Heap::collect(SweepToggle sweepToggle)
     // new bytes allocated) proportion, and seems to work well in benchmarks.
     size_t proportionalBytes = 2 * size();
     m_newSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));
-    m_newSpace.resetPropertyStorageNursery();
     JAVASCRIPTCORE_GC_END();
 
     (*m_activityCallback)();
index ef5e6d8..594b767 100644 (file)
@@ -91,9 +91,6 @@ namespace JSC {
         void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
         void collectAllGarbage();
 
-        inline void* allocatePropertyStorage(size_t);
-        inline bool inPropertyStorageNursery(void*);
-
         void reportExtraMemoryCost(size_t cost);
 
         void protect(JSValue);
@@ -362,22 +359,6 @@ namespace JSC {
         return allocate(sizeClass);
     }
 
-    inline void* Heap::allocatePropertyStorage(size_t bytes)
-    {
-        ASSERT(!(bytes % sizeof(JSValue)));
-        if (bytes >= NewSpace::PropertyStorageNurserySize)
-            return 0;
-        if (void* result = m_newSpace.allocatePropertyStorage(bytes))
-            return result;
-        collect(DoNotSweep);
-        return m_newSpace.allocatePropertyStorage(bytes);
-    }
-    
-    inline bool Heap::inPropertyStorageNursery(void* ptr)
-    {
-        return m_newSpace.inPropertyStorageNursery(ptr);
-    }
-
 } // namespace JSC
 
 #endif // Heap_h
index 866082d..2f16f99 100644 (file)
@@ -32,9 +32,7 @@ namespace JSC {
 class Structure;
 
 NewSpace::NewSpace(Heap* heap)
-    : m_propertyStorageNursery(static_cast<char*>(fastMalloc(PropertyStorageNurserySize)))
-    , m_propertyStorageAllocationPoint(m_propertyStorageNursery)
-    , m_waterMark(0)
+    : m_waterMark(0)
     , m_highWaterMark(0)
     , m_heap(heap)
 {
index f22d770..90cf881 100644 (file)
@@ -46,7 +46,6 @@ namespace JSC {
         WTF_MAKE_NONCOPYABLE(NewSpace);
     public:
         static const size_t maxCellSize = 1024;
-        static const size_t PropertyStorageNurserySize = 4 * MB;
 
         struct SizeClass {
             SizeClass();
@@ -64,9 +63,6 @@ namespace JSC {
 
         SizeClass& sizeClassFor(size_t);
         void* allocate(SizeClass&);
-        inline void* allocatePropertyStorage(size_t);
-        inline bool inPropertyStorageNursery(void* ptr);
-        inline void resetPropertyStorageNursery();
         
         void resetAllocator();
 
@@ -96,8 +92,6 @@ namespace JSC {
 
         SizeClass m_preciseSizeClasses[preciseCount];
         SizeClass m_impreciseSizeClasses[impreciseCount];
-        char* m_propertyStorageNursery;
-        char* m_propertyStorageAllocationPoint;
         size_t m_waterMark;
         size_t m_highWaterMark;
         Heap* m_heap;
@@ -166,30 +160,6 @@ namespace JSC {
         sizeClass.firstFreeCell = firstFreeCell->next;
         return firstFreeCell;
     }
-
-    inline void NewSpace::resetPropertyStorageNursery()
-    {
-        m_propertyStorageAllocationPoint = m_propertyStorageNursery;
-    }
-    
-    inline void* NewSpace::allocatePropertyStorage(size_t size)
-    {
-        char* result = m_propertyStorageAllocationPoint;
-        if (size > PropertyStorageNurserySize)
-            CRASH();
-        m_propertyStorageAllocationPoint += size;
-        if (static_cast<size_t>(m_propertyStorageAllocationPoint - m_propertyStorageNursery) > PropertyStorageNurserySize) {
-            m_propertyStorageAllocationPoint = result;
-            return 0;
-        }
-        return result;
-    }
-
-    inline bool NewSpace::inPropertyStorageNursery(void* ptr)
-    {
-        char* addr = static_cast<char*>(ptr);
-        return static_cast<size_t>(addr - m_propertyStorageNursery) < PropertyStorageNurserySize;
-    }
     
     template <typename Functor> inline typename Functor::ReturnType NewSpace::forEachBlock(Functor& functor)
     {
index 224268a..3c65e42 100644 (file)
@@ -596,16 +596,7 @@ void JSObject::allocatePropertyStorage(JSGlobalData& globalData, size_t oldSize,
     // It's important that this function not rely on m_structure, since
     // we might be in the middle of a transition.
     PropertyStorage newPropertyStorage = 0;
-    if (globalData.heap.inPropertyStorageNursery(m_propertyStorage.get())) {
-        newPropertyStorage = static_cast<PropertyStorage>(globalData.heap.allocatePropertyStorage(newSize * sizeof(WriteBarrierBase<Unknown>)));
-        if (!newPropertyStorage || !globalData.heap.inPropertyStorageNursery(m_propertyStorage.get())) {
-            // If allocation failed because it's too big, or it triggered a GC
-            // that promoted us to old space, we need to allocate our property
-            // storage in old space.
-            newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];
-        }
-    } else
-        newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];
+    newPropertyStorage = new WriteBarrierBase<Unknown>[newSize];
 
     PropertyStorage oldPropertyStorage = m_propertyStorage.get();
     ASSERT(newPropertyStorage);
@@ -613,7 +604,7 @@ void JSObject::allocatePropertyStorage(JSGlobalData& globalData, size_t oldSize,
     for (unsigned i = 0; i < oldSize; ++i)
        newPropertyStorage[i] = oldPropertyStorage[i];
 
-    if (!isUsingInlineStorage() && !globalData.heap.inPropertyStorageNursery(m_propertyStorage.get()))
+    if (!isUsingInlineStorage())
         delete [] oldPropertyStorage;
 
     m_propertyStorage.set(globalData, this, newPropertyStorage);
index 774ed96..a473e80 100644 (file)
@@ -438,7 +438,7 @@ inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure, Proper
 
 inline JSObject::~JSObject()
 {
-    if (!isUsingInlineStorage() && !Heap::heap(this)->inPropertyStorageNursery(m_propertyStorage.get()))
+    if (!isUsingInlineStorage())
         delete [] m_propertyStorage.get();
 }
 
@@ -826,12 +826,6 @@ ALWAYS_INLINE void JSObject::visitChildrenDirect(SlotVisitor& visitor)
     JSCell::visitChildren(visitor);
 
     PropertyStorage storage = propertyStorage();
-    if (Heap::heap(this)->inPropertyStorageNursery(storage)) {
-        m_propertyStorage.set(new WriteBarrierBase<Unknown>[structure()->propertyStorageCapacity()], StorageBarrier::Unchecked);
-        if (structure()->propertyStorageCapacity() > m_structure->propertyStorageSize())
-            ASSERT(!storage[m_structure->propertyStorageSize()]);
-        memcpy(m_propertyStorage.get(), storage, m_structure->propertyStorageSize() * sizeof(WriteBarrierBase<Unknown>));
-    }
     size_t storageSize = m_structure->propertyStorageSize();
     visitor.appendValues(storage, storageSize);
     if (m_inheritorID)
index 9fc946a..2a0c842 100644 (file)
@@ -47,10 +47,8 @@ public:
         set(storage, Unchecked);
     }
     
-    void set(JSGlobalData& globalData, JSCell* owner, PropertyStorage newStorage)
+    void set(JSGlobalData&, JSCell*, PropertyStorage newStorage)
     {
-        if (!globalData.heap.inPropertyStorageNursery(m_storage))
-            globalData.heap.writeBarrier(owner, JSValue());
         m_storage = newStorage;
     }