Skip to content

Remove unused resume parent executor #36490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/swift/ABI/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,6 @@ class alignas(MaximumAlignment) AsyncContext {
TaskContinuationFunction * __ptrauth_swift_async_context_resume
ResumeParent;

/// The executor that the parent needs to be resumed on.
/// FIXME: remove this
ExecutorRef ResumeParentExecutor;

/// Flags describing this context.
///
/// Note that this field is only 32 bits; any alignment padding
Expand All @@ -499,7 +495,6 @@ class alignas(MaximumAlignment) AsyncContext {
TaskContinuationFunction *resumeParent,
AsyncContext *parent)
: Parent(parent), ResumeParent(resumeParent),
ResumeParentExecutor(ExecutorRef::generic()),
Flags(flags) {}

AsyncContext(const AsyncContext &) = delete;
Expand Down
34 changes: 3 additions & 31 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
valTypes.push_back(ty);
typeInfos.push_back(&ti);
};
auto addExecutor = [&]() {
auto ty = SILType();
auto &ti = IGM.getSwiftExecutorPtrTypeInfo();
valTypes.push_back(ty);
typeInfos.push_back(&ti);
};

// AsyncContext * __ptrauth_swift_async_context_parent Parent;
{
auto ty = SILType();
Expand All @@ -133,9 +126,6 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
// ResumeParent;
addTaskContinuationFunction();

// ExecutorRef ResumeParentExecutor;
addExecutor();

// AsyncContextFlags Flags;
{
auto ty = SILType::getPrimitiveObjectType(
Expand All @@ -146,13 +136,6 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
typeInfos.push_back(&ti);
}

// SwiftError **errorResult;
auto errorCanType = IGM.Context.getExceptionType();
auto errorType = SILType::getPrimitiveObjectType(errorCanType);
auto &errorTypeInfo =
IGM.getTypeInfoForLowered(CanInOutType::get(errorCanType));
typeInfos.push_back(&errorTypeInfo);
valTypes.push_back(errorType);
// Add storage for data used by runtime entry points.
// See TaskFutureWaitAsyncContext.
if (kind.isSpecial()) {
Expand Down Expand Up @@ -196,22 +179,18 @@ irgen::getAsyncContextLayout(IRGenModule &IGM, CanSILFunctionType originalType,
} break;
}
}
bool canHaveValidError = substitutedType->hasErrorResult();
return AsyncContextLayout(IGM, LayoutStrategy::Optimal, valTypes, typeInfos,
originalType, substitutedType, substitutionMap,
errorType, canHaveValidError);
originalType, substitutedType, substitutionMap);
}

