Clean up the TaskGroup ABI:

- stop storing the parent task in the TaskGroup at the .swift level
- make sure that swift_taskGroup_isCancelled is implied by the parent
  task being cancelled
- make the TaskGroup structs frozen
- make the withTaskGroup functions inlinable
- remove swift_taskGroup_create
- teach IRGen to allocate memory for the task group
- don't deallocate the task group in swift_taskGroup_destroy

To achieve the allocation change, introduce paired create/destroy builtins.

Furthermore, remove the _swiftRetain and _swiftRelease functions and
several calls to them.  Replace them with uses of the appropriate builtins.
I should probably change the builtins to return retained, since they're
working with a managed type, but I'll do that in a separate commit.
This commit is contained in:
John McCall
2021-04-09 01:07:48 -04:00
parent 6c11713a10
commit efeb818161
20 changed files with 185 additions and 165 deletions

View File

@@ -1481,6 +1481,18 @@ static ValueDecl *getResumeContinuationThrowing(ASTContext &ctx,
_void);
}
static ValueDecl *getCreateTaskGroup(ASTContext &ctx, Identifier id) {
return getBuiltinFunction(ctx, id, _thin,
_parameters(),
_rawPointer);
}
static ValueDecl *getDestroyTaskGroup(ASTContext &ctx, Identifier id) {
return getBuiltinFunction(ctx, id, _thin,
_parameters(_rawPointer),
_void);
}
static ValueDecl *getBuildSerialExecutorRef(ASTContext &ctx, Identifier id) {
// TODO: restrict the generic parameter to the SerialExecutor protocol
return getBuiltinFunction(ctx, id, _thin,
@@ -2728,6 +2740,12 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
case BuiltinValueKind::DestroyDefaultActor:
return getDefaultActorInitDestroy(Context, Id);
case BuiltinValueKind::CreateTaskGroup:
return getCreateTaskGroup(Context, Id);
case BuiltinValueKind::DestroyTaskGroup:
return getDestroyTaskGroup(Context, Id);
case BuiltinValueKind::ResumeNonThrowingContinuationReturning:
case BuiltinValueKind::ResumeThrowingContinuationReturning:
return getResumeContinuationReturning(Context, Id);