LLVM API Documentation

MCJIT.cpp
Go to the documentation of this file.
00001 //===-- MCJIT.cpp - MC-based Just-in-Time Compiler ------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "MCJIT.h"
00011 #include "llvm/ExecutionEngine/GenericValue.h"
00012 #include "llvm/ExecutionEngine/JITEventListener.h"
00013 #include "llvm/ExecutionEngine/MCJIT.h"
00014 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
00015 #include "llvm/IR/DataLayout.h"
00016 #include "llvm/IR/DerivedTypes.h"
00017 #include "llvm/IR/Function.h"
00018 #include "llvm/IR/Mangler.h"
00019 #include "llvm/IR/Module.h"
00020 #include "llvm/MC/MCAsmInfo.h"
00021 #include "llvm/Object/Archive.h"
00022 #include "llvm/Object/ObjectFile.h"
00023 #include "llvm/PassManager.h"
00024 #include "llvm/Support/DynamicLibrary.h"
00025 #include "llvm/Support/ErrorHandling.h"
00026 #include "llvm/Support/MemoryBuffer.h"
00027 #include "llvm/Support/MutexGuard.h"
00028 #include "llvm/Target/TargetLowering.h"
00029 #include "llvm/Target/TargetSubtargetInfo.h"
00030 
00031 using namespace llvm;
00032 
00033 void ObjectCache::anchor() {}
00034 
00035 namespace {
00036 
00037 static struct RegisterJIT {
00038   RegisterJIT() { MCJIT::Register(); }
00039 } JITRegistrator;
00040 
00041 }
00042 
00043 extern "C" void LLVMLinkInMCJIT() {
00044 }
00045 
00046 ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M,
00047                                   std::string *ErrorStr,
00048                                   std::unique_ptr<RTDyldMemoryManager> MemMgr,
00049                                   std::unique_ptr<TargetMachine> TM) {
00050   // Try to register the program as a source of symbols to resolve against.
00051   //
00052   // FIXME: Don't do this here.
00053   sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr);
00054 
00055   std::unique_ptr<RTDyldMemoryManager> MM = std::move(MemMgr);
00056   if (!MM)
00057     MM = std::unique_ptr<SectionMemoryManager>(new SectionMemoryManager());
00058 
00059   return new MCJIT(std::move(M), std::move(TM), std::move(MM));
00060 }
00061 
00062 MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
00063              std::unique_ptr<RTDyldMemoryManager> MM)
00064     : ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
00065       MemMgr(this, std::move(MM)), Dyld(&MemMgr), ObjCache(nullptr) {
00066   // FIXME: We are managing our modules, so we do not want the base class
00067   // ExecutionEngine to manage them as well. To avoid double destruction
00068   // of the first (and only) module added in ExecutionEngine constructor
00069   // we remove it from EE and will destruct it ourselves.
00070   //
00071   // It may make sense to move our module manager (based on SmallStPtr) back
00072   // into EE if the JIT and Interpreter can live with it.
00073   // If so, additional functions: addModule, removeModule, FindFunctionNamed,
00074   // runStaticConstructorsDestructors could be moved back to EE as well.
00075   //
00076   std::unique_ptr<Module> First = std::move(Modules[0]);
00077   Modules.clear();
00078 
00079   OwnedModules.addModule(std::move(First));
00080   setDataLayout(TM->getSubtargetImpl()->getDataLayout());
00081   RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
00082 }
00083 
00084 MCJIT::~MCJIT() {
00085   MutexGuard locked(lock);
00086 
00087   Dyld.deregisterEHFrames();
00088 
00089   for (auto &Obj : LoadedObjects)
00090     if (Obj)
00091       NotifyFreeingObject(*Obj);
00092 
00093   Archives.clear();
00094 }
00095 
00096 void MCJIT::addModule(std::unique_ptr<Module> M) {
00097   MutexGuard locked(lock);
00098   OwnedModules.addModule(std::move(M));
00099 }
00100 
00101 bool MCJIT::removeModule(Module *M) {
00102   MutexGuard locked(lock);
00103   return OwnedModules.removeModule(M);
00104 }
00105 
00106 void MCJIT::addObjectFile(std::unique_ptr<object::ObjectFile> Obj) {
00107   std::unique_ptr<RuntimeDyld::LoadedObjectInfo> L = Dyld.loadObject(*Obj);
00108   if (Dyld.hasError())
00109     report_fatal_error(Dyld.getErrorString());
00110 
00111   NotifyObjectEmitted(*Obj, *L);
00112 
00113   LoadedObjects.push_back(std::move(Obj));
00114 }
00115 
00116 void MCJIT::addObjectFile(object::OwningBinary<object::ObjectFile> Obj) {
00117   std::unique_ptr<object::ObjectFile> ObjFile;
00118   std::unique_ptr<MemoryBuffer> MemBuf;
00119   std::tie(ObjFile, MemBuf) = Obj.takeBinary();
00120   addObjectFile(std::move(ObjFile));
00121   Buffers.push_back(std::move(MemBuf));
00122 }
00123 
00124 void MCJIT::addArchive(object::OwningBinary<object::Archive> A) {
00125   Archives.push_back(std::move(A));
00126 }
00127 
00128 void MCJIT::setObjectCache(ObjectCache* NewCache) {
00129   MutexGuard locked(lock);
00130   ObjCache = NewCache;
00131 }
00132 
00133 std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
00134   MutexGuard locked(lock);
00135 
00136   // This must be a module which has already been added but not loaded to this
00137   // MCJIT instance, since these conditions are tested by our caller,
00138   // generateCodeForModule.
00139 
00140   PassManager PM;
00141 
00142   M->setDataLayout(TM->getSubtargetImpl()->getDataLayout());
00143   PM.add(new DataLayoutPass());
00144 
00145   // The RuntimeDyld will take ownership of this shortly
00146   SmallVector<char, 4096> ObjBufferSV;
00147   raw_svector_ostream ObjStream(ObjBufferSV);
00148 
00149   // Turn the machine code intermediate representation into bytes in memory
00150   // that may be executed.
00151   if (TM->addPassesToEmitMC(PM, Ctx, ObjStream, !getVerifyModules()))
00152     report_fatal_error("Target does not support MC emission!");
00153 
00154   // Initialize passes.
00155   PM.run(*M);
00156   // Flush the output buffer to get the generated code into memory
00157   ObjStream.flush();
00158 
00159   std::unique_ptr<MemoryBuffer> CompiledObjBuffer(
00160                                 new ObjectMemoryBuffer(std::move(ObjBufferSV)));
00161 
00162   // If we have an object cache, tell it about the new object.
00163   // Note that we're using the compiled image, not the loaded image (as below).
00164   if (ObjCache) {
00165     // MemoryBuffer is a thin wrapper around the actual memory, so it's OK
00166     // to create a temporary object here and delete it after the call.
00167     MemoryBufferRef MB = CompiledObjBuffer->getMemBufferRef();
00168     ObjCache->notifyObjectCompiled(M, MB);
00169   }
00170 
00171   return CompiledObjBuffer;
00172 }
00173 
00174 void MCJIT::generateCodeForModule(Module *M) {
00175   // Get a thread lock to make sure we aren't trying to load multiple times
00176   MutexGuard locked(lock);
00177 
00178   // This must be a module which has already been added to this MCJIT instance.
00179   assert(OwnedModules.ownsModule(M) &&
00180          "MCJIT::generateCodeForModule: Unknown module.");
00181 
00182   // Re-compilation is not supported
00183   if (OwnedModules.hasModuleBeenLoaded(M))
00184     return;
00185 
00186   std::unique_ptr<MemoryBuffer> ObjectToLoad;
00187   // Try to load the pre-compiled object from cache if possible
00188   if (ObjCache)
00189     ObjectToLoad = ObjCache->getObject(M);
00190 
00191   // If the cache did not contain a suitable object, compile the object
00192   if (!ObjectToLoad) {
00193     ObjectToLoad = emitObject(M);
00194     assert(ObjectToLoad && "Compilation did not produce an object.");
00195   }
00196 
00197   // Load the object into the dynamic linker.
00198   // MCJIT now owns the ObjectImage pointer (via its LoadedObjects list).
00199   ErrorOr<std::unique_ptr<object::ObjectFile>> LoadedObject =
00200     object::ObjectFile::createObjectFile(ObjectToLoad->getMemBufferRef());
00201   std::unique_ptr<RuntimeDyld::LoadedObjectInfo> L =
00202     Dyld.loadObject(*LoadedObject.get());
00203 
00204   if (Dyld.hasError())
00205     report_fatal_error(Dyld.getErrorString());
00206 
00207   NotifyObjectEmitted(*LoadedObject.get(), *L);
00208 
00209   Buffers.push_back(std::move(ObjectToLoad));
00210   LoadedObjects.push_back(std::move(*LoadedObject));
00211 
00212   OwnedModules.markModuleAsLoaded(M);
00213 }
00214 
00215 void MCJIT::finalizeLoadedModules() {
00216   MutexGuard locked(lock);
00217 
00218   // Resolve any outstanding relocations.
00219   Dyld.resolveRelocations();
00220 
00221   OwnedModules.markAllLoadedModulesAsFinalized();
00222 
00223   // Register EH frame data for any module we own which has been loaded
00224   Dyld.registerEHFrames();
00225 
00226   // Set page permissions.
00227   MemMgr.finalizeMemory();
00228 }
00229 
00230 // FIXME: Rename this.
00231 void MCJIT::finalizeObject() {
00232   MutexGuard locked(lock);
00233 
00234   // Generate code for module is going to move objects out of the 'added' list,
00235   // so we need to copy that out before using it:
00236   SmallVector<Module*, 16> ModsToAdd;
00237   for (auto M : OwnedModules.added())
00238     ModsToAdd.push_back(M);
00239 
00240   for (auto M : ModsToAdd)
00241     generateCodeForModule(M);
00242 
00243   finalizeLoadedModules();
00244 }
00245 
00246 void MCJIT::finalizeModule(Module *M) {
00247   MutexGuard locked(lock);
00248 
00249   // This must be a module which has already been added to this MCJIT instance.
00250   assert(OwnedModules.ownsModule(M) && "MCJIT::finalizeModule: Unknown module.");
00251 
00252   // If the module hasn't been compiled, just do that.
00253   if (!OwnedModules.hasModuleBeenLoaded(M))
00254     generateCodeForModule(M);
00255 
00256   finalizeLoadedModules();
00257 }
00258 
00259 uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) {
00260   Mangler Mang(TM->getSubtargetImpl()->getDataLayout());
00261   SmallString<128> FullName;
00262   Mang.getNameWithPrefix(FullName, Name);
00263   return Dyld.getSymbolLoadAddress(FullName);
00264 }
00265 
00266 Module *MCJIT::findModuleForSymbol(const std::string &Name,
00267                                    bool CheckFunctionsOnly) {
00268   MutexGuard locked(lock);
00269 
00270   // If it hasn't already been generated, see if it's in one of our modules.
00271   for (ModulePtrSet::iterator I = OwnedModules.begin_added(),
00272                               E = OwnedModules.end_added();
00273        I != E; ++I) {
00274     Module *M = *I;
00275     Function *F = M->getFunction(Name);
00276     if (F && !F->isDeclaration())
00277       return M;
00278     if (!CheckFunctionsOnly) {
00279       GlobalVariable *G = M->getGlobalVariable(Name);
00280       if (G && !G->isDeclaration())
00281         return M;
00282       // FIXME: Do we need to worry about global aliases?
00283     }
00284   }
00285   // We didn't find the symbol in any of our modules.
00286   return nullptr;
00287 }
00288 
00289 uint64_t MCJIT::getSymbolAddress(const std::string &Name,
00290                                  bool CheckFunctionsOnly)
00291 {
00292   MutexGuard locked(lock);
00293 
00294   // First, check to see if we already have this symbol.
00295   uint64_t Addr = getExistingSymbolAddress(Name);
00296   if (Addr)
00297     return Addr;
00298 
00299   for (object::OwningBinary<object::Archive> &OB : Archives) {
00300     object::Archive *A = OB.getBinary();
00301     // Look for our symbols in each Archive
00302     object::Archive::child_iterator ChildIt = A->findSym(Name);
00303     if (ChildIt != A->child_end()) {
00304       // FIXME: Support nested archives?
00305       ErrorOr<std::unique_ptr<object::Binary>> ChildBinOrErr =
00306           ChildIt->getAsBinary();
00307       if (ChildBinOrErr.getError())
00308         continue;
00309       std::unique_ptr<object::Binary> &ChildBin = ChildBinOrErr.get();
00310       if (ChildBin->isObject()) {
00311         std::unique_ptr<object::ObjectFile> OF(
00312             static_cast<object::ObjectFile *>(ChildBin.release()));
00313         // This causes the object file to be loaded.
00314         addObjectFile(std::move(OF));
00315         // The address should be here now.
00316         Addr = getExistingSymbolAddress(Name);
00317         if (Addr)
00318           return Addr;
00319       }
00320     }
00321   }
00322 
00323   // If it hasn't already been generated, see if it's in one of our modules.
00324   Module *M = findModuleForSymbol(Name, CheckFunctionsOnly);
00325   if (M) {
00326     generateCodeForModule(M);
00327 
00328     // Check the RuntimeDyld table again, it should be there now.
00329     return getExistingSymbolAddress(Name);
00330   }
00331 
00332   // If a LazyFunctionCreator is installed, use it to get/create the function.
00333   // FIXME: Should we instead have a LazySymbolCreator callback?
00334   if (LazyFunctionCreator)
00335     Addr = (uint64_t)LazyFunctionCreator(Name);
00336 
00337   return Addr;
00338 }
00339 
00340 uint64_t MCJIT::getGlobalValueAddress(const std::string &Name) {
00341   MutexGuard locked(lock);
00342   uint64_t Result = getSymbolAddress(Name, false);
00343   if (Result != 0)
00344     finalizeLoadedModules();
00345   return Result;
00346 }
00347 
00348 uint64_t MCJIT::getFunctionAddress(const std::string &Name) {
00349   MutexGuard locked(lock);
00350   uint64_t Result = getSymbolAddress(Name, true);
00351   if (Result != 0)
00352     finalizeLoadedModules();
00353   return Result;
00354 }
00355 
00356 // Deprecated.  Use getFunctionAddress instead.
00357 void *MCJIT::getPointerToFunction(Function *F) {
00358   MutexGuard locked(lock);
00359 
00360   Mangler Mang(TM->getSubtargetImpl()->getDataLayout());
00361   SmallString<128> Name;
00362   TM->getNameWithPrefix(Name, F, Mang);
00363 
00364   if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) {
00365     bool AbortOnFailure = !F->hasExternalWeakLinkage();
00366     void *Addr = getPointerToNamedFunction(Name, AbortOnFailure);
00367     updateGlobalMapping(F, Addr);
00368     return Addr;
00369   }
00370 
00371   Module *M = F->getParent();
00372   bool HasBeenAddedButNotLoaded = OwnedModules.hasModuleBeenAddedButNotLoaded(M);
00373 
00374   // Make sure the relevant module has been compiled and loaded.
00375   if (HasBeenAddedButNotLoaded)
00376     generateCodeForModule(M);
00377   else if (!OwnedModules.hasModuleBeenLoaded(M)) {
00378     // If this function doesn't belong to one of our modules, we're done.
00379     // FIXME: Asking for the pointer to a function that hasn't been registered,
00380     //        and isn't a declaration (which is handled above) should probably
00381     //        be an assertion.
00382     return nullptr;
00383   }
00384 
00385   // FIXME: Should the Dyld be retaining module information? Probably not.
00386   //
00387   // This is the accessor for the target address, so make sure to check the
00388   // load address of the symbol, not the local address.
00389   return (void*)Dyld.getSymbolLoadAddress(Name);
00390 }
00391 
00392 void MCJIT::runStaticConstructorsDestructorsInModulePtrSet(
00393     bool isDtors, ModulePtrSet::iterator I, ModulePtrSet::iterator E) {
00394   for (; I != E; ++I) {
00395     ExecutionEngine::runStaticConstructorsDestructors(**I, isDtors);
00396   }
00397 }
00398 
00399 void MCJIT::runStaticConstructorsDestructors(bool isDtors) {
00400   // Execute global ctors/dtors for each module in the program.
00401   runStaticConstructorsDestructorsInModulePtrSet(
00402       isDtors, OwnedModules.begin_added(), OwnedModules.end_added());
00403   runStaticConstructorsDestructorsInModulePtrSet(
00404       isDtors, OwnedModules.begin_loaded(), OwnedModules.end_loaded());
00405   runStaticConstructorsDestructorsInModulePtrSet(
00406       isDtors, OwnedModules.begin_finalized(), OwnedModules.end_finalized());
00407 }
00408 
00409 Function *MCJIT::FindFunctionNamedInModulePtrSet(const char *FnName,
00410                                                  ModulePtrSet::iterator I,
00411                                                  ModulePtrSet::iterator E) {
00412   for (; I != E; ++I) {
00413     if (Function *F = (*I)->getFunction(FnName))
00414       return F;
00415   }
00416   return nullptr;
00417 }
00418 
00419 Function *MCJIT::FindFunctionNamed(const char *FnName) {
00420   Function *F = FindFunctionNamedInModulePtrSet(
00421       FnName, OwnedModules.begin_added(), OwnedModules.end_added());
00422   if (!F)
00423     F = FindFunctionNamedInModulePtrSet(FnName, OwnedModules.begin_loaded(),
00424                                         OwnedModules.end_loaded());
00425   if (!F)
00426     F = FindFunctionNamedInModulePtrSet(FnName, OwnedModules.begin_finalized(),
00427                                         OwnedModules.end_finalized());
00428   return F;
00429 }
00430 
00431 GenericValue MCJIT::runFunction(Function *F,
00432                                 const std::vector<GenericValue> &ArgValues) {
00433   assert(F && "Function *F was null at entry to run()");
00434 
00435   void *FPtr = getPointerToFunction(F);
00436   assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
00437   FunctionType *FTy = F->getFunctionType();
00438   Type *RetTy = FTy->getReturnType();
00439 
00440   assert((FTy->getNumParams() == ArgValues.size() ||
00441           (FTy->isVarArg() && FTy->getNumParams() <= ArgValues.size())) &&
00442          "Wrong number of arguments passed into function!");
00443   assert(FTy->getNumParams() == ArgValues.size() &&
00444          "This doesn't support passing arguments through varargs (yet)!");
00445 
00446   // Handle some common cases first.  These cases correspond to common `main'
00447   // prototypes.
00448   if (RetTy->isIntegerTy(32) || RetTy->isVoidTy()) {
00449     switch (ArgValues.size()) {
00450     case 3:
00451       if (FTy->getParamType(0)->isIntegerTy(32) &&
00452           FTy->getParamType(1)->isPointerTy() &&
00453           FTy->getParamType(2)->isPointerTy()) {
00454         int (*PF)(int, char **, const char **) =
00455           (int(*)(int, char **, const char **))(intptr_t)FPtr;
00456 
00457         // Call the function.
00458         GenericValue rv;
00459         rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(),
00460                                  (char **)GVTOP(ArgValues[1]),
00461                                  (const char **)GVTOP(ArgValues[2])));
00462         return rv;
00463       }
00464       break;
00465     case 2:
00466       if (FTy->getParamType(0)->isIntegerTy(32) &&
00467           FTy->getParamType(1)->isPointerTy()) {
00468         int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
00469 
00470         // Call the function.
00471         GenericValue rv;
00472         rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(),
00473                                  (char **)GVTOP(ArgValues[1])));
00474         return rv;
00475       }
00476       break;
00477     case 1:
00478       if (FTy->getNumParams() == 1 &&
00479           FTy->getParamType(0)->isIntegerTy(32)) {
00480         GenericValue rv;
00481         int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
00482         rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
00483         return rv;
00484       }
00485       break;
00486     }
00487   }
00488 
00489   // Handle cases where no arguments are passed first.
00490   if (ArgValues.empty()) {
00491     GenericValue rv;
00492     switch (RetTy->getTypeID()) {
00493     default: llvm_unreachable("Unknown return type for function call!");
00494     case Type::IntegerTyID: {
00495       unsigned BitWidth = cast<IntegerType>(RetTy)->getBitWidth();
00496       if (BitWidth == 1)
00497         rv.IntVal = APInt(BitWidth, ((bool(*)())(intptr_t)FPtr)());
00498       else if (BitWidth <= 8)
00499         rv.IntVal = APInt(BitWidth, ((char(*)())(intptr_t)FPtr)());
00500       else if (BitWidth <= 16)
00501         rv.IntVal = APInt(BitWidth, ((short(*)())(intptr_t)FPtr)());
00502       else if (BitWidth <= 32)
00503         rv.IntVal = APInt(BitWidth, ((int(*)())(intptr_t)FPtr)());
00504       else if (BitWidth <= 64)
00505         rv.IntVal = APInt(BitWidth, ((int64_t(*)())(intptr_t)FPtr)());
00506       else
00507         llvm_unreachable("Integer types > 64 bits not supported");
00508       return rv;
00509     }
00510     case Type::VoidTyID:
00511       rv.IntVal = APInt(32, ((int(*)())(intptr_t)FPtr)());
00512       return rv;
00513     case Type::FloatTyID:
00514       rv.FloatVal = ((float(*)())(intptr_t)FPtr)();
00515       return rv;
00516     case Type::DoubleTyID:
00517       rv.DoubleVal = ((double(*)())(intptr_t)FPtr)();
00518       return rv;
00519     case Type::X86_FP80TyID:
00520     case Type::FP128TyID:
00521     case Type::PPC_FP128TyID:
00522       llvm_unreachable("long double not supported yet");
00523     case Type::PointerTyID:
00524       return PTOGV(((void*(*)())(intptr_t)FPtr)());
00525     }
00526   }
00527 
00528   llvm_unreachable("Full-featured argument passing not supported yet!");
00529 }
00530 
00531 void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
00532   if (!isSymbolSearchingDisabled()) {
00533     void *ptr = MemMgr.getPointerToNamedFunction(Name, false);
00534     if (ptr)
00535       return ptr;
00536   }
00537 
00538   /// If a LazyFunctionCreator is installed, use it to get/create the function.
00539   if (LazyFunctionCreator)
00540     if (void *RP = LazyFunctionCreator(Name))
00541       return RP;
00542 
00543   if (AbortOnFailure) {
00544     report_fatal_error("Program used external function '"+Name+
00545                        "' which could not be resolved!");
00546   }
00547   return nullptr;
00548 }
00549 
00550 void MCJIT::RegisterJITEventListener(JITEventListener *L) {
00551   if (!L)
00552     return;
00553   MutexGuard locked(lock);
00554   EventListeners.push_back(L);
00555 }
00556 
00557 void MCJIT::UnregisterJITEventListener(JITEventListener *L) {
00558   if (!L)
00559     return;
00560   MutexGuard locked(lock);
00561   auto I = std::find(EventListeners.rbegin(), EventListeners.rend(), L);
00562   if (I != EventListeners.rend()) {
00563     std::swap(*I, EventListeners.back());
00564     EventListeners.pop_back();
00565   }
00566 }
00567 
00568 void MCJIT::NotifyObjectEmitted(const object::ObjectFile& Obj,
00569                                 const RuntimeDyld::LoadedObjectInfo &L) {
00570   MutexGuard locked(lock);
00571   MemMgr.notifyObjectLoaded(this, Obj);
00572   for (unsigned I = 0, S = EventListeners.size(); I < S; ++I) {
00573     EventListeners[I]->NotifyObjectEmitted(Obj, L);
00574   }
00575 }
00576 
00577 void MCJIT::NotifyFreeingObject(const object::ObjectFile& Obj) {
00578   MutexGuard locked(lock);
00579   for (JITEventListener *L : EventListeners)
00580     L->NotifyFreeingObject(Obj);
00581 }
00582 
00583 uint64_t LinkingMemoryManager::getSymbolAddress(const std::string &Name) {
00584   uint64_t Result = ParentEngine->getSymbolAddress(Name, false);
00585   // If the symbols wasn't found and it begins with an underscore, try again
00586   // without the underscore.
00587   if (!Result && Name[0] == '_')
00588     Result = ParentEngine->getSymbolAddress(Name.substr(1), false);
00589   if (Result)
00590     return Result;
00591   if (ParentEngine->isSymbolSearchingDisabled())
00592     return 0;
00593   return ClientMM->getSymbolAddress(Name);
00594 }