diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-11-04 14:58:56 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-11-04 14:58:56 +0000 |
commit | 7ff99155c39edd73ebf1c6adfa023b1048fee9a4 (patch) | |
tree | b4dc751bcee540346911aa4115729eff2f991657 /include/llvm/ExecutionEngine/ExecutionEngine.h | |
parent | d1f06de484602e72707476a6152974847bac1570 (diff) | |
download | FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.zip FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.tar.gz |
Update LLVM to r86025.
Diffstat (limited to 'include/llvm/ExecutionEngine/ExecutionEngine.h')
-rw-r--r-- | include/llvm/ExecutionEngine/ExecutionEngine.h | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index b9da0fc..4b828e46 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -19,6 +19,7 @@ #include <map> #include <string> #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/ValueMap.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/Mutex.h" #include "llvm/Target/TargetMachine.h" @@ -42,26 +43,23 @@ class Type; class ExecutionEngineState { public: - class MapUpdatingCVH : public CallbackVH { - ExecutionEngineState &EES; - - public: - MapUpdatingCVH(ExecutionEngineState &EES, const GlobalValue *GV); - - operator const GlobalValue*() const { - return cast<GlobalValue>(getValPtr()); - } - - virtual void deleted(); - virtual void allUsesReplacedWith(Value *new_value); + struct AddressMapConfig : public ValueMapConfig<const GlobalValue*> { + typedef ExecutionEngineState *ExtraData; + static sys::Mutex *getMutex(ExecutionEngineState *EES); + static void onDelete(ExecutionEngineState *EES, const GlobalValue *Old); + static void onRAUW(ExecutionEngineState *, const GlobalValue *, + const GlobalValue *); }; + typedef ValueMap<const GlobalValue *, void *, AddressMapConfig> + GlobalAddressMapTy; + private: ExecutionEngine &EE; /// GlobalAddressMap - A mapping between LLVM global values and their /// actualized version... - std::map<MapUpdatingCVH, void *> GlobalAddressMap; + GlobalAddressMapTy GlobalAddressMap; /// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap, /// used to convert raw addresses into the LLVM global value that is emitted @@ -70,13 +68,9 @@ private: std::map<void *, AssertingVH<const GlobalValue> > GlobalAddressReverseMap; public: - ExecutionEngineState(ExecutionEngine &EE) : EE(EE) {} + ExecutionEngineState(ExecutionEngine &EE); - MapUpdatingCVH getVH(const GlobalValue *GV) { - return MapUpdatingCVH(*this, GV); - } - - std::map<MapUpdatingCVH, void *> & + GlobalAddressMapTy & getGlobalAddressMap(const MutexGuard &) { return GlobalAddressMap; } @@ -94,7 +88,7 @@ public: class ExecutionEngine { const TargetData *TD; ExecutionEngineState EEState; - bool LazyCompilationDisabled; + bool CompilingLazily; bool GVCompilationDisabled; bool SymbolSearchingDisabled; bool DlsymStubsEnabled; @@ -269,12 +263,17 @@ public: /// getPointerToFunction - The different EE's represent function bodies in /// different ways. They should each implement this to say what a function /// pointer should look like. When F is destroyed, the ExecutionEngine will - /// remove its global mapping but will not yet free its machine code. Call - /// freeMachineCodeForFunction(F) explicitly to do that. Note that global - /// optimizations can destroy Functions without notifying the ExecutionEngine. + /// remove its global mapping and free any machine code. Be sure no threads + /// are running inside F when that happens. /// virtual void *getPointerToFunction(Function *F) = 0; + /// getPointerToBasicBlock - The different EE's represent basic blocks in + /// different ways. Return the representation for a blockaddress of the + /// specified block. + /// + virtual void *getPointerToBasicBlock(BasicBlock *BB) = 0; + /// getPointerToFunctionOrStub - If the specified function has been /// code-gen'd, return a pointer to the function. If not, compile it, or use /// a stub to implement lazy compilation if available. See @@ -326,13 +325,29 @@ public: virtual void RegisterJITEventListener(JITEventListener *) {} virtual void UnregisterJITEventListener(JITEventListener *) {} - /// DisableLazyCompilation - If called, the JIT will abort if lazy compilation - /// is ever attempted. + /// DisableLazyCompilation - When lazy compilation is off (the default), the + /// JIT will eagerly compile every function reachable from the argument to + /// getPointerToFunction. If lazy compilation is turned on, the JIT will only + /// compile the one function and emit stubs to compile the rest when they're + /// first called. If lazy compilation is turned off again while some lazy + /// stubs are still around, and one of those stubs is called, the program will + /// abort. + /// + /// In order to safely compile lazily in a threaded program, the user must + /// ensure that 1) only one thread at a time can call any particular lazy + /// stub, and 2) any thread modifying LLVM IR must hold the JIT's lock + /// (ExecutionEngine::lock) or otherwise ensure that no other thread calls a + /// lazy stub. See http://llvm.org/PR5184 for details. void DisableLazyCompilation(bool Disabled = true) { - LazyCompilationDisabled = Disabled; + CompilingLazily = !Disabled; + } + bool isCompilingLazily() const { + return CompilingLazily; } + // Deprecated in favor of isCompilingLazily (to reduce double-negatives). + // Remove this in LLVM 2.8. bool isLazyCompilationDisabled() const { - return LazyCompilationDisabled; + return !CompilingLazily; } /// DisableGVCompilation - If called, the JIT will abort if it's asked to @@ -485,15 +500,8 @@ class EngineBuilder { } ExecutionEngine *create(); - }; -inline bool operator<(const ExecutionEngineState::MapUpdatingCVH& lhs, - const ExecutionEngineState::MapUpdatingCVH& rhs) { - return static_cast<const GlobalValue*>(lhs) < - static_cast<const GlobalValue*>(rhs); -} - } // End llvm namespace #endif |