9#ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
10#define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H
30 std::shared_ptr<LegacyJITSymbolResolver>
Resolver)
42 std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
43 void anchor()
override;
67 MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
68 std::shared_ptr<MCJITMemoryManager> MemMgr,
69 std::shared_ptr<LegacyJITSymbolResolver> Resolver);
73 class OwningModuleContainer {
75 OwningModuleContainer() =
default;
76 ~OwningModuleContainer() {
77 freeModulePtrSet(AddedModules);
78 freeModulePtrSet(LoadedModules);
79 freeModulePtrSet(FinalizedModules);
94 void addModule(std::unique_ptr<Module> M) {
95 AddedModules.
insert(M.release());
99 return AddedModules.
erase(M) || LoadedModules.
erase(M) ||
100 FinalizedModules.
erase(M);
103 bool hasModuleBeenAddedButNotLoaded(
Module *M) {
107 bool hasModuleBeenLoaded(
Module *M) {
113 bool hasModuleBeenFinalized(
Module *M) {
114 return FinalizedModules.
contains(M);
117 bool ownsModule(
Module* M) {
122 void markModuleAsLoaded(
Module *M) {
127 "markModuleAsLoaded: Module not found in AddedModules");
130 AddedModules.
erase(M);
136 void markModuleAsFinalized(
Module *M) {
142 "markModuleAsFinalized: Module not found in LoadedModules");
145 LoadedModules.
erase(M);
149 FinalizedModules.
insert(M);
152 void markAllLoadedModulesAsFinalized() {
154 LoadedModules.
clear();
158 ModulePtrSet AddedModules;
159 ModulePtrSet LoadedModules;
160 ModulePtrSet FinalizedModules;
162 void freeModulePtrSet(ModulePtrSet& MPS) {
170 std::unique_ptr<TargetMachine> TM;
172 std::shared_ptr<MCJITMemoryManager> MemMgr;
175 std::vector<JITEventListener*> EventListeners;
177 OwningModuleContainer OwnedModules;
197 void runStaticConstructorsDestructorsInModulePtrSet(
bool isDtors,
206 void addModule(std::unique_ptr<Module> M)
override;
207 void addObjectFile(std::unique_ptr<object::ObjectFile> O)
override;
221 bool AllowInternal =
false)
override;
227 Dyld.setProcessAllSections(ProcessAllSections);
265 bool AbortOnFailure =
true)
override;
273 Dyld.mapSectionAddress(LocalAddress, TargetAddress);
295 createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
296 std::shared_ptr<MCJITMemoryManager> MemMgr,
297 std::shared_ptr<LegacyJITSymbolResolver>
Resolver,
298 std::unique_ptr<TargetMachine> TM);
314 bool CheckFunctionsOnly);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter...
static ExecutionEngine *(* MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< LegacyJITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM)
ExecutionEngine(DataLayout DL)
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
Represents a symbol in the JIT.
Legacy symbol resolution interface.
LinkingSymbolResolver(MCJIT &Parent, std::shared_ptr< LegacyJITSymbolResolver > Resolver)
JITSymbol findSymbol(const std::string &Name) override
This method returns the address of the specified function or variable.
JITSymbol findSymbolInLogicalDylib(const std::string &Name) override
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
Context object for machine code objects.
GenericValue runFunction(Function *F, ArrayRef< GenericValue > ArgValues) override
runFunction - Execute the specified function with the specified arguments, and return the result.
void setProcessAllSections(bool ProcessAllSections) override
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are p...
void * getPointerToNamedFunction(StringRef Name, bool AbortOnFailure=true) override
getPointerToNamedFunction - This method returns the address of the specified function by using the dl...
void RegisterJITEventListener(JITEventListener *L) override
Registers a listener to be called back on various events within the JIT.
static ExecutionEngine * createJIT(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< LegacyJITSymbolResolver > Resolver, std::unique_ptr< TargetMachine > TM)
void runStaticConstructorsDestructors(bool isDtors) override
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or d...
Module * findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly)
void addArchive(object::OwningBinary< object::Archive > O) override
addArchive - Add an Archive to the execution engine.
Function * FindFunctionNamed(StringRef FnName) override
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
void finalizeObject() override
finalizeObject - ensure the module is fully processed and is usable.
void finalizeLoadedModules()
void notifyObjectLoaded(const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L)
void generateCodeForModule(Module *M) override
generateCodeForModule - Run code generation for the specified module and load it into memory.
uint64_t getFunctionAddress(const std::string &Name) override
getFunctionAddress - Return the address of the specified function.
void addObjectFile(std::unique_ptr< object::ObjectFile > O) override
addObjectFile - Add an ObjectFile to the execution engine.
std::unique_ptr< MemoryBuffer > emitObject(Module *M)
emitObject – Generate a JITed object in memory from the specified module Currently,...
TargetMachine * getTargetMachine() override
Return the target machine (if available).
void UnregisterJITEventListener(JITEventListener *L) override
bool removeModule(Module *M) override
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress) override
mapSectionAddress - map a section to its target address space value.
JITSymbol findExistingSymbol(const std::string &Name)
GlobalVariable * FindGlobalVariableNamed(StringRef Name, bool AllowInternal=false) override
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines N...
uint64_t getGlobalValueAddress(const std::string &Name) override
getGlobalValueAddress - Return the address of the specified global value.
uint64_t getSymbolAddress(const std::string &Name, bool CheckFunctionsOnly)
void notifyFreeingObject(const object::ObjectFile &Obj)
virtual void finalizeModule(Module *)
JITSymbol findSymbol(const std::string &Name, bool CheckFunctionsOnly)
void * getPointerToFunction(Function *F) override
getPointerToFunction - The different EE's represent function bodies in different ways.
void setObjectCache(ObjectCache *manager) override
Sets the object manager that MCJIT should use to avoid compilation.
void addModule(std::unique_ptr< Module > M) override
Add a Module to the list of modules that we can JIT from.
A Module instance is used to store all the information related to an LLVM module.
This is the base ObjectCache type which can be provided to an ExecutionEngine for the purpose of avoi...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Information about the loaded object.
bool erase(PtrType Ptr)
Remove pointer from the set.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSetIterator< PtrType > iterator
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
A range adaptor for a pair of iterators.
This class is the base class for all object file types.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.