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