Commit Graph

772 Commits

Author SHA1 Message Date
Dmitriy Novozhilov f61a318c9d [Test] Migrate AbstractBytecodeTextTest to new test infrastructure 2021-01-25 17:11:21 +03:00
Alexander Udalov e0363788f4 Remove some remaining tests on old coroutines 2021-01-13 19:16:31 +01:00
Alexander Udalov c2d7b69e5f Remove bytecode text test kt15806.kt
It's not correct to expect that the backend generates the `when` in this
test as tableswitch because there are only two branches. JVM IR has a
cutoff in the when optimization and generates `when`s with fewer than 3
branches as if-else chains, which is probably better. Note that there's
also a corresponding box test in when/enumOptimization/, so the backend
behavior is still tested.
2021-01-11 17:27:03 +01:00
Mads Ager 6fc0de39c2 [PSI2IR] Propagate smart cast information for variable loads.
This gives us more precise type information and can enable backend
optimizations. This was motivated by when expressions not compiled
to table switches in the JVM_IR backend.

Fixed KT-36845.
2021-01-11 12:01:47 +03:00
Steven Schäfer dad10e94aa JVM IR: Mangle names of $$forInline functions 2021-01-08 16:30:18 +01:00
Iaroslav Postovalov 8a7bc2ef6f Rename continuation fields according the convention and count them in IR 2020-12-23 19:45:13 +01:00
Iaroslav Postovalov 6f34f00c61 Do not generate the field for unused parameters in suspend lambdas 2020-12-23 19:45:04 +01:00
Georgy Bronnikov 076272f7ca FIR2IR: avoid descriptors computing hashCode
When synthesizing the hashCode function for data classes, descriptors
were used, in partcular, memberScope for primitive classes.
IrBasedDescriptors have no member scope, so we compute the hashCode
function based on IR structures.
2020-12-23 18:50:52 +03:00
Kristoffer Andersen 8a5f260d04 [IR] Align debugging of suspend lambdas with old BE
The existing backend restores LVs and parameters from the suspend lambda
fields used for spilling between suspension points, hence they are
visible in the debugger as local variables, plain and simple.

This PR introduces the same pattern to the IR backend, to bring the
debugging experience in line with the existing backend.

Both backends are still at the mercy of the liveness analysis
performed in the coroutine transformer where a liveness analysis
minimizes live ranges of entries in the LVT. E.g. an unused parameter
will be dropped entirely.

Adjusted existing test expectations accounting for the differences in
LV behavior.
2020-12-12 11:48:47 +01:00
Mads Ager c922484758 [JVM_IR] Use direct field access to backing fields on current class.
The current backend uses direct field access to the backing field
instead of calling the companion object accessor, which calls
an accessibility bridge, which then gets the field for code such as:

```
class A {
  companion object {
    val s: String = "OK"
  }

  // f uses direct access to the A.s backing field.
  fun f() = s
}
```

This change does the same for the IR backend.
2020-12-11 06:24:55 +01:00
Dmitriy Novozhilov b416c669b0 [TEST] Update testdata due to dropped COMMON_COROUTINE_TEST directive 2020-12-10 01:31:04 +03:00
Dmitry Petrov 69c88a8a0a PSI2IR KT-41284 use getters for open data class property values
'allopen' compiler plug-in can make data classes and their members open,
which is a compilation error in usual case, but makes sense for Spring
and other frameworks that generate proxy-classes.
2020-12-09 10:29:09 +03:00
Ilmir Usmanov 0dc5f3ac00 IC: call JvmDefault method of inline class using boxed receiver
#KT-43698 Fixed
2020-12-08 04:33:36 +01:00
Dmitry Petrov e6a3e38c4d JVM_IR no static inline class members for Kotlin JvmDefault methods
KT-43698 KT-43051
2020-12-02 20:04:13 +03:00
Dmitry Petrov b2aed536c9 JVM_IR KT-39612 process subexpressions recursively in 'name' lowering 2020-11-30 15:49:02 +03:00
Georgy Bronnikov 6381d97aab JVM_IR: compute classId on IR structures 2020-11-27 10:56:07 +03:00
Mikhail Glukhikh 1c71e64f58 [FIR] Create string interpolating call even for single argument
Before this commit, questionable optimization existed which
unwrapped string interpolating call with single argument to this argument.
However, this led to source element loss and the necessity of sub-hacks.
In this commit we dropped this optimization (anyway user can remove
this single-expression string template in code if needed) to keep
source elements intact.
2020-11-26 08:37:50 +03:00
Steven Schäfer 7bfe2c0bbc JVM IR: Update test expectation for testSamAdapterAndInlineOnce
...and remove redundant bytecode text tests.
2020-11-19 19:46:49 +01:00
Steven Schäfer 8574cb4466 JVM IR: Don't generate line numbers and null checks in SAM wrapper constructors 2020-11-19 19:46:49 +01:00
Steven Schäfer 68e2d0d245 JVM IR: Generate synthetic final implementation methods in SAM wrappers 2020-11-19 19:46:49 +01:00
Steven Schäfer a475fa2a21 JVM IR: Use raw types in SAM wrappers 2020-11-19 19:46:49 +01:00
Steven Schäfer 999151abac JVM IR: Generate SAM wrapper fields as synthetic final 2020-11-19 19:46:49 +01:00
Steven Schäfer ec1d42e92b JVM IR: Generate SAM wrapper classes as non-synthetic 2020-11-19 19:46:49 +01:00
Steven Schäfer 36711a768b JVM IR: Use inline SAM wrappers inside of inline lambdas 2020-11-19 19:46:49 +01:00
Ilmir Usmanov b33774e5f2 IC mangling: Use empty list as a separator in the new mangling scheme 2020-11-19 17:39:28 +01:00
Ilmir Usmanov 488d4ab018 IC mangling: Use '_' instead of 'x' as a placeholder before hashing 2020-11-19 17:39:27 +01:00
Ilmir Usmanov f7164404c9 IC mangling: Ignore FIR tests 2020-11-19 17:39:26 +01:00
Ilmir Usmanov c62093f54c IC mangling: Change mangling rules
1. Use 'x' for each parameter, which is not an inline class, every
possible clash is handled by signature rather than name. This change
makes more API changes binary-compatible. So, the changes are in line
with the vision of inline classes are value classes, like primitives.

