diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2005-07-12 15:51:55 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2005-07-12 15:51:55 +0000 |
commit | ee448630bdf7eb6037fe2c50518d32010c433ca3 (patch) | |
tree | f8ecc527ec9e16ba1b610b08cbb35e2e05e5ebef /lib/ExecutionEngine/ExecutionEngine.cpp | |
parent | b2164e5cb5086f0595e96fdbb5ffc614dea9c441 (diff) |
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
Diffstat (limited to 'lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index f72ddcbba6..36f7d2fdfc 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -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 |