@@ -1875,6 +1875,60 @@ static void swift_task_startOnMainActorImpl(AsyncTask* task) {
1875
1875
_swift_task_setCurrent (originalTask);
1876
1876
}
1877
1877
1878
+ // ==== Load-time setup code ----------------------------------------------------
1879
+ //
1880
+ // The ctor below is placed here so that it must always be linked into the final
1881
+ // image even if the libswift_Concurrency is linked in as a static library.
1882
+
1883
+ #if !SWIFT_CONCURRENCY_EMBEDDED
1884
+
1885
+ // Helper macros for figuring out the mangled name of a context descriptor.
1886
+ #define DESCRIPTOR_MANGLING_SUFFIX_Structure Mn
1887
+ #define DESCRIPTOR_MANGLING_SUFFIX_Class Mn
1888
+ #define DESCRIPTOR_MANGLING_SUFFIX_Enum Mn
1889
+ #define DESCRIPTOR_MANGLING_SUFFIX_Protocol Mp
1890
+
1891
+ #define DESCRIPTOR_MANGLING_SUFFIX_ (X ) X
1892
+ #define DESCRIPTOR_MANGLING_SUFFIX (KIND ) \
1893
+ DESCRIPTOR_MANGLING_SUFFIX_ (DESCRIPTOR_MANGLING_SUFFIX_##KIND)
1894
+
1895
+ #define DESCRIPTOR_MANGLING_ (CHAR, SUFFIX ) $sSc ##CHAR##SUFFIX
1896
+ #define DESCRIPTOR_MANGLING (CHAR, SUFFIX ) DESCRIPTOR_MANGLING_(CHAR, SUFFIX)
1897
+
1898
+ // Declare context descriptors for all of the concurrency descriptors with
1899
+ // standard manglings.
1900
+ #define STANDARD_TYPE (KIND, MANGLING, TYPENAME )
1901
+ #define STANDARD_TYPE_CONCURRENCY (KIND, MANGLING, TYPENAME ) \
1902
+ extern " C" const swift::ContextDescriptor DESCRIPTOR_MANGLING ( \
1903
+ MANGLING, DESCRIPTOR_MANGLING_SUFFIX (KIND));
1904
+ #include " swift/Demangling/StandardTypesMangling.def"
1905
+
1906
+ // Defined in Swift, redeclared here so we can register it with the runtime.
1907
+ extern " C" SWIFT_CC (swift)
1908
+ bool _swift_task_isCurrentGlobalActor (
1909
+ const swift::Metadata *, const swift::WitnessTable *);
1910
+
1911
+ // Register our type descriptors with standard manglings when the concurrency
1912
+ // runtime is loaded. This allows the runtime to quickly resolve those standard
1913
+ // manglings.
1914
+ SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN
1915
+ __attribute__ ((constructor)) static void setupStandardConcurrencyDescriptors () {
1916
+ static const swift::ConcurrencyStandardTypeDescriptors descriptors = {
1917
+ #define STANDARD_TYPE (KIND, MANGLING, TYPENAME )
1918
+ #define STANDARD_TYPE_CONCURRENCY (KIND, MANGLING, TYPENAME ) \
1919
+ &DESCRIPTOR_MANGLING (MANGLING, DESCRIPTOR_MANGLING_SUFFIX (KIND)),
1920
+ #include " swift/Demangling/StandardTypesMangling.def"
1921
+ };
1922
+ _swift_registerConcurrencyRuntime (
1923
+ &descriptors,
1924
+ &_swift_task_isCurrentGlobalActor);
1925
+ }
1926
+ SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END
1927
+
1928
+ #endif
1929
+
1930
+ // ==== Back-deploy hooks -------------------------------------------------------
1931
+
1878
1932
#define OVERRIDE_TASK COMPATIBILITY_OVERRIDE
1879
1933
1880
1934
#ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
0 commit comments