Skip to content

Commit aedee28

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents dff460b + 3854e61 commit aedee28

File tree

18 files changed

+269
-172
lines changed

18 files changed

+269
-172
lines changed

Runtimes/Core/Concurrency/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_subdirectory(InternalShims)
22

33
gyb_expand(TaskGroup+addTask.swift.gyb TaskGroup+addTask.swift)
4-
gyb_expand(Task+startSynchronously.swift.gyb Task+startSynchronously.swift)
4+
gyb_expand(Task+immediate.swift.gyb Task+immediate.swift)
55

66
add_library(swift_Concurrency
77
Actor.cpp
@@ -97,7 +97,7 @@ add_library(swift_Concurrency
9797
TaskSleep.swift
9898
TaskSleepDuration.swift
9999
"${CMAKE_CURRENT_BINARY_DIR}/TaskGroup+addTask.swift"
100-
"${CMAKE_CURRENT_BINARY_DIR}/Task+startSynchronously.swift")
100+
"${CMAKE_CURRENT_BINARY_DIR}/Task+immediate.swift")
101101

102102
include(${SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR}.cmake)
103103
target_compile_definitions(swift_Concurrency PRIVATE

include/swift/ABI/Executor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class SerialExecutorRef {
7777
/// Executor that may need to participate in complex "same context" checks,
7878
/// by invoking `isSameExclusiveExecutionContext` when comparing execution contexts.
7979
ComplexEquality = 0b01,
80-
/// Mark this executor as the one used by `Task.startSynchronously`,
80+
/// Mark this executor as the one used by `Task.immediate`,
8181
/// It cannot participate in switching.
8282
// TODO: Perhaps make this a generic "cannot switch" rather than start synchronously specific.
83-
StartSynchronously = 0b10,
83+
Immediate = 0b10,
8484
};
8585

8686
static_assert(static_cast<uintptr_t>(ExecutorKind::Ordinary) == 0);
@@ -107,12 +107,12 @@ class SerialExecutorRef {
107107

108108
static SerialExecutorRef forSynchronousStart() {
109109
auto wtable = reinterpret_cast<uintptr_t>(nullptr) |
110-
static_cast<uintptr_t>(ExecutorKind::StartSynchronously);
110+
static_cast<uintptr_t>(ExecutorKind::Immediate);
111111
return SerialExecutorRef(nullptr, wtable);
112112
}
113113
bool isForSynchronousStart() const {
114114
return getIdentity() == nullptr &&
115-
getExecutorKind() == ExecutorKind::StartSynchronously;
115+
getExecutorKind() == ExecutorKind::Immediate;
116116
}
117117

118118
/// Given a pointer to a serial executor and its SerialExecutor

include/swift/ABI/MetadataValues.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,7 @@ class TaskCreateFlags : public FlagSet<size_t> {
27462746
///
27472747
/// Supported starting in Swift 6.1.
27482748
Task_IsTaskFunctionConsumed = 15,
2749-
Task_IsStartSynchronouslyTask = 16,
2749+
Task_IsImmediateTask = 16,
27502750
};
27512751

27522752
explicit constexpr TaskCreateFlags(size_t bits) : FlagSet(bits) {}
@@ -2779,9 +2779,9 @@ class TaskCreateFlags : public FlagSet<size_t> {
27792779
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsTaskFunctionConsumed,
27802780
isTaskFunctionConsumed,
27812781
setIsTaskFunctionConsumed)
2782-
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsStartSynchronouslyTask,
2783-
isSynchronousStartTask,
2784-
setIsSYnchronousStartTask)
2782+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsImmediateTask,
2783+
isImmediateTask,
2784+
setIsImmediateTask)
27852785
};
27862786

27872787
/// Flags for schedulable jobs.

