JVM_IR KT-29822 KT-48669 loop over unsigned array, indices, withIndex
This commit is contained in:
committed by
TeamCityServer
parent
2cc6b589f3
commit
be28b3c74d
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for (ui in uis) {
|
||||
s += ui
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "123") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for (i in uis.indices) {
|
||||
s += "$i:${uis[i]};"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "0:1;1:2;2:3;") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for (i in uis.indices.reversed()) {
|
||||
s += "$i:${uis[i]};"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "2:3;1:2;0:1;") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for (ui in uis.reversed()) {
|
||||
s += ui
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "321") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for ((i, ui) in uis.withIndex()) {
|
||||
s += "$i:$ui;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "0:1;1:2;2:3;") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for ((i, _) in uis.withIndex()) {
|
||||
s += "$i:${uis[i]};"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "0:1;1:2;2:3;") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for ((_, ui) in uis.withIndex()) {
|
||||
s += ui
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "123") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun test(uis: UIntArray): String {
|
||||
var s = ""
|
||||
for ((i, ui) in uis.withIndex().reversed()) {
|
||||
s += "$i:$ui;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val test = test(uintArrayOf(1U, 2U, 3U))
|
||||
if (test != "2:3;1:2;0:1;") return "Failed: $test"
|
||||
return "OK"
|
||||
}
|
||||
+3
-1
@@ -47,7 +47,9 @@ fun testLong() {
|
||||
s += i
|
||||
if (t > 2) throw Exception("too many iterations: $t")
|
||||
}
|
||||
if (s != "-9223372036854775807-9223372036854775808") throw Exception(s)
|
||||
if (s != "-9223372036854775807-9223372036854775808" &&
|
||||
s != "-9223372036854776000-9223372036854776000" // JS
|
||||
) throw Exception(s)
|
||||
}
|
||||
|
||||
fun testChar() {
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// IMPORTANT!
|
||||
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||
// examine the resulting bytecode shape carefully.
|
||||
// Range and progression-based loops generated with Kotlin compiler should be
|
||||
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||
// with compiler built from your changes if you are not sure.
|
||||
|
||||
fun test(uis: UIntArray): UInt {
|
||||
var s = 0U
|
||||
for (ui in uis) {
|
||||
s += ui
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 1 IF_ICMPGE
|
||||
// 0 IF_ICMPGT
|
||||
// 0 IF_ICMPLE
|
||||
// 1 IF
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 6 ILOAD
|
||||
// 5 ISTORE
|
||||
// 1 IADD
|
||||
// 0 ISUB
|
||||
// 1 IINC
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// IMPORTANT!
|
||||
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||
// examine the resulting bytecode shape carefully.
|
||||
// Range and progression-based loops generated with Kotlin compiler should be
|
||||
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||
// with compiler built from your changes if you are not sure.
|
||||
|
||||
fun test(uis: UIntArray): UInt {
|
||||
var s = 0U
|
||||
for (i in uis.indices) {
|
||||
s += uis[i]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 getStart
|
||||
// 0 getEnd
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 getFirst
|
||||
// 1 getLast
|
||||
// 0 IF_ICMPGE
|
||||
// 1 IF_ICMPGT
|
||||
// 0 IF_ICMPLE
|
||||
// 2 IF
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 getFirst
|
||||
// 0 getLast
|
||||
// 1 IF_ICMPGE
|
||||
// 0 IF_ICMPGT
|
||||
// 0 IF_ICMPLE
|
||||
// 1 IF
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 5 ILOAD
|
||||
// 4 ISTORE
|
||||
// 1 IADD
|
||||
// 0 ISUB
|
||||
// 1 IINC
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
// IMPORTANT!
|
||||
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
|
||||
// examine the resulting bytecode shape carefully.
|
||||
// Range and progression-based loops generated with Kotlin compiler should be
|
||||
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }').
|
||||
// Otherwise it may result in performance regression due to missing HotSpot optimizations.
|
||||
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
|
||||
// with compiler built from your changes if you are not sure.
|
||||
|
||||
fun test(uis: UIntArray): UInt {
|
||||
var s = 0U
|
||||
for ((i, ui) in uis.withIndex()) {
|
||||
s += ui
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 1 withIndex
|
||||
// 1 iterator
|
||||
// 1 hasNext
|
||||
// 1 next
|
||||
// 1 component1
|
||||
// 1 component2
|
||||
// 0 ARRAYLENGTH
|
||||
// 1 ICONST_0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 withIndex
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
// 0 component1
|
||||
// 0 component2
|
||||
// 1 INVOKESTATIC kotlin\/UIntArray\.getSize\-impl \(\[I\)I
|
||||
// 2 ICONST_0
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 7 ILOAD
|
||||
// 6 ISTORE
|
||||
// 1 IADD
|
||||
// 0 ISUB
|
||||
// 1 IINC
|
||||
Reference in New Issue
Block a user