Update bytecode text tests for JVM_IR
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun testPrimitiveArray(i: Int, ints: IntArray) = i in ints.indices
|
||||
|
||||
fun testObjectArray(i: Int, xs: Array<Any>) = i in xs.indices
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun testCharSequence(i: Int, cs: CharSequence) = i in cs.indices
|
||||
|
||||
fun testLongWithCharSequence(i: Long, cs: CharSequence) = i in cs.indices
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun testCollection(i: Int, xs: List<Any>) = i in xs.indices
|
||||
|
||||
fun testLongWithCollection(i: Long, xs: List<Any>) = i in xs.indices
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun test1(a: String) = a in "alpha" .. "omega"
|
||||
fun test2(a: String) = a !in "alpha" .. "omega"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
|
||||
fun ub_ub(x: UByte, a: UByte, b: UByte) = x in a..b
|
||||
fun ub_us(x: UByte, a: UShort, b: UShort) = x in a..b
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun inInt(x: Long): Boolean {
|
||||
return x in 1..2
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun Byte.inByte(left: Byte, right: Byte) = this in left..right
|
||||
|
||||
fun Short.inInt(left: Int, right: Int) = this in left .. right
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
|
||||
fun testUIntRangeLiteral(a: UInt, b: UInt) = 42u in a .. b
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36829 Optimize 'in' expressions in JVM_IR
|
||||
fun testByte(a: Byte, x: Byte, y: Byte) = a in x until y
|
||||
|
||||
fun testShort(a: Short, x: Short, y: Short) = a in x until y
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
object A {
|
||||
val r: Int = 1
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// Field initialized in constant pool
|
||||
// A super constructor call and INSTANCE put
|
||||
// 2 ALOAD 0
|
||||
// 2 ALOAD 0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates 'dup' instead of 'astore 0; aload 0' in <clinit> method of object class
|
||||
// 1 ALOAD 0
|
||||
+16
-9
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// -IGNORE_BACKEND: JVM_IR
|
||||
inline fun <T> runAfterLoop(fn: () -> T): T {
|
||||
for (i in 1..2);
|
||||
return fn()
|
||||
@@ -6,18 +6,25 @@ inline fun <T> runAfterLoop(fn: () -> T): T {
|
||||
|
||||
inline fun bar(x: Int, y: Long, z: Byte, s: String) = runAfterLoop { x.toString() + y.toString() + z.toString() + s }
|
||||
|
||||
fun foobar(x: Int, y: Long, s: String, z: Byte) = x.toString() + y.toString() + s + z.toString()
|
||||
fun foobar(x: Int, y: Long, s: String, z: Byte) {}
|
||||
|
||||
fun foo() : String {
|
||||
return foobar(1, 2L, bar(3, 4L, 5.toByte(), "6"), 7.toByte())
|
||||
fun foo() {
|
||||
foobar(1, 2L, bar(3, 4L, 5.toByte(), "6"), 7.toByte())
|
||||
}
|
||||
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 16 ISTORE
|
||||
// 13 ILOAD
|
||||
// 2 ASTORE
|
||||
// 8 ALOAD
|
||||
// 7 ALOAD
|
||||
// 2 LSTORE
|
||||
// 4 LLOAD
|
||||
// 3 LLOAD
|
||||
// 1 MAXLOCALS = 10
|
||||
// 0 InlineMarker
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 16 ISTORE
|
||||
// 11 ILOAD
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates an extra induction variable in 'for (i in 1..2)' (see KT-36837)
|
||||
// 19 ISTORE
|
||||
// 14 ILOAD
|
||||
|
||||
+13
-6
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// -IGNORE_BACKEND: JVM_IR
|
||||
inline fun <T> runAfterLoop(fn: () -> T): T {
|
||||
for (i in 1..2);
|
||||
return fn()
|
||||
@@ -6,7 +6,7 @@ inline fun <T> runAfterLoop(fn: () -> T): T {
|
||||
|
||||
fun bar() : Boolean = true
|
||||
|
||||
fun foobar(x: Boolean, y: String, z: String) = x.toString() + y + z
|
||||
fun foobar(x: Boolean, y: String, z: String) {}
|
||||
|
||||
inline fun foo() = runAfterLoop { "-" }
|
||||
|
||||
@@ -14,11 +14,18 @@ fun test() {
|
||||
val result = foobar(if (1 == 1) true else bar(), foo(), "OK")
|
||||
}
|
||||
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 14 ISTORE
|
||||
// 8 ILOAD
|
||||
// 2 ASTORE
|
||||
// 7 ALOAD
|
||||
// 5 ALOAD
|
||||
// 1 MAXLOCALS = 3
|
||||
// 1 MAXLOCALS = 4
|
||||
// 0 InlineMarker
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 14 ISTORE
|
||||
// 7 ILOAD
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates an extra induction variable in 'for (i in 1..2)' (see KT-36837)
|
||||
// 17 ISTORE
|
||||
// 10 ILOAD
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234U
|
||||
val ub = 5678U
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234U
|
||||
val ub = 5678U
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234U
|
||||
val ub = 5678U
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
fun box(): String {
|
||||
val min = 0U.toString()
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234UL
|
||||
val ub = 5678UL
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234UL
|
||||
val ub = 5678UL
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
val ua = 1234UL
|
||||
val ub = 5678UL
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
|
||||
|
||||
fun box(): String {
|
||||
val min = 0UL.toString()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36839 Generate 'when' with unsigned subject using TABLESWITCH/LOOKUPSWITCH in JVM_IR
|
||||
|
||||
const val M1: UInt = 2147483648u
|
||||
|
||||
|
||||
+8
-9
@@ -1,13 +1,12 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
enum class A { V }
|
||||
enum class A { V1, V2, V3 }
|
||||
|
||||
fun box(): String {
|
||||
val a: A = A.V
|
||||
val b: Boolean
|
||||
when (a) {
|
||||
A.V -> b = true
|
||||
}
|
||||
return if (b) "OK" else "FAIL"
|
||||
fun test(a: A) {
|
||||
val x: Int
|
||||
when (a) {
|
||||
A.V1 -> x = 11
|
||||
A.V2 -> x = 22
|
||||
A.V3 -> x = 33
|
||||
}
|
||||
}
|
||||
|
||||
// 1 TABLESWITCH
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
enum class A { V }
|
||||
//- IGNORE_BACKEND: JVM_IR
|
||||
enum class A { V1, V2, V3 }
|
||||
|
||||
fun box(): String {
|
||||
val a: A = A.V
|
||||
fun box(a: A): String {
|
||||
when (a) {
|
||||
A.V -> return "OK"
|
||||
A.V1 -> return "V1"
|
||||
A.V2 -> return "V2"
|
||||
A.V3 -> return "V3"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36840 Don't generate 'throw' clause for statement 'when' in JVM_IR
|
||||
|
||||
enum class AccessMode { READ, WRITE, EXECUTE }
|
||||
|
||||
fun whenExpr(access: AccessMode) {
|
||||
@@ -9,11 +11,6 @@ fun whenExpr(access: AccessMode) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
whenExpr(AccessMode.EXECUTE)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 1 TABLESWITCH
|
||||
// 0 LOOKUPSWITCH
|
||||
// 0 ATHROW
|
||||
|
||||
+10
-2
@@ -1,6 +1,9 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun foo1(x: Int): Boolean {
|
||||
when(x) {
|
||||
0 -> return true
|
||||
1 -> return false
|
||||
2 -> return true
|
||||
3 -> return false
|
||||
2 + 2 -> return true
|
||||
else -> return false
|
||||
}
|
||||
@@ -8,9 +11,14 @@ fun foo1(x: Int): Boolean {
|
||||
|
||||
fun foo2(x: Int): Boolean {
|
||||
when(x) {
|
||||
0 -> return true
|
||||
1 -> return false
|
||||
2 -> return true
|
||||
3 -> return false
|
||||
Integer.MAX_VALUE -> return true
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
// 2 TABLESWITCH
|
||||
// 1 TABLESWITCH
|
||||
// 1 LOOKUPSWITCH
|
||||
|
||||
+11
-18
@@ -1,27 +1,20 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FILE: C.kt
|
||||
class CInt(val value: Int)
|
||||
val nCInt3: CInt? = CInt(3)
|
||||
// TODO KT-36646 Don't box primitive values in equality comparison with objects in JVM_IR
|
||||
|
||||
class CLong(val value: Long)
|
||||
val nCLong3: CLong? = CLong(3)
|
||||
|
||||
// FILE: test.kt
|
||||
fun testInt(i: Int?) =
|
||||
when (i) {
|
||||
0 -> "zero"
|
||||
42 -> "magic"
|
||||
else -> "other"
|
||||
}
|
||||
when (i) {
|
||||
0 -> "zero"
|
||||
42 -> "magic"
|
||||
else -> "other"
|
||||
}
|
||||
|
||||
fun testLong(i: Long?) =
|
||||
when (i) {
|
||||
0L -> "zero"
|
||||
42L -> "magic"
|
||||
else -> "other"
|
||||
}
|
||||
when (i) {
|
||||
0L -> "zero"
|
||||
42L -> "magic"
|
||||
else -> "other"
|
||||
}
|
||||
|
||||
// @TestKt.class:
|
||||
// 0 valueOf
|
||||
// 0 Integer.valueOf
|
||||
// 0 Long.valueOf
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36841 Generate integer comparison with 0 instructions (IFNE, etc) when comparing integers with 0 in JVM_IR
|
||||
|
||||
fun test(a: Int, b: Int, c: Int) {
|
||||
when (0) {
|
||||
a -> throw IllegalArgumentException("a is 0")
|
||||
|
||||
+10
-16
@@ -1,23 +1,20 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36845 Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR
|
||||
|
||||
enum class En { A, B, С }
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res1 = "fail"
|
||||
var res2 = "fail2"
|
||||
fun box() {
|
||||
var r = ""
|
||||
|
||||
val en: En = En.A
|
||||
when (en) {
|
||||
En.A -> {res1 = ""}
|
||||
En.A -> { r = "when-1" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
|
||||
when (en as En) {
|
||||
En.A -> {res1 += "O"}
|
||||
En.A -> { r = "when-2" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
@@ -27,13 +24,13 @@ fun box(): String {
|
||||
val en2: Any? = En.A
|
||||
if (en2 is En) {
|
||||
when (en2) {
|
||||
En.A -> {res1 += "K"}
|
||||
En.A -> { r = "when-3" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
|
||||
when (en2 as En) {
|
||||
En.A -> {res2 = ""}
|
||||
En.A -> { r = "when-4" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
@@ -44,20 +41,17 @@ fun box(): String {
|
||||
val en1: Any = En.A
|
||||
if (en1 is En) {
|
||||
when (en1) {
|
||||
En.A -> {res2 += "O"}
|
||||
En.A -> { r = "when-5" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
// Working without other examples
|
||||
when (en1 as En) {
|
||||
En.A -> {res2 += "K"}
|
||||
En.A -> { r = "when-6" }
|
||||
En.B -> {}
|
||||
En.С -> {}
|
||||
}
|
||||
}
|
||||
|
||||
if (res1 != res2) return "different results: $res1 != $res2"
|
||||
return res1
|
||||
}
|
||||
|
||||
// 6 TABLESWITCH
|
||||
@@ -1,4 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36845 Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR
|
||||
|
||||
class EncapsulatedEnum<T : Enum<T>>(val value: T)
|
||||
|
||||
enum class MyEnum(val value: String) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TODO KT-36845 Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR
|
||||
|
||||
private fun Any?.doTheThing(): String {
|
||||
when (this) {
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
import kotlin.test.assertEquals
|
||||
// TODO KT-36846 Generate TABLESWITCH/LOOKUPSWITCH in case of matching hashCodes in JVM_IR
|
||||
|
||||
fun foo(x : String) : String {
|
||||
assert("abz]".hashCode() == "aby|".hashCode())
|
||||
|
||||
Reference in New Issue
Block a user