Commit Graph

377 Commits

Author SHA1 Message Date
Ilmir Usmanov 8a098545e6 Minor. Add test 2020-08-11 22:10:51 +02:00
Ilmir Usmanov 824991a9dd Minor. Add tests. 2020-08-04 15:42:38 +02:00
Ilmir Usmanov 70e91bd5db Shrink and split LVT records of variables according to their liveness
Otherwise, debugger will show uninitialized values of dead variables
after resume.
 #KT-16222
 #KT-28016 Fixed
 #KT-20571 Fixed
2020-07-29 00:01:10 +02:00
Steven Schäfer d62a6a2631 JVM IR: Do not create accessors for enum entry constructors 2020-07-20 22:37:49 +02:00
Steven Schäfer 097e0fb46c JVM IR: Mangle delegated properties with inline class type (KT-40125) 2020-07-10 17:06:44 +02:00
Abduqodiri Qurbonzoda d3fb9cc5f3 Deprecate with error mixed Int/FP contains operator for ranges KT-22423 2020-06-29 12:18:19 +03:00
Abduqodiri Qurbonzoda 194791a168 Introduce minByOrNull and maxByOrNull extension functions #KT-38854 2020-06-19 04:53:51 +03:00
Georgy Bronnikov c015463926 IR: remove field fake overrides 2020-06-17 20:02:26 +03:00
Kristoffer Andersen f0ff8f202c [JVM IR] Use JVM8 support for unsigned int operations
- unmute tests
- add test to ensure JVM target is respected
- add test to cover smart-casted cases
- implement function matching and replacement
- Switching on uint constants
- introduce lowering for standard library replacements
2020-06-15 14:26:28 +03:00
Dmitry Petrov 202bbdf8dd Forward compatibility hacks for Result.{success, failure}
Don't mangled functions annotated with @JvmName.
Annotate 'Result.success' and 'Result.failure' with @JvmName and
@Suppress("INAPPLICABLE_JVM_NAME").
NB this would require bootstrap.
2020-06-04 12:16:27 +03:00
Dmitry Petrov a270ee094c Language feature for new inline class mangling rules (since 1.4) 2020-05-29 00:53:01 +03:00
pyos 25e1fb8502 JVM: map synthetic line numbers through the SMAP
This is necessary so that IDEA does not ignore the line number.
2020-05-25 20:03:56 +02:00
Steven Schäfer 933440dc63 JVM IR: Fix mangling of @JvmStatic internal function in companion objects 2020-05-20 15:57:03 +02:00
pyos c51c537504 JVM: use precise line bounds when regenerating objects with no SMAPs 2020-05-19 18:33:27 +02:00
Alexander Udalov ed8efafa9b Generate InnerClasses attribute for nested classes in annotation arguments
Otherwise we incorrectly try to load a nested class "A.B" as if it is a
top level class named "A$B" and fail.

 #KT-38853 Fixed
2020-05-14 13:20:13 +02:00
Mark Punzalan f249e7f5e9 ForLoopsLowering: Add additional bytecode text tests for optimization of
unsigned progressions.
2020-05-13 13:54:35 +02:00
pyos deecb6a28e JVM: move synthetic line number generation to the inliner
This makes the behavior of JVM and JVM_IR the same without having to
deal with PSI nodes.
2020-04-28 17:21:07 +02:00
Steven Schäfer b6b8dd1eab JVM IR: Avoid unnecessary CHECKCASTs in enum classes 2020-04-28 16:31:13 +02:00
Georgy Bronnikov 611c4fe052 JVM_IR: repair super calls to methods of Any 2020-04-16 10:53:48 +03:00
Mikhael Bogdanov 0c0bd67a6b Add new tests 2020-04-09 07:37:30 +02:00
pyos 0037d5a7c8 JVM: erase conditional suspension markers from inline-only functions
Otherwise, the generated bytecode is unnecessarily suboptimal in some
(arguably weird) cases.

In the JVM backend, this was an accidental regression in #3260, as I had
not noticed that effectively inline-only functions were handled by a
separate branch in FunctionCodegen. In JVM_IR, I'm pretty sure the
redundant markers have always been there as `isSuspensionPoint` in
ExpressionCodegen never checked for effectively-inline-only-ness.
2020-04-08 12:31:23 +02:00
pyos 5ed845d0b4 JVM_IR: reuse same bodies for suspend funs and $$forInline versions 2020-04-03 19:51:45 +02:00
Dmitry Petrov 042424d599 KT-27524 Don't box (some) inline classes in suspend fun return
If an inline class is mapped to a reference type (or an array), it's Ok
to treat JVM view on a suspend function as returning a value of
corresponding inline class (although in reality it returns 'Any?'
because of COROUTINE_SUSPENDED).
2020-03-27 18:29:36 +03:00
Mads Ager 5570a5fe74 [JVM_IR] Use iinc for incrementing Int variables.
Fix line number generation for assignments where the right-hand
side of the assignment is not on the same line.

Fix line number generation for intrinsics functions where the
function is not on the same line as the last argument.

Be careful to not break stepping behavior with the iinc
optimizations.
2020-03-27 18:17:53 +03:00
Steven Schäfer 58685be4e2 IR: Don't use IrStringConcatenation for ordinary toString calls
We can only use IrStrinConcatentation to represent calls to Any?.toString
and toString calls on primitive types. Otherwise, x.toString() and "$x"
are observably different when x is a non-null type with null value
(e.g., an @NotNull value coming from Java).
2020-03-27 17:31:48 +03:00
Mark Punzalan 4234fa79c0 [JVM IR] Use append(Char) for 1-length string literals in string
templates and plus concatenations.

