//===-- MCJIT.h - Class definition for the MCJIT ----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H #define LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" namespace llvm { class MCJIT; class Module; class ObjectCache; // This is a helper class that the MCJIT execution engine uses for linking // functions across modules that it owns. It aggregates the memory manager // that is passed in to the MCJIT constructor and defers most functionality // to that object. class LinkingSymbolResolver : public LegacyJITSymbolResolver { … }; // About Module states: added->loaded->finalized. // // The purpose of the "added" state is having modules in standby. (added=known // but not compiled). The idea is that you can add a module to provide function // definitions but if nothing in that module is referenced by a module in which // a function is executed (note the wording here because it's not exactly the // ideal case) then the module never gets compiled. This is sort of lazy // compilation. // // The purpose of the "loaded" state (loaded=compiled and required sections // copied into local memory but not yet ready for execution) is to have an // intermediate state wherein clients can remap the addresses of sections, using // MCJIT::mapSectionAddress, (in preparation for later copying to a new location // or an external process) before relocations and page permissions are applied. // // It might not be obvious at first glance, but the "remote-mcjit" case in the // lli tool does this. In that case, the intermediate action is taken by the // RemoteMemoryManager in response to the notifyObjectLoaded function being // called. class MCJIT : public ExecutionEngine { … }; } // end llvm namespace #endif // LLVM_LIB_EXECUTIONENGINE_MCJIT_MCJIT_H