Update bytecode text tests in JVM_IR

This commit is contained in:
Dmitry Petrov
2020-02-12 14:53:05 +03:00
parent db91b520a5
commit 59cdf3c52e
26 changed files with 87 additions and 58 deletions
@@ -1,12 +0,0 @@
// IGNORE_BACKEND: JVM_IR
class A {
fun test(x: String?, a: String?, b: String?){}
fun box(): String {
test(x = "x", b = "K", a = "O")
return "OK"
}
}
// Test argument reordering when call site argument order differs from declaration one
// 4 LOAD
// 2 STORE
@@ -1,15 +0,0 @@
// IGNORE_BACKEND: JVM_IR
class A {
fun test(x: String? = "x", a: String?, b: String?, y: String? = "y") {
}
fun box(): String {
test(b = "K", a = "O")
return "OK"
}
}
// Test argument reordering when call site argument order differs from declaration one
// 12 LOAD
// 5 STORE
@@ -1,4 +1,5 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36645 Don't box primitive values in string template and string concatenation in JVM_IR
// FILE: list.kt
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36646 Don't box primitive values in equality comparison with nullable primitive values in JVM_IR
fun Long.id() = this
fun String.drop2() = if (length >= 2) subSequence(2, length) else null
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36651 Avoid boxing in safe call / elvis chains in JVM_IR
class A(val x : Int, val y : A?)
fun check(a : A?) : Int {
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
fun test() {
var x = 0
run {
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
fun test() {
var x = 0
run { ++x }
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
// In JVM IR, SharedVariablesLowering transforms `x` into a shared variable to be able to update it from a lambda,
// which is a separate function (...$lambda-0).
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
fun box(): String {
var xl = 0L // Long, size 2
var xi = 0 // Int, size 1
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
fun box(): String {
run {
run {
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36648 Captured variables not optimized in JVM_IR
fun add(x: Int, y: Int) = x + y
fun test() {
@@ -1,4 +1,5 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36650 Don't generate CHECKCAST on null values in JVM_IR
// KT-15411 Unnecessary CHECKCAST bytecode when dealing with null
fun test1(): String? {
@@ -1,4 +1,5 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36654 Generate more compact bytecode for safe call in JVM_IR
interface A {
fun foo()
}
@@ -7,5 +8,9 @@ fun test(x: A?) {
x?.foo()
}
// JVM_TEMPLATES
// 1 POP
// 0 ACONST_NULL
// JVM_IR_TEMPLATES
// 0 ACONST_NULL
@@ -1,4 +1,5 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36654 Generate more compact bytecode for safe call in JVM_IR
interface A {
fun foo(): Any
}
@@ -7,5 +8,10 @@ fun test(x: A?) {
x?.foo()
}
// JVM_TEMPLATES
// 2 POP
// 0 ACONST_NULL
// JVM_IR_TEMPLATES
// 1 POP
// 0 ACONST_NULL
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36650 Don't generate CHECKCAST on null values in JVM_IR
// TODO KT-36654 Generate more compact bytecode for safe call in JVM_IR
fun test(ss: List<String?>) {
val shortStrings = hashSetOf<String>()
val longStrings = hashSetOf<String>()
@@ -14,7 +16,14 @@ fun test(ss: List<String?>) {
}
}
// JVM_TEMPLATES
// 2 POP
// 0 INVOKESTATIC java/lang/Boolean\.valueOf
// 0 CHECKCAST java/lang/Boolean
// 0 ACONST_NULL
// JVM_IR_TEMPLATES
// 2 POP
// 0 INVOKESTATIC java/lang/Boolean\.valueOf
// 1 CHECKCAST java/lang/Boolean
// 1 ACONST_NULL
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36637 Trivial closure optimizatin in JVM_IR
fun test() {
fun local(){
@@ -1,6 +1,9 @@
// IGNORE_BACKEND: JVM_IR
val a : Int? = 10
fun foo() = a?.toString()
// JVM_TEMPLATES
// 1 IFNULL
// JVM_IR_TEMPLATES
// 1 IFNONNULL
+15 -4
View File
@@ -1,7 +1,6 @@
// IGNORE_BACKEND: JVM_IR
fun box(): String {
var encl1 = "fail";
var encl2 = "fail";
var encl1 = "fail"
var encl2 = "fail"
test {
{
encl1 = "OK"
@@ -18,6 +17,18 @@ inline fun test(s: () -> Unit) {
s()
}
// JVM_TEMPLATES
// 2 INNERCLASS Kt10259Kt\$box\$\$inlined\$test\$lambda\$1\s
// 2 INNERCLASS Kt10259Kt\$box\$\$inlined\$test\$lambda\$1\$1
// 4 INNERCLASS
// 4 INNERCLASS
// NB: JVM_IR generates 'INNERCLASS Kt10259Kt$box$1$1' in 'Kt10259Kt'.
// Although Oracle JVM doesn't check for consistency of InnerClasses attributes,
// this behavior is equivalent to javac and seems to be correct.
// JVM_IR_TEMPLATES
// 3 INNERCLASS Kt10259Kt\$box\$1\$1\s
// 2 INNERCLASS Kt10259Kt\$box\$1\$1\$1
// 5 INNERCLASS
// 1 class Kt10259Kt\$box\$1\$1\ extends
// 1 class Kt10259Kt\$box\$1\$1\$1 extends
+18 -2
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
fun box(): String {
var encl1 = "fail";
test {
@@ -20,6 +19,7 @@ inline fun test(crossinline s: () -> Unit) {
}()
}
// JVM_TEMPLATES
// 3 INNERCLASS Kt10259_3Kt\$test\$1 null
// 2 INNERCLASS Kt10259_3Kt\$test\$1\$1
// 2 INNERCLASS Kt10259_3Kt\$box\$\$inlined\$test\$1\s
@@ -27,4 +27,20 @@ inline fun test(crossinline s: () -> Unit) {
// inlined:
// 2 INNERCLASS Kt10259_3Kt\$box\$\$inlined\$test\$1\$1\$lambda\$1\s
// 2 INNERCLASS Kt10259_3Kt\$box\$\$inlined\$test\$1\$1\$lambda\$1\$1\s
// 13 INNERCLASS
// 13 INNERCLASS
// NB JVM_IR generates
// final static INNERCLASS Kt10259_3Kt$box$1$1 null null
// public final static INNERCLASS Kt10259_3Kt$test$1 null null
// in Kt10259_3Kt.
// Although Oracle JVM doesn't check for consistency of InnerClasses attributes,
// this behavior is equivalent to javac and seems to be correct.
// JVM_IR_TEMPLATES
// 3 INNERCLASS Kt10259_3Kt\$box\$1\$1\s
// 2 INNERCLASS Kt10259_3Kt\$box\$1\$1\$1\s
// 3 INNERCLASS Kt10259_3Kt\$test\$1\s
// 2 INNERCLASS Kt10259_3Kt\$test\$1\$1\s
// 2 INNERCLASS Kt10259_3Kt\$box\$\$inlined\$test\$1\s
// 2 INNERCLASS Kt10259_3Kt\$box\$\$inlined\$test\$1\$1\s
// 14 INNERCLASS
+2
View File
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36638 Use 'java/lang/StringBuilder.append (C)Ljava/lang/StringBuilder;' when appending single character in JVM_IR
// KT-5016 wrong StringBuilder append method invoked
class kt5016 {
fun f1(name : String) : String {
+2
View File
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36638 Use 'java/lang/StringBuilder.append (C)Ljava/lang/StringBuilder;' when appending single character in JVM_IR
// KT-5016 wrong StringBuilder append method invoked
class kt5016int {
fun f1(num : Int) : String {
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36638 Use 'java/lang/StringBuilder.append (C)Ljava/lang/StringBuilder;' when appending single character in JVM_IR
// KT-5016 wrong StringBuilder append method invoked
class kt5016intOrNull {
fun f1(num : Int?) : String {
@@ -1,4 +1,6 @@
// IGNORE_BACKEND: JVM_IR
// KT-36641 TODO Generate IINC instruction for prefix increment in JVM_IR
fun main(args: Array<String>) {
var i = 10
++i