JVM_IR more compact safe call chains (almost as old BE)
This commit is contained in:
committed by
teamcityserver
parent
f4eaf611c8
commit
0a67ab54fe
-5
@@ -6,9 +6,4 @@ fun check(a : A?) : Int {
|
||||
|
||||
// 0 valueOf
|
||||
// 0 Value\s\(\)
|
||||
|
||||
// JVM_TEMPLATES:
|
||||
// 0 ACONST_NULL
|
||||
|
||||
// JVM_IR_TEMPLATES:
|
||||
// 1 ACONST_NULL
|
||||
|
||||
Vendored
-5
@@ -10,9 +10,4 @@ fun check(a : A?) : Int {
|
||||
|
||||
// 0 valueOf
|
||||
// 0 Value\s\(\)
|
||||
|
||||
// JVM_TEMPLATES:
|
||||
// 0 ACONST_NULL
|
||||
|
||||
// JVM_IR_TEMPLATES:
|
||||
// 1 ACONST_NULL
|
||||
|
||||
Vendored
+11
-5
@@ -9,13 +9,13 @@
|
||||
|
||||
fun box(): String {
|
||||
for (i in (4 .. 1).reversed()) {
|
||||
throw AssertionError("Loop should not be executed")
|
||||
throw AssertionError("Loop over empty Int range should not be executed")
|
||||
}
|
||||
for (i in (4L .. 1L).reversed()) {
|
||||
throw AssertionError("Loop should not be executed")
|
||||
throw AssertionError("Loop over empty Long range should not be executed")
|
||||
}
|
||||
for (i in ('D' .. 'A').reversed()) {
|
||||
throw AssertionError("Loop should not be executed")
|
||||
throw AssertionError("Loop over empty Char range should not be executed")
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -29,8 +29,14 @@ fun box(): String {
|
||||
// 0 getStep
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// Int- and Char-based loops are completely elimiated
|
||||
// 0 ILOAD
|
||||
// 2 ISTORE
|
||||
// 0 ISTORE
|
||||
// 0 IADD
|
||||
// 0 ISUB
|
||||
// 0 IINC
|
||||
// 0 IINC
|
||||
// 3 LLOAD
|
||||
// 2 LSTORE
|
||||
// 1 LADD
|
||||
// 0 LSUB
|
||||
// 4 LDC
|
||||
+2
-2
@@ -33,8 +33,8 @@ fun f(a: UInt): Int {
|
||||
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 6 ILOAD
|
||||
// 4 ISTORE
|
||||
// 5 ILOAD
|
||||
// 3 ISTORE
|
||||
// 0 IADD
|
||||
// 0 ISUB
|
||||
// 2 IINC
|
||||
+1
-1
@@ -30,4 +30,4 @@ suspend fun ApplicationCall.test(authenticationService: AuthenticationService) {
|
||||
// 0 ILOAD 3
|
||||
// 0 ILOAD 2
|
||||
// 1 \$i\$f\$receiveJSON I .* 2
|
||||
// 3 \$i\$f\$respond I .* 3
|
||||
// 2 \$i\$f\$respond I .* 3
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ inline fun lookAtMe(f: (String) -> Unit) {
|
||||
f(a) // Should be no unneeded nops on this line, that might be generated for zero-parameters lambda
|
||||
}
|
||||
|
||||
// 2 NOP
|
||||
// 0 NOP
|
||||
@@ -2,8 +2,4 @@ val a : Int? = 10
|
||||
|
||||
fun foo() = a?.toString()
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 IFNULL
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 IFNONNULL
|
||||
|
||||
+3
-3
@@ -13,6 +13,6 @@ class A(val x: String) {
|
||||
// 2 ACONST_NULL
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 IFNULL
|
||||
// 4 IFNONNULL
|
||||
// 0 ACONST_NULL
|
||||
// 4 IFNULL
|
||||
// 2 IFNONNULL
|
||||
// 2 ACONST_NULL
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A(val b: B)
|
||||
class B(val c: C)
|
||||
class C(val s: String)
|
||||
|
||||
fun test(na: A?) =
|
||||
na?.b?.c?.s
|
||||
|
||||
// 1 POP
|
||||
// 1 ACONST_NULL
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 DUP
|
||||
// 1 IFNULL
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 3 DUP
|
||||
// 3 IFNULL
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fun test(a: Any?, b: Any?, c: String) =
|
||||
a?.toString() ?: b?.toString() ?: c
|
||||
|
||||
// 2 IFNULL
|
||||
// 1 ACONST_NULL
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 IFNONNULL
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 2 IFNONNULL
|
||||
@@ -0,0 +1,17 @@
|
||||
fun test(a: Any?) =
|
||||
a?.toString()?.hashCode() ?: 0
|
||||
|
||||
// 1 ALOAD
|
||||
// 0 ASTORE
|
||||
// 0 ISTORE
|
||||
// 0 ILOAD
|
||||
// 1 POP
|
||||
// 0 valueOf
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 DUP
|
||||
// 1 IFNULL
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 2 DUP
|
||||
// 2 IFNULL
|
||||
Reference in New Issue
Block a user