diff options
author | Zachary Turner <zturner@google.com> | 2014-06-20 21:07:14 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-06-20 21:07:14 +0000 |
commit | 91e18f7639c61ca40efe39efbfcba825570a824e (patch) | |
tree | dd4ecf9c26f55bb430daef6c1efb180b3a48cca4 /lib/ExecutionEngine/MCJIT/MCJIT.cpp | |
parent | 5b8e73ef81bdbc3ce4d020f66d875e22827b7626 (diff) | |
download | llvm-91e18f7639c61ca40efe39efbfcba825570a824e.tar.gz llvm-91e18f7639c61ca40efe39efbfcba825570a824e.tar.bz2 llvm-91e18f7639c61ca40efe39efbfcba825570a824e.tar.xz |
Revert "Replace Execution Engine's mutex with std::recursive_mutex."
This reverts commit 1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd, due to
GCC / MinGW's lack of support for C++11 threading.
It's possible this will go back in after we come up with a
reasonable solution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211401 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/MCJIT/MCJIT.cpp')
-rw-r--r-- | lib/ExecutionEngine/MCJIT/MCJIT.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index f149edcb7b..e9ba96a649 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/MutexGuard.h" #include "llvm/Target/TargetLowering.h" using namespace llvm; @@ -65,7 +66,7 @@ MCJIT::MCJIT(Module *m, TargetMachine *tm, RTDyldMemoryManager *MM, } MCJIT::~MCJIT() { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // FIXME: We are managing our modules, so we do not want the base class // ExecutionEngine to manage them as well. To avoid double destruction // of the first (and only) module added in ExecutionEngine constructor @@ -101,12 +102,12 @@ MCJIT::~MCJIT() { } void MCJIT::addModule(Module *M) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); OwnedModules.addModule(M); } bool MCJIT::removeModule(Module *M) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); return OwnedModules.removeModule(M); } @@ -128,12 +129,12 @@ void MCJIT::addArchive(object::Archive *A) { void MCJIT::setObjectCache(ObjectCache* NewCache) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); ObjCache = NewCache; } ObjectBufferStream* MCJIT::emitObject(Module *M) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // This must be a module which has already been added but not loaded to this // MCJIT instance, since these conditions are tested by our caller, @@ -173,7 +174,7 @@ ObjectBufferStream* MCJIT::emitObject(Module *M) { void MCJIT::generateCodeForModule(Module *M) { // Get a thread lock to make sure we aren't trying to load multiple times - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // This must be a module which has already been added to this MCJIT instance. assert(OwnedModules.ownsModule(M) && @@ -213,7 +214,7 @@ void MCJIT::generateCodeForModule(Module *M) { } void MCJIT::finalizeLoadedModules() { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // Resolve any outstanding relocations. Dyld.resolveRelocations(); @@ -229,7 +230,7 @@ void MCJIT::finalizeLoadedModules() { // FIXME: Rename this. void MCJIT::finalizeObject() { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); for (ModulePtrSet::iterator I = OwnedModules.begin_added(), E = OwnedModules.end_added(); @@ -242,7 +243,7 @@ void MCJIT::finalizeObject() { } void MCJIT::finalizeModule(Module *M) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // This must be a module which has already been added to this MCJIT instance. assert(OwnedModules.ownsModule(M) && "MCJIT::finalizeModule: Unknown module."); @@ -267,7 +268,7 @@ uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) { Module *MCJIT::findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // If it hasn't already been generated, see if it's in one of our modules. for (ModulePtrSet::iterator I = OwnedModules.begin_added(), @@ -291,7 +292,7 @@ Module *MCJIT::findModuleForSymbol(const std::string &Name, uint64_t MCJIT::getSymbolAddress(const std::string &Name, bool CheckFunctionsOnly) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); // First, check to see if we already have this symbol. uint64_t Addr = getExistingSymbolAddress(Name); @@ -335,7 +336,7 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name, } uint64_t MCJIT::getGlobalValueAddress(const std::string &Name) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); uint64_t Result = getSymbolAddress(Name, false); if (Result != 0) finalizeLoadedModules(); @@ -343,7 +344,7 @@ uint64_t MCJIT::getGlobalValueAddress(const std::string &Name) { } uint64_t MCJIT::getFunctionAddress(const std::string &Name) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); uint64_t Result = getSymbolAddress(Name, true); if (Result != 0) finalizeLoadedModules(); @@ -352,7 +353,7 @@ uint64_t MCJIT::getFunctionAddress(const std::string &Name) { // Deprecated. Use getFunctionAddress instead. void *MCJIT::getPointerToFunction(Function *F) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) { bool AbortOnFailure = !F->hasExternalWeakLinkage(); @@ -551,13 +552,13 @@ void *MCJIT::getPointerToNamedFunction(const std::string &Name, void MCJIT::RegisterJITEventListener(JITEventListener *L) { if (!L) return; - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); EventListeners.push_back(L); } void MCJIT::UnregisterJITEventListener(JITEventListener *L) { if (!L) return; - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); SmallVector<JITEventListener*, 2>::reverse_iterator I= std::find(EventListeners.rbegin(), EventListeners.rend(), L); if (I != EventListeners.rend()) { @@ -566,14 +567,14 @@ void MCJIT::UnregisterJITEventListener(JITEventListener *L) { } } void MCJIT::NotifyObjectEmitted(const ObjectImage& Obj) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); MemMgr.notifyObjectLoaded(this, &Obj); for (unsigned I = 0, S = EventListeners.size(); I < S; ++I) { EventListeners[I]->NotifyObjectEmitted(Obj); } } void MCJIT::NotifyFreeingObject(const ObjectImage& Obj) { - std::lock_guard<std::recursive_mutex> locked(lock); + MutexGuard locked(lock); for (unsigned I = 0, S = EventListeners.size(); I < S; ++I) { EventListeners[I]->NotifyFreeingObject(Obj); } |