@@ -96,18 +96,18 @@ namespace {
96
96
// / bugpoint or gdb users to search for a function by name without any context.
97
97
class JitPool {
98
98
SmallPtrSet<JIT*, 1 > JITs; // Optimize for process containing just 1 JIT.
99
- mutable sys::Mutex Lock;
99
+ mutable std::recursive_mutex Lock;
100
100
public:
101
101
void Add (JIT *jit) {
102
- MutexGuard guard (Lock);
102
+ std::lock_guard<std::recursive_mutex> guard (Lock);
103
103
JITs.insert (jit);
104
104
}
105
105
void Remove (JIT *jit) {
106
- MutexGuard guard (Lock);
106
+ std::lock_guard<std::recursive_mutex> guard (Lock);
107
107
JITs.erase (jit);
108
108
}
109
109
void *getPointerToNamedFunction (const char *Name) const {
110
- MutexGuard guard (Lock);
110
+ std::lock_guard<std::recursive_mutex> guard (Lock);
111
111
assert (JITs.size () != 0 && " No Jit registered" );
112
112
// search function in every instance of JIT
113
113
for (SmallPtrSet<JIT*, 1 >::const_iterator Jit = JITs.begin (),
@@ -150,7 +150,7 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
150
150
AllJits->Add (this );
151
151
152
152
// Add target data
153
- MutexGuard locked (lock);
153
+ std::lock_guard<std::recursive_mutex> locked (lock);
154
154
FunctionPassManager &PM = jitstate->getPM ();
155
155
M->setDataLayout (TM.getDataLayout ());
156
156
PM.add (new DataLayoutPass (M));
@@ -177,7 +177,7 @@ JIT::~JIT() {
177
177
// / addModule - Add a new Module to the JIT. If we previously removed the last
178
178
// / Module, we need re-initialize jitstate with a valid Module.
179
179
void JIT::addModule (Module *M) {
180
- MutexGuard locked (lock);
180
+ std::lock_guard<std::recursive_mutex> locked (lock);
181
181
182
182
if (Modules.empty ()) {
183
183
assert (!jitstate && " jitstate should be NULL if Modules vector is empty!" );
@@ -206,7 +206,7 @@ void JIT::addModule(Module *M) {
206
206
bool JIT::removeModule (Module *M) {
207
207
bool result = ExecutionEngine::removeModule (M);
208
208
209
- MutexGuard locked (lock);
209
+ std::lock_guard<std::recursive_mutex> locked (lock);
210
210
211
211
if (jitstate && jitstate->getModule () == M) {
212
212
delete jitstate;
@@ -408,13 +408,13 @@ GenericValue JIT::runFunction(Function *F,
408
408
void JIT::RegisterJITEventListener (JITEventListener *L) {
409
409
if (!L)
410
410
return ;
411
- MutexGuard locked (lock);
411
+ std::lock_guard<std::recursive_mutex> locked (lock);
412
412
EventListeners.push_back (L);
413
413
}
414
414
void JIT::UnregisterJITEventListener (JITEventListener *L) {
415
415
if (!L)
416
416
return ;
417
- MutexGuard locked (lock);
417
+ std::lock_guard<std::recursive_mutex> locked (lock);
418
418
std::vector<JITEventListener*>::reverse_iterator I=
419
419
std::find (EventListeners.rbegin (), EventListeners.rend (), L);
420
420
if (I != EventListeners.rend ()) {
@@ -426,14 +426,14 @@ void JIT::NotifyFunctionEmitted(
426
426
const Function &F,
427
427
void *Code, size_t Size ,
428
428
const JITEvent_EmittedFunctionDetails &Details) {
429
- MutexGuard locked (lock);
429
+ std::lock_guard<std::recursive_mutex> locked (lock);
430
430
for (unsigned I = 0 , S = EventListeners.size (); I < S; ++I) {
431
431
EventListeners[I]->NotifyFunctionEmitted (F, Code, Size , Details);
432
432
}
433
433
}
434
434
435
435
void JIT::NotifyFreeingMachineCode (void *OldPtr) {
436
- MutexGuard locked (lock);
436
+ std::lock_guard<std::recursive_mutex> locked (lock);
437
437
for (unsigned I = 0 , S = EventListeners.size (); I < S; ++I) {
438
438
EventListeners[I]->NotifyFreeingMachineCode (OldPtr);
439
439
}
@@ -444,7 +444,7 @@ void JIT::NotifyFreeingMachineCode(void *OldPtr) {
444
444
// / GlobalAddress[F] with the address of F's machine code.
445
445
// /
446
446
void JIT::runJITOnFunction (Function *F, MachineCodeInfo *MCI) {
447
- MutexGuard locked (lock);
447
+ std::lock_guard<std::recursive_mutex> locked (lock);
448
448
449
449
class MCIListener : public JITEventListener {
450
450
MachineCodeInfo *const MCI;
@@ -505,7 +505,7 @@ void *JIT::getPointerToFunction(Function *F) {
505
505
if (void *Addr = getPointerToGlobalIfAvailable (F))
506
506
return Addr; // Check if function already code gen'd
507
507
508
- MutexGuard locked (lock);
508
+ std::lock_guard<std::recursive_mutex> locked (lock);
509
509
510
510
// Now that this thread owns the lock, make sure we read in the function if it
511
511
// exists in this Module.
@@ -534,7 +534,7 @@ void *JIT::getPointerToFunction(Function *F) {
534
534
}
535
535
536
536
void JIT::addPointerToBasicBlock (const BasicBlock *BB, void *Addr) {
537
- MutexGuard locked (lock);
537
+ std::lock_guard<std::recursive_mutex> locked (lock);
538
538
539
539
BasicBlockAddressMapTy::iterator I =
540
540
getBasicBlockAddressMap ().find (BB);
@@ -546,7 +546,7 @@ void JIT::addPointerToBasicBlock(const BasicBlock *BB, void *Addr) {
546
546
}
547
547
548
548
void JIT::clearPointerToBasicBlock (const BasicBlock *BB) {
549
- MutexGuard locked (lock);
549
+ std::lock_guard<std::recursive_mutex> locked (lock);
550
550
getBasicBlockAddressMap ().erase (BB);
551
551
}
552
552
@@ -555,7 +555,7 @@ void *JIT::getPointerToBasicBlock(BasicBlock *BB) {
555
555
(void )getPointerToFunction (BB->getParent ());
556
556
557
557
// resolve basic block address
558
- MutexGuard locked (lock);
558
+ std::lock_guard<std::recursive_mutex> locked (lock);
559
559
560
560
BasicBlockAddressMapTy::iterator I =
561
561
getBasicBlockAddressMap ().find (BB);
@@ -592,7 +592,7 @@ void *JIT::getPointerToNamedFunction(const std::string &Name,
592
592
// / variable, possibly emitting it to memory if needed. This is used by the
593
593
// / Emitter.
594
594
void *JIT::getOrEmitGlobalVariable (const GlobalVariable *GV) {
595
- MutexGuard locked (lock);
595
+ std::lock_guard<std::recursive_mutex> locked (lock);
596
596
597
597
void *Ptr = getPointerToGlobalIfAvailable (GV);
598
598
if (Ptr ) return Ptr ;
@@ -666,7 +666,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
666
666
size_t S = getDataLayout ()->getTypeAllocSize (GlobalType);
667
667
size_t A = getDataLayout ()->getPreferredAlignment (GV);
668
668
if (GV->isThreadLocal ()) {
669
- MutexGuard locked (lock);
669
+ std::lock_guard<std::recursive_mutex> locked (lock);
670
670
Ptr = TJI.allocateThreadLocalMemory (S);
671
671
} else if (TJI.allocateSeparateGVMemory ()) {
672
672
if (A <= 8 ) {
@@ -687,7 +687,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
687
687
}
688
688
689
689
void JIT::addPendingFunction (Function *F) {
690
- MutexGuard locked (lock);
690
+ std::lock_guard<std::recursive_mutex> locked (lock);
691
691
jitstate->getPendingFunctions ().push_back (F);
692
692
}
693
693
0 commit comments