mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Do not check, that all Unit predecessors are POPs. This is safe for the same reason, as it is safe to allow some of ARETURN sources not be suspension point results. To elaborate, before Unit, the stack is empty. This is because if there are multiple paths to Unit and at least one of them comes from POP after suspension point (we are interested in this case only - otherwise, the call is not tail-call), in path from said POP the stack is empty, since after suspension point the stack contains only one element. Thus, the stack in other paths leading to Unit has to be empty, otherwise, merge operation is not possible and ASM will report error during analysis. Since the stack is empty in all paths, we can hoist Unit and following ARETURN to predecessors, effectively turning path from suspension point to tail-call.