summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/JIT/JITEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ExecutionEngine/JIT/JITEmitter.cpp')
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index 1e1f5d5580..50b8c10b63 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -40,6 +40,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Memory.h"
+#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetJITInfo.h"
@@ -49,7 +50,6 @@
#ifndef NDEBUG
#include <iomanip>
#endif
-#include <mutex>
using namespace llvm;
#define DEBUG_TYPE "jit"
@@ -230,22 +230,22 @@ namespace {
std::map<void*, JITResolver*> Map;
/// Guards Map from concurrent accesses.
- mutable std::recursive_mutex Lock;
+ mutable sys::Mutex Lock;
public:
/// Registers a Stub to be resolved by Resolver.
void RegisterStubResolver(void *Stub, JITResolver *Resolver) {
- std::lock_guard<std::recursive_mutex> guard(Lock);
+ MutexGuard guard(Lock);
Map.insert(std::make_pair(Stub, Resolver));
}
/// Unregisters the Stub when it's invalidated.
void UnregisterStubResolver(void *Stub) {
- std::lock_guard<std::recursive_mutex> guard(Lock);
+ MutexGuard guard(Lock);
Map.erase(Stub);
}
/// Returns the JITResolver instance that owns the Stub.
JITResolver *getResolverFromStub(void *Stub) const {
- std::lock_guard<std::recursive_mutex> guard(Lock);
+ MutexGuard guard(Lock);
// The address given to us for the stub may not be exactly right, it might
// be a little bit after the stub. As such, use upper_bound to find it.
// This is the same trick as in LookupFunctionFromCallSite from
@@ -258,7 +258,7 @@ namespace {
/// True if any stubs refer to the given resolver. Only used in an assert().
/// O(N)
bool ResolverHasStubs(JITResolver* Resolver) const {
- std::lock_guard<std::recursive_mutex> guard(Lock);
+ MutexGuard guard(Lock);
for (std::map<void*, JITResolver*>::const_iterator I = Map.begin(),
E = Map.end(); I != E; ++I) {
if (I->second == Resolver)
@@ -494,7 +494,7 @@ JITResolver::~JITResolver() {
/// getLazyFunctionStubIfAvailable - This returns a pointer to a function stub
/// if it has already been created.
void *JITResolver::getLazyFunctionStubIfAvailable(Function *F) {
- std::lock_guard<std::recursive_mutex> guard(TheJIT->lock);
+ MutexGuard locked(TheJIT->lock);
// If we already have a stub for this function, recycle it.
return state.getFunctionToLazyStubMap().lookup(F);
@@ -503,7 +503,7 @@ void *JITResolver::getLazyFunctionStubIfAvailable(Function *F) {
/// getFunctionStub - This returns a pointer to a function stub, creating
/// one on demand as needed.
void *JITResolver::getLazyFunctionStub(Function *F) {
- std::lock_guard<std::recursive_mutex> guard(TheJIT->lock);
+ MutexGuard locked(TheJIT->lock);
// If we already have a lazy stub for this function, recycle it.
void *&Stub = state.getFunctionToLazyStubMap()[F];
@@ -564,7 +564,7 @@ void *JITResolver::getLazyFunctionStub(Function *F) {
/// getGlobalValueIndirectSym - Return a lazy pointer containing the specified
/// GV address.
void *JITResolver::getGlobalValueIndirectSym(GlobalValue *GV, void *GVAddress) {
- std::lock_guard<std::recursive_mutex> guard(TheJIT->lock);
+ MutexGuard locked(TheJIT->lock);
// If we already have a stub for this global variable, recycle it.
void *&IndirectSym = state.getGlobalToIndirectSymMap()[GV];
@@ -622,7 +622,7 @@ void *JITResolver::JITCompilerFn(void *Stub) {
// Only lock for getting the Function. The call getPointerToFunction made
// in this function might trigger function materializing, which requires
// JIT lock to be unlocked.
- std::lock_guard<std::recursive_mutex> guard(JR->TheJIT->lock);
+ MutexGuard locked(JR->TheJIT->lock);
// The address given to us for the stub may not be exactly right, it might
// be a little bit after the stub. As such, use upper_bound to find it.
@@ -654,7 +654,7 @@ void *JITResolver::JITCompilerFn(void *Stub) {
}
// Reacquire the lock to update the GOT map.
- std::lock_guard<std::recursive_mutex> locked(JR->TheJIT->lock);
+ MutexGuard locked(JR->TheJIT->lock);
// We might like to remove the call site from the CallSiteToFunction map, but
// we can't do that! Multiple threads could be stuck, waiting to acquire the