21 Commits

Author SHA1 Message Date
Ivan Kylchik 44cf64a00c Convert const values in ranges without explicit cast 2022-05-18 21:20:01 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Dmitry Petrov 271368ac53 JVM_IR prefer loop with inclusive bound for unsigned integer ranges
In general, we would rather prefer a range-based for loop to look like
a counter loop in Java ('for (i = start; i < end; ++i) { <BODY> }').
This corresponds to

    i = start;
    do {
        if (i >= end) break;
        <BODY>
    } while ( { ++i; true } )

However, HotSpot doesn't recognize Kotlin unsigned integer comparison
in 'if (i >= end) break;' as a counter loop condition. Thus, the loop
doesn't get optimized as a counter loop, resulting in a performance
regression.
If we use exclusive range-based for loop instead, then we actually use
unsigned integer equality instead of unsigned integer comparison, which
is Ok for HotSpot.

KT-49444
2021-11-09 13:25:06 +03:00
Ivan Kochurkin b4fada82ae [FIR2IR] Fix conversion of loops with withIndex 2021-10-25 21:21:42 +03:00
Ivan Kochurkin 3210a2a950 [FIR2IR] Recognize postfix inc/dec pattern from block statements 2021-10-25 21:21:40 +03:00
Dmitry Petrov 45a4cea655 IR KT-49372 cache progression loop parameters if their values can change 2021-10-25 19:03:13 +03:00
Dmitry Petrov 0a67ab54fe JVM_IR more compact safe call chains (almost as old BE) 2021-09-29 19:14:32 +03:00
Dmitry Petrov be28b3c74d JVM_IR KT-29822 KT-48669 loop over unsigned array, indices, withIndex 2021-09-24 12:12:42 +03:00
Dmitry Petrov df700117c3 Minor: update testData 2021-09-08 09:05:36 +03:00
Dmitry Petrov e28d4a1877 JVM_IR allow remapped variables in inplace arguments transformation 2021-09-07 19:46:03 +03:00
Dmitry Petrov 860c80d210 JVM_IR add bytecode shape check to all relevant for-loop tests 2021-09-06 22:16:41 +03:00
Dmitry Petrov b669de1663 JVM_IR generate range-based loop closer to Java counter loop
KT-48435 KT-48507
2021-09-03 10:38:20 +03:00
Dmitry Petrov 38d6c8ded0 JVM_IR generate range loops as counter loops when possible 2021-07-29 20:45:14 +03:00
Mark Punzalan ccbf7cc2ee ForLoopsLowering: Use last-exclusive for-loops for optimized until
progressions instead of decrementing "last".

#KT-41352 Fixed
2020-10-09 21:34:56 +02:00
pyos adcbfc7b4c IR: add an emptiness check to all unsigned until loops
Unlike signed integers, a larger unsigned type does not mean a lower
minimum value, so `x - 1` can overflow even if `x` is casted to a larger
type.

 #KT-42186 Fixed
2020-10-07 12:53:00 +02:00
Mikhail Glukhikh ac50433e17 Fix failing bytecode text test
In this commit I moved IGNORE_BACKEND_FIR to the end or deleted it
when it was applicable, to preserve correct line numbers
2020-09-29 19:16:42 +03:00
Mark Punzalan 238cc7c257 [FIR] Enable BytecodeText tests for FIR.
143 out of 767 tests (18.6%) are currently failing.
2020-09-29 10:21:21 +03:00
Mark Punzalan 2cfd776092 ForLoopsLowering: Assume step == 1 for *Range (e.g., IntRange) and
handle accordingly (e.g., do not read `step` property).
2020-07-29 20:44:51 +02:00
Mark Punzalan b1ce21bc55 ForLoopsLowering: Reduce unnecessary temporary variables for the
"checked step" (check for a positive step arg) and "negated step"
(negate the step arg when the nested step is negative).
2020-07-22 22:32:29 +02:00
Mark Punzalan 177967258b ForLoopsLowering: Eliminate construction/boxing/unboxing of UInt/ULong.
This needs further cleanup to encapsulate more logic into ProgressionType.
2020-05-13 13:54:35 +02:00
Mark Punzalan f249e7f5e9 ForLoopsLowering: Add additional bytecode text tests for optimization of
unsigned progressions.
2020-05-13 13:54:35 +02:00