Commit Graph

864 Commits

Author SHA1 Message Date
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
Dmitry Petrov 041773fd25 JVM optimize out temporary variables in bytecode 2021-08-24 18:56:11 +03:00
Steven Schäfer c9b0cc5b32 JVM: Only produce inline SAM wrappers in public inline scope 2021-08-23 18:25:33 +02:00
Dmitriy Novozhilov 40614507d3 [FE 1.0] Report warning about new IL operator resolve in initializers and default values
^KT-48361 Fixed
2021-08-23 16:20:41 +03:00
Dmitriy Novozhilov 27ac7dbf9a [Test] Unmute passing codegen tests 2021-08-23 14:29:12 +03:00
Ilmir Usmanov ebb340fe68 Do not just merge consequent LVT ranges, but also extend them 2021-08-13 23:12:10 +03:00
Dmitry Petrov b01c13a4df JVM_IR KT-47984 inplace arguments inlining for @InlineOnly functions 2021-08-13 18:08:44 +03:00
Alexander Udalov afacff326d JVM IR: fix smart cast on argument of 'throw'
#KT-48163 Fixed
2021-08-09 22:34:44 +02:00
Dmitry Petrov 02d8c7527e JVM_IR more aggressive if-null expressions fusion
Assume that changing a return type from T to T?
is not a binary-compatible change.
2021-08-05 17:51:49 +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 37050e0616 JVM_IR KT-34594 don't generate fake local variable for @InlineOnly 2021-08-03 20:41:31 +03:00
Dmitriy Novozhilov 199ec60742 [JVM] Reduce number of param slots for string concatenation
With paramSlot = 200 those tests fails on JDKs which are newer than JDK 9
- testConcatDynamic200Long
- testConcatDynamicIndy200Long()
2021-08-01 22:23:48 +03:00
Mikhael Bogdanov c9c82ab3a6 Update test affected by SafeCallsAreAlwaysNullable feature 2021-07-29 19:45:55 +02:00
Dmitry Petrov 38d6c8ded0 JVM_IR generate range loops as counter loops when possible 2021-07-29 20:45:14 +03:00
Dmitriy Novozhilov 85c7f386eb Add Kotlin 1.7 language version 2021-07-20 13:33:41 +03:00
Ilmir Usmanov e870a200c4 Merge consequent LVT records
that is, if LVT record starts where previous one ends, merge them.
 #KT-47749 Fixed
2021-07-19 22:07:16 +00:00
Ilmir Usmanov 5ae01c8b2a Do not duplicate $result in LVT
#KT-47749
2021-07-19 22:07:16 +00:00
Ilmir Usmanov b4d356c5bd Split LVT record for known nulls
Since they are not spilled, the logic for splitting LVT records, that
is applied for spilled variables, was not applied for known nulls.
Fix that by applying the logic to them.
 #KT-47749
2021-07-19 22:07:15 +00:00
Mads Ager 83dddd73b0 Always add a local variable for its live ranges.
There used to be code that extended a previous range instead.
However, that does not work as that extension could have the
local cover code where it does not exists. Since we no longer
extend the range of locals, we should always introduce a new
one even if there was another one for a previous range.
2021-07-19 22:07:14 +00:00
Ilya Chernikov 8f5d5c3ace FIR: Fixes in testdata after implementing FIR-specific IrBuiltIns 2021-07-16 02:24:29 +03:00
pyos d988853c11 JVM_IR: optimize out redundant delegated property receiver fields
Now this:

    class C {
        val x = something
        val y by x::property
    }

is *exactly* the same as this:

    class C {
        val x = something
        val y get() = x.property
    }

(plus a `getY$delegate` method)
2021-07-12 22:38:45 +02:00
pyos 5d0102a966 JVM_IR: generate $delegate methods for val x by ::y 2021-07-12 22:38:44 +02:00
pyos e49410e07b JVM_IR: optimize delegation by property references
E.g. a statement like

    var x by ::y

is semantically equivalent to

    var x
      get() = y
      set(value) { y = value }

