summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/jit/ExecutableAllocator.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/jit/ExecutableAllocator.cpp
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/jit/ExecutableAllocator.cpp')
-rw-r--r--Source/JavaScriptCore/jit/ExecutableAllocator.cpp45
1 files changed, 28 insertions, 17 deletions
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 <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
@@ -57,7 +56,7 @@ public:
DemandExecutableAllocator()
: MetaAllocator(jitAllocationGranule)
{
- MutexLocker lock(allocatorsMutex());
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
allocators().add(this);
// Don't preallocate any memory here.
}
@@ -65,7 +64,7 @@ public:
virtual ~DemandExecutableAllocator()
{
{
- MutexLocker lock(allocatorsMutex());
+ std::lock_guard<StaticLock> 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<StaticLock> lock(allocatorsMutex());
for (HashSet<DemandExecutableAllocator*>::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<StaticLock> lock(allocatorsMutex());
for (HashSet<DemandExecutableAllocator*>::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<StaticLock> lock(allocatorsMutex());
for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
(*allocator)->dumpProfile();
}
@@ -135,12 +134,14 @@ private:
Vector<PageReservation, 16> reservations;
static HashSet<DemandExecutableAllocator*>& allocators()
{
- DEFINE_STATIC_LOCAL(HashSet<DemandExecutableAllocator*>, sAllocators, ());
- return sAllocators;
+ static NeverDestroyed<HashSet<DemandExecutableAllocator*>> 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<DemandExecutableAllocator>())
#endif
{
ASSERT(allocator());
@@ -212,11 +213,11 @@ double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage)
}
-PassRefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort)
+RefPtr<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.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)