The allocator used to allocate memory for MarkedBlocks and LargeAllocations should...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 20:50:51 +0000 (20:50 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 20:50:51 +0000 (20:50 +0000)
commit9d9d4a92cace33afe01267a0c4dcacc2dbc203f1
tree370827ac418da0d2135b54821f0f1f8a286341e9
parentb7401f517e8392c73521311d1b1a2c443db1f16f
The allocator used to allocate memory for MarkedBlocks and LargeAllocations should not be the Subspace itself
https://bugs.webkit.org/show_bug.cgi?id=175141

Reviewed by Mark Lam.
Source/JavaScriptCore:

To make it easier to have multiple gigacages and maybe even fancier methods of allocating, this
decouples the allocator used to allocate memory from the GC Subspace. This means we no longer have
to create a new Subspace subclass to allocate memory a different way. Instead, the allocator is now
determined by the AlignedMemoryAllocator object.

This also simplifies trading of blocks. Before, Subspaces had to determine if other Subspaces could
trade blocks with them using canTradeBlocksWith(). This makes it difficult for two different
Subspaces that both use the same underlying allocator to realize that they can trade blocks with
each other. Now, you just need to ask the block being stolen and the subspace doing the stealing if
they use the same AlignedMemoryAllocator.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/AlignedMemoryAllocator.cpp: Added.
(JSC::AlignedMemoryAllocator::AlignedMemoryAllocator):
(JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator):
* heap/AlignedMemoryAllocator.h: Added.
* heap/FastMallocAlignedMemoryAllocator.cpp: Added.
(JSC::FastMallocAlignedMemoryAllocator::singleton):
(JSC::FastMallocAlignedMemoryAllocator::FastMallocAlignedMemoryAllocator):
(JSC::FastMallocAlignedMemoryAllocator::~FastMallocAlignedMemoryAllocator):
(JSC::FastMallocAlignedMemoryAllocator::tryAllocateAlignedMemory):
(JSC::FastMallocAlignedMemoryAllocator::freeAlignedMemory):
(JSC::FastMallocAlignedMemoryAllocator::dump const):
* heap/FastMallocAlignedMemoryAllocator.h: Added.
* heap/GigacageAlignedMemoryAllocator.cpp: Added.
(JSC::GigacageAlignedMemoryAllocator::singleton):
(JSC::GigacageAlignedMemoryAllocator::GigacageAlignedMemoryAllocator):
(JSC::GigacageAlignedMemoryAllocator::~GigacageAlignedMemoryAllocator):
(JSC::GigacageAlignedMemoryAllocator::tryAllocateAlignedMemory):
(JSC::GigacageAlignedMemoryAllocator::freeAlignedMemory):
(JSC::GigacageAlignedMemoryAllocator::dump const):
* heap/GigacageAlignedMemoryAllocator.h: Added.
* heap/GigacageSubspace.cpp: Removed.
* heap/GigacageSubspace.h: Removed.
* heap/LargeAllocation.cpp:
(JSC::LargeAllocation::tryCreate):
(JSC::LargeAllocation::destroy):
* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateWithoutCollecting):
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::tryCreate):
(JSC::MarkedBlock::Handle::Handle):
(JSC::MarkedBlock::Handle::~Handle):
(JSC::MarkedBlock::Handle::didAddToAllocator):
(JSC::MarkedBlock::Handle::subspace const):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::Handle::alignedMemoryAllocator const):
(JSC::MarkedBlock::Handle::subspace const): Deleted.
* heap/Subspace.cpp:
(JSC::Subspace::Subspace):
(JSC::Subspace::findEmptyBlockToSteal):
(JSC::Subspace::canTradeBlocksWith): Deleted.
(JSC::Subspace::tryAllocateAlignedMemory): Deleted.
(JSC::Subspace::freeAlignedMemory): Deleted.
* heap/Subspace.h:
(JSC::Subspace::name const):
(JSC::Subspace::alignedMemoryAllocator const):
* runtime/JSDestructibleObjectSubspace.cpp:
(JSC::JSDestructibleObjectSubspace::JSDestructibleObjectSubspace):
* runtime/JSDestructibleObjectSubspace.h:
* runtime/JSSegmentedVariableObjectSubspace.cpp:
(JSC::JSSegmentedVariableObjectSubspace::JSSegmentedVariableObjectSubspace):
* runtime/JSSegmentedVariableObjectSubspace.h:
* runtime/JSStringSubspace.cpp:
(JSC::JSStringSubspace::JSStringSubspace):
* runtime/JSStringSubspace.h:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
* wasm/js/JSWebAssemblyCodeBlockSubspace.cpp:
(JSC::JSWebAssemblyCodeBlockSubspace::JSWebAssemblyCodeBlockSubspace):
* wasm/js/JSWebAssemblyCodeBlockSubspace.h:

Source/WebCore:

No new tests because no new behavior.

Just adapting to an API change.

* ForwardingHeaders/heap/FastMallocAlignedMemoryAllocator.h: Added.
* bindings/js/WebCoreJSClientData.cpp:
(WebCore::JSVMClientData::JSVMClientData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/heap/AlignedMemoryAllocator.cpp [moved from Source/JavaScriptCore/heap/GigacageSubspace.cpp with 67% similarity]
Source/JavaScriptCore/heap/AlignedMemoryAllocator.h [new file with mode: 0644]
Source/JavaScriptCore/heap/FastMallocAlignedMemoryAllocator.cpp [new file with mode: 0644]
Source/JavaScriptCore/heap/FastMallocAlignedMemoryAllocator.h [moved from Source/JavaScriptCore/heap/GigacageSubspace.h with 82% similarity]
Source/JavaScriptCore/heap/GigacageAlignedMemoryAllocator.cpp [new file with mode: 0644]
Source/JavaScriptCore/heap/GigacageAlignedMemoryAllocator.h [new file with mode: 0644]
Source/JavaScriptCore/heap/LargeAllocation.cpp
Source/JavaScriptCore/heap/MarkedAllocator.cpp
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/heap/Subspace.cpp
Source/JavaScriptCore/heap/Subspace.h
Source/JavaScriptCore/runtime/JSDestructibleObjectSubspace.cpp
Source/JavaScriptCore/runtime/JSDestructibleObjectSubspace.h
Source/JavaScriptCore/runtime/JSSegmentedVariableObjectSubspace.cpp
Source/JavaScriptCore/runtime/JSSegmentedVariableObjectSubspace.h
Source/JavaScriptCore/runtime/JSStringSubspace.cpp
Source/JavaScriptCore/runtime/JSStringSubspace.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlockSubspace.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlockSubspace.h
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/heap/FastMallocAlignedMemoryAllocator.h [new file with mode: 0644]
Source/WebCore/bindings/js/WebCoreJSClientData.cpp