@@ -96,18 +96,18 @@ namespace {
9696// / bugpoint or gdb users to search for a function by name without any context.
9797class JitPool {
9898 SmallPtrSet<JIT*, 1 > JITs; // Optimize for process containing just 1 JIT.
99- mutable sys::Mutex Lock;
99+ mutable std::recursive_mutex Lock;
100100public:
101101 void Add (JIT *jit) {
102- MutexGuard guard (Lock);
102+ std::lock_guard<std::recursive_mutex> guard (Lock);
103103 JITs.insert (jit);
104104 }
105105 void Remove (JIT *jit) {
106- MutexGuard guard (Lock);
106+ std::lock_guard<std::recursive_mutex> guard (Lock);
107107 JITs.erase (jit);
108108 }
109109 void *getPointerToNamedFunction (const char *Name) const {
110- MutexGuard guard (Lock);
110+ std::lock_guard<std::recursive_mutex> guard (Lock);
111111 assert (JITs.size () != 0 && " No Jit registered" );
112112 // search function in every instance of JIT
113113 for (SmallPtrSet<JIT*, 1 >::const_iterator Jit = JITs.begin (),
@@ -150,7 +150,7 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
150150 AllJits->Add (this );
151151
152152 // Add target data
153- MutexGuard locked (lock);
153+ std::lock_guard<std::recursive_mutex> locked (lock);
154154 FunctionPassManager &PM = jitstate->getPM ();
155155 M->setDataLayout (TM.getDataLayout ());
156156 PM.add (new DataLayoutPass (M));
@@ -177,7 +177,7 @@ JIT::~JIT() {
177177// / addModule - Add a new Module to the JIT. If we previously removed the last
178178// / Module, we need re-initialize jitstate with a valid Module.
179179void JIT::addModule (Module *M) {
180- MutexGuard locked (lock);
180+ std::lock_guard<std::recursive_mutex> locked (lock);
181181
182182 if (Modules.empty ()) {
183183 assert (!jitstate && " jitstate should be NULL if Modules vector is empty!" );
@@ -206,7 +206,7 @@ void JIT::addModule(Module *M) {
206206bool JIT::removeModule (Module *M) {
207207 bool result = ExecutionEngine::removeModule (M);
208208
209- MutexGuard locked (lock);
209+ std::lock_guard<std::recursive_mutex> locked (lock);
210210
211211 if (jitstate && jitstate->getModule () == M) {
212212 delete jitstate;
@@ -408,13 +408,13 @@ GenericValue JIT::runFunction(Function *F,
408408void JIT::RegisterJITEventListener (JITEventListener *L) {
409409 if (!L)
410410 return ;
411- MutexGuard locked (lock);
411+ std::lock_guard<std::recursive_mutex> locked (lock);
412412 EventListeners.push_back (L);
413413}
414414void JIT::UnregisterJITEventListener (JITEventListener *L) {
415415 if (!L)
416416 return ;
417- MutexGuard locked (lock);
417+ std::lock_guard<std::recursive_mutex> locked (lock);
418418 std::vector<JITEventListener*>::reverse_iterator I=
419419 std::find (EventListeners.rbegin (), EventListeners.rend (), L);
420420 if (I != EventListeners.rend ()) {
@@ -426,14 +426,14 @@ void JIT::NotifyFunctionEmitted(
426426 const Function &F,
427427 void *Code, size_t Size,
428428 const JITEvent_EmittedFunctionDetails &Details) {
429- MutexGuard locked (lock);
429+ std::lock_guard<std::recursive_mutex> locked (lock);
430430 for (unsigned I = 0 , S = EventListeners.size (); I < S; ++I) {
431431 EventListeners[I]->NotifyFunctionEmitted (F, Code, Size, Details);
432432 }
433433}
434434
435435void JIT::NotifyFreeingMachineCode (void *OldPtr) {
436- MutexGuard locked (lock);
436+ std::lock_guard<std::recursive_mutex> locked (lock);
437437 for (unsigned I = 0 , S = EventListeners.size (); I < S; ++I) {
438438 EventListeners[I]->NotifyFreeingMachineCode (OldPtr);
439439 }
@@ -444,7 +444,7 @@ void JIT::NotifyFreeingMachineCode(void *OldPtr) {
444444// / GlobalAddress[F] with the address of F's machine code.
445445// /
446446void JIT::runJITOnFunction (Function *F, MachineCodeInfo *MCI) {
447- MutexGuard locked (lock);
447+ std::lock_guard<std::recursive_mutex> locked (lock);
448448
449449 class MCIListener : public JITEventListener {
450450 MachineCodeInfo *const MCI;
@@ -505,7 +505,7 @@ void *JIT::getPointerToFunction(Function *F) {
505505 if (void *Addr = getPointerToGlobalIfAvailable (F))
506506 return Addr; // Check if function already code gen'd
507507
508- MutexGuard locked (lock);
508+ std::lock_guard<std::recursive_mutex> locked (lock);
509509
510510 // Now that this thread owns the lock, make sure we read in the function if it
511511 // exists in this Module.
@@ -534,7 +534,7 @@ void *JIT::getPointerToFunction(Function *F) {
534534}
535535
536536void JIT::addPointerToBasicBlock (const BasicBlock *BB, void *Addr) {
537- MutexGuard locked (lock);
537+ std::lock_guard<std::recursive_mutex> locked (lock);
538538
539539 BasicBlockAddressMapTy::iterator I =
540540 getBasicBlockAddressMap ().find (BB);
@@ -546,7 +546,7 @@ void JIT::addPointerToBasicBlock(const BasicBlock *BB, void *Addr) {
546546}
547547
548548void JIT::clearPointerToBasicBlock (const BasicBlock *BB) {
549- MutexGuard locked (lock);
549+ std::lock_guard<std::recursive_mutex> locked (lock);
550550 getBasicBlockAddressMap ().erase (BB);
551551}
552552
@@ -555,7 +555,7 @@ void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
555555 (void )getPointerToFunction (BB->getParent ());
556556
557557 // resolve basic block address
558- MutexGuard locked (lock);
558+ std::lock_guard<std::recursive_mutex> locked (lock);
559559
560560 BasicBlockAddressMapTy::iterator I =
561561 getBasicBlockAddressMap ().find (BB);
@@ -592,7 +592,7 @@ void *JIT::getPointerToNamedFunction(const std::string &Name,
592592// / variable, possibly emitting it to memory if needed. This is used by the
593593// / Emitter.
594594void *JIT::getOrEmitGlobalVariable (const GlobalVariable *GV) {
595- MutexGuard locked (lock);
595+ std::lock_guard<std::recursive_mutex> locked (lock);
596596
597597 void *Ptr = getPointerToGlobalIfAvailable (GV);
598598 if (Ptr) return Ptr;
@@ -666,7 +666,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
666666 size_t S = getDataLayout ()->getTypeAllocSize (GlobalType);
667667 size_t A = getDataLayout ()->getPreferredAlignment (GV);
668668 if (GV->isThreadLocal ()) {
669- MutexGuard locked (lock);
669+ std::lock_guard<std::recursive_mutex> locked (lock);
670670 Ptr = TJI.allocateThreadLocalMemory (S);
671671 } else if (TJI.allocateSeparateGVMemory ()) {
672672 if (A <= 8 ) {
@@ -687,7 +687,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
687687}
688688
689689void JIT::addPendingFunction (Function *F) {
690- MutexGuard locked (lock);
690+ std::lock_guard<std::recursive_mutex> locked (lock);
691691 jitstate->getPendingFunctions ().push_back (F);
692692}
693693
0 commit comments