JVM: streamline handling of tail-call suspend functions

Just see if every suspend call is followed only by safe instructions or
returns, then insert a suspension point check if there isn't a direct
return.

The first part of this is equivalent to the old implementation, just
refactored. The second part generates strictly more checks; see, for
example, the fixed test, in which the previous implementation failed to
insert a check before a CHECKCAST.

^KT-51818 Fixed
This commit is contained in:
pyos
2022-04-08 12:31:07 +02:00
committed by teamcity
parent 97fc97e63d
commit a07e21d913
7 changed files with 124 additions and 202 deletions
@@ -12770,6 +12770,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/checkcast.kt");
}
@Test
@TestMetadata("checkcast2.kt")
public void testCheckcast2() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/checkcast2.kt");
}
@Test
@TestMetadata("crossinline.kt")
public void testCrossinline() throws Exception {