diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGAllocator.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGAllocator.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGAllocator.h | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGAllocator.h b/Source/JavaScriptCore/dfg/DFGAllocator.h index 80e1034cf..0a0e99e93 100644 --- a/Source/JavaScriptCore/dfg/DFGAllocator.h +++ b/Source/JavaScriptCore/dfg/DFGAllocator.h @@ -23,15 +23,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DFGAllocator_h -#define DFGAllocator_h - -#include <wtf/Platform.h> +#pragma once #if ENABLE(DFG_JIT) #include "DFGCommon.h" -#include <wtf/PageAllocationAligned.h> #include <wtf/StdLibExtras.h> namespace JSC { namespace DFG { @@ -52,7 +48,7 @@ public: void* allocate(); // Use placement new to allocate, and avoid using this method. void free(T*); // Call this method to delete; never use 'delete' directly. - void freeAll(); // Only call this if T has a trivial destructor. + void freeAll(); // Only call this if you've either freed everything or if T has a trivial destructor. void reset(); // Like freeAll(), but also returns all memory to the OS. unsigned indexOf(const T*); @@ -72,7 +68,7 @@ private: bool isInThisRegion(const T* pointer) { return static_cast<unsigned>(pointer - data()) < numberOfThingsPerRegion(); } static Region* regionFor(const T* pointer) { return bitwise_cast<Region*>(bitwise_cast<uintptr_t>(pointer) & ~(size() - 1)); } - PageAllocationAligned m_allocation; + void* m_allocation; Allocator* m_allocator; Region* m_next; }; @@ -155,11 +151,14 @@ void Allocator<T>::reset() template<typename T> unsigned Allocator<T>::indexOf(const T* object) { - unsigned baseIndex = 0; + unsigned numRegions = 0; + for (Region* region = m_regionHead; region; region = region->m_next) + numRegions++; + unsigned regionIndex = 0; for (Region* region = m_regionHead; region; region = region->m_next) { if (region->isInThisRegion(object)) - return baseIndex + (object - region->data()); - baseIndex += Region::numberOfThingsPerRegion(); + return (numRegions - 1 - regionIndex) * Region::numberOfThingsPerRegion() + (object - region->data()); + regionIndex++; } CRASH(); return 0; @@ -200,11 +199,9 @@ void* Allocator<T>::allocateSlow() if (logCompilationChanges()) dataLog("Allocating another allocator region.\n"); - - PageAllocationAligned allocation = PageAllocationAligned::allocate(Region::size(), Region::size(), OSAllocator::JSGCHeapPages); - if (!static_cast<bool>(allocation)) - CRASH(); - Region* region = static_cast<Region*>(allocation.base()); + + void* allocation = fastAlignedMalloc(Region::size(), Region::size()); + Region* region = static_cast<Region*>(allocation); region->m_allocation = allocation; region->m_allocator = this; startBumpingIn(region); @@ -221,7 +218,7 @@ void Allocator<T>::freeRegionsStartingAt(typename Allocator<T>::Region* region) { while (region) { Region* nextRegion = region->m_next; - region->m_allocation.deallocate(); + fastAlignedFree(region->m_allocation); region = nextRegion; } } @@ -236,6 +233,3 @@ void Allocator<T>::startBumpingIn(typename Allocator<T>::Region* region) } } // namespace JSC::DFG #endif // ENABLE(DFG_JIT) - -#endif // DFGAllocator_h - |