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