Optimize more redundant kotlin/jvm/internal/Refs
The number of initializations of the `value` field before the live range begins does not really matter so long as we insert a write of a default value to the local if there were none.
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36648 Captured variables not optimized in JVM_IR
|
||||
|
||||
fun test(): java.lang.Integer {
|
||||
val c: java.lang.Integer
|
||||
run {
|
||||
@@ -10,4 +7,9 @@ fun test(): java.lang.Integer {
|
||||
}
|
||||
|
||||
// 2 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Integer; L1 L.* 0
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Integer;
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Object;
|
||||
@@ -6,5 +6,5 @@ fun test(): java.lang.Integer {
|
||||
return c
|
||||
}
|
||||
|
||||
// 1 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$ObjectRef; L1 L.* 0
|
||||
// 2 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Object;
|
||||
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline fun <reified T> foo(default: T): T {
|
||||
val t: T
|
||||
run {
|
||||
@@ -13,6 +11,6 @@ fun test() {
|
||||
}
|
||||
|
||||
// two in foo and two in test
|
||||
|
||||
// 4 ASTORE 2
|
||||
// 1 LOCALVARIABLE t\$iv Ljava/lang/Object; L3 L.* 2
|
||||
// 1 LOCALVARIABLE t Ljava/lang/Object;
|
||||
// 1 LOCALVARIABLE t\$iv Ljava/lang/Object;
|
||||
+3
-4
@@ -1,4 +1,3 @@
|
||||
|
||||
inline fun <reified T> foo(default: T): T {
|
||||
var t: T
|
||||
run {
|
||||
@@ -12,6 +11,6 @@ fun test() {
|
||||
}
|
||||
|
||||
// two in foo and two in test
|
||||
|
||||
// 2 ASTORE 2
|
||||
// 1 LOCALVARIABLE t\$iv Lkotlin/jvm/internal/Ref\$ObjectRef; L3 L.* 2
|
||||
// 4 ASTORE 2
|
||||
// 1 LOCALVARIABLE t Ljava/lang/Object;
|
||||
// 1 LOCALVARIABLE t\$iv Ljava/lang/Object;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36648 Captured variables not optimized in JVM_IR
|
||||
// TODO: JVM_IR uses ObjectRef instead of IntRef for the value
|
||||
|
||||
fun test(): UInt {
|
||||
val c: UInt
|
||||
@@ -10,4 +10,4 @@ fun test(): UInt {
|
||||
}
|
||||
|
||||
// 2 ISTORE 0
|
||||
// 1 LOCALVARIABLE c I L1 L.* 0
|
||||
// 1 LOCALVARIABLE c I
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36648 Captured variables not optimized in JVM_IR
|
||||
// TODO: JVM_IR uses ObjectRef instead of IntRef for the value
|
||||
|
||||
fun test(): UInt {
|
||||
var c: UInt
|
||||
@@ -9,5 +9,5 @@ fun test(): UInt {
|
||||
return c
|
||||
}
|
||||
|
||||
// 1 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$IntRef; L1 L.* 0
|
||||
// 2 ISTORE 0
|
||||
// 1 LOCALVARIABLE c I
|
||||
@@ -1,6 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36648 Captured variables not optimized in JVM_IR
|
||||
|
||||
fun test(): Char {
|
||||
lateinit var c: Any
|
||||
run {
|
||||
@@ -9,5 +6,11 @@ fun test(): Char {
|
||||
return c as Char
|
||||
}
|
||||
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Object;
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 2 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Ljava/lang/Object; L1 L.* 0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 3 ASTORE 0
|
||||
// *two* of them are after the start of c's live range
|
||||
@@ -1,6 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36648 Captured variables not optimized in JVM_IR
|
||||
|
||||
fun test(): Char {
|
||||
val c: Char
|
||||
run {
|
||||
@@ -12,4 +9,4 @@ fun test(): Char {
|
||||
|
||||
// The first on declaration, the other on initialization
|
||||
// 2 ISTORE 0
|
||||
// 1 LOCALVARIABLE c C L1 L.* 0
|
||||
// 1 LOCALVARIABLE c C
|
||||
@@ -6,5 +6,5 @@ fun test(): Char {
|
||||
return c
|
||||
}
|
||||
|
||||
// 1 ASTORE 0
|
||||
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$CharRef; L1 L.* 0
|
||||
// 2 ISTORE 0
|
||||
// 1 LOCALVARIABLE c C
|
||||
Reference in New Issue
Block a user