Skip to content

Commit ca34a30

Browse files
authored
Merge pull request #41390 from xedin/adjust-async-features-of-exec-target
[Distributed] Treat `swift_distributed_execute_target` like a regular…
2 parents 5cda4f4 + 39a66b5 commit ca34a30

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

lib/IRGen/Callee.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ namespace irgen {
247247
case SpecialKind::AsyncLetGetThrowing:
248248
case SpecialKind::AsyncLetFinish:
249249
case SpecialKind::TaskGroupWaitNext:
250-
case SpecialKind::DistributedExecuteTarget:
251250
return true;
251+
case SpecialKind::DistributedExecuteTarget:
252+
return false;
252253
}
253254
llvm_unreachable("covered switch");
254255
}
@@ -276,8 +277,9 @@ namespace irgen {
276277
case SpecialKind::AsyncLetGetThrowing:
277278
case SpecialKind::AsyncLetFinish:
278279
case SpecialKind::TaskGroupWaitNext:
279-
case SpecialKind::DistributedExecuteTarget:
280280
return true;
281+
case SpecialKind::DistributedExecuteTarget:
282+
return false;
281283
}
282284
llvm_unreachable("covered switch");
283285
}

stdlib/public/Distributed/DistributedActor.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ using TargetExecutorSignature =
5959
/*resultBuffer=*/void *,
6060
/*substitutions=*/void *,
6161
/*witnessTables=*/void **,
62-
/*numWitnessTables=*/size_t,
63-
/*resumeFunc=*/TaskContinuationFunction *,
64-
/*callContext=*/AsyncContext *),
62+
/*numWitnessTables=*/size_t),
6563
/*throws=*/true>;
6664

6765
SWIFT_CC(swiftasync)
@@ -102,7 +100,7 @@ static void ::swift_distributed_execute_target_resume(
102100
swift_task_dealloc(context);
103101
// See `swift_distributed_execute_target` - `parentCtx` in this case
104102
// is `callContext` which should be completely transparent on resume.
105-
return resumeInParent(parentCtx->Parent, error);
103+
return resumeInParent(parentCtx, error);
106104
}
107105

108106
SWIFT_CC(swiftasync)
@@ -115,9 +113,7 @@ void ::swift_distributed_execute_target(
115113
void *resultBuffer,
116114
void *substitutions,
117115
void **witnessTables,
118-
size_t numWitnessTables,
119-
TaskContinuationFunction *resumeFunc,
120-
AsyncContext *callContext) {
116+
size_t numWitnessTables) {
121117
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
122118
if (!accessor) {
123119
assert(false && "no distributed accessor");
@@ -135,17 +131,7 @@ void ::swift_distributed_execute_target(
135131
AsyncContext *calleeContext = reinterpret_cast<AsyncContext *>(
136132
swift_task_alloc(asyncFnPtr->ExpectedContextSize));
137133

138-
// TODO(concurrency): Special functions like this one are currently set-up
139-
// to pass "caller" context and resume function as extra parameters due to
140-
// how they are declared in C. But this particular function behaves exactly
141-
// like a regular `async throws`, which means that we need to initialize
142-
// intermediate `callContext` using parent `callerContext`. A better fix for
143-
// this situation would be to adjust IRGen and handle function like this
144-
// like regular `async` functions even though they are classified as special.
145-
callContext->Parent = callerContext;
146-
callContext->ResumeParent = resumeFunc;
147-
148-
calleeContext->Parent = callContext;
134+
calleeContext->Parent = callerContext;
149135
calleeContext->ResumeParent = reinterpret_cast<TaskContinuationFunction *>(
150136
swift_distributed_execute_target_resume);
151137

0 commit comments

Comments
 (0)