Replace CHECKCAST kotlin/Unit with ARETURN for tail call optimization
Sometimes instead of {POP, GETSTATIC Unit.INSTANCE, ARETURN} sequence
the codegen emits {CHECKCAST Unit, ARETURN} sequence, which breaks tail
call optimization. By replacing CHECKCAST with ARETURN we eliminate
this issue.
#KT-19790: Fixed
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
var p: Int = 5846814
|
||||
private suspend fun withoutInline() {
|
||||
val c = { c: Continuation<Unit> ->
|
||||
if (p > 52158) Unit else COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
return suspendCoroutineOrReturn(c)
|
||||
}
|
||||
|
||||
private suspend fun withInline() {
|
||||
return suspendCoroutineOrReturn { c ->
|
||||
if (p > 52158) Unit else COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user