Implement unit suspend functions tail-call optimisation
Unlike previously, this optimisation works on every callee return type. Tail-calls inside unit functions can be either INVOKE... ARETURN or INVOKE POP GETSTATIC kotlin/Unit.INSTANCE ARETURN The first pattern is already covered. The second one is a bit tricky, since we cannot just assume than the function is tail-call, we also need to check whether the callee returned COROUTINE_SUSPENDED marker. Thus, resulting bytecode of function's 'epilogue' look like DUP INVOKESTATIC getCOROUTINE_SUSPENDED IF_ACMPNE LN ARETURN LN: POP #KT-28938 Fixed
This commit is contained in:
@@ -101,6 +101,6 @@ fun box() : String {
|
||||
checkContinuation(savedContinuation!!)
|
||||
}
|
||||
}
|
||||
if (!continuationChanged) return "FAIL 5"
|
||||
if (continuationChanged) return "FAIL 5"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user