summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2014-06-18 20:17:35 +0000
committerZachary Turner <zturner@google.com>2014-06-18 20:17:35 +0000
commit1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd (patch)
tree82933a5d1d0e64418c721231a411dac3d9267f12 /include
parentb2791542c2c5df2912848b8bdf06fb1093d4ac12 (diff)
downloadllvm-1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd.tar.gz
llvm-1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd.tar.bz2
llvm-1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd.tar.xz
Replace Execution Engine's mutex with std::recursive_mutex.
This change has a bit of a trickle down effect due to the fact that there are a number of derived implementations of ExecutionEngine, and that the mutex is not tightly encapsulated so is used by other classes directly. Reviewed by: rnk Differential Revision: http://reviews.llvm.org/D4196 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h7
-rw-r--r--include/llvm/IR/ValueMap.h12
2 files changed, 9 insertions, 10 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index e5dab6191a..d349af8106 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -22,10 +22,10 @@
#include "llvm/IR/ValueMap.h"
#include "llvm/MC/MCCodeGenInfo.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Mutex.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <map>
+#include <mutex>
#include <string>
#include <vector>
@@ -42,7 +42,6 @@ class JITEventListener;
class JITMemoryManager;
class MachineCodeInfo;
class Module;
-class MutexGuard;
class ObjectCache;
class RTDyldMemoryManager;
class Triple;
@@ -59,7 +58,7 @@ class ExecutionEngineState {
public:
struct AddressMapConfig : public ValueMapConfig<const GlobalValue*> {
typedef ExecutionEngineState *ExtraData;
- static sys::Mutex *getMutex(ExecutionEngineState *EES);
+ static std::recursive_mutex *getMutex(ExecutionEngineState *EES);
static void onDelete(ExecutionEngineState *EES, const GlobalValue *Old);
static void onRAUW(ExecutionEngineState *, const GlobalValue *,
const GlobalValue *);
@@ -164,7 +163,7 @@ public:
/// lock - This lock protects the ExecutionEngine, MCJIT, JIT, JITResolver and
/// JITEmitter classes. It must be held while changing the internal state of
/// any of those classes.
- sys::Mutex lock;
+ std::recursive_mutex lock;
//===--------------------------------------------------------------------===//
// ExecutionEngine Startup
diff --git a/include/llvm/IR/ValueMap.h b/include/llvm/IR/ValueMap.h
index f196f334b6..17b0fe01b1 100644
--- a/include/llvm/IR/ValueMap.h
+++ b/include/llvm/IR/ValueMap.h
@@ -28,9 +28,9 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/ValueHandle.h"
-#include "llvm/Support/Mutex.h"
#include "llvm/Support/type_traits.h"
#include <iterator>
+#include <mutex>
namespace llvm {
@@ -45,7 +45,7 @@ class ValueMapConstIterator;
/// This class defines the default behavior for configurable aspects of
/// ValueMap<>. User Configs should inherit from this class to be as compatible
/// as possible with future versions of ValueMap.
-template<typename KeyT, typename MutexT = sys::Mutex>
+template<typename KeyT, typename MutexT = std::recursive_mutex>
struct ValueMapConfig {
typedef MutexT mutex_type;
@@ -216,11 +216,11 @@ public:
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
if (M)
- M->acquire();
+ M->lock();
Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this.
Copy.Map->Map.erase(Copy); // Definitely destroys *this.
if (M)
- M->release();
+ M->unlock();
}
void allUsesReplacedWith(Value *new_key) override {
assert(isa<KeySansPointerT>(new_key) &&
@@ -229,7 +229,7 @@ public:
ValueMapCallbackVH Copy(*this);
typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data);
if (M)
- M->acquire();
+ M->lock();
KeyT typed_new_key = cast<KeySansPointerT>(new_key);
// Can destroy *this:
@@ -245,7 +245,7 @@ public:
}
}
if (M)
- M->release();
+ M->unlock();
}
};