Use tail call optimization if ARETURN has multiple sources

#KT-21977: Fixed
This commit is contained in:
Ilmir Usmanov
2018-01-09 19:19:27 +03:00
parent 5dbab2f907
commit 32a94c70e9
4 changed files with 49 additions and 6 deletions
@@ -701,12 +701,11 @@ private fun allSuspensionPointsAreTailCalls(
if (insideTryBlock) return@all false
safelyReachableReturns[endIndex + 1]?.all { returnIndex ->
val sourceInsn =
sourceFrames[returnIndex].top().sure {
"There must be some value on stack to return"
}.insns.singleOrNull()
sourceInsn?.let(instructions::indexOf) in beginIndex..endIndex
sourceFrames[returnIndex].top().sure {
"There must be some value on stack to return"
}.insns.all { sourceInsn ->
sourceInsn?.let(instructions::indexOf) in beginIndex..endIndex
}
} ?: false
}
}