JVM_IR KT-29822 KT-48669 loop over unsigned array, indices, withIndex
This commit is contained in:
committed by
TeamCityServer
parent
2cc6b589f3
commit
be28b3c74d
+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