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

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore:

Removes some more custom allocation code.

Looks like a speedup. (See results attached to bugzilla.)

Will hopefully reduce memory use by improving sharing between the GC and
malloc heaps.

* API/JSBase.cpp:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj: Feed the compiler.

* heap/BlockAllocator.cpp: Removed.
* heap/BlockAllocator.h: Removed. No need for a custom allocator anymore.

* heap/CodeBlockSet.cpp:
(JSC::CodeBlockSet::CodeBlockSet):
* heap/CodeBlockSet.h: Feed the compiler.

* heap/CopiedBlock.h:
(JSC::CopiedBlock::createNoZeroFill):
(JSC::CopiedBlock::create):
(JSC::CopiedBlock::CopiedBlock):
(JSC::CopiedBlock::isOversize):
(JSC::CopiedBlock::payloadEnd):
(JSC::CopiedBlock::capacity):
* heap/CopiedBlockInlines.h:
(JSC::CopiedBlock::reportLiveBytes): Each copied block now tracks its
own size, since we can't rely on Region to tell us our size anymore.

* heap/CopiedSpace.cpp:
(JSC::CopiedSpace::~CopiedSpace):
(JSC::CopiedSpace::tryAllocateOversize):
(JSC::CopiedSpace::tryReallocateOversize):
* heap/CopiedSpaceInlines.h:
(JSC::CopiedSpace::recycleEvacuatedBlock):
(JSC::CopiedSpace::recycleBorrowedBlock):
(JSC::CopiedSpace::allocateBlockForCopyingPhase):
(JSC::CopiedSpace::allocateBlock):
(JSC::CopiedSpace::startedCopying): Deallocate blocks directly, rather
than pushing them onto the block allocator's free list; the block
allocator doesn't exist anymore.

* heap/CopyWorkList.h:
(JSC::CopyWorkListSegment::create):
(JSC::CopyWorkListSegment::CopyWorkListSegment):
(JSC::CopyWorkList::~CopyWorkList):
(JSC::CopyWorkList::append):
(JSC::CopyWorkList::CopyWorkList): Deleted.
* 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):
* heap/GCThreadSharedData.cpp:
(JSC::GCThreadSharedData::GCThreadSharedData):
* heap/GCThreadSharedData.h: Feed the compiler.

* heap/HandleBlock.h:
* heap/HandleBlockInlines.h:
(JSC::HandleBlock::create):
(JSC::HandleBlock::HandleBlock):
(JSC::HandleBlock::payloadEnd):
* heap/HandleSet.cpp:
(JSC::HandleSet::~HandleSet):
(JSC::HandleSet::grow): Same as above.

* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/Heap.h: Removed the block allocator since it is unused now.

* heap/HeapBlock.h:
(JSC::HeapBlock::destroy):
(JSC::HeapBlock::HeapBlock):
(JSC::HeapBlock::region): Deleted. Removed the Region pointer from each
HeapBlock since a HeapBlock is just a normal allocation now.

* heap/HeapInlines.h:
(JSC::Heap::blockAllocator): Deleted.

* heap/HeapTimer.cpp:
* heap/MarkStack.cpp:
(JSC::MarkStackArray::MarkStackArray):
* heap/MarkStack.h: Feed the compiler.

* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::allocateBlock): No need to use a custom code path
based on size, since we use a general purpose allocator now.

* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::create):
(JSC::MarkedBlock::destroy):
(JSC::MarkedBlock::MarkedBlock):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::capacity): Track block size explicitly, like CopiedBlock.

* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::freeBlock):
* heap/MarkedSpace.h:

* heap/Region.h: Removed.

* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor): Removed reference to block allocator.

* heap/SuperRegion.cpp: Removed.
* heap/SuperRegion.h: Removed.

* heap/WeakBlock.cpp:
(JSC::WeakBlock::create):
(JSC::WeakBlock::WeakBlock):
* heap/WeakBlock.h:
* heap/WeakSet.cpp:
(JSC::WeakSet::~WeakSet):
(JSC::WeakSet::addAllocator):
(JSC::WeakSet::removeAllocator): Removed reference to block allocator.

Source/WebCore:

* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::install): Be sure to release other
memory after GC and not before, since GC might contribute to free
malloc pages now.

Source/WTF:

New interface for aligned allocation: fastAlignedMalloc / fastAlignedFree.
We require a special function call on free because Windows.

* wtf/FastMalloc.cpp:
(WTF::fastAlignedMalloc):
(WTF::fastAlignedFree): Do it.

(WTF::do_memalign): Un-ifdef this, since we use it now.

* wtf/FastMalloc.h: Make our new function names visible like the rest
of fastMalloc.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed:
Source/JavaScriptCore/API/JSBase.cpp
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/heap/BlockAllocator.cpp [deleted file]
Source/JavaScriptCore/heap/BlockAllocator.h [deleted file]
Source/JavaScriptCore/heap/CodeBlockSet.cpp
Source/JavaScriptCore/heap/CodeBlockSet.h
Source/JavaScriptCore/heap/CopiedBlock.h
Source/JavaScriptCore/heap/CopiedBlockInlines.h
Source/JavaScriptCore/heap/CopiedSpace.cpp
Source/JavaScriptCore/heap/CopiedSpaceInlines.h
Source/JavaScriptCore/heap/CopyWorkList.h
Source/JavaScriptCore/heap/GCSegmentedArray.h
Source/JavaScriptCore/heap/GCSegmentedArrayInlines.h
Source/JavaScriptCore/heap/GCThreadSharedData.cpp
Source/JavaScriptCore/heap/GCThreadSharedData.h
Source/JavaScriptCore/heap/HandleBlock.h
Source/JavaScriptCore/heap/HandleBlockInlines.h
Source/JavaScriptCore/heap/HandleSet.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/HeapBlock.h
Source/JavaScriptCore/heap/HeapInlines.h
Source/JavaScriptCore/heap/HeapTimer.cpp
Source/JavaScriptCore/heap/MarkStack.cpp
Source/JavaScriptCore/heap/MarkStack.h
Source/JavaScriptCore/heap/MarkedAllocator.cpp
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/heap/Region.h [deleted file]
Source/JavaScriptCore/heap/SlotVisitor.cpp
Source/JavaScriptCore/heap/SuperRegion.cpp [deleted file]
Source/JavaScriptCore/heap/SuperRegion.h [deleted file]
Source/JavaScriptCore/heap/WeakBlock.cpp
Source/JavaScriptCore/heap/WeakBlock.h
Source/JavaScriptCore/heap/WeakSet.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/FastMalloc.cpp
Source/WTF/wtf/FastMalloc.h
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm