Skip to content

Commit 09003d6

Browse files
authored
Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d26.
1 parent 53b3460 commit 09003d6

Some content is hidden

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

44 files changed

+1068
-1151
lines changed

Runtimes/Core/Concurrency/CMakeLists.txt

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

3-
gyb_expand(TaskGroup+addTask.swift.gyb TaskGroup+addTask.swift)
4-
53
add_library(swift_Concurrency
64
Actor.cpp
75
AsyncLet.cpp
@@ -79,11 +77,10 @@ add_library(swift_Concurrency
7977
Task+TaskExecutor.swift
8078
TaskCancellation.swift
8179
TaskGroup.swift
80+
TaskGroup+TaskExecutor.swift
8281
TaskLocal.swift
8382
TaskSleep.swift
84-
TaskSleepDuration.swift
85-
"${CMAKE_CURRENT_BINARY_DIR}/TaskGroup+addTask.swift")
86-
83+
TaskSleepDuration.swift)
8784
include(${SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR}.cmake)
8885
target_compile_definitions(swift_Concurrency PRIVATE
8986
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swift_Concurrency>

include/swift/ABI/MetadataValues.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,6 @@ class JobFlags : public FlagSet<uint32_t> {
27302730
// 27 is currently unused
27312731
Task_IsAsyncLetTask = 28,
27322732
Task_HasInitialTaskExecutorPreference = 29,
2733-
Task_HasInitialTaskName = 30,
27342733
};
27352734
// clang-format on
27362735

@@ -2767,9 +2766,6 @@ class JobFlags : public FlagSet<uint32_t> {
27672766
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_HasInitialTaskExecutorPreference,
27682767
task_hasInitialTaskExecutorPreference,
27692768
task_setHasInitialTaskExecutorPreference)
2770-
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_HasInitialTaskName,
2771-
task_hasInitialTaskName,
2772-
task_setHasInitialTaskName)
27732769
};
27742770

27752771
/// Kinds of task status record.
@@ -2799,9 +2795,6 @@ enum class TaskStatusRecordKind : uint8_t {
27992795
/// enqueued on.
28002796
TaskExecutorPreference = 5,
28012797

2802-
/// A human-readable task name.
2803-
TaskName = 6,
2804-
28052798
// Kinds >= 192 are private to the implementation.
28062799
First_Reserved = 192,
28072800
Private_RecordLock = 192
@@ -2825,8 +2818,6 @@ enum class TaskOptionRecordKind : uint8_t {
28252818
/// Set the initial task executor preference of the task.
28262819
InitialTaskExecutorUnowned = 5,
28272820
InitialTaskExecutorOwned = 6,
2828-
// Set a human-readable task name.
2829-
InitialTaskName = 7,
28302821
/// Request a child task for swift_task_run_inline.
28312822
RunInline = UINT8_MAX,
28322823
};

include/swift/ABI/Task.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -421,28 +421,6 @@ class AsyncTask : public Job {
421421
/// Checking this is, of course, inherently race-prone on its own.
422422
bool isCancelled() const;
423423

424-
// ==== INITIAL TASK RECORDS =================================================
425-
// A task may have a number of "initial" records set, they MUST be set in the
426-
// following order to make the task-local allocation/deallocation's stack
427-
// discipline easy to work out at the tasks destruction:
428-
//
429-
// - Initial TaskName
430-
// - Initial ExecutorPreference
431-
432-
// ==== Task Naming ----------------------------------------------------------
433-
434-
/// At task creation a task may be assigned a name.
435-
void pushInitialTaskName(const char* taskName);
436-
void dropInitialTaskNameRecord();
437-
438-
/// Get the initial task name that was given to this task during creation,
439-
/// or nullptr if the task has no name
440-
const char* getTaskName();
441-
442-
bool hasInitialTaskNameRecord() const {
443-
return Flags.task_hasInitialTaskName();
444-
}
445-
446424
// ==== Task Executor Preference ---------------------------------------------
447425

448426
/// Get the preferred task executor reference if there is one set for this

include/swift/ABI/TaskOptions.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,6 @@ class InitialTaskExecutorOwnedPreferenceTaskOptionRecord
131131
}
132132
};
133133

134-
class InitialTaskNameTaskOptionRecord
135-
: public TaskOptionRecord {
136-
137-
const char* TaskName;
138-
139-
public:
140-
InitialTaskNameTaskOptionRecord(
141-
const char* taskName)
142-
: TaskOptionRecord(TaskOptionRecordKind::InitialTaskName),
143-
TaskName(taskName) {}
144-
145-
const char* getTaskName() const {
146-
return TaskName;
147-
}
148-
149-
static bool classof(const TaskOptionRecord *record) {
150-
return record->getKind() == TaskOptionRecordKind::InitialTaskName;
151-
}
152-
};
153-
154134
/// Task option to specify the initial serial executor for the task.
155135
class InitialSerialExecutorTaskOptionRecord : public TaskOptionRecord {
156136
const SerialExecutorRef Executor;

include/swift/ABI/TaskStatus.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,6 @@ class TaskExecutorPreferenceStatusRecord : public TaskStatusRecord {
325325
}
326326
};
327327

328-
class TaskNameStatusRecord : public TaskStatusRecord {
329-
private:
330-
const char *Name;
331-
332-
public:
333-
TaskNameStatusRecord(const char *name)
334-
: TaskStatusRecord(TaskStatusRecordKind::TaskName),
335-
Name(name) {}
336-
337-
const char *getName() { return Name; }
338-
339-
static bool classof(const TaskStatusRecord *record) {
340-
return record->getKind() == TaskStatusRecordKind::TaskName;
341-
}
342-
};
343-
344328
// This record is allocated for a task to record what it is dependent on before
345329
// the task can make progress again.
346330
class TaskDependencyStatusRecord : public TaskStatusRecord {

include/swift/AST/ASTSynthesis.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ enum SingletonTypeSynthesizer {
5757
_taskExecutor, // the '_Concurrency.TaskExecutor' protocol
5858
_actor, // the '_Concurrency.Actor' protocol
5959
_distributedActor, // the 'Distributed.DistributedActor' protocol
60-
_unsafeRawBufferPointer // UnsafeRawBufferPointer
6160
};
6261
inline Type synthesizeType(SynthesisContext &SC,
6362
SingletonTypeSynthesizer kind) {
@@ -90,8 +89,6 @@ inline Type synthesizeType(SynthesisContext &SC,
9089
case _distributedActor:
9190
return SC.Context.getProtocol(KnownProtocolKind::DistributedActor)
9291
->getDeclaredInterfaceType();
93-
case _unsafeRawBufferPointer:
94-
return SC.Context.getUnsafeRawBufferPointerType();
9592
case _copyable:
9693
return SC.Context.getProtocol(KnownProtocolKind::Copyable)
9794
->getDeclaredInterfaceType();

include/swift/AST/Builtins.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,7 @@ BUILTIN_MISC_OPERATION(UnprotectedAddressOfBorrowOpaque, "unprotectedAddressOfBo
954954
/// createTask<T>(flags: Int,
955955
/// initialSerialExecutor: (Builtin.Executor)? = nil,
956956
/// taskGroup: Builtin.RawPointer? = nil,
957-
/// initialTaskExecutorDeprecated: (Builtin.Executor)? = nil,
958-
/// initialTaskExecutorOwned: (any TaskExecutor)? = nil,
957+
/// initialTaskExecutor: (Builtin.Executor)? = nil,
959958
/// operation: sending @escaping () async throws -> T)
960959
/// -> Builtin.NativeObject, Builtin.RawPointer)
961960
///

include/swift/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ BASELINE_LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins")
151151
BASELINE_LANGUAGE_FEATURE(BuiltinBuildComplexEqualityExecutor, 0, "Executor-building for 'complexEquality executor' builtins")
152152
BASELINE_LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building builtin")
153153
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskOwnedTaskExecutor, 0, "Task create with owned TaskExecutor")
154-
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskName, 0, "Task create with a name")
155154
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroup, 0, "Task create in task group builtin with extra flags")
156155
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroupWithExecutor, 0, "Task create in task group builtin with extra flags")
157156
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroup, 0, "Task create in discarding task group builtin, accounting for the Void return type")

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,6 @@ void swift_task_reportUnexpectedExecutor(
10221022
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
10231023
JobPriority swift_task_getCurrentThreadPriority(void);
10241024

1025-
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
1026-
const char *swift_task_getCurrentTaskName(void);
1027-
10281025
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
10291026
void swift_task_startOnMainActor(AsyncTask* job);
10301027

lib/AST/Builtins.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,6 @@ static ValueDecl *getCreateTask(ASTContext &ctx, Identifier id) {
15731573
_existential(_taskExecutor),
15741574
/*else*/ _executor))),
15751575
_nil)),
1576-
_label("taskName", _defaulted(_optional(_rawPointer), _nil)),
15771576
_label("operation",
15781577
_sending(_function(_async(_throws(_thick)), _typeparam(0),
15791578
_parameters())))),
@@ -1598,7 +1597,6 @@ static ValueDecl *getCreateDiscardingTask(ASTContext &ctx, Identifier id) {
15981597
_existential(_taskExecutor),
15991598
/*else*/ _executor))),
16001599
_nil)),
1601-
_label("taskName", _defaulted(_optional(_rawPointer), _nil)),
16021600
_label("operation", _sending(_function(_async(_throws(_thick)), _void,
16031601
_parameters())))),
16041602
_tuple(_nativeObject, _rawPointer));

lib/IRGen/GenConcurrency.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -747,29 +747,6 @@ struct InitialTaskExecutorOwnedRecordTraits {
747747
}
748748
};
749749

750-
struct InitialTaskNameRecordTraits {
751-
static StringRef getLabel() {
752-
return "task_name";
753-
}
754-
static llvm::StructType *getRecordType(IRGenModule &IGM) {
755-
return IGM.SwiftInitialTaskNameTaskOptionRecordTy;
756-
}
757-
static TaskOptionRecordFlags getRecordFlags() {
758-
return TaskOptionRecordFlags(TaskOptionRecordKind::InitialTaskName);
759-
}
760-
static CanType getValueType(ASTContext &ctx) {
761-
return ctx.TheRawPointerType;
762-
}
763-
764-
// Create 'InitialTaskNameTaskOptionRecord'
765-
void initialize(IRGenFunction &IGF, Address recordAddr,
766-
Explosion &taskName) const {
767-
auto record =
768-
IGF.Builder.CreateStructGEP(recordAddr, 1, 2 * IGF.IGM.getPointerSize());
769-
IGF.Builder.CreateStore(taskName.claimNext(), record);
770-
}
771-
};
772-
773750
} // end anonymous namespace
774751

775752
static llvm::Value *
@@ -806,20 +783,12 @@ maybeAddInitialTaskExecutorOwnedOptionRecord(IRGenFunction &IGF,
806783
taskExecutorExistential);
807784
}
808785

809-
static llvm::Value *
810-
maybeAddTaskNameOptionRecord(IRGenFunction &IGF, llvm::Value *prevOptions,
811-
OptionalExplosion &taskName) {
812-
return maybeAddOptionRecord(IGF, prevOptions, InitialTaskNameRecordTraits(),
813-
taskName);
814-
}
815-
816786
std::pair<llvm::Value *, llvm::Value *>
817787
irgen::emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags,
818788
OptionalExplosion &serialExecutor,
819789
OptionalExplosion &taskGroup,
820790
OptionalExplosion &taskExecutorUnowned,
821791
OptionalExplosion &taskExecutorExistential,
822-
OptionalExplosion &taskName,
823792
Explosion &taskFunction,
824793
SubstitutionMap subs) {
825794
llvm::Value *taskOptions =
@@ -856,9 +825,6 @@ irgen::emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags,
856825
IGF, taskOptions, taskExecutorExistential);
857826
}
858827

