Use &_dispatch_main_q as the identity of the main actor.

I added Builtin.buildMainActorExecutor before, but because I never
implemented it correctly in IRGen, it's not okay to use it on old
versions, so I had to introduce a new feature only for it.

The shim dispatch queue class in the Concurrency runtime is rather
awful, but I couldn't think of a reasonable alternative without
just entirely hard-coding the witness table in the runtime.
It's not ABI, at least.
This commit is contained in:
John McCall
2021-06-17 02:48:51 -04:00
parent 4cc1035ba2
commit ca62a79079
14 changed files with 128 additions and 30 deletions

View File

@@ -137,4 +137,29 @@
#define SWIFT_POINTER_IS_4_BYTES 1
#endif
// Produce a string literal for the raw argument tokens.
#define SWIFT_STRINGIZE_RAW(TOK) #TOK
// Produce a string literal for the macro-expanded argument tokens.
#define SWIFT_STRINGIZE_EXPANDED(TOK) SWIFT_STRINGIZE_RAW(TOK)
#if defined(__USER_LABEL_PREFIX__)
#define SWIFT_SYMBOL_PREFIX_STRING \
SWIFT_STRINGIZE_EXPANDED(__USER_LABEL_PREFIX__)
#else
// Clang and GCC always define __USER_LABEL_PREFIX__, so this should
// only come up with MSVC, and Windows doesn't use a prefix.
#define SWIFT_SYMBOL_PREFIX_STRING ""
#endif
// An attribute to override the symbol name of a declaration.
// This does not compensate for platform symbol prefixes; for that,
// use SWIFT_ASM_LABEL_WITH_PREFIX.
//
// This only actually works on Clang or GCC; MSVC does not provide
// an attribute to change the asm label.
#define SWIFT_ASM_LABEL_RAW(STRING) __asm__(STRING)
#define SWIFT_ASM_LABEL_WITH_PREFIX(STRING) \
SWIFT_ASM_LABEL_RAW(SWIFT_SYMBOL_PREFIX_STRING STRING)
#endif // SWIFT_BASIC_COMPILER_H

View File

@@ -51,5 +51,6 @@ LANGUAGE_FEATURE(BuiltinTaskGroup, 0, "TaskGroup builtins", true)
LANGUAGE_FEATURE(InheritActorContext, 0, "@_inheritActorContext attribute", true)
LANGUAGE_FEATURE(ImplicitSelfCapture, 0, "@_implicitSelfCapture attribute", true)
LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins", true)
LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building builtin", true)
#undef LANGUAGE_FEATURE