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
@@ -10203,6 +10203,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/checkcast.kt");
}
@TestMetadata("checkcast2.kt")
public void testCheckcast2() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/checkcast2.kt");
}
@TestMetadata("crossinline.kt")
public void testCrossinline() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/crossinline.kt");