99 Commits

Author SHA1 Message Date
Ilya Gorbunov c2e28149e6 [stdlib] Enable link-via-signatures to workaround KT-62798 2024-02-20 19:59:16 +00:00
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Alexander Udalov 28759a3ac3 Optimize rangeUntil operator in for-loops and contains
Newly added tests are basically copies of the existing tests on `until`.
Note that this operator is optimized for all backends, but the fact that
it's optimized is only checked for the JVM backend in bytecode text
tests.

 #KT-53330 Fixed
2023-01-02 12:55:48 +00:00
Ivan Kylchik 44cf64a00c Convert const values in ranges without explicit cast 2022-05-18 21:20:01 +03:00
Xin Wang 9ae452e489 JVM_IR generate less bytecode for for-loops if possible(KT-22334). 2021-12-31 18:29:04 +03:00
Dmitry Petrov bcec952beb JVM_IR KT-50585 array constructor loop should end with IINC 2021-12-30 21:38:58 +03:00
Dmitry Petrov 1e5fc1c3aa JVM_IR KT-27427 use checkNotNull with message in checked casts
This would prevent extra branching in 'as <not-null-type>', which
usually would not be covered.
2021-12-30 13:41:21 +03:00
Dmitry Petrov 100d7123c2 JVM_IR KT-50078 fix for-in-array loop bytecode shape 2021-12-07 17:41:59 +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 2cc6b589f3 JVM_IR KT-48640 generate for-in-downTo as a counter loop 2021-09-24 12:12:41 +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 041773fd25 JVM optimize out temporary variables in bytecode 2021-08-24 18:56:11 +03:00
Dmitry Petrov bd71fbe982 JVM_IR KT-34594 strip fake variable initialization during inlining 2021-08-03 20:41:31 +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 8bc7370b92 ForLoopsLowering: Add PLUSEQ origin to increment to use IINC
instructions if possible.
2020-10-09 21:34:56 +02: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 174576af61 ForLoopsLowering: Handle Sequence<*>.withIndex(). 2020-07-22 22:32:29 +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
Mark Punzalan 03ef3724f4 ForLoopsLowering: Add support for unsigned progressions. 2020-05-13 13:54:35 +02:00
Dmitry Petrov 94d20d9176 Update bytecode text tests in JVM_IR 2020-02-17 23:52:48 +03:00
Steven Schäfer 5760c0be9c JVM IR: Avoid redundant coercions in ExpressionCodegen 2020-02-15 22:32:23 +03:00
Alexander Udalov 025360edc4 JVM IR: lookup symbols by name in ProgressionHandlers in known classes only
Alternatively, we could improve the lookup utilities and their usages to
always find the exact override of a symbol from
Collection/Iterable/CharSequence/etc, but since we need to load the
original symbol anyway in cases when the loop subject's type is a type
parameter, we might as well simplify everything and always reference the
original symbol.

Also improve exception message and removed unused declarations in
IrBackendUtils.kt.
2019-12-12 14:55:47 +03:00
Mark Punzalan 1a2e09e6a5 ForLoopsLowering: Handle Iterable.withIndex() where the type is a
bounded type parameter.

TODO: Handle Sequences by extending DefaultIterableHandler.
2019-11-27 10:59:34 +01:00
Mark Punzalan 7adffe0007 Handle withIndex() on Iterables (including progressions) and Sequences
in ForLoopsLowering.
2019-11-20 13:02:21 +01:00
Mark Punzalan a54d9482dd Handle withIndex() on arrays and CharSequences in ForLoopsLowering. 2019-11-20 13:02:21 +01:00
Mark Punzalan 7f803e60b6 Fix typo in forInArrayWithIndex testdata filenames. 2019-11-20 13:02:21 +01:00
Mark Punzalan f444702cf3 JVM: Always invoke get()/charAt() in optimized for-loop over
CharSequence.withIndex(), even if element variable is unused in
destructuring declaration.

#KT-34779 Fixed
2019-11-08 10:55:09 +03:00
Mark Punzalan 21178a4f1a Fix issue getting the size property from Collection bounded type
parameters, when lowering for-loops over Collection.indices.
2019-11-07 13:43:24 +01:00
Mark Punzalan de333c18fc JVM_IR: Enable loopVarInterval and forInReversedCollectionIndices
bytecode text tests.
2019-10-29 07:43:37 +01:00
Mark Punzalan 9bb9ab67a7 Add bytecode text tests for ForLoopsLowering. 2019-10-28 15:26:38 +01:00
Mark Punzalan 277cb39e3b Add new tests for step progressions and fix existing tests. 2019-10-28 15:26:38 +01:00
Mads Ager 507857d452 [IR] Support Collection<*>.indices in for loop lowering.
Unmute a couple of tests that are working as intended.
2019-09-18 19:00:17 +02:00
Mads Ager 90a37617a4 [JVM_IR, IR] Remove more needless temporary variables.
Avoid using a separate origin for temporary variables introduced
for for loops. That doesn't add anything and gives one more case
for optimizations to deal with.

Extend the JVM specific optimizations to remove temporary
variables to deal with more cases encountered in for loops
lowering.
2019-09-11 10:07:45 +02:00
Mads Ager 3f28b71509 [IR] Fix issue getting the length property from CharSequence bounded type parameter
Use the class of the subtype of CharSequence when available. When
it is not (for type parameters bounded by CharSequence) call the
CharSequence getter and 'get' method. Using the most specific type
posible fixes the forInStringSpecialized test that expects the
use of INVOKEVIRTUAL and not INVOKEINTERFACE.

Add tests for the type parameter use.
2019-09-03 20:18:03 +02:00
Mads Ager 85b1e0165b [IR] For loop lowering for CharacterSequence.indices. 2019-09-03 13:18:21 +02:00