@@ -2734,6 +2734,21 @@ struct TargetResilientWitnessesHeader {
27342734};
27352735using ResilientWitnessesHeader = TargetResilientWitnessesHeader<InProcess>;
27362736
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+
27372752// / The structure of a protocol conformance.
27382753// /
27392754// / This contains enough static information to recover the witness table for a
@@ -2747,7 +2762,8 @@ struct TargetProtocolConformanceDescriptor final
27472762 GenericPackShapeDescriptor,
27482763 TargetResilientWitnessesHeader<Runtime>,
27492764 TargetResilientWitness<Runtime>,
2750- TargetGenericWitnessTable<Runtime>> {
2765+ TargetGenericWitnessTable<Runtime>,
2766+ TargetGlobalActorReference<Runtime>> {
27512767
27522768 using TrailingObjects = swift::ABI::TrailingObjects<
27532769 TargetProtocolConformanceDescriptor<Runtime>,
@@ -2756,7 +2772,8 @@ struct TargetProtocolConformanceDescriptor final
27562772 GenericPackShapeDescriptor,
27572773 TargetResilientWitnessesHeader<Runtime>,
27582774 TargetResilientWitness<Runtime>,
2759- TargetGenericWitnessTable<Runtime>>;
2775+ TargetGenericWitnessTable<Runtime>,
2776+ TargetGlobalActorReference<Runtime>>;
27602777 friend TrailingObjects;
27612778
27622779 template <typename T>
@@ -2871,8 +2888,13 @@ struct TargetProtocolConformanceDescriptor final
28712888 // / Get the witness table for the specified type, realizing it if
28722889 // / necessary, or return null if the conformance does not apply to the
28732890 // / 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.
28742895 const swift::TargetWitnessTable<Runtime> *
2875- getWitnessTable (const TargetMetadata<Runtime> *type) const ;
2896+ getWitnessTable (const TargetMetadata<Runtime> *type,
2897+ ConformanceExecutionContext &context) const ;
28762898
28772899 // / Retrieve the resilient witnesses.
28782900 llvm::ArrayRef<ResilientWitness> getResilientWitnesses () const {
@@ -2892,6 +2914,32 @@ struct TargetProtocolConformanceDescriptor final
28922914 return this ->template getTrailingObjects <GenericWitnessTable>();
28932915 }
28942916
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+
28952943#if !defined(NDEBUG) && SWIFT_OBJC_INTEROP
28962944 void dump () const ;
28972945#endif
@@ -2934,6 +2982,10 @@ struct TargetProtocolConformanceDescriptor final
29342982 size_t numTrailingObjects (OverloadToken<GenericWitnessTable>) const {
29352983 return Flags.hasGenericWitnessTable () ? 1 : 0 ;
29362984 }
2985+
2986+ size_t numTrailingObjects (OverloadToken<RelativeDirectPointer<const char , /* nullable*/ true >>) const {
2987+ return Flags.hasGlobalActorIsolation () ? 1 : 0 ;
2988+ }
29372989};
29382990using ProtocolConformanceDescriptor
29392991 = TargetProtocolConformanceDescriptor<InProcess>;
0 commit comments