@@ -54,8 +54,8 @@ using SymbolFlagsMap = DenseMap<SymbolStringPtr, JITSymbolFlags>;
54
54
// / symbols to be obtained for logging.
55
55
using SymbolDependenceMap = DenseMap<JITDylib *, SymbolNameSet>;
56
56
57
- // / A list of ( JITDylib*, bool) pairs .
58
- using JITDylibSearchList = std::vector<std::pair< JITDylib *, bool > >;
57
+ // / A list of JITDylib pointers .
58
+ using JITDylibList = std::vector<JITDylib *>;
59
59
60
60
// / Render a SymbolStringPtr.
61
61
raw_ostream &operator <<(raw_ostream &OS, const SymbolStringPtr &Sym);
@@ -85,8 +85,8 @@ raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
85
85
// / Render a MaterializationUnit.
86
86
raw_ostream &operator <<(raw_ostream &OS, const MaterializationUnit &MU);
87
87
88
- // / Render a JITDylibSearchList .
89
- raw_ostream &operator <<(raw_ostream &OS, const JITDylibSearchList &JDs);
88
+ // / Render a JITDylibList .
89
+ raw_ostream &operator <<(raw_ostream &OS, const JITDylibList &JDs);
90
90
91
91
// / Callback to notify client that symbols have been resolved.
92
92
using SymbolsResolvedCallback = std::function<void (Expected<SymbolMap>)>;
@@ -351,15 +351,14 @@ using SymbolAliasMap = DenseMap<SymbolStringPtr, SymbolAliasMapEntry>;
351
351
class ReExportsMaterializationUnit : public MaterializationUnit {
352
352
public:
353
353
// / SourceJD is allowed to be nullptr, in which case the source JITDylib is
354
- // / taken to be whatever JITDylib these definitions are materialized in (and
355
- // / MatchNonExported has no effect). This is useful for defining aliases
356
- // / within a JITDylib.
354
+ // / taken to be whatever JITDylib these definitions are materialized in. This
355
+ // / is useful for defining aliases within a JITDylib.
357
356
// /
358
357
// / Note: Care must be taken that no sets of aliases form a cycle, as such
359
358
// / a cycle will result in a deadlock when any symbol in the cycle is
360
359
// / resolved.
361
- ReExportsMaterializationUnit (JITDylib *SourceJD, bool MatchNonExported ,
362
- SymbolAliasMap Aliases, VModuleKey K);
360
+ ReExportsMaterializationUnit (JITDylib *SourceJD, SymbolAliasMap Aliases ,
361
+ VModuleKey K);
363
362
364
363
StringRef getName () const override ;
365
364
@@ -369,7 +368,6 @@ class ReExportsMaterializationUnit : public MaterializationUnit {
369
368
static SymbolFlagsMap extractFlags (const SymbolAliasMap &Aliases);
370
369
371
370
JITDylib *SourceJD = nullptr ;
372
- bool MatchNonExported = false ;
373
371
SymbolAliasMap Aliases;
374
372
};
375
373
@@ -387,19 +385,16 @@ class ReExportsMaterializationUnit : public MaterializationUnit {
387
385
inline std::unique_ptr<ReExportsMaterializationUnit>
388
386
symbolAliases (SymbolAliasMap Aliases, VModuleKey K = VModuleKey()) {
389
387
return llvm::make_unique<ReExportsMaterializationUnit>(
390
- nullptr , true , std::move (Aliases), std::move (K));
388
+ nullptr , std::move (Aliases), std::move (K));
391
389
}
392
390
393
391
// / Create a materialization unit for re-exporting symbols from another JITDylib
394
392
// / with alternative names/flags.
395
- // / If MatchNonExported is true then non-exported symbols from SourceJD can be
396
- // / re-exported. If it is false, attempts to re-export a non-exported symbol
397
- // / will result in a "symbol not found" error.
398
393
inline std::unique_ptr<ReExportsMaterializationUnit>
399
394
reexports (JITDylib &SourceJD, SymbolAliasMap Aliases,
400
- bool MatchNonExported = false , VModuleKey K = VModuleKey()) {
395
+ VModuleKey K = VModuleKey()) {
401
396
return llvm::make_unique<ReExportsMaterializationUnit>(
402
- &SourceJD, MatchNonExported, std::move (Aliases), std::move (K));
397
+ &SourceJD, std::move (Aliases), std::move (K));
403
398
}
404
399
405
400
// / Build a SymbolAliasMap for the common case where you want to re-export
@@ -416,14 +411,13 @@ class ReexportsGenerator {
416
411
// / Create a reexports generator. If an Allow predicate is passed, only
417
412
// / symbols for which the predicate returns true will be reexported. If no
418
413
// / Allow predicate is passed, all symbols will be exported.
419
- ReexportsGenerator (JITDylib &SourceJD, bool MatchNonExported = false ,
414
+ ReexportsGenerator (JITDylib &SourceJD,
420
415
SymbolPredicate Allow = SymbolPredicate());
421
416
422
417
SymbolNameSet operator ()(JITDylib &JD, const SymbolNameSet &Names);
423
418
424
419
private:
425
420
JITDylib &SourceJD;
426
- bool MatchNonExported = false ;
427
421
SymbolPredicate Allow;
428
422
};
429
423
@@ -542,18 +536,16 @@ class JITDylib {
542
536
// / as the first in the search order (instead of this dylib) ensures that
543
537
// / definitions within this dylib resolve to the lazy-compiling stubs,
544
538
// / rather than immediately materializing the definitions in this dylib.
545
- void setSearchOrder (JITDylibSearchList NewSearchOrder,
546
- bool SearchThisJITDylibFirst = true ,
547
- bool MatchNonExportedInThisDylib = true );
539
+ void setSearchOrder (JITDylibList NewSearchOrder,
540
+ bool SearchThisJITDylibFirst = true );
548
541
549
542
// / Add the given JITDylib to the search order for definitions in this
550
543
// / JITDylib.
551
- void addToSearchOrder (JITDylib &JD, bool MatcNonExported = false );
544
+ void addToSearchOrder (JITDylib &JD);
552
545
553
546
// / Replace OldJD with NewJD in the search order if OldJD is present.
554
547
// / Otherwise this operation is a no-op.
555
- void replaceInSearchOrder (JITDylib &OldJD, JITDylib &NewJD,
556
- bool MatchNonExported = false );
548
+ void replaceInSearchOrder (JITDylib &OldJD, JITDylib &NewJD);
557
549
558
550
// / Remove the given JITDylib from the search order for this JITDylib if it is
559
551
// / present. Otherwise this operation is a no-op.
@@ -562,7 +554,7 @@ class JITDylib {
562
554
// / Do something with the search order (run under the session lock).
563
555
template <typename Func>
564
556
auto withSearchOrderDo (Func &&F)
565
- -> decltype(F(std::declval<const JITDylibSearchList &>()));
557
+ -> decltype(F(std::declval<const JITDylibList &>()));
566
558
567
559
// / Define all symbols provided by the materialization unit to be part of this
568
560
// / JITDylib.
@@ -650,12 +642,12 @@ class JITDylib {
650
642
const SymbolNameSet &Names);
651
643
652
644
void lodgeQuery (std::shared_ptr<AsynchronousSymbolQuery> &Q,
653
- SymbolNameSet &Unresolved, bool MatchNonExported ,
654
- MaterializationUnitList &MUs);
645
+ SymbolNameSet &Unresolved, JITDylib *MatchNonExportedInJD ,
646
+ bool MatchNonExported, MaterializationUnitList &MUs);
655
647
656
648
void lodgeQueryImpl (std::shared_ptr<AsynchronousSymbolQuery> &Q,
657
- SymbolNameSet &Unresolved, bool MatchNonExported ,
658
- MaterializationUnitList &MUs);
649
+ SymbolNameSet &Unresolved, JITDylib *MatchNonExportedInJD ,
650
+ bool MatchNonExported, MaterializationUnitList &MUs);
659
651
660
652
LookupImplActionFlags
661
653
lookupImpl (std::shared_ptr<AsynchronousSymbolQuery> &Q,
@@ -690,7 +682,7 @@ class JITDylib {
690
682
UnmaterializedInfosMap UnmaterializedInfos;
691
683
MaterializingInfosMap MaterializingInfos;
692
684
GeneratorFunction DefGenerator;
693
- JITDylibSearchList SearchOrder;
685
+ JITDylibList SearchOrder;
694
686
};
695
687
696
688
// / An ExecutionSession represents a running JIT program.
@@ -774,10 +766,6 @@ class ExecutionSession {
774
766
775
767
// / Search the given JITDylib list for the given symbols.
776
768
// /
777
- // / SearchOrder lists the JITDylibs to search. For each dylib, the associated
778
- // / boolean indicates whether the search should match against non-exported
779
- // / (hidden visibility) symbols in that dylib (true means match against
780
- // / non-exported symbols, false means do not match).
781
769
// /
782
770
// / The OnResolve callback will be called once all requested symbols are
783
771
// / resolved, or if an error occurs prior to resolution.
@@ -794,9 +782,19 @@ class ExecutionSession {
794
782
// / dependenant symbols for this query (e.g. it is being made by a top level
795
783
// / client to get an address to call) then the value NoDependenciesToRegister
796
784
// / can be used.
797
- void lookup (const JITDylibSearchList &SearchOrder, SymbolNameSet Symbols,
785
+ // /
786
+ // / If the MatchNonExportedInJD pointer is non-null, then the lookup will find
787
+ // / non-exported symbols defined in the JITDylib pointed to by
788
+ // / MatchNonExportedInJD.
789
+ // / If MatchNonExported is true the lookup will find non-exported symbols in
790
+ // / any JITDylib (setting MatchNonExportedInJD is redundant in such cases).
791
+ // / If MatchNonExported is false and MatchNonExportedInJD is null,
792
+ // / non-exported symbols will never be found.
793
+ void lookup (const JITDylibList &JDs, SymbolNameSet Symbols,
798
794
SymbolsResolvedCallback OnResolve, SymbolsReadyCallback OnReady,
799
- RegisterDependenciesFunction RegisterDependencies);
795
+ RegisterDependenciesFunction RegisterDependencies,
796
+ JITDylib *MatchNonExportedInJD = nullptr ,
797
+ bool MatchNonExported = false );
800
798
801
799
// / Blocking version of lookup above. Returns the resolved symbol map.
802
800
// / If WaitUntilReady is true (the default), will not return until all
@@ -805,29 +803,24 @@ class ExecutionSession {
805
803
// / or an error occurs. If WaitUntilReady is false and an error occurs
806
804
// / after resolution, the function will return a success value, but the
807
805
// / error will be reported via reportErrors.
808
- Expected<SymbolMap> lookup (const JITDylibSearchList &SearchOrder ,
806
+ Expected<SymbolMap> lookup (const JITDylibList &JDs ,
809
807
const SymbolNameSet &Symbols,
810
808
RegisterDependenciesFunction RegisterDependencies =
811
809
NoDependenciesToRegister,
812
- bool WaitUntilReady = true );
813
-
814
- // / Convenience version of blocking lookup.
815
- // / Searches each of the JITDylibs in the search order in turn for the given
816
- // / symbol.
817
- Expected<JITEvaluatedSymbol> lookup (const JITDylibSearchList &SearchOrder,
818
- SymbolStringPtr Symbol);
810
+ bool WaitUntilReady = true ,
811
+ JITDylib *MatchNonExportedInJD = nullptr ,
812
+ bool MatchNonExported = false );
819
813
820
814
// / Convenience version of blocking lookup.
821
- // / Searches each of the JITDylibs in the search order in turn for the given
822
- // / symbol. The search will not find non-exported symbols.
823
- Expected<JITEvaluatedSymbol> lookup (ArrayRef<JITDylib *> SearchOrder ,
824
- SymbolStringPtr Symbol );
815
+ // / Performs a single-symbol lookup.
816
+ Expected<JITEvaluatedSymbol> lookup ( const JITDylibList &JDs,
817
+ SymbolStringPtr Symbol ,
818
+ bool MatchNonExported = false );
825
819
826
820
// / Convenience version of blocking lookup.
827
- // / Searches each of the JITDylibs in the search order in turn for the given
828
- // / symbol. The search will not find non-exported symbols.
829
- Expected<JITEvaluatedSymbol> lookup (ArrayRef<JITDylib *> SearchOrder,
830
- StringRef Symbol);
821
+ // / Performs a single-symbol lookup, auto-interning the given symbol name.
822
+ Expected<JITEvaluatedSymbol> lookup (const JITDylibList &JDs, StringRef Symbol,
823
+ bool MatchNonExported = false );
831
824
832
825
// / Materialize the given unit.
833
826
void dispatchMaterialization (JITDylib &JD,
@@ -873,7 +866,7 @@ class ExecutionSession {
873
866
874
867
template <typename Func>
875
868
auto JITDylib::withSearchOrderDo (Func &&F)
876
- -> decltype(F(std::declval<const JITDylibSearchList &>())) {
869
+ -> decltype(F(std::declval<const JITDylibList &>())) {
877
870
return ES.runSessionLocked ([&]() { return F (SearchOrder); });
878
871
}
879
872
0 commit comments