include/swift/AST/ModuleDependencies.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ class ModuleDependencyInfo {
690690
storage->importedSwiftModules.assign(dependencyIDs.begin(),
691691
dependencyIDs.end());
692692
}
693-
const ArrayRef<ModuleDependencyID> getImportedSwiftDependencies() const {
693+
ArrayRef<ModuleDependencyID> getImportedSwiftDependencies() const {
694694
return storage->importedSwiftModules;
695695
}
696696

@@ -699,7 +699,7 @@ class ModuleDependencyInfo {
699699
storage->importedClangModules.assign(dependencyIDs.begin(),
700700
dependencyIDs.end());
701701
}
702-
const ArrayRef<ModuleDependencyID> getImportedClangDependencies() const {
702+
ArrayRef<ModuleDependencyID> getImportedClangDependencies() const {
703703
return storage->importedClangModules;
704704
}
705705

@@ -733,7 +733,7 @@ class ModuleDependencyInfo {
733733
}
734734
}
735735
}
736-
const ArrayRef<ModuleDependencyID> getHeaderClangDependencies() const {
736+
ArrayRef<ModuleDependencyID> getHeaderClangDependencies() const {
737737
switch (getKind()) {
738738
case swift::ModuleDependencyKind::SwiftInterface: {
739739
auto swiftInterfaceStorage =
@@ -761,7 +761,7 @@ class ModuleDependencyInfo {
761761
storage->swiftOverlayDependencies.assign(dependencyIDs.begin(),
762762
dependencyIDs.end());
763763
}
764-
const ArrayRef<ModuleDependencyID> getSwiftOverlayDependencies() const {
764+
ArrayRef<ModuleDependencyID> getSwiftOverlayDependencies() const {
765765
return storage->swiftOverlayDependencies;
766766
}
767767

@@ -771,11 +771,11 @@ class ModuleDependencyInfo {
771771
storage->crossImportOverlayModules.assign(dependencyIDs.begin(),
772772
dependencyIDs.end());
773773
}
774-
const ArrayRef<ModuleDependencyID> getCrossImportOverlayDependencies() const {
774+
ArrayRef<ModuleDependencyID> getCrossImportOverlayDependencies() const {
775775
return storage->crossImportOverlayModules;
776776
}
777777

778-
const ArrayRef<LinkLibrary> getLinkLibraries() const {
778+
ArrayRef<LinkLibrary> getLinkLibraries() const {
779779
return storage->linkLibraries;
780780
}
781781

@@ -784,7 +784,7 @@ class ModuleDependencyInfo {
784784
storage->linkLibraries.assign(linkLibraries.begin(), linkLibraries.end());
785785
}
786786

787-
const ArrayRef<std::string> getAuxiliaryFiles() const {
787+
ArrayRef<std::string> getAuxiliaryFiles() const {
788788
return storage->auxiliaryFiles;
789789
}
790790

@@ -796,7 +796,7 @@ class ModuleDependencyInfo {
796796
return false;
797797
}
798798

799-
const ArrayRef<std::string> getHeaderInputSourceFiles() const {
799+
ArrayRef<std::string> getHeaderInputSourceFiles() const {
800800
if (auto *detail = getAsSwiftInterfaceModule())
801801
return detail->textualModuleDetails.bridgingSourceFiles;
802802
if (auto *detail = getAsSwiftSourceModule())
@@ -806,7 +806,7 @@ class ModuleDependencyInfo {
806806
return {};
807807
}
808808

809-
std::vector<std::string> getCommandline() const {
809+
ArrayRef<std::string> getCommandline() const {
810810
if (auto *detail = getAsClangModule())
811811
return detail->buildCommandLine;
812812
if (auto *detail = getAsSwiftInterfaceModule())
@@ -829,7 +829,7 @@ class ModuleDependencyInfo {
829829
llvm_unreachable("Unexpected type");
830830
}
831831

832-
std::vector<std::string> getBridgingHeaderCommandline() const {
832+
ArrayRef<std::string> getBridgingHeaderCommandline() const {
833833
if (auto *detail = getAsSwiftSourceModule())
834834
return detail->bridgingHeaderBuildCommandLine;
835835
return {};

include/swift/Runtime/Concurrency.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
10631063
void swift_task_startOnMainActor(AsyncTask* job);
10641064

10651065
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
1066-
void swift_task_startSynchronously(AsyncTask* job, SerialExecutorRef targetExecutor);
1066+
void swift_task_immediate(AsyncTask* job, SerialExecutorRef targetExecutor);
10671067

10681068
/// Donate this thread to the global executor until either the
10691069
/// given condition returns true or we've run out of cooperative

lib/DependencyScan/ModuleDependencyScanner.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
468468
// build command to main module to ensure frontend gets the same result.
469469
// This needs to happen after visiting all the top-level decls from all
470470
// SourceFiles.
471-
auto buildArgs = mainDependencies.getCommandline();
471+
std::vector<std::string> buildArgs = mainDependencies.getCommandline();
472472
mainModule->getASTContext().forEachCanImportVersionCheck(
473473
[&](StringRef moduleName, const llvm::VersionTuple &Version,
474474
const llvm::VersionTuple &UnderlyingVersion) {
@@ -1328,25 +1328,33 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
13281328
recordResult(clangDep);
13291329

13301330
// C++ Interop requires additional handling
1331-
if (ScanCompilerInvocation.getLangOptions().EnableCXXInterop) {
1332-
for (const auto &clangDepName : allClangDependencies) {
1333-
// If this Clang module is a part of the C++ stdlib, and we haven't loaded
1334-
// the overlay for it so far, it is a split libc++ module (e.g.
1335-
// std_vector). Load the CxxStdlib overlay explicitly.
1336-
const auto &clangDepInfo =
1337-
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
1338-
.value()
1339-
->getAsClangModule();
1340-
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
1341-
!swiftOverlayDependencies.contains(
1342-
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1343-
!swiftOverlayDependencies.contains(
1344-
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
1345-
ScanningThreadPool.async(
1346-
scanForSwiftDependency,
1347-
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
1348-
ScanningThreadPool.wait();
1349-
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
1331+
if (ScanCompilerInvocation.getLangOptions().EnableCXXInterop &&
1332+
moduleID.Kind == ModuleDependencyKind::SwiftInterface) {
1333+
const auto &moduleInfo = cache.findKnownDependency(moduleID);
1334+
const auto commandLine = moduleInfo.getCommandline();
1335+
1336+
// If the textual interface was built without C++ interop, do not query
1337+
// the C++ Standard Library Swift overlay for its compilation.
1338+
if (llvm::find(commandLine, "-formal-cxx-interoperability-mode=off") ==
1339+
commandLine.end()) {
1340+
for (const auto &clangDepName : allClangDependencies) {
1341+
// If this Clang module is a part of the C++ stdlib, and we haven't
1342+
// loaded the overlay for it so far, it is a split libc++ module (e.g.
1343+
// std_vector). Load the CxxStdlib overlay explicitly.
1344+
const auto &clangDepInfo =
1345+
cache.findDependency(clangDepName, ModuleDependencyKind::Clang)
1346+
.value()
1347+
->getAsClangModule();
1348+
if (importer::isCxxStdModule(clangDepName, clangDepInfo->IsSystem) &&
1349+
!swiftOverlayDependencies.contains(
1350+
{clangDepName, ModuleDependencyKind::SwiftInterface}) &&
1351+
!swiftOverlayDependencies.contains(
1352+
{clangDepName, ModuleDependencyKind::SwiftBinary})) {
1353+
scanForSwiftDependency(
1354+
getModuleImportIdentifier(ScanASTContext.Id_CxxStdlib.str()));
1355+
recordResult(ScanASTContext.Id_CxxStdlib.str().str());
1356+
break;
1357+
}
13501358
}
13511359
}
13521360
}
@@ -1401,7 +1409,7 @@ void ModuleDependencyScanner::resolveCrossImportOverlayDependencies(
14011409
// Update the command-line on the main module to
14021410
// disable implicit cross-import overlay search.
14031411
auto mainDep = cache.findKnownDependency(actualMainID);
1404-
auto cmdCopy = mainDep.getCommandline();
1412+
std::vector<std::string> cmdCopy = mainDep.getCommandline();
14051413
cmdCopy.push_back("-disable-cross-import-overlay-search");
14061414
for (auto &entry : overlayFiles) {
14071415
mainDep.addAuxiliaryFile(entry.second);

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ generateFullDependencyGraph(const CompilerInstance &instance,
933933
moduleInfo->details = getModuleDetails();
934934

935935
// Create a link libraries set for this module
936-
auto &linkLibraries = moduleDependencyInfo.getLinkLibraries();
936+
auto linkLibraries = moduleDependencyInfo.getLinkLibraries();
937937
swiftscan_link_library_set_t *linkLibrarySet =
938938
new swiftscan_link_library_set_t;
939939
linkLibrarySet->count = linkLibraries.size();

stdlib/public/CompatibilityOverride/CompatibilityOverrideConcurrency.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ OVERRIDE_TASK(task_startOnMainActor, void,
439439
swift::, (AsyncTask *task), (task))
440440

441441
// In ACTOR since we need ExecutorTracking info
442-
OVERRIDE_ACTOR(task_startSynchronously, void,
442+
OVERRIDE_ACTOR(task_immediate, void,
443443
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
444444
swift::, (AsyncTask *task, SerialExecutorRef targetExecutor),
445445
(task, targetExecutor))

stdlib/public/Concurrency/Actor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,8 +2511,8 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
25112511

25122512
SWIFT_CC(swift)
25132513
static void
2514-
swift_task_startSynchronouslyImpl(AsyncTask *task,
2515-
SerialExecutorRef targetExecutor) {
2514+
swift_task_immediateImpl(AsyncTask *task,
2515+
SerialExecutorRef targetExecutor) {
25162516
swift_retain(task);
25172517
if (targetExecutor.isGeneric()) {
25182518
// If the target is generic, it means that the closure did not specify
@@ -2526,7 +2526,7 @@ swift_task_startSynchronouslyImpl(AsyncTask *task,
25262526
_swift_task_setCurrent(originalTask);
25272527
} else {
25282528
assert(swift_task_isCurrentExecutor(targetExecutor) &&
2529-
"startSynchronously must only be invoked when it is correctly in "
2529+
"'immediate' must only be invoked when it is correctly in "
25302530
"the same isolation already, but wasn't!");
25312531

25322532
// We can run synchronously, we're on the expected executor so running in

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
223223

224224
GYB_SOURCES
225225
TaskGroup+addTask.swift.gyb
226-
Task+startSynchronously.swift.gyb
226+
Task+immediate.swift.gyb
227227

228228
SWIFT_MODULE_DEPENDS ${SWIFT_CONCURRENCY_DEPENDENCIES}
229229
SWIFT_MODULE_DEPENDS_ANDROID Android

0 commit comments

Comments
 (0)