Commit Graph

900 Commits

Author SHA1 Message Date
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
Alexander Udalov e857966edb JVM: remove support for disabling NoConstantValueAttributeForNonConstVals
This feature is enabled by default since 1.4, which is the earliest
language version supported by Kotlin at this moment.
2021-09-14 22:29:12 +02:00
pyos d07070e184 JVM_IR: avoid redundant accessors in private inline funs
Their call sites are all in the same file, so we can check whether the
declarations used in the inline function are accessible from all the
places where it will be inlined.

 #KT-48736 Fixed
2021-09-14 22:17:10 +02: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
Dmitriy Novozhilov 1e0878cde0 [FE 1.0] Postpone SafeCallsAreAlwaysNullable till 1.7
^KT-46860 Fixed
2021-09-02 13:34:27 +03:00
Dmitry Petrov 1c1b9547c1 JVM_IR KT-48435 use Java-like counter loop when possible 2021-08-31 16:39:25 +03:00
Alexander Udalov 04c5bbdcf8 JVM IR: change generation scheme of property $delegate methods
Generate $delegate method as instance method in
PropertyReferenceDelegationLowering, and remove dispatch receiver later
in MakePropertyDelegateMethodsStatic. The method needs to be static to
be non-overridable (see delegateMethodIsNonOverridable.kt), and public
to be accessible in reflection.

Otherwise we generated incorrect IR where a static function accessed an
instance field of the containing class, which failed in multiple places
including LocalDeclarationsLowering.

 #KT-48350 Fixed
2021-08-31 14:07:22 +02:00
Mads Ager a12b22c04d [JVM] Force lock object in JVM synchronized implementation into local.
This fixes a performance problem in the case where the lock object
is a capture and the monitor enter/exit happens directly on
field loads. When the locking happens on field loads instead of a
local, the JVM cannot prove that locking is balanced. That has
the consequence that the code is runs very slow (always in the
interpreter).

^KT-48367 Fixed.
2021-08-27 21:29:12 +02:00
Dmitry Petrov 7df5ebf6ee JVM_IR KT-48433 don't generate null check on 'this$0' parameter 2021-08-26 20:06:20 +03:00
Dmitry Petrov dd98f72fd7 JVM_IR KT-42010 use IINC for postfix int increment/decrement 2021-08-26 20:06:19 +03:00
Dmitry Petrov c30b23ed01 JVM_IR fixes after review 2021-08-24 18:56:22 +03:00
Dmitry Petrov f4a1e27124 JVM optimize unneeded temporary vals 2021-08-24 18:56:20 +03:00
Dmitry Petrov d8f6d82411 JVM don't optimize temporary vals in old back-end 2021-08-24 18:56:19 +03:00
Dmitry Petrov 568958492a JVM_IR optimize temporary vals initialized with other vals 2021-08-24 18:56:18 +03:00
Dmitry Petrov 939f25333e JVM update testData 2021-08-24 18:56:17 +03:00
Dmitry Petrov 7e943ab757 JVM don't optimize out starting ASTORE of TCB handler 2021-08-24 18:56:14 +03:00
Dmitry Petrov dcbc2ea2b3 JVM infer temporary vals from bytecode 2021-08-24 18:56:13 +03:00