@@ -10,138 +10,24 @@ using TaskGroup = swift::TaskGroup;
1010
1111// ===--- swift_task_future_wait -------------------------------------------===//
1212
13- SWIFT_CC (swiftasync)
14- static void
15- task_future_wait_resume_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
16- return _context->ResumeParent (_context->Parent );
17- }
18-
19- #ifdef __ARM_ARCH_7K__
20- __attribute__ ((noinline))
21- SWIFT_CC(swiftasync) static void workaround_function_swift_task_future_waitImpl(
22- OpaqueValue *result, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
23- AsyncTask *task, TaskContinuationFunction resumeFunction,
24- AsyncContext *callContext) {
25- // Make sure we don't eliminate calls to this function.
26- asm volatile (" " // Do nothing.
27- : // Output list, empty.
28- : " r" (result), " r" (callerContext), " r" (task) // Input list.
29- : // Clobber list, empty.
30- );
31- return ;
32- }
33- #endif
34-
3513void SWIFT_CC (swiftasync) swift::swift56override_swift_task_future_wait(
3614 OpaqueValue *result,
3715 SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
3816 AsyncTask *task,
3917 TaskContinuationFunction *resumeFn,
4018 AsyncContext *callContext,
4119 TaskFutureWait_t *original) {
42- // Suspend the waiting task.
43- auto waitingTask = swift_task_getCurrent ();
44- waitingTask->ResumeTask = task_future_wait_resume_adapter;
45- waitingTask->ResumeContext = callContext;
46-
47- // Wait on the future.
48- assert (task->isFuture ());
49-
50- switch (task->waitFuture (waitingTask, callContext, resumeFn, callerContext,
51- result)) {
52- case FutureFragment::Status::Executing:
53- // The waiting task has been queued on the future.
54- #ifdef __ARM_ARCH_7K__
55- return workaround_function_swift_task_future_waitImpl (
56- result, callerContext, task, resumeFn, callContext);
57- #else
58- return ;
59- #endif
60-
61- case FutureFragment::Status::Success: {
62- // Run the task with a successful result.
63- auto future = task->futureFragment ();
64- future->getResultType ()->vw_initializeWithCopy (result,
65- future->getStoragePtr ());
66- return resumeFn (callerContext);
67- }
68-
69- case FutureFragment::Status::Error:
70- swift_Concurrency_fatalError (0 , " future reported an error, but wait cannot throw" );
71- }
20+ original (result, callerContext, task, resumeFn, callContext);
7221}
7322
7423// ===--- swift_task_future_wait_throwing ----------------------------------===//
7524
76- SWIFT_CC (swiftasync)
77- static void task_wait_throwing_resume_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
78-
79- auto context = static_cast <TaskFutureWaitAsyncContext *>(_context);
80- auto resumeWithError =
81- reinterpret_cast <AsyncVoidClosureEntryPoint *>(context->ResumeParent );
82- return resumeWithError (context->Parent , context->errorResult );
83- }
84-
85-
86- #ifdef __ARM_ARCH_7K__
87- __attribute__ ((noinline))
88- SWIFT_CC(swiftasync) static void workaround_function_swift_task_future_wait_throwingImpl(
89- OpaqueValue *result, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
90- AsyncTask *task, ThrowingTaskFutureWaitContinuationFunction resumeFunction,
91- AsyncContext *callContext) {
92- // Make sure we don't eliminate calls to this function.
93- asm volatile (" " // Do nothing.
94- : // Output list, empty.
95- : " r" (result), " r" (callerContext), " r" (task) // Input list.
96- : // Clobber list, empty.
97- );
98- return ;
99- }
100- #endif
101-
102-
10325void SWIFT_CC (swiftasync) swift::swift56override_swift_task_future_wait_throwing(
10426 OpaqueValue *result,
10527 SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
10628 AsyncTask *task,
10729 ThrowingTaskFutureWaitContinuationFunction *resumeFunction,
10830 AsyncContext *callContext,
10931 TaskFutureWaitThrowing_t *original) {
110- auto waitingTask = swift_task_getCurrent ();
111- // Suspend the waiting task.
112- waitingTask->ResumeTask = task_wait_throwing_resume_adapter;
113- waitingTask->ResumeContext = callContext;
114-
115- auto resumeFn = reinterpret_cast <TaskContinuationFunction *>(resumeFunction);
116-
117- // Wait on the future.
118- assert (task->isFuture ());
119-
120- switch (task->waitFuture (waitingTask, callContext, resumeFn, callerContext,
121- result)) {
122- case FutureFragment::Status::Executing:
123- // The waiting task has been queued on the future.
124- #ifdef __ARM_ARCH_7K__
125- return workaround_function_swift_task_future_wait_throwingImpl (
126- result, callerContext, task, resumeFunction, callContext);
127- #else
128- return ;
129- #endif
130-
131- case FutureFragment::Status::Success: {
132- auto future = task->futureFragment ();
133- future->getResultType ()->vw_initializeWithCopy (result,
134- future->getStoragePtr ());
135- return resumeFunction (callerContext, nullptr /* error*/ );
136- }
137-
138- case FutureFragment::Status::Error: {
139- // Run the task with an error result.
140- auto future = task->futureFragment ();
141- auto error = future->getError ();
142- swift_errorRetain (error);
143- return resumeFunction (callerContext, error);
144- }
145- }
146-
32+ original (result, callerContext, task, resumeFunction, callContext);
14733}
0 commit comments