1919#include " llvm/ADT/IntrusiveRefCntPtr.h"
2020#include " llvm/ExecutionEngine/JITLink/JITLinkDylib.h"
2121#include " llvm/ExecutionEngine/JITSymbol.h"
22+ #include " llvm/ExecutionEngine/Orc/CoreContainers.h"
2223#include " llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
24+ #include " llvm/ExecutionEngine/Orc/MaterializationUnit.h"
2325#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
2426#include " llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
2527#include " llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
@@ -39,7 +41,6 @@ namespace orc {
3941// Forward declare some classes.
4042class AsynchronousSymbolQuery ;
4143class ExecutionSession ;
42- class MaterializationUnit ;
4344class MaterializationResponsibility ;
4445class JITDylib ;
4546class ResourceTracker ;
@@ -109,23 +110,6 @@ class ResourceManager {
109110 ResourceKey SrcK) = 0;
110111};
111112
112- // / A set of symbol names (represented by SymbolStringPtrs for
113- // efficiency).
114- using SymbolNameSet = DenseSet<SymbolStringPtr>;
115-
116- // / A vector of symbol names.
117- using SymbolNameVector = std::vector<SymbolStringPtr>;
118-
119- // / A map from symbol names (as SymbolStringPtrs) to JITSymbols
120- // / (address/flags pairs).
121- using SymbolMap = DenseMap<SymbolStringPtr, ExecutorSymbolDef>;
122-
123- // / A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
124- using SymbolFlagsMap = DenseMap<SymbolStringPtr, JITSymbolFlags>;
125-
126- // / A map from JITDylibs to sets of symbols.
127- using SymbolDependenceMap = DenseMap<JITDylib *, SymbolNameSet>;
128-
129113// / Lookup flags that apply to each dylib in the search order for a lookup.
130114// /
131115// / If MatchHiddenSymbolsOnly is used (the default) for a given dylib, then
@@ -682,83 +666,6 @@ class MaterializationResponsibility {
682666 SymbolStringPtr InitSymbol;
683667};
684668
685- // / A MaterializationUnit represents a set of symbol definitions that can
686- // / be materialized as a group, or individually discarded (when
687- // / overriding definitions are encountered).
688- // /
689- // / MaterializationUnits are used when providing lazy definitions of symbols to
690- // / JITDylibs. The JITDylib will call materialize when the address of a symbol
691- // / is requested via the lookup method. The JITDylib will call discard if a
692- // / stronger definition is added or already present.
693- class MaterializationUnit {
694- friend class ExecutionSession ;
695- friend class JITDylib ;
696-
697- public:
698- static char ID;
699-
700- struct Interface {
701- Interface () = default ;
702- Interface (SymbolFlagsMap InitalSymbolFlags, SymbolStringPtr InitSymbol)
703- : SymbolFlags(std::move(InitalSymbolFlags)),
704- InitSymbol (std::move(InitSymbol)) {
705- assert ((!this ->InitSymbol || this ->SymbolFlags .count (this ->InitSymbol )) &&
706- " If set, InitSymbol should appear in InitialSymbolFlags map" );
707- }
708-
709- SymbolFlagsMap SymbolFlags;
710- SymbolStringPtr InitSymbol;
711- };
712-
713- MaterializationUnit (Interface I)
714- : SymbolFlags(std::move(I.SymbolFlags)),
715- InitSymbol(std::move(I.InitSymbol)) {}
716- virtual ~MaterializationUnit () = default ;
717-
718- // / Return the name of this materialization unit. Useful for debugging
719- // / output.
720- virtual StringRef getName () const = 0;
721-
722- // / Return the set of symbols that this source provides.
723- const SymbolFlagsMap &getSymbols () const { return SymbolFlags; }
724-
725- // / Returns the initialization symbol for this MaterializationUnit (if any).
726- const SymbolStringPtr &getInitializerSymbol () const { return InitSymbol; }
727-
728- // / Implementations of this method should materialize all symbols
729- // / in the materialzation unit, except for those that have been
730- // / previously discarded.
731- virtual void
732- materialize (std::unique_ptr<MaterializationResponsibility> R) = 0;
733-
734- // / Called by JITDylibs to notify MaterializationUnits that the given symbol
735- // / has been overridden.
736- void doDiscard (const JITDylib &JD, const SymbolStringPtr &Name) {
737- SymbolFlags.erase (Name);
738- if (InitSymbol == Name) {
739- DEBUG_WITH_TYPE (" orc" , {
740- dbgs () << " In " << getName () << " : discarding init symbol \" "
741- << *Name << " \"\n " ;
742- });
743- InitSymbol = nullptr ;
744- }
745- discard (JD, std::move (Name));
746- }
747-
748- protected:
749- SymbolFlagsMap SymbolFlags;
750- SymbolStringPtr InitSymbol;
751-
752- private:
753- virtual void anchor ();
754-
755- // / Implementations of this method should discard the given symbol
756- // / from the source (e.g. if the source is an LLVM IR Module and the
757- // / symbol is a function, delete the function body or mark it available
758- // / externally).
759- virtual void discard (const JITDylib &JD, const SymbolStringPtr &Name) = 0;
760- };
761-
762669// / A MaterializationUnit implementation for pre-existing absolute symbols.
763670// /
764671// / All symbols will be resolved and marked ready as soon as the unit is
0 commit comments