X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/jit/ExecutableAllocator.cpp?ds=inline diff --git a/jit/ExecutableAllocator.cpp b/jit/ExecutableAllocator.cpp index 5ac6cc4..bb49e73 100644 --- a/jit/ExecutableAllocator.cpp +++ b/jit/ExecutableAllocator.cpp @@ -24,17 +24,16 @@ */ #include "config.h" - #include "ExecutableAllocator.h" +#include "JSCInlines.h" + #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) #include "CodeProfiling.h" #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, ()); + DEPRECATED_DEFINE_STATIC_LOCAL(HashSet, sAllocators, ()); return sAllocators; } - static Mutex& allocatorsMutex() + + static std::mutex& allocatorsMutex() { - DEFINE_STATIC_LOCAL(Mutex, mutex, ()); + static NeverDestroyed 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()