JVM: Make coroutines spilling tests runtime
instead of bytecode text ones. Check the content of continuation object instead of bytecode, since this is less prone to changes during changes in coroutines codegen. #KT-48678
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
suspend fun test() {
|
||||
for (i in 0..10) {
|
||||
// Should be cleanup, since there is a back edge from the rest of the loop
|
||||
dummy()
|
||||
val a = ""
|
||||
dummy()
|
||||
blackhole(a)
|
||||
}
|
||||
}
|
||||
|
||||
// 1 ACONST_NULL
|
||||
// 2 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
@@ -1,24 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
fun check(): Boolean = true
|
||||
|
||||
suspend fun test() {
|
||||
if (check()) {
|
||||
val a = ""
|
||||
dummy()
|
||||
blackhole(a)
|
||||
} else {
|
||||
val a = ""
|
||||
val b = ""
|
||||
dummy()
|
||||
blackhole(a, b)
|
||||
}
|
||||
// Cleanup both a and b, since the compiler does not know, which branch is going to executed
|
||||
dummy()
|
||||
}
|
||||
|
||||
// 2 ACONST_NULL
|
||||
// 3 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
// 2 PUTFIELD .*L\$1 : Ljava/lang/Object;
|
||||
@@ -1,18 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
suspend fun test() {
|
||||
var a: String? = ""
|
||||
dummy()
|
||||
blackhole(a)
|
||||
a = null
|
||||
// a is null, known at compile time, do not spill, but cleanup
|
||||
dummy()
|
||||
blackhole(a)
|
||||
}
|
||||
|
||||
// 2 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
|
||||
// two stores to initialize the `a` variable and one null constant to store in the spill slot.
|
||||
// 3 ACONST_NULL
|
||||
@@ -1,15 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
suspend fun test() {
|
||||
val a = null
|
||||
// a is null, known at compile time, do not spill
|
||||
dummy()
|
||||
blackhole(a)
|
||||
dummy()
|
||||
}
|
||||
|
||||
// before and after suspension point
|
||||
// 2 ACONST_NULL
|
||||
// 0 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
@@ -1,14 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
suspend fun test() {
|
||||
val a = ""
|
||||
dummy()
|
||||
blackhole(a)
|
||||
// a is dead, cleanup
|
||||
dummy()
|
||||
}
|
||||
|
||||
// 1 ACONST_NULL
|
||||
// 2 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
@@ -1,9 +0,0 @@
|
||||
suspend fun blackhole(a: Any?) {}
|
||||
|
||||
suspend fun cleanUpExample(a: String, b: String) {
|
||||
blackhole(a) // 1
|
||||
blackhole(b) // 2
|
||||
}
|
||||
|
||||
// 3 ACONST_NULL
|
||||
// 2 PUTFIELD .*L\$0 : .*;
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
val f: suspend (Int) -> Unit = { unused ->
|
||||
}
|
||||
|
||||
// 0 GETFIELD .*I\$0
|
||||
// 0 PUTFIELD .*I\$0
|
||||
@@ -1,34 +0,0 @@
|
||||
fun blackhole(vararg a: Any?) {}
|
||||
|
||||
suspend fun dummy() {}
|
||||
|
||||
fun check(): Int = 1
|
||||
|
||||
suspend fun test() {
|
||||
when (check()) {
|
||||
0 -> {
|
||||
val a = ""
|
||||
dummy()
|
||||
blackhole(a)
|
||||
}
|
||||
1 -> {
|
||||
val a = ""
|
||||
val b = ""
|
||||
dummy()
|
||||
blackhole(a, b)
|
||||
}
|
||||
else -> {
|
||||
val a = ""
|
||||
val b = ""
|
||||
val c = 1
|
||||
dummy()
|
||||
blackhole(a, b, c)
|
||||
}
|
||||
}
|
||||
// Cleanup both a and b, but c is primitive, so no need to clean it up
|
||||
dummy()
|
||||
}
|
||||
|
||||
// 2 ACONST_NULL
|
||||
// 4 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
// 3 PUTFIELD .*L\$1 : Ljava/lang/Object;
|
||||
Reference in New Issue
Block a user