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