mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
For 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -50,16 +50,18 @@ ExecutionEngine::~ExecutionEngine() {
|
||||
/// 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 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user