JVM infer temporary vals from bytecode

This commit is contained in:
Dmitry Petrov
2021-08-20 17:20:59 +03:00
committed by TeamCityServer
parent a4e299b8e1
commit dcbc2ea2b3
10 changed files with 433 additions and 105 deletions
@@ -12,4 +12,4 @@ suspend fun suspendThere(param: Int, param2: String, param3: Long): String {
return a + b
}
// 1 ASTORE 4
// 0 ASTORE 4
@@ -43,8 +43,6 @@ fun box(): String {
// 1 LOCALVARIABLE i Ljava/lang/String; L.* 3
// 1 PUTFIELD VarValueConflictsWithTableSameSortKt\$box\$1.L\$0 : Ljava/lang/Object;
/* 1 load in the catch (e: Throwable) { throw e } block which is implicitly wrapped around try/finally */
// 1 ALOAD 3\s+ATHROW
/* 1 load in result = s */
// 1 ALOAD 3\s+PUTFIELD kotlin/jvm/internal/Ref\$ObjectRef\.element
/* 1 load in spill */
@@ -52,7 +50,7 @@ fun box(): String {
/* 2 loads in println(s) */
// 2 ALOAD 3\s+INVOKEVIRTUAL java/io/PrintStream.println \(Ljava/lang/Object;\)V
/* But no further load when spilling 's' to the continuation */
// 5 ALOAD 3
// 4 ALOAD 3
// We merge LVT records for two consequent branches, but we split the local over the restore code.
// JVM_IR_TEMPLATES
@@ -21,6 +21,6 @@ fun foo() : String {
)
}
// 12 ALOAD
// 2 ASTORE
// 11 ALOAD
// 1 ASTORE
// 0 InlineMarker
@@ -11,7 +11,7 @@ fun foo() : String {
return foobar("abc", bar("ghi") { x -> x + "jkl" }, "mno")
}
// 6 ASTORE
// 18 ALOAD
// 4 ASTORE
// 16 ALOAD
// 1 MAXLOCALS = 7
// 0 InlineMarker