@@ -1483,6 +1483,7 @@ static void swift_job_runImpl(Job *job, ExecutorRef executor) {
1483
1483
// / the actor lives for the duration of job execution.
1484
1484
// / Note that this may conflict with the retain/release
1485
1485
// / design in the DefaultActorImpl, but it does fix bugs!
1486
+ SWIFT_CC (swiftasync)
1486
1487
static void processDefaultActor (DefaultActorImpl *currentActor,
1487
1488
RunningJobInfo runner) {
1488
1489
#if SWIFT_TASK_PRINTF_DEBUG
@@ -1557,6 +1558,7 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
1557
1558
swift_release (actor);
1558
1559
}
1559
1560
1561
+ SWIFT_CC (swiftasync)
1560
1562
void ProcessInlineJob::process (Job *job) {
1561
1563
DefaultActorImpl *actor = DefaultActorImpl::fromInlineJob (job);
1562
1564
@@ -1565,11 +1567,11 @@ void ProcessInlineJob::process(Job *job) {
1565
1567
auto targetPriority = job->getPriority ();
1566
1568
auto runner = RunningJobInfo::forInline (targetPriority);
1567
1569
1568
- // FIXME: force tail call
1569
1570
swift_retain (actor);
1570
- return processDefaultActor (actor, runner);
1571
+ return processDefaultActor (actor, runner); // 'return' forces tail call
1571
1572
}
1572
1573
1574
+ SWIFT_CC (swiftasync)
1573
1575
void ProcessOutOfLineJob::process (Job *job) {
1574
1576
auto self = cast<ProcessOutOfLineJob>(job);
1575
1577
DefaultActorImpl *actor = self->Actor ;
@@ -1581,21 +1583,20 @@ void ProcessOutOfLineJob::process(Job *job) {
1581
1583
1582
1584
delete self;
1583
1585
1584
- // FIXME: force tail call
1585
1586
swift_retain (actor);
1586
- return processDefaultActor (actor, runner);
1587
+ return processDefaultActor (actor, runner); // 'return' forces tail call
1587
1588
}
1588
1589
1590
+ SWIFT_CC (swiftasync)
1589
1591
void ProcessOverrideJob::process (Job *job) {
1590
1592
auto self = cast<ProcessOverrideJob>(job);
1591
1593
1592
1594
// Pull the actor and priority out of the job.
1593
1595
auto actor = self->Actor ;
1594
1596
auto runner = RunningJobInfo::forOverride (self);
1595
1597
1596
- // FIXME: force tail call
1597
1598
swift_retain (actor);
1598
- return processDefaultActor (actor, runner);
1599
+ return processDefaultActor (actor, runner); // 'return' forces tail call
1599
1600
}
1600
1601
1601
1602
void DefaultActorImpl::enqueue (Job *job) {
@@ -1800,13 +1801,6 @@ static bool tryAssumeThreadForSwitch(ExecutorRef newExecutor,
1800
1801
return false ;
1801
1802
}
1802
1803
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
-
1810
1804
// / Given that we've assumed control of an executor on this thread,
1811
1805
// / continue to run the given task on it.
1812
1806
SWIFT_CC (swiftasync)
@@ -1819,10 +1813,7 @@ static void runOnAssumedThread(AsyncTask *task, ExecutorRef executor,
1819
1813
if (oldTracking) {
1820
1814
oldTracking->setActiveExecutor (executor);
1821
1815
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
1826
1817
}
1827
1818
1828
1819
// Otherwise, set up tracking info.
@@ -1865,8 +1856,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
1865
1856
// we can just immediately continue running with the resume function
1866
1857
// we were passed in.
1867
1858
if (!currentExecutor.mustSwitchToRun (newExecutor)) {
1868
- // FIXME: force tail call
1869
- return resumeFunction (resumeContext);
1859
+ return resumeFunction (resumeContext); // 'return' forces tail call
1870
1860
}
1871
1861
1872
1862
auto task = swift_task_getCurrent ();
@@ -1890,7 +1880,7 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
1890
1880
fprintf (stderr, " [%p] switch succeeded, task %p assumed thread for executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
1891
1881
#endif
1892
1882
giveUpThreadForSwitch (currentExecutor, runner);
1893
- // FIXME: force tail call
1883
+ // 'return' forces tail call
1894
1884
return runOnAssumedThread (task, newExecutor, trackingInfo, runner);
1895
1885
}
1896
1886
0 commit comments