[IR] Eliminate redundant boxing/unboxing of MFVC after inlining

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
This commit is contained in:
Evgeniy.Zhelenskiy
2022-11-13 21:57:15 +01:00
committed by Space Team
parent a3e396e7e4
commit 40f38c8adb
25 changed files with 726 additions and 2292 deletions
@@ -3,38 +3,13 @@
// WITH_COROUTINES
// TARGET_BACKEND: JVM_IR
// LANGUAGE: +ValueClasses
// FIR_IDENTICAL
// FILE: caller.kt
import kotlin.coroutines.*
fun runSuspend(block: suspend () -> Unit) {
val run = RunSuspend()
block.startCoroutine(run)
run.await()
}
private class RunSuspend : Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
var result: Result<Unit>? = null
override fun resumeWith(result: Result<Unit>) = synchronized(this) {
this.result = result
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (this as Object).notifyAll()
}
fun await() = synchronized(this) {
while (true) {
when (val result = this.result) {
null -> @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (this as Object).wait()
else -> {
result.getOrThrow() // throw up failure
return
}
}
}
}
block.startCoroutine(Continuation(EmptyCoroutineContext) { it.getOrThrow() })
}
// FILE: test.kt