and thus does not need a full property reference object, or even a field
if the receiver is not bound.

 #KT-39054 Fixed
 #KT-47102 Fixed
2021-07-12 22:38:43 +02:00
Xin Wang 8317daa00b Don't generate nullability assertions in methods for directly invoked lambdas 2021-07-07 20:32:47 +03:00
pyos c3a91efea3 JVM_IR: fix primitive comparison optimizations
1. the `primitive == object?.something` fusion should not apply to
    `primitive.equals(object?.something)` because it can't;

 2. coercions to Int are there for a reason - don't remove them;

 3. better optimize `primitive == object?.something` -- the result
    should be subject to if-null fusion, so it needs to have a specific
    pattern that resembles safe calls.

 #KT-47597 Fixed
2021-07-05 18:13:09 +03:00
Mikhael Bogdanov 0fd1f549a9 Properly process special symbols during indy-with-constants concatenation
#KT-47320 Fixed
2021-06-26 06:10:16 +02:00
Dmitriy Novozhilov 26b9948e5f [FE 1.0] Make type of safe call always nullable
^KT-46860 In Progress
2021-06-25 16:37:30 +03:00
Andrey Zinovyev 3572a96bb9 [FIR] Lookup in local sources in default imports based on the flag
Reuse ALLOW_KOTLIN_PACKAGE for that
2021-06-08 08:23:25 +00:00
pyos 288451db4d JVM_IR: remove an unnecessary hack from BridgeLowering
Correct IR is more important than whether some inaccessible members
precisely match what was generated by the old backend.
2021-06-03 12:35:23 +03:00
pyos 34878d17eb JVM: be more careful when removing unused constants
1. if an argument of a `pop` cannot be removed, then all other potential
   arguments of that `pop` can't be removed either, and the same applies
   to other `pop`s that touch them;
2. the same is true for primitive conversions, but this is even trickier
   to implement correctly, so I simply did the same thing as with
   boxing operators: replace the conversion itself with a `pop` and keep
   the argument as-is.

Somehow this actually removes *more* redundant primitive type conversions
than the old code in a couple bytecode text tests, so I've patched them
to kind of use the value, forcing the instructions to stay.

 #KT-46921 Fixed
2021-05-27 12:24:22 +02:00
Mads Ager d023966054 [JVM] Fix various undefined locals issues.
CoroutineTransformermethodVisitor attempts to extend the ranges
of local variables in various situations. Probably in an attempt
to give a better debugging experience. However, all of these
range extensions lead to invalid local variable tables where
something is in the local variable table where nothing is in the
corresponding slot.

The code that extends variables to the next suspension point
instead of ending them when they are no longer live has issues
with loops. When resuming and reentering the loop, the locals
table will mention a local that we did not spill and which
is therefore not restored when resuming.

The code that extends local variable table entries if there
are no suspension points between two entries doesn't work
for code such as:

```
var s: String
if (suspendHere() == "OK") {
  s = "OK"
} else {
  s = "FAIL"
}
```

If the local variable ranges are collapsed into one, one of
the branches will have the local defined in the local variable
table before the slot is initialized.
2021-05-26 08:33:34 +02:00
Andrey Zinovyev 64b45e6d1b Add comments to skipped FIR tests 2021-05-25 19:23:30 +03:00
Andrey Zinovyev dce8bd4e62 [FIR] Support constructor call of unsigned in checker 2021-05-25 19:23:29 +03:00
Denis.Zharkov f0c85e0935 FIR: Add comments to freshly muted tests 2021-05-21 13:53:55 +03:00
Denis.Zharkov cd401b5b8a FIR: Update integer literal-related tests
They started failing once we began reporting diagnostics from completion

^KT-46419 Relates
2021-05-20 17:24:14 +03:00
Dmitry Petrov 851980e36f JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs 2021-05-18 22:20:12 +03:00
Ilmir Usmanov c4ddf3530d Use GETFIELD instead of unbox-impl inside inline classes
#KT-36783 Fixed
2021-05-12 06:50:06 +00:00