21
21
#include " llvm/ExecutionEngine/JITSymbol.h"
22
22
#include " llvm/ExecutionEngine/Orc/CoreContainers.h"
23
23
#include " llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
24
+ #include " llvm/ExecutionEngine/Orc/MaterializationUnit.h"
24
25
#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
25
26
#include " llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
26
27
#include " llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
@@ -40,7 +41,6 @@ namespace orc {
40
41
// Forward declare some classes.
41
42
class AsynchronousSymbolQuery ;
42
43
class ExecutionSession ;
43
- class MaterializationUnit ;
44
44
class MaterializationResponsibility ;
45
45
class JITDylib ;
46
46
class ResourceTracker ;
@@ -666,83 +666,6 @@ class MaterializationResponsibility {
666
666
SymbolStringPtr InitSymbol;
667
667
};
668
668
669
- // / A MaterializationUnit represents a set of symbol definitions that can
670
- // / be materialized as a group, or individually discarded (when
671
- // / overriding definitions are encountered).
672
- // /
673
- // / MaterializationUnits are used when providing lazy definitions of symbols to
674
- // / JITDylibs. The JITDylib will call materialize when the address of a symbol
675
- // / is requested via the lookup method. The JITDylib will call discard if a
676
- // / stronger definition is added or already present.
677
- class MaterializationUnit {
678
- friend class ExecutionSession ;
679
- friend class JITDylib ;
680
-
681
- public:
682
- static char ID;
683
-
684
- struct Interface {
685
- Interface () = default ;
686
- Interface (SymbolFlagsMap InitalSymbolFlags, SymbolStringPtr InitSymbol)
687
- : SymbolFlags(std::move(InitalSymbolFlags)),
688
- InitSymbol (std::move(InitSymbol)) {
689
- assert ((!this ->InitSymbol || this ->SymbolFlags .count (this ->InitSymbol )) &&
690
- " If set, InitSymbol should appear in InitialSymbolFlags map" );
691
- }
692
-
693
- SymbolFlagsMap SymbolFlags;
694
- SymbolStringPtr InitSymbol;
695
- };
696
-
697
- MaterializationUnit (Interface I)
698
- : SymbolFlags(std::move(I.SymbolFlags)),
699
- InitSymbol(std::move(I.InitSymbol)) {}
700
- virtual ~MaterializationUnit () = default ;
701
-
702
- // / Return the name of this materialization unit. Useful for debugging
703
- // / output.
704
- virtual StringRef getName () const = 0;
705
-
706
- // / Return the set of symbols that this source provides.
707
- const SymbolFlagsMap &getSymbols () const { return SymbolFlags; }
708
-
709
- // / Returns the initialization symbol for this MaterializationUnit (if any).
710
- const SymbolStringPtr &getInitializerSymbol () const { return InitSymbol; }
711
-
712
- // / Implementations of this method should materialize all symbols
713
- // / in the materialzation unit, except for those that have been
714
- // / previously discarded.
715
- virtual void
716
- materialize (std::unique_ptr<MaterializationResponsibility> R) = 0;
717
-
718
- // / Called by JITDylibs to notify MaterializationUnits that the given symbol
719
- // / has been overridden.
720
- void doDiscard (const JITDylib &JD, const SymbolStringPtr &Name) {
721
- SymbolFlags.erase (Name);
722
- if (InitSymbol == Name) {
723
- DEBUG_WITH_TYPE (" orc" , {
724
- dbgs () << " In " << getName () << " : discarding init symbol \" "
725
- << *Name << " \"\n " ;
726
- });
727
- InitSymbol = nullptr ;
728
- }
729
- discard (JD, std::move (Name));
730
- }
731
-
732
- protected:
733
- SymbolFlagsMap SymbolFlags;
734
- SymbolStringPtr InitSymbol;
735
-
736
- private:
737
- virtual void anchor ();
738
-
739
- // / Implementations of this method should discard the given symbol
740
- // / from the source (e.g. if the source is an LLVM IR Module and the
741
- // / symbol is a function, delete the function body or mark it available
742
- // / externally).
743
- virtual void discard (const JITDylib &JD, const SymbolStringPtr &Name) = 0;
744
- };
745
-
746
669
// / A MaterializationUnit implementation for pre-existing absolute symbols.
747
670
// /
748
671
// / All symbols will be resolved and marked ready as soon as the unit is
0 commit comments