Generate for-in-indices as a precondition loop

Precondition loops are better optimized by HotSpot
(and, quite likely, by ART).
Also, we generate more compact bytecode that way.

KT-17903 Generate 'for-in-indices' as a precondition loop
This commit is contained in:
Dmitry Petrov
2017-05-16 11:06:05 +03:00
parent 793fb65666
commit 899ad7bb53
6 changed files with 33 additions and 16 deletions

View File

@@ -12,4 +12,8 @@ fun test(s: CharSequence): Int {
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getLast
// 0 IF_ICMPGT
// 0 IF_ICMPEQ
// 1 IF_ICMPGE

View File

@@ -12,4 +12,8 @@ fun Collection<Int>.sumIndices(): Int {
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getLast
// 0 IF_ICMPGT
// 0 IF_ICMPEQ
// 1 IF_ICMPGE

View File

@@ -11,4 +11,8 @@ fun test() {
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getLast
// 0 IF_ICMPGT
// 0 IF_ICMPEQ
// 1 IF_ICMPGE

View File

@@ -11,4 +11,8 @@ fun test() {
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getLast
// 0 IF_ICMPGT
// 0 IF_ICMPEQ
// 1 IF_ICMPGE

View File

@@ -11,4 +11,8 @@ fun test() {
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getLast
// 0 IF_ICMPGT
// 0 IF_ICMPEQ
// 1 IF_ICMPGE