Minor. Add tests.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
|
||||
// jsut before suspension point
|
||||
// 1 ACONST_NULL
|
||||
// 2 PUTFIELD .*L\$0 : Ljava/lang/Object;
|
||||
@@ -0,0 +1,15 @@
|
||||
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;
|
||||
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
@@ -0,0 +1,34 @@
|
||||
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