Unreviewed, rolling out r179426.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jan 2015 18:28:17 +0000 (18:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jan 2015 18:28:17 +0000 (18:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141119

"caused a memory use regression" (Requested by Guest45 on
#webkit).

Reverted changeset:

"Use FastMalloc (bmalloc) instead of BlockAllocator for GC
pages"
https://bugs.webkit.org/show_bug.cgi?id=140900
http://trac.webkit.org/changeset/179426

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/HandleBlock.h
Source/JavaScriptCore/heap/HandleBlockInlines.h
Source/JavaScriptCore/heap/HandleSet.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/FastMalloc.cpp
Source/WTF/wtf/FastMalloc.h
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm

index fd3eb31..192a97b 100644 (file)
@@ -1,3 +1,18 @@
+2015-01-31  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r179426.
+        https://bugs.webkit.org/show_bug.cgi?id=141119
+
+        "caused a memory use regression" (Requested by Guest45 on
+        #webkit).
+
+        Reverted changeset:
+
+        "Use FastMalloc (bmalloc) instead of BlockAllocator for GC
+        pages"
+        https://bugs.webkit.org/show_bug.cgi?id=140900
+        http://trac.webkit.org/changeset/179426
+
 2015-01-30  Daniel Bates  <dabates@apple.com>
 
         Clean up: Remove unnecessary <dispatch/dispatch.h> header from RemoteInspectorDebuggableConnection.h
index 6f31322..962d37c 100644 (file)
@@ -34,11 +34,9 @@ class DeadBlock;
 class HandleSet;
 class HandleNode;
 
-class HandleBlock : public DoublyLinkedListNode<HandleBlock> {
-    friend class WTF::DoublyLinkedListNode<HandleBlock>;
+class HandleBlock : public HeapBlock<HandleBlock> {
 public:
-    static HandleBlock* create(HandleSet*);
-    static void destroy(HandleBlock*);
+    static HandleBlock* create(DeadBlock*, HandleSet*);
     static HandleBlock* blockFor(HandleNode*);
 
     static const size_t blockSize = 4 * KB;
@@ -50,15 +48,13 @@ public:
     unsigned nodeCapacity();
 
 private:
-    HandleBlock(HandleSet*);
+    HandleBlock(Region*, HandleSet*);
 
     char* payload();
     char* payloadEnd();
 
     static const size_t s_blockMask = ~(blockSize - 1);
 
-    HandleBlock* m_prev;
-    HandleBlock* m_next;
     HandleSet* m_handleSet;
 };
 
index 370e683..7c77193 100644 (file)
 
 #include "BlockAllocator.h"
 #include "HandleBlock.h"
-#include <wtf/FastMalloc.h>
 
 namespace JSC {
 
-inline HandleBlock* HandleBlock::create(HandleSet* handleSet)
+inline HandleBlock* HandleBlock::create(DeadBlock* block, HandleSet* handleSet)
 {
-    return new (NotNull, fastAlignedMalloc(blockSize, blockSize)) HandleBlock(handleSet);
+    Region* region = block->region();
+    return new (NotNull, block) HandleBlock(region, handleSet);
 }
 
-inline void HandleBlock::destroy(HandleBlock* block)
-{
-    block->~HandleBlock();
-    fastAlignedFree(block);
-}
-
-inline HandleBlock::HandleBlock(HandleSet* handleSet)
-    : DoublyLinkedListNode<HandleBlock>()
+inline HandleBlock::HandleBlock(Region* region, HandleSet* handleSet)
+    : HeapBlock<HandleBlock>(region)
     , m_handleSet(handleSet)
 {
 }
 
 inline char* HandleBlock::payloadEnd()
 {
-    return reinterpret_cast<char*>(this) + blockSize;
+    return reinterpret_cast<char*>(this) + region()->blockSize();
 }
 
 inline char* HandleBlock::payload()
index dec8370..be667e8 100644 (file)
@@ -44,12 +44,12 @@ HandleSet::HandleSet(VM* vm)
 HandleSet::~HandleSet()
 {
     while (!m_blockList.isEmpty())
-        HandleBlock::destroy(m_blockList.removeHead());
+        m_vm->heap.blockAllocator().deallocate(HandleBlock::destroy(m_blockList.removeHead()));
 }
 
 void HandleSet::grow()
 {
-    HandleBlock* newBlock = HandleBlock::create(this);
+    HandleBlock* newBlock = HandleBlock::create(m_vm->heap.blockAllocator().allocate<HandleBlock>(), this);
     m_blockList.append(newBlock);
 
     for (int i = newBlock->nodeCapacity() - 1; i >= 0; --i) {
index 8d879e0..285e3a6 100644 (file)
@@ -1,5 +1,20 @@
 2015-01-31  Commit Queue  <commit-queue@webkit.org>
 
+        Unreviewed, rolling out r179426.
+        https://bugs.webkit.org/show_bug.cgi?id=141119
+
+        "caused a memory use regression" (Requested by Guest45 on
+        #webkit).
+
+        Reverted changeset:
+
+        "Use FastMalloc (bmalloc) instead of BlockAllocator for GC
+        pages"
+        https://bugs.webkit.org/show_bug.cgi?id=140900
+        http://trac.webkit.org/changeset/179426
+
+2015-01-31  Commit Queue  <commit-queue@webkit.org>
+
         Unreviewed, rolling out r179408.
         https://bugs.webkit.org/show_bug.cgi?id=141117
 
index c5320d2..d7757b2 100644 (file)
@@ -162,34 +162,6 @@ size_t fastMallocGoodSize(size_t bytes)
 #endif
 }
 
-#if OS(WINDOWS)
-
-void* fastAlignedMalloc(size_t alignment, size_t size) 
-{
-    return _aligned_malloc(alignment, size);
-}
-
-void fastAlignedFree(void* p) 
-{
-    _aligned_free(p);
-}
-
-#else
-
-void* fastAlignedMalloc(size_t alignment, size_t size) 
-{
-    void* p = nullptr;
-    posix_memalign(&p, alignment, size);
-    return p;
-}
-
-void fastAlignedFree(void* p) 
-{
-    free(p);
-}
-
-#endif // OS(WINDOWS)
-
 TryMallocReturnValue tryFastMalloc(size_t n) 
 {
     return malloc(n);
@@ -301,16 +273,6 @@ size_t fastMallocGoodSize(size_t size)
     return size;
 }
     
-void* fastAlignedMalloc(size_t alignment, size_t size) 
-{
-    return bmalloc::api::memalign(alignment, size);
-}
-
-void fastAlignedFree(void* p) 
-{
-    bmalloc::api::free(p);
-}
-
 TryMallocReturnValue tryFastMalloc(size_t size)
 {
     return fastMalloc(size);
@@ -4062,6 +4024,7 @@ static ALWAYS_INLINE void do_free(void* ptr) {
   }
 }
 
+#ifndef WTF_CHANGES
 // For use by exported routines below that want specific alignments
 //
 // Note: this code can be slow, and can significantly fragment memory.
@@ -4132,6 +4095,7 @@ static void* do_memalign(size_t align, size_t size) {
   }
   return SpanToMallocResult(span);
 }
+#endif
 
 // Helpers for use by exported routines below:
 
@@ -4188,16 +4152,6 @@ extern "C"
 template <bool crashOnFailure>
 ALWAYS_INLINE void* malloc(size_t);
 
-void* fastAlignedMalloc(size_t alignment, size_t size) 
-{
-    return do_memalign(alignment, size);
-}
-
-void fastAlignedFree(void* p) 
-{
-    do_free(p);
-}
-
 void* fastMalloc(size_t size)
 {
     void* result = malloc<true>(size);
index f7612e0..5c0f821 100644 (file)
@@ -37,10 +37,6 @@ namespace WTF {
     WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
     WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);
 
-    // Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
-    WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
-    WTF_EXPORT_PRIVATE void fastAlignedFree(void*);
-
     struct TryMallocReturnValue {
         TryMallocReturnValue(void* data)
             : m_data(data)
@@ -108,8 +104,6 @@ using WTF::tryFastCalloc;
 using WTF::tryFastMalloc;
 using WTF::tryFastRealloc;
 using WTF::tryFastZeroedMalloc;
-using WTF::fastAlignedMalloc;
-using WTF::fastAlignedFree;
 
 #if COMPILER(GCC) && OS(DARWIN)
 #define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline))
index 6f02d55..5de2a67 100644 (file)
@@ -1,3 +1,18 @@
+2015-01-31  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r179426.
+        https://bugs.webkit.org/show_bug.cgi?id=141119
+
+        "caused a memory use regression" (Requested by Guest45 on
+        #webkit).
+
+        Reverted changeset:
+
+        "Use FastMalloc (bmalloc) instead of BlockAllocator for GC
+        pages"
+        https://bugs.webkit.org/show_bug.cgi?id=140900
+        http://trac.webkit.org/changeset/179426
+
 2015-01-30  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Improve FlowContentsIterator::TextFragment's encapsulation.
index 8907fba..f584ce2 100644 (file)
@@ -115,11 +115,14 @@ void MemoryPressureHandler::install()
 
     // Allow simulation of memory pressure with "notifyutil -p org.WebKit.lowMemory"
     notify_register_dispatch("org.WebKit.lowMemory", &_notifyToken, dispatch_get_main_queue(), ^(int) {
+        memoryPressureHandler().respondToMemoryPressure(true);
+
         // We only do a synchronous GC when *simulating* memory pressure.
         // This gives us a more consistent picture of live objects at the end of testing.
         gcController().garbageCollectNow();
 
-        memoryPressureHandler().respondToMemoryPressure(true);
+        // Release any freed up blocks from the JS heap back to the system.
+        JSDOMWindowBase::commonVM().heap.blockAllocator().releaseFreeRegions();
 
         malloc_zone_pressure_relief(nullptr, 0);
     });