Commit Graph

919 Commits

Author SHA1 Message Date
Xin Wang fdbcb64d39 JVM_IR: frame optimization for cast to IntProgression
#KT-29199
2022-02-03 17:45:06 +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 4ad6cfcf53 JVM_IR fix cast to not-null type
We can't rely on argument type nullability here, because it still can
hold an uninitialized value on JVM.

KT-50577 KT-35272 KT-27427
2021-12-30 13:41:17 +03:00
Alexander Udalov d5372521f1 Add tests for obsolete issues
#KT-12126
 #KT-12189
 #KT-23628
 #KT-24209
 #KT-34338
 #KT-47279
 #KT-48498
2021-12-29 17:07:03 +00:00
Ivan Kylchik 6fc56477bf Drop all tests that disable features for language version less than 3 2021-12-28 20:08:56 +03:00
Alexander Udalov 92c80873ba Revert "JVM: remove support for disabling NoConstantValueAttributeForNonConstVals"
This is a partial revert of e857966edb.

Specifically, behavior is restored in the old backend, which will allow
to support language version 1.3, where this language feature was not
enabled yet. There are no changes in the JVM IR backend, because to
enable JVM IR with LV 1.3, you need to pass the compiler argument
`-Xuse-ir` which is not stable and we don't guarantee anything about it.

 #KT-50251
2021-12-28 13:21:18 +01:00
Xin Wang 944fa7e2f8 JVM IR: recover accidentally lost backingField (KT-49998) 2021-12-22 00:35:33 +01:00
Dmitry Petrov 8905586cbb IR KT-50258 rewrite enum-based 'when' more carefully 2021-12-21 06:06:45 +00:00
Dmitry Petrov 42dd8aa12d JVM_IR KT-50193 remove temporary variable in argument null check 2021-12-14 17:10:23 +03:00
Dmitry Petrov 34c70ea04e JVM_IR KT-50193 result of !! is non-null 2021-12-14 17:10:20 +03:00
Dmitry Petrov df460a842b JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter 2021-12-13 14:13:34 +00:00
Dmitry Petrov 6f148c594f Revert "JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter"
This reverts commit 627d838343.
2021-12-13 14:13:33 +00:00
Mikhail Glukhikh febf336d23 IrConstTransformer: transform constants also inside call children 2021-12-13 16:24:59 +03:00
Dmitry Petrov 627d838343 JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter 2021-12-11 08:04:26 +00:00
Dmitry Petrov 94bb465e62 JVM_IR KT-50076 don't null check moved dispatch receiver parameter 2021-12-11 08:04:26 +00:00
Dmitry Petrov 3017397960 JVM_IR fix string concatenation performance issues
KT-50080 KT-50084 KT-50140
2021-12-09 15:32:13 +03:00
Dmitry Petrov 100d7123c2 JVM_IR KT-50078 fix for-in-array loop bytecode shape 2021-12-07 17:41:59 +03:00
Dmitry Petrov de3203ee48 JVM KT-49903 prohibit reordering of 'getstatic System.out' 2021-12-01 12:13:13 +03:00
Ivan Kochurkin b83ed7a6ed [FIR] Fix KtExpression.usedAsExpression for labeled expression 2021-11-24 23:13:37 +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
Alexander Udalov 1071919706 Remove backend tests on old inference
Also remove any mentions of NewInference, and rename some tests.
2021-11-09 20:07:33 +01:00
Mikhail Glukhikh 5a44fda42c FIR2IR: bind fake override calls via symbol table 2021-11-09 21:04:37 +03:00
Mikhail Glukhikh 0622a47493 FIR2IR: implement early f/o overridden symbols binding #KT-42784 Fixed
Related to KT-49288
2021-11-09 21:04:36 +03:00
Mikhail Glukhikh 5b6e21690b FIR2IR: call fake overrides properly #KT-49288 Fixed 2021-11-09 21:04:35 +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 82591bb107 [FIR2IR] More accurate equals intrinsic for double/float types 2021-10-25 21:21:43 +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
Ivan Kochurkin 0d91e16a15 [FIR2IR] Fix considering of Contains intrinsic 2021-10-25 21:21:40 +03:00
Ivan Kochurkin 15d23f2a72 [FIR2IR] Fix applying of equals intrinsics 2021-10-25 21:21:39 +03:00
Ivan Kochurkin 31507e7e7e [FIR2IR] Fix origin for desugared blocks (to enable jvm optimization lowering)
Move getIrAssignmentOrigin to ConversionUtils
2021-10-25 21:21:37 +03:00
Ivan Kochurkin 4bafa8628e [FIR2IR] Fix generating of IINC instruction with FIR for inc/dec with constants 2021-10-25 21:21:35 +03:00
Ivan Kochurkin 98596eaa08 [FIR2IR] Fix generating of IINC instruction with FIR for inc/dec operations 2021-10-25 21:21:33 +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 aea2db97c5 JVM_IR simplify null check on trivially initialized vals only 2021-10-01 14:31:48 +03:00
Dmitry Petrov 7e86f5dcd9 JVM_IR don't use Intrinsics.stringPlus for 2-argument concatenation 2021-10-01 02:59:52 +03:00
Mads Ager b61389f6f9 [JVM IR] Do not generate clinit as enclosing method.
The JVM and newer Android runtimes treats that the same as if
there is no enclosing method. However, older Android runtimes
for Android 5 and 6 throw exceptions on reflective access
and even older runtimes have different behavior. To avoid
those issues, exclude <clinit> from enclosing method attributes.

^ KT-48754 Fixed
2021-09-30 23:02:43 +02:00
Dmitry Petrov 9325660f06 JVM_IR fold safe calls and elvises 2021-09-29 19:14:36 +03:00
Dmitry Petrov 7370d096ee JVM_IR recognize safe calls and elvises in arbitrary IR 2021-09-29 19:14:34 +03:00
Dmitry Petrov ca7ee75f88 JVM replace redundant GOTOs with NOPs to preserve debugging behavior 2021-09-29 19:14:33 +03:00
Dmitry Petrov 0a67ab54fe JVM_IR more compact safe call chains (almost as old BE) 2021-09-29 19:14:32 +03:00
pyos e1520c61da IR: use parameters for captures in field/instance initializers
val y = 1
    object { val x = y }
  ->
    class XKt$1(`$y`: Int) { val x: Int = `$y` }

Note that `$y` is not stored in a field because it's not used outside
the primary constructor.

One exception is captured inline parameters on the JVM backend, as the
bytecode inliner uses field assignment instructions (setfield) to locate
them; removing the field is thus not possible.
2021-09-29 16:25:43 +02:00
pyos 85c53bc24e IR: do not create unused capture fields
^KT-48784 Fixed
2021-09-29 16:25:43 +02:00
Dmitriy Novozhilov de7fb9606a Migrate all JDK 9 related tests to JDK 11 2021-09-28 13:01:47 +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
pyos e9d5d9da48 JVM_IR: optimize property accesses in inline lambdas and private funs 2021-09-21 16:41:30 +02:00
pyos 0864f9faf8 JVM_IR: mark inline lambda functions with a special origin
Keeping the origin as LOCAL_FUNCTION_FOR_LAMBDA was a mistake as this
tells codegen nothing. Changing the origin in allows, for example,
removing the hack that detaches inline lambdas from the IR tree before
verification and codegen, or treating inline lambdas and inline
anonymous functions the same way.

This includes fake functions created for inline callable references.

 #KT-48319 Fixed
 #KT-47279 Fixed?
2021-09-15 13:23:11 +02:00