Disable tail call optimization, if the call is inside try block

#KT-21165: Fixed
This commit is contained in:
Ilmir Usmanov
2018-01-09 17:13:19 +03:00
parent 3cfe43f83a
commit 5dbab2f907
9 changed files with 102 additions and 0 deletions
@@ -692,6 +692,14 @@ private fun allSuspensionPointsAreTailCalls(
val beginIndex = instructions.indexOf(suspensionPoint.suspensionCallBegin)
val endIndex = instructions.indexOf(suspensionPoint.suspensionCallEnd)
val insideTryBlock = methodNode.tryCatchBlocks.any { block ->
val tryBlockStartIndex = instructions.indexOf(block.start)
val tryBlockEndIndex = instructions.indexOf(block.end)
beginIndex in tryBlockStartIndex..tryBlockEndIndex
}
if (insideTryBlock) return@all false
safelyReachableReturns[endIndex + 1]?.all { returnIndex ->
val sourceInsn =
sourceFrames[returnIndex].top().sure {