LLVM API Documentation

Public Member Functions | Protected Member Functions
llvm::MCJIT Class Reference

#include <MCJIT.h>

Inheritance diagram for llvm::MCJIT:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCJIT:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~MCJIT ()
ExecutionEngine interface implementation
virtual void setObjectCache (ObjectCache *manager)
 Sets the object manager that MCJIT should use to avoid compilation.
virtual void finalizeObject ()
virtual void * getPointerToBasicBlock (BasicBlock *BB)
virtual void * getPointerToFunction (Function *F)
virtual void * recompileAndRelinkFunction (Function *F)
virtual void freeMachineCodeForFunction (Function *F)
virtual GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues)
virtual void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)
virtual void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
virtual void RegisterJITEventListener (JITEventListener *L)
virtual void UnregisterJITEventListener (JITEventListener *L)

Static Public Member Functions

(Private) Registration Interfaces
static void Register ()
static ExecutionEnginecreateJIT (Module *M, std::string *ErrorStr, RTDyldMemoryManager *MemMgr, bool GVsWithCode, TargetMachine *TM)

Protected Member Functions

ObjectBufferStreamemitObject (Module *M)
void loadObject (Module *M)
void NotifyObjectEmitted (const ObjectImage &Obj)
void NotifyFreeingObject (const ObjectImage &Obj)

Detailed Description

Definition at line 27 of file lib/ExecutionEngine/MCJIT/MCJIT.h.


Constructor & Destructor Documentation

MCJIT::~MCJIT ( )

Definition at line 62 of file MCJIT.cpp.

References llvm::OwningPtr< T >::get(), and NotifyFreeingObject().


Member Function Documentation

ExecutionEngine * MCJIT::createJIT ( Module M,
std::string *  ErrorStr,
RTDyldMemoryManager MemMgr,
bool  GVsWithCode,
TargetMachine TM 
) [static]

Definition at line 40 of file MCJIT.cpp.

References llvm::sys::DynamicLibrary::LoadLibraryPermanently().

Referenced by Register().

ObjectBufferStream * MCJIT::emitObject ( Module M) [protected]

emitObject -- Generate a JITed object in memory from the specified module Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module. The module is passed as a parameter here to prepare for multiple module support in the future.

Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module. The module is passed as a parameter here to prepare for multiple module support in the future.

Definition at line 73 of file MCJIT.cpp.

References llvm::PassManager::add(), llvm::TargetMachine::addPassesToEmitMC(), llvm::TargetMachine::getDataLayout(), llvm::ExecutionEngine::lock, llvm::ObjectCache::notifyObjectCompiled(), llvm::report_fatal_error(), llvm::PassManager::run(), and llvm::OwningPtr< T >::take().

Referenced by loadObject().

void MCJIT::finalizeObject ( ) [virtual]

finalizeObject - ensure the module is fully processed and is usable.

It is the user-level function for completing the process of making the object usable for execution. It should be called after sections within an object have been relocated using mapSectionAddress. When this method is called the MCJIT execution engine will reapply relocations for a loaded object.

Reimplemented from llvm::ExecutionEngine.

Definition at line 165 of file MCJIT.cpp.

References llvm::StringRef::empty(), llvm::RTDyldMemoryManager::finalizeMemory(), llvm::RuntimeDyld::getEHFrameSection(), loadObject(), llvm::RTDyldMemoryManager::registerEHFrames(), and llvm::RuntimeDyld::resolveRelocations().

void MCJIT::freeMachineCodeForFunction ( Function F) [virtual]

freeMachineCodeForFunction - Release memory in the ExecutionEngine corresponding to the machine code emitted to execute this function, useful for garbage-collecting generated code.

Implements llvm::ExecutionEngine.

Definition at line 221 of file MCJIT.cpp.

References llvm::report_fatal_error().

void * MCJIT::getPointerToBasicBlock ( BasicBlock BB) [virtual]

getPointerToBasicBlock - The different EE's represent basic blocks in different ways. Return the representation for a blockaddress of the specified block.

Implements llvm::ExecutionEngine.

Definition at line 184 of file MCJIT.cpp.

References llvm::report_fatal_error().

void * MCJIT::getPointerToFunction ( Function F) [virtual]

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 and free any machine code. Be sure no threads are running inside F when that happens.

Implements llvm::ExecutionEngine.

Definition at line 188 of file MCJIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), llvm::MCAsmInfo::getGlobalPrefix(), llvm::TargetMachine::getMCAsmInfo(), llvm::Value::getName(), getPointerToNamedFunction(), llvm::RuntimeDyld::getSymbolLoadAddress(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::isDeclaration(), loadObject(), and llvm::StringRef::substr().

Referenced by runFunction().

void * MCJIT::getPointerToNamedFunction ( const std::string &  Name,
bool  AbortOnFailure = true 
) [virtual]

getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. As such it is only useful for resolving library symbols, not code generated symbols.

If AbortOnFailure is false and no function with the given name is found, this function silently returns a null pointer. Otherwise, it prints a message to stderr and aborts.

If a LazyFunctionCreator is installed, use it to get/create the function.

Implements llvm::ExecutionEngine.

Definition at line 325 of file MCJIT.cpp.

References llvm::RTDyldMemoryManager::getPointerToNamedFunction(), llvm::ExecutionEngine::isSymbolSearchingDisabled(), llvm::ExecutionEngine::LazyFunctionCreator, loadObject(), and llvm::report_fatal_error().

Referenced by getPointerToFunction().

void MCJIT::loadObject ( Module M) [protected]
virtual void llvm::MCJIT::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
) [inline, virtual]

mapSectionAddress - map a section to its target address space value. Map the address of a JIT section as returned from the memory manager to the address in the target process as the running code will see it. This is the address which will be used for relocation resolution.

Reimplemented from llvm::ExecutionEngine.

Definition at line 90 of file lib/ExecutionEngine/MCJIT/MCJIT.h.

References llvm::RuntimeDyld::mapSectionAddress().

void MCJIT::NotifyFreeingObject ( const ObjectImage Obj) [protected]

Definition at line 372 of file MCJIT.cpp.

References I, llvm::ExecutionEngine::lock, and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by ~MCJIT().

void MCJIT::NotifyObjectEmitted ( const ObjectImage Obj) [protected]
void * MCJIT::recompileAndRelinkFunction ( Function F) [virtual]

recompileAndRelinkFunction - This method is used to force a function which has already been compiled to be compiled again, possibly after it has been modified. Then the entry to the old copy is overwritten with a branch to the new copy. If there was no old copy, this acts just like VM::getPointerToFunction().

Implements llvm::ExecutionEngine.

Definition at line 217 of file MCJIT.cpp.

References llvm::report_fatal_error().

static void llvm::MCJIT::Register ( ) [inline, static]
void MCJIT::RegisterJITEventListener ( JITEventListener ) [virtual]

Registers a listener to be called back on various events within the JIT. See JITEventListener.h for more details. Does not take ownership of the argument. The argument may be NULL, in which case these functions do nothing.

Reimplemented from llvm::ExecutionEngine.

Definition at line 349 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock, and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().

GenericValue MCJIT::runFunction ( Function F,
const std::vector< GenericValue > &  ArgValues 
) [virtual]
void MCJIT::setObjectCache ( ObjectCache manager) [virtual]

Sets the object manager that MCJIT should use to avoid compilation.

Reimplemented from llvm::ExecutionEngine.

Definition at line 69 of file MCJIT.cpp.

void MCJIT::UnregisterJITEventListener ( JITEventListener L) [virtual]

The documentation for this class was generated from the following files: