]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - jit/ExecutableAllocator.cpp
JavaScriptCore-7600.1.4.15.12.tar.gz
[apple/javascriptcore.git] / jit / ExecutableAllocator.cpp
index 5ac6cc4124b5bc017fce7b6bfbc0efd0f296b99a..accf5fcf60aa7e045c15b5997c47a32b1016ac4b 100644 (file)
  */
 
 #include "config.h"
-
 #include "ExecutableAllocator.h"
 
+#include "JSCInlines.h"
+
 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
 #include "CodeProfiling.h"
 #include <wtf/HashSet.h>
 #include <wtf/MetaAllocator.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/PageReservation.h>
 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
 #include <wtf/PassOwnPtr.h>
@@ -57,7 +59,7 @@ public:
     DemandExecutableAllocator()
         : MetaAllocator(jitAllocationGranule)
     {
-        MutexLocker lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         allocators().add(this);
         // Don't preallocate any memory here.
     }
@@ -65,7 +67,7 @@ public:
     virtual ~DemandExecutableAllocator()
     {
         {
-            MutexLocker lock(allocatorsMutex());
+            std::lock_guard<std::mutex> lock(allocatorsMutex());
             allocators().remove(this);
         }
         for (unsigned i = 0; i < reservations.size(); ++i)
@@ -75,7 +77,7 @@ public:
     static size_t bytesAllocatedByAllAllocators()
     {
         size_t total = 0;
-        MutexLocker lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             total += (*allocator)->bytesAllocated();
         return total;
@@ -84,7 +86,7 @@ public:
     static size_t bytesCommittedByAllocactors()
     {
         size_t total = 0;
-        MutexLocker lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             total += (*allocator)->bytesCommitted();
         return total;
@@ -93,7 +95,7 @@ public:
 #if ENABLE(META_ALLOCATOR_PROFILE)
     static void dumpProfileFromAllAllocators()
     {
-        MutexLocker lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             (*allocator)->dumpProfile();
     }
@@ -135,12 +137,14 @@ private:
     Vector<PageReservation, 16> reservations;
     static HashSet<DemandExecutableAllocator*>& allocators()
     {
-        DEFINE_STATIC_LOCAL(HashSet<DemandExecutableAllocator*>, sAllocators, ());
+        DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<DemandExecutableAllocator*>, sAllocators, ());
         return sAllocators;
     }
-    static Mutex& allocatorsMutex()
+
+    static std::mutex& allocatorsMutex()
     {
-        DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+        static NeverDestroyed<std::mutex> mutex;
+
         return mutex;
     }
 };