@@ -1483,6 +1483,7 @@ static void swift_job_runImpl(Job *job, ExecutorRef executor) {
14831483// / the actor lives for the duration of job execution.
14841484// / Note that this may conflict with the retain/release
14851485// / design in the DefaultActorImpl, but it does fix bugs!
1486+ SWIFT_CC (swiftasync)
14861487static void processDefaultActor (DefaultActorImpl *currentActor,
14871488 RunningJobInfo runner) {
14881489#if SWIFT_TASK_PRINTF_DEBUG
@@ -1557,6 +1558,7 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
15571558 swift_release (actor);
15581559}
15591560
1561+ SWIFT_CC (swiftasync)
15601562void ProcessInlineJob::process (Job *job) {
15611563 DefaultActorImpl *actor = DefaultActorImpl::fromInlineJob (job);
15621564
@@ -1565,11 +1567,11 @@ void ProcessInlineJob::process(Job *job) {
15651567 auto targetPriority = job->getPriority ();
15661568 auto runner = RunningJobInfo::forInline (targetPriority);
15671569
1568- // FIXME: force tail call
15691570 swift_retain (actor);
1570- return processDefaultActor (actor, runner);
1571+ return processDefaultActor (actor, runner); // 'return' forces tail call
15711572}
15721573
1574+ SWIFT_CC (swiftasync)
15731575void ProcessOutOfLineJob::process (Job *job) {
15741576 auto self = cast<ProcessOutOfLineJob>(job);
15751577 DefaultActorImpl *actor = self->Actor ;
@@ -1581,21 +1583,20 @@ void ProcessOutOfLineJob::process(Job *job) {
15811583
15821584 delete self;
15831585
1584- // FIXME: force tail call
15851586 swift_retain (actor);
1586- return processDefaultActor (actor, runner);
1587+ return processDefaultActor (actor, runner); // 'return' forces tail call
15871588}
15881589
1590+ SWIFT_CC (swiftasync)
15891591void ProcessOverrideJob::process (Job *job) {
15901592 auto self = cast<ProcessOverrideJob>(job);
15911593
15921594 // Pull the actor and priority out of the job.
15931595 auto actor = self->Actor ;
15941596 auto runner = RunningJobInfo::forOverride (self);
15951597
1596- // FIXME: force tail call
15971598 swift_retain (actor);
1598- return processDefaultActor (actor, runner);
1599+ return processDefaultActor (actor, runner); // 'return' forces tail call
15991600}
16001601
16011602void DefaultActorImpl::enqueue (Job *job) {
@@ -1800,13 +1801,6 @@ static bool tryAssumeThreadForSwitch(ExecutorRef newExecutor,
18001801 return false ;
18011802}
18021803
1803- __attribute__ ((noinline))
1804- SWIFT_CC (swiftasync)
1805- static void force_tail_call_hack (AsyncTask *task) {
1806- // This *should* be executed as a tail call.
1807- return task->runInFullyEstablishedContext ();
1808- }
1809-
18101804// / Given that we've assumed control of an executor on this thread,
18111805// / continue to run the given task on it.
18121806SWIFT_CC (swiftasync)
@@ -1819,10 +1813,7 @@ static void runOnAssumedThread(AsyncTask *task, ExecutorRef executor,
18191813 if (oldTracking) {
18201814 oldTracking->setActiveExecutor (executor);
18211815
1822- // FIXME: force tail call
1823- // return task->runInFullyEstablishedContext();
1824- // This hack "ensures" that this call gets executed as a tail call.
1825- return force_tail_call_hack (task);
1816+ return task->runInFullyEstablishedContext (); // 'return' forces tail call
18261817 }
18271818
18281819 // Otherwise, set up tracking info.
@@ -1865,8 +1856,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
18651856 // we can just immediately continue running with the resume function
18661857 // we were passed in.
18671858 if (!currentExecutor.mustSwitchToRun (newExecutor)) {
1868- // FIXME: force tail call
1869- return resumeFunction (resumeContext);
1859+ return resumeFunction (resumeContext); // 'return' forces tail call
18701860 }
18711861
18721862 auto task = swift_task_getCurrent ();
@@ -1890,7 +1880,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
18901880 fprintf (stderr, " [%p] switch succeeded, task %p assumed thread for executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
18911881#endif
18921882 giveUpThreadForSwitch (currentExecutor, runner);
1893- // FIXME: force tail call
1883+ // 'return' forces tail call
18941884 return runOnAssumedThread (task, newExecutor, trackingInfo, runner);
18951885 }
18961886
0 commit comments