AsyncContextLayout::AsyncContextLayout(
IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
ArrayRef<const TypeInfo *> fieldTypeInfos, CanSILFunctionType originalType,
CanSILFunctionType substitutedType, SubstitutionMap substitutionMap,
SILType errorType, bool canHaveValidError)
CanSILFunctionType substitutedType, SubstitutionMap substitutionMap)
: StructLayout(IGM, /*decl=*/nullptr, LayoutKind::NonHeapObject, strategy,
fieldTypeInfos, /*typeToFill*/ nullptr),
originalType(originalType), substitutedType(substitutedType),
substitutionMap(substitutionMap), errorType(errorType),
canHaveValidError(canHaveValidError) {
substitutionMap(substitutionMap) {
#ifndef NDEBUG
assert(fieldTypeInfos.size() == fieldTypes.size() &&
"type infos don't match types");
Expand Down Expand Up @@ -2317,13 +2296,6 @@ class AsyncCallEmission final : public CallEmission {
IGF.Builder.CreateZExt(dynamicContextSize32, IGF.IGM.SizeTy);
contextBuffer = emitAllocAsyncContext(IGF, dynamicContextSize);
context = layout.emitCastTo(IGF, contextBuffer.getAddress());
if (layout.canHaveError()) {
auto fieldLayout = layout.getErrorLayout();
auto ptrToAddr =
fieldLayout.project(IGF, context, /*offsets*/ llvm::None);
auto errorSlot = IGF.getAsyncCalleeErrorResultSlot(layout.getErrorType());
IGF.Builder.CreateStore(errorSlot.getAddress(), ptrToAddr);
}
}
void end() override {
assert(contextBuffer.isValid());
Expand Down
23 changes: 2 additions & 21 deletions lib/IRGen/GenCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ namespace irgen {
// SwiftPartialFunction * __ptrauth(...) returnToCaller;
// SwiftActor * __ptrauth(...) callerActor;
// SwiftPartialFunction * __ptrauth(...) yieldToCaller?;
// SwiftError **errorResult;
// };
struct AsyncContextLayout : StructLayout {
struct ArgumentInfo {
Expand All @@ -84,52 +83,34 @@ namespace irgen {
enum class FixedIndex : unsigned {
Parent = 0,
ResumeParent = 1,
ResumeParentExecutor = 2,
Flags = 3,
Flags = 2,
};
enum class FixedCount : unsigned {
Parent = 1,
ResumeParent = 1,
ResumeParentExecutor = 1,
Error = 1,
};
CanSILFunctionType originalType;
CanSILFunctionType substitutedType;
SubstitutionMap substitutionMap;
SILType errorType;
bool canHaveValidError;

unsigned getParentIndex() { return (unsigned)FixedIndex::Parent; }
unsigned getResumeParentIndex() {
return (unsigned)FixedIndex::ResumeParent;
}
unsigned getResumeParentExecutorIndex() {
return (unsigned)FixedIndex::ResumeParentExecutor;
}
unsigned getFlagsIndex() { return (unsigned)FixedIndex::Flags; }
unsigned getErrorIndex() {
return getFlagsIndex() + 1;
}

public:
ElementLayout getParentLayout() { return getElement(getParentIndex()); }
ElementLayout getResumeParentLayout() {
return getElement(getResumeParentIndex());
}
ElementLayout getResumeParentExecutorLayout() {
return getElement(getResumeParentExecutorIndex());
}
ElementLayout getFlagsLayout() { return getElement(getFlagsIndex()); }
bool canHaveError() { return canHaveValidError; }
ElementLayout getErrorLayout() { return getElement(getErrorIndex()); }
unsigned getErrorCount() { return (unsigned)FixedCount::Error; }
SILType getErrorType() { return errorType; }

AsyncContextLayout(
IRGenModule &IGM, LayoutStrategy strategy, ArrayRef<SILType> fieldTypes,
ArrayRef<const TypeInfo *> fieldTypeInfos,
CanSILFunctionType originalType, CanSILFunctionType substitutedType,
SubstitutionMap substitutionMap, SILType errorType, bool canHaveValidError);
SubstitutionMap substitutionMap);
};

AsyncContextLayout getAsyncContextLayout(IRGenModule &IGM,
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/Concurrency/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ static AsyncTaskAndContext swift_task_create_group_future_impl(
initialContext->Parent = nullptr;
initialContext->ResumeParent = reinterpret_cast<TaskContinuationFunction *>(
closureContext ? &completeTaskWithClosure : &completeTask);
initialContext->ResumeParentExecutor = ExecutorRef::generic();
initialContext->Flags = AsyncContextKind::Ordinary;
initialContext->Flags.setShouldNotDeallocateInCallee(true);

Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SomeClass {}
public func task_future_wait(_ task: __owned SomeClass) async throws -> Int

// CHECK: define{{.*}} swift{{(tail)?}}cc void @"$s5async8testThisyyAA9SomeClassCnYF"(%swift.context* swiftasync %0{{.*}}
// CHECK-64: call swiftcc i8* @swift_task_alloc(i64 64)
// CHECK-64: call swiftcc i8* @swift_task_alloc(i64 48)
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void @swift_task_future_wait(
public func testThis(_ task: __owned SomeClass) async {
do {
Expand Down