@@ -2734,6 +2734,21 @@ struct TargetResilientWitnessesHeader {
2734
2734
};
2735
2735
using ResilientWitnessesHeader = TargetResilientWitnessesHeader<InProcess>;
2736
2736
2737
+ // / Describes a reference to a global actor type and its conformance to the
2738
+ // / global actor protocol.
2739
+ template <typename Runtime>
2740
+ struct TargetGlobalActorReference {
2741
+ // / The type of the global actor.
2742
+ RelativeDirectPointer<const char , /* nullable*/ false > type;
2743
+
2744
+ // / The conformance of the global actor to the GlobalActor protocol.
2745
+ TargetRelativeProtocolConformanceDescriptorPointer<Runtime> conformance;
2746
+ };
2747
+
2748
+ // / Describes the context of a protocol conformance that is relevant when
2749
+ // / the conformance is used, such as global actor isolation.
2750
+ struct ConformanceExecutionContext ;
2751
+
2737
2752
// / The structure of a protocol conformance.
2738
2753
// /
2739
2754
// / This contains enough static information to recover the witness table for a
@@ -2747,7 +2762,8 @@ struct TargetProtocolConformanceDescriptor final
2747
2762
GenericPackShapeDescriptor,
2748
2763
TargetResilientWitnessesHeader<Runtime>,
2749
2764
TargetResilientWitness<Runtime>,
2750
- TargetGenericWitnessTable<Runtime>> {
2765
+ TargetGenericWitnessTable<Runtime>,
2766
+ TargetGlobalActorReference<Runtime>> {
2751
2767
2752
2768
using TrailingObjects = swift::ABI::TrailingObjects<
2753
2769
TargetProtocolConformanceDescriptor<Runtime>,
@@ -2756,7 +2772,8 @@ struct TargetProtocolConformanceDescriptor final
2756
2772
GenericPackShapeDescriptor,
2757
2773
TargetResilientWitnessesHeader<Runtime>,
2758
2774
TargetResilientWitness<Runtime>,
2759
- TargetGenericWitnessTable<Runtime>>;
2775
+ TargetGenericWitnessTable<Runtime>,
2776
+ TargetGlobalActorReference<Runtime>>;
2760
2777
friend TrailingObjects;
2761
2778
2762
2779
template <typename T>
@@ -2871,8 +2888,13 @@ struct TargetProtocolConformanceDescriptor final
2871
2888
// / Get the witness table for the specified type, realizing it if
2872
2889
// / necessary, or return null if the conformance does not apply to the
2873
2890
// / type.
2891
+ // /
2892
+ // / The context will be populated with any information that needs to be
2893
+ // / checked before this witness table can be used within a given execution
2894
+ // / context.
2874
2895
const swift::TargetWitnessTable<Runtime> *
2875
- getWitnessTable (const TargetMetadata<Runtime> *type) const ;
2896
+ getWitnessTable (const TargetMetadata<Runtime> *type,
2897
+ ConformanceExecutionContext &context) const ;
2876
2898
2877
2899
// / Retrieve the resilient witnesses.
2878
2900
llvm::ArrayRef<ResilientWitness> getResilientWitnesses () const {
@@ -2892,6 +2914,32 @@ struct TargetProtocolConformanceDescriptor final
2892
2914
return this ->template getTrailingObjects <GenericWitnessTable>();
2893
2915
}
2894
2916
2917
+ // / Whether this conformance has any conditional requirements that need to
2918
+ // / be evaluated.
2919
+ bool hasGlobalActorIsolation () const {
2920
+ return Flags.hasGlobalActorIsolation ();
2921
+ }
2922
+
2923
+ // / Retrieve the global actor type to which this conformance is isolated, if
2924
+ // / any.
2925
+ llvm::StringRef
2926
+ getGlobalActorType () const {
2927
+ if (!Flags.hasGlobalActorIsolation ())
2928
+ return llvm::StringRef ();
2929
+
2930
+ return Demangle::makeSymbolicMangledNameStringRef (this ->template getTrailingObjects <TargetGlobalActorReference<Runtime>>()->type );
2931
+ }
2932
+
2933
+ // / Retrieve the protocol conformance of the global actor type to the
2934
+ // / GlobalActor protocol.
2935
+ const TargetProtocolConformanceDescriptor<Runtime> *
2936
+ getGlobalActorConformance () const {
2937
+ if (!Flags.hasGlobalActorIsolation ())
2938
+ return nullptr ;
2939
+
2940
+ return this ->template getTrailingObjects <TargetGlobalActorReference<Runtime>>()->conformance ;
2941
+ }
2942
+
2895
2943
#if !defined(NDEBUG) && SWIFT_OBJC_INTEROP
2896
2944
void dump () const ;
2897
2945
#endif
@@ -2934,6 +2982,10 @@ struct TargetProtocolConformanceDescriptor final
2934
2982
size_t numTrailingObjects (OverloadToken<GenericWitnessTable>) const {
2935
2983
return Flags.hasGenericWitnessTable () ? 1 : 0 ;
2936
2984
}
2985
+
2986
+ size_t numTrailingObjects (OverloadToken<RelativeDirectPointer<const char , /* nullable*/ true >>) const {
2987
+ return Flags.hasGlobalActorIsolation () ? 1 : 0 ;
2988
+ }
2937
2989
};
2938
2990
using ProtocolConformanceDescriptor
2939
2991
= TargetProtocolConformanceDescriptor<InProcess>;
0 commit comments