Commit Graph

828 Commits

Author SHA1 Message Date
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
Mads Ager afa1b8bfdc [JVM] Extend boxing/unboxing optimizations to coroutine boxing. 2021-05-06 15:35:49 +02:00
Mads Ager df225c0c7f [JVM] Fix uninitialized locals after coroutine transformation.
The coroutine transformation would leave locals in the local
variable table across the code that reloads local variables from
the continuation on reentry. However, when reentering the function
the local has no value until after the reloads from the
continuation.

This change splits the locals in the local variable table to
avoid such uninitialized locals. A local alive across a
suspension point has its range split in two. One that goes
from the original start to the state label for the restart
after the suspension. The other goes from after the local
has been reloaded from the continuation until the previous
end of the local.
2021-04-30 22:24:03 +02:00
Steven Schäfer 84d78035e4 JVM IR: Avoid double mangling of function reference invoke methods 2021-04-29 13:10:43 +02:00
Dmitry Petrov b34e2c1474 JVM_IR KT-36646 fuze primitive equality with safe call 2021-04-27 19:41:31 +03:00
Dmitry Petrov 72849a3dc3 JVM_IR update test for KT-36637 2021-04-27 19:41:29 +03:00
Dmitry Petrov bdf914e8d5 JVM_IR use static 'hashCode' for boxed primitives on JVM 1.8+ 2021-04-27 19:41:28 +03:00
Mikhael Bogdanov dfc6d85aee Enable runtime string concatenation by default (for -Xjvm-target=9 or greater)
#KT-42522 Fixed
2021-04-27 09:08:28 +02:00
pyos dab693b075 Revert "JVM IR: Implement CHECK_NOT_NULL as a lowering"
This reverts commit dcd72b06d8.

Using a temporary variable has an effect on casts and GC.
2021-04-19 16:05:12 +02:00
pyos 85b4668b7c JVM_IR: optimize more if-null chains
1. consider reads of fields from the same file "stable" just like
    functions, i.e. assume their nullability information is correct
 2. apply if-null fusion repeatedly until the subject is no longer a
    nested if-null expression
2021-04-13 11:48:36 +03:00
Abduqodiri Qurbonzoda 968099fbec Advance deprecation level of FP to lesser than Int types to ERROR #KT-30360 2021-04-07 00:23:20 +03:00
Mads Ager 41f5ac393a Update D8 used for dexing tests to version 2.1.96. 2021-03-24 20:16:15 +01:00
Ilmir Usmanov 3124a4ddae Minor. Update test data 2021-03-22 17:35:08 +01:00
Steven Schäfer bea1a8c422 JVM IR: Use Object.clone in Enum.values 2021-03-16 21:30:18 +01:00
Dmitry Petrov 44e6483090 JVM_IR Spill stack on array constructor call
KT-42932
2021-03-12 09:18:35 +03:00
Dmitry Petrov 00a335129b JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+ 2021-03-10 21:04:08 +03:00
Dmitry Petrov 02b5b931d4 Revert "JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+"
This reverts commit 679756ad
2021-03-10 07:39:29 +03:00
Dmitry Petrov 679756ad07 JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+ 2021-03-09 23:16:11 +03:00
Ilmir Usmanov e79c9a3618 Extend LVT record of alive variables to end of next suspension point
Otherwise, arguments of suspend call become invisible in async stack
trace
 #KT-44714
2021-03-08 23:56:40 +01:00
Ilmir Usmanov b6bb8a576e Make start label of LVT record the point where variable becomes alive
Otherwise, there will be overlapping LVT records, which leads to
removal of the whole LVT by R8.
 #KT-44714 Fixed
2021-03-08 23:56:39 +01:00
Ilmir Usmanov e17b7f01b6 Do not remove dead variables' LVT records
Also, extend liveness of alive variable to nearest suspension points
 #KT-44714
2021-03-08 23:56:36 +01:00
Dmitriy Novozhilov af79265f42 [FIR] Fix creating overrides for functions with name same as renamed in JVM builtins 2021-03-02 19:11:15 +03:00
Mikhail Glukhikh 2bf3abcb29 FIR: cache accessor symbols in JavaClassUseSiteMemberScope 2021-02-26 12:27:07 +03:00
Denis.Zharkov a750d9466e FIR2IR: Rework resulted overridden-relation structure
The difference is how we deal with intermediate fake overrides
E.g., in case

interface A { /* $1 */ fun foo() }
interface B : A {
     /* $2 */ fake_override fun foo()
}
interface C : B {
   /* $3 */ override fun foo()
}

We've got FIR declarations only for $1 and $3, but we've got
a fake override for $2 in IR.

Previously, override $3 had $1 as its overridden IR symbol, just because
FIR declaration of $3 doesn't know anything about $2.

Now, when generating IR for $2, we save the necessary information
and using it for $3, so it has $2 as overridden.

So, it's consistent with the overridden structure of FE 1.0 and this
structure is necessary prerequisite for proper building of bridges
for special built-ins.
2021-02-20 10:59:22 +03:00
Alexander Udalov 56f9e3360f JVM IR: do not generate invokeinterface hashCode if smart cast is present
#KT-45008 Fixed
2021-02-19 14:21:54 +01:00
Dmitry Petrov c629ba5a3c JVM_IR indy-SAM: function reference to Java interface 2021-02-19 12:04:30 +03:00
Dmitry Petrov 6d019d9544 JVM_IR indy-SAM on functional expression 2021-02-17 22:18:06 +03:00
Mikhael Bogdanov 134fda8bad Support Unit/V types in string-concat indy calls
unitComponent.kt test fails with JVM target 9+
2021-02-17 18:43:24 +01:00
Mikhael Bogdanov 3d8e8dd3ba Fail on compilation errors in AbstractBytecodeTextTest 2021-02-17 18:43:23 +01:00
Mads Ager 05ff2b1292 [JVM_IR] Extend when to switch translation to deal with nested ors.
FIR translates:

```
when (x) {
  1, 2, 3 -> action
  else -> other_action
}
```

to an IR structure with nested ors:

```
if ((x == 1 || x == 2) || (x == 3)) action
else other_action
```

This change allows that to turn into switch instructions in the
JVM backend.
2021-02-16 03:20:07 -08:00
Dmitry Petrov 6ba57abb8f JVM don't use indy by default for SAM conversions (wait for KT-44844)
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:32 +03:00
Dmitry Petrov 052f6929c9 JVM_IR indy SAM conversions: update tests
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:30 +03:00
Dmitry Petrov 3ebeca5852 JVM_IR: use indy SAM conversions in jvmTarget 1.8+, fix bridges
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:30 +03:00
Alexander Udalov 2d60fa787d Remove codegen tests on old language and API versions 2021-02-11 13:50:09 +01:00
Mikhail Glukhikh 7050af9b79 FIR2IR: use invariant projections for SAM_CONVERSION types 2021-02-11 11:48:34 +03:00
Mikhail Glukhikh 2cbdad0bb1 FIR2IR: insert implicit cast of receiver to Any for interface Any calls 2021-02-08 14:28:26 +03:00
Dmitry Petrov d94912ed62 JVM_IR indy-lambdas: initial implementation and tests
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:22 +03:00