2. Take return type into account when mangling a function if the return
type is inline class. Otherwise, boxing bridge will not be generated,
which leads to CCE at runtime.
2020-11-19 17:39:24 +01:00
Jinseong Jeon 4cb32cd38a FIR2IR: add implicit NOT_NULL cast for @FlexibleNullability type 2020-11-18 13:06:48 +03:00
Denis Zharkov 4c9a4548f2 FIR: Fix overrides binding for Java inheritor
`overriddenMembers` contract requires original (non-enhanced) function
See other usages

Ignored tests have been working accidentally

^KT-43289 Open
2020-11-16 15:50:39 +03:00
Dmitry Petrov 653b26174b KT-43006 don't generate no-arg constructor with inline class parameters 2020-11-13 09:59:34 +03:00
Mikhail Glukhikh e7a84fd1ee [FIR2IR] Preserve 'EnhancedNullability' type annotation in IR 2020-11-10 21:07:26 +03:00
Georgy Bronnikov d246005891 JVM_IR: fix unbound type parameters in AddContinuationLowering 2020-11-10 17:49:55 +03:00
Ilmir Usmanov 7b315a8b52 JVM_IR: Do not box inline class in methods 2020-11-02 10:50:00 +01:00
Ilmir Usmanov 28e148d35a Old JVM: support init blocks in inline classes
#KT-28055 Fixed
2020-10-29 20:38:03 +01:00
Denis Zharkov 2bdb21793f FIR: Adjust test data 2020-10-28 11:43:25 +03:00
Jinseong Jeon 46cc01602e FIR2IR: add implicit NOT_NULL cast if needed 2020-10-22 10:51:20 +03:00
Dmitry Petrov b1b87becc8 PSI2IR more JVM-like exhaustive when behavior KT-36840 2020-10-21 20:07:11 +03:00
Mads Ager 0505bd958a [JVM] Fix the nop removal optimization.
Never remove a nop if that would cause a line number to move
across a local lifetime boundary.

This fixes KT-42725.
2020-10-16 19:21:08 +03:00
pyos a9b53adc50 JVM_IR: make primitive == object slightly less lazy.
Discarding the value used to leave an unused-but-never-destroyed
temporary variable. It's best to not separate calls to `enterTemp`
and `leaveTemp`.

Not sure what kind of test to add though, since this is minor -- if the
result of the comparison is discarded, then the entire statement is more
or less pointless.

 #KT-42251 Fixed
2020-10-16 12:25:55 +02:00
Jinseong Jeon 5f64d6ec76 FIR2IR: add support for callable reference to Java field
#KT-42656 Fixed
2020-10-15 08:47:46 +03:00
Mikhail Glukhikh 2f9b7495fc [FIR2IR] Make safe call result always nullable 2020-10-14 16:33:37 +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
Ilmir Usmanov 375d92cf67 Merge two consequent records in LVT
Otherwise, atomicfu will be unable to transform atomic variable usages.
2020-10-09 18:36:37 +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
Mikhael Bogdanov ed5c2b0565 Add tests for data class runtime string concatenation
#KT-35176
2020-10-06 13:20:41 +02:00
Mikhael Bogdanov eb32a6ddbd Add test for for kt42457 wrong behaviour. Align runtime concatenation with it
#KT-42457
2020-10-06 13:20:40 +02:00
Mikhael Bogdanov d2c4be18a0 Rename runtime-string-concat option into 'string-concat' 2020-10-06 07:14:39 +02:00
Dmitry Petrov e018f2bd3e JVM_IR more precise check for special bridges in super class
KT-41123
2020-10-02 12:51:49 +03:00