@@ -10,138 +10,24 @@ using TaskGroup = swift::TaskGroup;
10
10
11
11
// ===--- swift_task_future_wait -------------------------------------------===//
12
12
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
-
35
13
void SWIFT_CC (swiftasync) swift::swift56override_swift_task_future_wait(
36
14
OpaqueValue *result,
37
15
SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
38
16
AsyncTask *task,
39
17
TaskContinuationFunction *resumeFn,
40
18
AsyncContext *callContext,
41
19
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);
72
21
}
73
22
74
23
// ===--- swift_task_future_wait_throwing ----------------------------------===//
75
24
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
-
103
25
void SWIFT_CC (swiftasync) swift::swift56override_swift_task_future_wait_throwing(
104
26
OpaqueValue *result,
105
27
SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
106
28
AsyncTask *task,
107
29
ThrowingTaskFutureWaitContinuationFunction *resumeFunction,
108
30
AsyncContext *callContext,
109
31
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);
147
33
}
0 commit comments