df225c0c7f
The coroutine transformation would leave locals in the local variable table across the code that reloads local variables from the continuation on reentry. However, when reentering the function the local has no value until after the reloads from the continuation. This change splits the locals in the local variable table to avoid such uninitialized locals. A local alive across a suspension point has its range split in two. One that goes from the original start to the state label for the restart after the suspension. The other goes from after the local has been reloaded from the continuation until the previous end of the local.
42 lines
1.8 KiB
Kotlin
Vendored
42 lines
1.8 KiB
Kotlin
Vendored
|
|
// WITH_COROUTINES
|
|
// FILE: test.kt
|
|
class A
|
|
|
|
suspend fun A.foo() {}
|
|
suspend fun A.foo1(l: Long) {
|
|
foo()
|
|
foo()
|
|
val dead = l
|
|
}
|
|
|
|
suspend fun box() {
|
|
A().foo1(42)
|
|
}
|
|
|
|
// The lambda object constructor has a local variables table on the IR backend.
|
|
|
|
// LOCAL VARIABLES
|
|
// test.kt:14 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
|
// test.kt:4 <init>:
|
|
// test.kt:14 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
|
// test.kt:7 foo1:
|
|
|
|
// LOCAL VARIABLES JVM
|
|
// test.kt:-1 <init>:
|
|
// LOCAL VARIABLES JVM_IR
|
|
// test.kt:-1 <init>: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
|
|
|
// LOCAL VARIABLES
|
|
// test.kt:7 foo1:
|
|
// test.kt:8 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, $this$foo1:A=A, l:long=42:long
|
|
// test.kt:6 foo: $this$foo:A=A, $completion:kotlin.coroutines.Continuation=TestKt$foo1$1
|
|
// test.kt:8 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, $this$foo1:A=A, l:long=42:long
|
|
// test.kt:9 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, l:long=42:long, $this$foo1:A=A
|
|
// test.kt:6 foo: $this$foo:A=A, $completion:kotlin.coroutines.Continuation=TestKt$foo1$1
|
|
// test.kt:9 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, l:long=42:long
|
|
// test.kt:10 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, l:long=42:long
|
|
// test.kt:11 foo1: $continuation:kotlin.coroutines.Continuation=TestKt$foo1$1, $result:java.lang.Object=null, l:long=42:long, dead:long=42:long
|
|
// test.kt:14 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
|
// test.kt:15 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|