mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 08:31:29 +00:00
Instead, flip the branch targets. This generates java byte code
such as:
L2
IFNE L3
ALOAD 0
INVOKEVIRTUAL A.getX ()F
GOTO L4
L3
instead of:
L2
IFNE L3
ICONST_1
GOTO L4
L3
ICONST_0
L4
IFEQ L5
ALOAD 0
INVOKEVIRTUAL A.getX ()F
GOTO L6
L5
38 lines
880 B
Kotlin
Vendored
38 lines
880 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
// FILE: list.kt
|
|
|
|
val intList = listOf(1, 2, 3)
|
|
val longList = listOf(1L, 2L, 3L)
|
|
|
|
// FILE: box.kt
|
|
|
|
fun box(): String {
|
|
val intListMin = intList.minBy { it } ?: -1
|
|
if (intListMin != 1) return "Fail intListMin=$intListMin"
|
|
|
|
val intListMax = intList.maxBy { it } ?: -1
|
|
if (intListMax != 3) return "Fail intListMax=$intListMax"
|
|
|
|
val longListMin = longList.minBy { it } ?: -1
|
|
if (longListMin != 1L) return "Fail longListMin=$longListMin"
|
|
|
|
val longListMax = longList.maxBy { it } ?: -1
|
|
if (longListMax != 3L) return "Fail longListMax=$longListMax"
|
|
|
|
return "OK"
|
|
}
|
|
|
|
// @BoxKt.class:
|
|
// -- no boxing
|
|
// 0 valueOf
|
|
// -- no compareTo
|
|
// 0 compareTo
|
|
// -- comparisons are properly fused with conditional jumps
|
|
// comparisons: 0 + fake inline variables: 8
|
|
// 8 ICONST_0
|
|
// 1 IF_ICMPGE
|
|
// 1 IF_ICMPLE
|
|
// 4 LCMP
|
|
// 1 IFGE
|
|
// 1 IFLE
|