Skip to content

Commit 47fa717

Browse files
committed
Revert "Merge pull request swiftlang#80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358, reversing changes made to 033f667.
1 parent c824be3 commit 47fa717

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3610
-426
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,14 @@ NOTE(rbi_add_generic_parameter_sendable_conformance,none,
11331133
"consider making generic parameter %0 conform to the 'Sendable' protocol",
11341134
(Type))
11351135

1136+
// Concurrency related diagnostics
1137+
ERROR(cannot_find_executor_factory_type, none,
1138+
"the specified executor factory '%0' could not be found", (StringRef))
1139+
ERROR(executor_factory_must_conform, none,
1140+
"the executor factory '%0' does not conform to 'ExecutorFactory'", (Type))
1141+
ERROR(executor_factory_not_supported, none,
1142+
"deployment target too low for executor factory specification", ())
1143+
11361144
//===----------------------------------------------------------------------===//
11371145
// MARK: Misc Diagnostics
11381146
//===----------------------------------------------------------------------===//

include/swift/AST/FeatureAvailability.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ FEATURE(IsolatedDeinit, (6, 1))
8080

8181
FEATURE(ValueGenericType, (6, 2))
8282
FEATURE(InitRawStructMetadata2, (6, 2))
83+
FEATURE(CustomExecutors, (6, 2))
8384

8485
FEATURE(TaskExecutor, FUTURE)
8586
FEATURE(Differentiation, FUTURE)

include/swift/AST/KnownProtocols.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ PROTOCOL(Executor)
9797
PROTOCOL(SerialExecutor)
9898
PROTOCOL(TaskExecutor)
9999
PROTOCOL(GlobalActor)
100+
PROTOCOL(ExecutorFactory)
100101

101102
PROTOCOL_(BridgedNSError)
102103
PROTOCOL_(BridgedStoredNSError)

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ namespace swift {
409409
/// Specifies how strict concurrency checking will be.
410410
StrictConcurrency StrictConcurrencyLevel = StrictConcurrency::Minimal;
411411

412+
/// Specifies the name of the executor factory to use to create the
413+
/// default executors for Swift Concurrency.
414+
std::optional<std::string> ExecutorFactory;
415+
412416
/// Enable experimental concurrency model.
413417
bool EnableExperimentalConcurrency = false;
414418

include/swift/Option/Options.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,16 @@ def default_isolation_EQ : Joined<["-"], "default-isolation=">,
998998
Flags<[FrontendOption]>,
999999
Alias<default_isolation>;
10001000

1001+
def executor_factory : JoinedOrSeparate<["-"], "executor-factory">,
1002+
Flags<[FrontendOption]>,
1003+
HelpText<"Specify the factory to use to create the default executors for "
1004+
"Swift Concurrency. This must be a type conforming to the "
1005+
"'ExecutorFactory' protocol.">,
1006+
MetaVarName<"<factory-type>">;
1007+
def executor_factory_EQ : Joined<["-"], "executor-factory=">,
1008+
Flags<[FrontendOption]>,
1009+
Alias<executor_factory>;
1010+
10011011
def enable_experimental_feature :
10021012
Separate<["-"], "enable-experimental-feature">,
10031013
Flags<[FrontendOption, ModuleInterfaceOption]>,

include/swift/Runtime/Concurrency.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ void swift_task_dealloc(void *ptr);
127127
SWIFT_EXPORT_FROM(swift_Concurrency)
128128
SWIFT_CC(swift) void swift_task_dealloc_through(void *ptr);
129129

130+
/// Deallocate memory in a task.
131+
///
132+
/// The pointer provided must be the last pointer allocated on
133+
/// this task that has not yet been deallocated; that is, memory
134+
/// must be allocated and deallocated in a strict stack discipline.
135+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
136+
void swift_task_dealloc(void *ptr);
137+
138+
/// Allocate memory in a job.
139+
///
140+
/// All allocations will be rounded to a multiple of MAX_ALIGNMENT;
141+
/// if the job does not support allocation, this will return NULL.
142+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
143+
void *swift_job_allocate(Job *job, size_t size);
144+
145+
/// Deallocate memory in a job.
146+
///
147+
/// The pointer provided must be the last pointer allocated on
148+
/// this task that has not yet been deallocated; that is, memory
149+
/// must be allocated and deallocated in a strict stack discipline.
150+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
151+
void swift_job_deallocate(Job *job, void *ptr);
152+
130153
/// Cancel a task and all of its child tasks.
131154
///
132155
/// This can be called from any thread.

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
14581458
case KnownProtocolKind::Executor:
14591459
case KnownProtocolKind::TaskExecutor:
14601460
case KnownProtocolKind::SerialExecutor:
1461+
case KnownProtocolKind::ExecutorFactory:
14611462
M = getLoadedModule(Id_Concurrency);
14621463
break;
14631464
case KnownProtocolKind::DistributedActor:

lib/ClangImporter/SortedCFDatabase.def.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ with codecs.open(CFDatabaseFile, encoding='utf-8', errors='strict') as f:
3939
continue
4040

4141
# Otherwise, check for lines like FOO(BAR)
42-
m = re.match('^\w+\((\w+)\)', line)
42+
m = re.match(r'^\w+\((\w+)\)', line)
4343
if m:
4444
lineForName[m.group(1)] = line
4545
}%

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
377377
arguments.push_back(inputArgs.MakeArgString(globalRemapping));
378378
}
379379

380+
if (inputArgs.hasArg(options::OPT_executor_factory)) {
381+
inputArgs.AddLastArg(arguments, options::OPT_executor_factory);
382+
}
383+
380384
// Pass through the values passed to -Xfrontend.
381385
inputArgs.AddAllArgValues(arguments, options::OPT_Xfrontend);
382386

lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13641364
Opts.enableFeature(Feature::RegionBasedIsolation);
13651365
}
13661366

1367+
// Get the executor factory name
1368+
if (const Arg *A = Args.getLastArg(OPT_executor_factory)) {
1369+
printf("Got executor-factory option\n");
1370+
Opts.ExecutorFactory = A->getValue();
1371+
}
1372+
13671373
Opts.WarnImplicitOverrides =
13681374
Args.hasArg(OPT_warn_implicit_overrides);
13691375

0 commit comments

Comments
 (0)