diff options
Diffstat (limited to 'Source/JavaScriptCore/jit/ExecutableAllocator.cpp')
-rw-r--r-- | Source/JavaScriptCore/jit/ExecutableAllocator.cpp | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp index 4ede23531..5ac6cc412 100644 --- a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp +++ b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp @@ -24,17 +24,18 @@ */ #include "config.h" -#include "ExecutableAllocator.h" -#include "JSCInlines.h" +#include "ExecutableAllocator.h" #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) #include "CodeProfiling.h" #include <wtf/HashSet.h> -#include <wtf/Lock.h> #include <wtf/MetaAllocator.h> -#include <wtf/NeverDestroyed.h> #include <wtf/PageReservation.h> +#if ENABLE(ASSEMBLER_WX_EXCLUSIVE) +#include <wtf/PassOwnPtr.h> +#endif +#include <wtf/ThreadingPrimitives.h> #include <wtf/VMTags.h> #endif @@ -56,7 +57,7 @@ public: DemandExecutableAllocator() : MetaAllocator(jitAllocationGranule) { - std::lock_guard<StaticLock> lock(allocatorsMutex()); + MutexLocker lock(allocatorsMutex()); allocators().add(this); // Don't preallocate any memory here. } @@ -64,7 +65,7 @@ public: virtual ~DemandExecutableAllocator() { { - std::lock_guard<StaticLock> lock(allocatorsMutex()); + MutexLocker lock(allocatorsMutex()); allocators().remove(this); } for (unsigned i = 0; i < reservations.size(); ++i) @@ -74,7 +75,7 @@ public: static size_t bytesAllocatedByAllAllocators() { size_t total = 0; - std::lock_guard<StaticLock> lock(allocatorsMutex()); + MutexLocker lock(allocatorsMutex()); for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) total += (*allocator)->bytesAllocated(); return total; @@ -83,7 +84,7 @@ public: static size_t bytesCommittedByAllocactors() { size_t total = 0; - std::lock_guard<StaticLock> lock(allocatorsMutex()); + MutexLocker lock(allocatorsMutex()); for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) total += (*allocator)->bytesCommitted(); return total; @@ -92,7 +93,7 @@ public: #if ENABLE(META_ALLOCATOR_PROFILE) static void dumpProfileFromAllAllocators() { - std::lock_guard<StaticLock> lock(allocatorsMutex()); + MutexLocker lock(allocatorsMutex()); for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) (*allocator)->dumpProfile(); } @@ -134,14 +135,12 @@ private: Vector<PageReservation, 16> reservations; static HashSet<DemandExecutableAllocator*>& allocators() { - static NeverDestroyed<HashSet<DemandExecutableAllocator*>> set; - return set; + DEFINE_STATIC_LOCAL(HashSet<DemandExecutableAllocator*>, sAllocators, ()); + return sAllocators; } - - static StaticLock& allocatorsMutex() + static Mutex& allocatorsMutex() { - static StaticLock mutex; - + DEFINE_STATIC_LOCAL(Mutex, mutex, ()); return mutex; } }; @@ -170,7 +169,7 @@ void ExecutableAllocator::initializeAllocator() ExecutableAllocator::ExecutableAllocator(VM&) #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) - : m_allocator(std::make_unique<DemandExecutableAllocator>()) + : m_allocator(adoptPtr(new DemandExecutableAllocator())) #endif { ASSERT(allocator()); @@ -213,11 +212,11 @@ double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage) } -RefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) +PassRefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) { RefPtr<ExecutableMemoryHandle> result = allocator()->allocate(sizeInBytes, ownerUID); RELEASE_ASSERT(result || effort != JITCompilationMustSucceed); - return result; + return result.release(); } size_t ExecutableAllocator::committedByteCount() @@ -232,16 +231,6 @@ void ExecutableAllocator::dumpProfile() } #endif -Lock& ExecutableAllocator::getLock() const -{ - return gAllocator->getLock(); -} - -bool ExecutableAllocator::isValidExecutableMemory(const LockHolder& locker, void* address) -{ - return gAllocator->isInAllocatedMemory(locker, address); -} - #endif // ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) |