[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Reid Spencer
reid at x10sys.com
Tue Jul 12 08:52:08 PDT 2005
Changes in directory llvm/lib/ExecutionEngine:
ExecutionEngine.cpp updated: 1.70 -> 1.71
---
Log message:
For PR540: http://llvm.cs.uiuc.edu/PR540 :
This patch completes the changes for making lli thread-safe. Here's the list
of changes:
* The Support/ThreadSupport* files were removed and replaced with the
MutexGuard.h file since all ThreadSupport* declared was a Mutex Guard.
The implementation of MutexGuard.h is now based on sys::Mutex which hides
its implementation and makes it unnecessary to have the -NoSupport.h and
-PThreads.h versions of ThreadSupport.
* All places in ExecutionEngine that previously referred to "Mutex" now
refer to sys::Mutex
* All places in ExecutionEngine that previously referred to "MutexLocker"
now refer to MutexGuard (this is frivolous but I believe the technically
correct name for such a class is "Guard" not a "Locker").
These changes passed all of llvm-test. All we need now are some test cases
that actually use multiple threads.
---
Diffs of the changes: (+10 -7)
ExecutionEngine.cpp | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.70 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.71
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.70 Sun Jul 10 21:49:16 2005
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Tue Jul 12 10:51:55 2005
@@ -50,16 +50,18 @@
/// at the specified address.
///
const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
+ MutexGuard locked(lock);
+
// If we haven't computed the reverse mapping yet, do so first.
- if (GlobalAddressReverseMap.empty()) {
+ if (state.getGlobalAddressReverseMap(locked).empty()) {
for (std::map<const GlobalValue*, void *>::iterator I =
- GlobalAddressMap.begin(), E = GlobalAddressMap.end(); I != E; ++I)
- GlobalAddressReverseMap.insert(std::make_pair(I->second, I->first));
+ state.getGlobalAddressMap(locked).begin(), E = state.getGlobalAddressMap(locked).end(); I != E; ++I)
+ state.getGlobalAddressReverseMap(locked).insert(std::make_pair(I->second, I->first));
}
std::map<void *, const GlobalValue*>::iterator I =
- GlobalAddressReverseMap.find(Addr);
- return I != GlobalAddressReverseMap.end() ? I->second : 0;
+ state.getGlobalAddressReverseMap(locked).find(Addr);
+ return I != state.getGlobalAddressReverseMap(locked).end() ? I->second : 0;
}
// CreateArgv - Turn a vector of strings into a nice argv style array of
@@ -168,8 +170,9 @@
if (Function *F = const_cast<Function*>(dyn_cast<Function>(GV)))
return getPointerToFunction(F);
- assert(GlobalAddressMap[GV] && "Global hasn't had an address allocated yet?");
- return GlobalAddressMap[GV];
+ MutexGuard locked(lock);
+ assert(state.getGlobalAddressMap(locked)[GV] && "Global hasn't had an address allocated yet?");
+ return state.getGlobalAddressMap(locked)[GV];
}
/// FIXME: document
More information about the llvm-commits
mailing list