From a4e969f4965059196ca948db781e52f7cfebf19e Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 24 May 2016 08:28:08 +0000 Subject: webkitgtk-2.12.3 --- Source/JavaScriptCore/jit/ExecutableAllocator.cpp | 45 ++++++++++++++--------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'Source/JavaScriptCore/jit/ExecutableAllocator.cpp') diff --git a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp index 5ac6cc412..4ede23531 100644 --- a/Source/JavaScriptCore/jit/ExecutableAllocator.cpp +++ b/Source/JavaScriptCore/jit/ExecutableAllocator.cpp @@ -24,18 +24,17 @@ */ #include "config.h" - #include "ExecutableAllocator.h" +#include "JSCInlines.h" + #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) #include "CodeProfiling.h" #include +#include #include +#include #include -#if ENABLE(ASSEMBLER_WX_EXCLUSIVE) -#include -#endif -#include #include #endif @@ -57,7 +56,7 @@ public: DemandExecutableAllocator() : MetaAllocator(jitAllocationGranule) { - MutexLocker lock(allocatorsMutex()); + std::lock_guard lock(allocatorsMutex()); allocators().add(this); // Don't preallocate any memory here. } @@ -65,7 +64,7 @@ public: virtual ~DemandExecutableAllocator() { { - MutexLocker lock(allocatorsMutex()); + std::lock_guard lock(allocatorsMutex()); allocators().remove(this); } for (unsigned i = 0; i < reservations.size(); ++i) @@ -75,7 +74,7 @@ public: static size_t bytesAllocatedByAllAllocators() { size_t total = 0; - MutexLocker lock(allocatorsMutex()); + std::lock_guard lock(allocatorsMutex()); for (HashSet::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) total += (*allocator)->bytesAllocated(); return total; @@ -84,7 +83,7 @@ public: static size_t bytesCommittedByAllocactors() { size_t total = 0; - MutexLocker lock(allocatorsMutex()); + std::lock_guard lock(allocatorsMutex()); for (HashSet::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) total += (*allocator)->bytesCommitted(); return total; @@ -93,7 +92,7 @@ public: #if ENABLE(META_ALLOCATOR_PROFILE) static void dumpProfileFromAllAllocators() { - MutexLocker lock(allocatorsMutex()); + std::lock_guard lock(allocatorsMutex()); for (HashSet::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) (*allocator)->dumpProfile(); } @@ -135,12 +134,14 @@ private: Vector reservations; static HashSet& allocators() { - DEFINE_STATIC_LOCAL(HashSet, sAllocators, ()); - return sAllocators; + static NeverDestroyed> set; + return set; } - static Mutex& allocatorsMutex() + + static StaticLock& allocatorsMutex() { - DEFINE_STATIC_LOCAL(Mutex, mutex, ()); + static StaticLock mutex; + return mutex; } }; @@ -169,7 +170,7 @@ void ExecutableAllocator::initializeAllocator() ExecutableAllocator::ExecutableAllocator(VM&) #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) - : m_allocator(adoptPtr(new DemandExecutableAllocator())) + : m_allocator(std::make_unique()) #endif { ASSERT(allocator()); @@ -212,11 +213,11 @@ double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage) } -PassRefPtr ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) +RefPtr ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) { RefPtr result = allocator()->allocate(sizeInBytes, ownerUID); RELEASE_ASSERT(result || effort != JITCompilationMustSucceed); - return result.release(); + return result; } size_t ExecutableAllocator::committedByteCount() @@ -231,6 +232,16 @@ 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) -- cgit v1.2.1