This is slightly more efficient and mirrors the behavior of the non-IR
backend for templates (but not for plus concatenations).

#KT-36638 Fixed
2020-03-26 12:39:39 +03:00
Steven Schäfer 6a1e35389c JVM IR: Mangle interface implementation methods in inline classes 2020-03-16 18:48:16 +01:00
Georgy Bronnikov 92268c8144 JVM_IR: do not generate excessive stubs for immutable collections 2020-03-12 23:14:17 +03:00
Georgy Bronnikov fded6fb494 JVM_IR: fix suspendCoroutineUninterceptedOrReturn 2020-03-12 11:28:42 +03:00
Dmitry Petrov a9ab3ae192 KT-36047 Support when-with-subject in optimized 'when' generators 2020-03-11 18:09:17 +03:00
Mark Punzalan 368b0d9b0b [JVM IR] Use reference equality when comparing enums. 2020-03-06 23:01:32 +01:00
Georgy Bronnikov 8b559b20e2 Add a test for getOrDefault() bridge 2020-03-04 16:02:54 +03:00
Steven Schäfer 465e9f2d68 JVM IR: Always produce stubs for interface methods in inline classes
This matches the behavior of the JVM backend, with the exception of
@JvmDefault methods, which are currently broken on the JVM backend.
2020-02-28 14:48:17 +01:00
Ilya Gorbunov b53cb5cb4c Cover with a test current Double/Float companion values access 2020-02-28 01:26:56 +03:00
Steven Schäfer 2b6a0d6c58 JVM IR: Don't create $annotations stubs for fake overridden properties 2020-02-25 11:31:01 +01:00
Ilmir Usmanov 325ad14ac9 JVM_IR: Treat suspend main wrapper as always tail-call function
In other words, never generate suspend call markers inside it.
2020-02-21 12:00:54 +01:00
Dmitry Petrov 0b9b1b6945 Update bytecode text tests for JVM_IR 2020-02-18 22:51:29 +03:00
Mark Punzalan 64141b8b38 [JVM IR] Fix issue where fields are not being set to their default
values within initializer blocks.

The issue occurs in code like this:
```
class C {
  var b = true
  init {
    b = false   // Missing PUTFIELD for this statement
  }
}
```

Added a new statement origin for field initialization (at declaration)
instead of relying on `origin == null` in ExpressionCodegen to determine
whether to generate the initializations.

This was unintentionally broken in
d68a1898d0.
2020-02-17 23:04:11 +03:00
Dmitry Petrov 59cdf3c52e Update bytecode text tests in JVM_IR 2020-02-14 14:07:03 +03:00
Yan Zhulanow cc2fe6b0c6 Debugger, BE: Generate original line number after inlining if call is used in an if condition
If a part of an 'if' condition is an inline function call, we need to insert the original condition line after it. Otherwise, the debugger will think it is inside the inline function implementation. Obviously, this breaks stepping – instead of the 'if' body, we go on stepping through the inline function.

This commit fixes 'KotlinSteppingTestGenerated.StepOver#testSoInlineLibFun' test.
2020-02-14 17:35:17 +09:00
Steven Schäfer 6d23e50142 JVM IR: Create non-synthetic multifile parts for -Xmultifile-parts-inherit 2020-02-11 17:01:22 +01:00
Steven Schäfer 5f6af58aeb JVM IR: (Un)mute tests and add more tests for bridge generation 2020-02-07 18:44:50 +03:00
pyos bda5b0d5a9 JVM_IR: further refine synthetic accessor generation
References to protected members from crossinline lambdas in the same
package do not need accessors.
2020-01-31 13:20:30 +01:00
Steven Schäfer cf3e4608f3 JVM IR: Support -Xno-call-assertions 2020-01-30 14:43:23 +03:00
Steven Schäfer 8e07482862 JVM IR: Fix generation of parameterless default constructor
The JVM backend does not generate parameterless default constructors for
private constructors and constructors of local, inner, or inline
classes.
2020-01-21 16:34:33 +01:00
Dmitry Petrov f8341ad7eb JVM: Update tests for IEEE 754 comparisons 2020-01-17 14:14:59 +03:00
Dmitry Petrov 6bbfb2ffe9 JVM: add tests for companion object accessor generation 2020-01-15 16:40:06 +03:00
Dmitry Petrov a16b21a7cc JVM: Don't generate accessors to companions in earlier language versions 2020-01-14 16:12:19 +03:00
Alexander Udalov b48d7f4ba7 JVM IR: fix InterfaceLowering for $default methods from base interfaces
The first change here is swapping the isCompatibility and hasJvmDefault
checks. Otherwise behavior could be different depending on -Xjvm-default
mode even for non-JvmDefault declarations, which makes little sense.

Another change is avoiding generating $default stubs for fake overrides
in interfaces, which replicates the behavior of the current backend.
(Note that this change also fixes the first problem on the newly added
tests, but the first change seems useful anyway.)
2020-01-10 14:05:27 +01:00
Alexander Udalov 8a4510c21b Regenerate tests 2020-01-02 10:31:00 +01:00