859-
// Add an option record for the initial task name, if present.
860-
taskOptions = maybeAddTaskNameOptionRecord(IGF, taskOptions, taskName);
861-
862828
// In embedded Swift, create and pass result type info.
863829
taskOptions = maybeAddEmbeddedSwiftResultTypeInfo(IGF, taskOptions, resultType);
864830

lib/IRGen/GenConcurrency.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags,
106106
OptionalExplosion &taskGroup,
107107
OptionalExplosion &taskExecutorUnowned,
108108
OptionalExplosion &taskExecutorExistential,
109-
OptionalExplosion &taskName,
110109
Explosion &taskFunction,
111110
SubstitutionMap subs);
112111

lib/IRGen/IRGenModule.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,6 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
724724
SwiftTaskOptionRecordTy, // Base option record
725725
SwiftExecutorTy, // Executor
726726
});
727-
SwiftInitialTaskNameTaskOptionRecordTy =
728-
createStructType(*this, "swift.task_name_task_option", {
729-
SwiftTaskOptionRecordTy, // Base option record
730-
Int8PtrTy, // Task name string (char*)
731-
});
732727
SwiftJobTy = createStructType(*this, "swift.job", {
733728
RefCountedStructTy, // object header
734729
Int8PtrTy, Int8PtrTy, // SchedulerPrivate

lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ class IRGenModule {
829829
llvm::StructType *SwiftTaskGroupTaskOptionRecordTy;
830830
llvm::StructType *SwiftInitialTaskExecutorUnownedPreferenceTaskOptionRecordTy;
831831
llvm::StructType *SwiftInitialTaskExecutorOwnedPreferenceTaskOptionRecordTy;
832-
llvm::StructType *SwiftInitialTaskNameTaskOptionRecordTy;
833832
llvm::StructType *SwiftResultTypeInfoTaskOptionRecordTy;
834833
llvm::PointerType *SwiftJobPtrTy;
835834
llvm::IntegerType *ExecutorFirstTy;

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,21 +3734,19 @@ static void emitBuiltinStackDealloc(IRGenSILFunction &IGF,
37343734

37353735
static void emitBuiltinCreateAsyncTask(IRGenSILFunction &IGF,
37363736
swift::BuiltinInst *i) {
3737-
assert(i->getOperandValues().size() == 7 &&
3738-
"createAsyncTask needs 7 operands");
3737+
assert(i->getOperandValues().size() == 6 &&
3738+
"createAsyncTask needs 6 operands");
37393739
auto flags = IGF.getLoweredSingletonExplosion(i->getOperand(0));
37403740
auto serialExecutor = IGF.getLoweredOptionalExplosion(i->getOperand(1));
37413741
auto taskGroup = IGF.getLoweredOptionalExplosion(i->getOperand(2));
37423742
auto taskExecutorUnowned = IGF.getLoweredOptionalExplosion(i->getOperand(3));
37433743
auto taskExecutorOwned = IGF.getLoweredOptionalExplosion(i->getOperand(4));
3744-
// %11 = enum $Optional<UnsafeRawBufferPointer>, #Optional.some!enumelt, %10 : $UnsafeRawBufferPointer // user: %20
3745-
auto taskName = IGF.getLoweredOptionalExplosion(i->getOperand(5));
3746-
Explosion taskFunction = IGF.getLoweredExplosion(i->getOperand(6));
3744+
Explosion taskFunction = IGF.getLoweredExplosion(i->getOperand(5));
37473745

37483746
auto taskAndContext =
37493747
emitTaskCreate(IGF, flags, serialExecutor, taskGroup,
37503748
taskExecutorUnowned, taskExecutorOwned,
3751-
taskName, taskFunction, i->getSubstitutions());
3749+
taskFunction, i->getSubstitutions());
37523750
Explosion out;
37533751
out.add(taskAndContext.first);
37543752
out.add(taskAndContext.second);

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,8 +2427,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24272427
if (builtinKind == BuiltinValueKind::CreateAsyncTask) {
24282428
requireType(BI->getType(), _object(_tuple(_nativeObject, _rawPointer)),
24292429
"result of createAsyncTask");
2430-
require(arguments.size() == 7,
2431-
"createAsyncTask expects seven arguments");
2430+
require(arguments.size() == 6,
2431+
"createAsyncTask expects six arguments");
24322432
requireType(arguments[0]->getType(), _object(_swiftInt),
24332433
"first argument of createAsyncTask");
24342434
requireType(arguments[1]->getType(), _object(_optional(_executor)),
@@ -2448,9 +2448,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24482448
_object(_optional(_executor)),
24492449
"fifth argument of createAsyncTask");
24502450
}
2451-
requireType(arguments[5]->getType(), _object(_optional(_rawPointer)),
2452-
"sixth argument of createAsyncTask");
2453-
auto fnType = requireObjectType(SILFunctionType, arguments[6],
2451+
auto fnType = requireObjectType(SILFunctionType, arguments[5],
24542452
"result of createAsyncTask");
24552453
bool haveSending =
24562454
F.getASTContext().LangOpts.hasFeature(Feature::SendingArgsAndResults);

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,14 +1636,6 @@ static ManagedValue emitCreateAsyncTask(SILGenFunction &SGF, SILLocation loc,
16361636
}
16371637
}();
16381638

1639-
ManagedValue taskName = [&] {
1640-
if (options & CreateTaskOptions::OptionalEverything) {
1641-
return nextArg().getAsSingleValue(SGF);
1642-
} else {
1643-
return emitOptionalNone(ctx.TheRawPointerType);
1644-
}
1645-
}();
1646-
16471639
auto functionValue = [&] {
16481640
// No reabstraction required.
16491641
if (options & CreateTaskOptions::Discarding) {
@@ -1701,7 +1693,6 @@ static ManagedValue emitCreateAsyncTask(SILGenFunction &SGF, SILLocation loc,
17011693
taskGroup.getUnmanagedValue(),
17021694
taskExecutorDeprecated.getUnmanagedValue(),
17031695
taskExecutorConsuming.forward(SGF),
1704-
taskName.forward(SGF),
17051696
functionValue.forward(SGF)
17061697
};
17071698

stdlib/public/Concurrency/Actor.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,6 @@ JobPriority swift::swift_task_getCurrentThreadPriority() {
314314
#endif
315315
}
316316

317-
const char *swift_task_getTaskName(AsyncTask *task) {
318-
if (!task) {
319-
return nullptr;
320-
}
321-
return task->getTaskName();
322-
}
323-
324-
const char *swift::swift_task_getCurrentTaskName() {
325-
auto task = swift_task_getCurrent();
326-
return swift_task_getTaskName(task);
327-
}
328-
329317
// Implemented in Swift to avoid some annoying hard-coding about
330318
// SerialExecutor's protocol witness table. We could inline this
331319
// with effort, though.

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES
144144
Task+TaskExecutor.swift
145145
TaskCancellation.swift
146146
TaskGroup.swift
147-
TaskGroup+Embedded.swift
147+
TaskGroup+TaskExecutor.swift
148148
DiscardingTaskGroup.swift
149149
TaskLocal.swift
150150
TaskSleep.swift
@@ -181,9 +181,6 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
181181
${SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES}
182182
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES}
183183

184-
GYB_SOURCES
185-
TaskGroup+addTask.swift.gyb
186-
187184
SWIFT_MODULE_DEPENDS_ANDROID Android
188185
SWIFT_MODULE_DEPENDS_LINUX Glibc
189186
SWIFT_MODULE_DEPENDS_LINUX_STATIC Musl

0 commit comments

Comments
 (0)