Commit Graph

688 Commits

Author SHA1 Message Date
Dmitry Petrov dae358c792 JVM: KT-40664 disable optimization for 'ULong in range of UInt' case 2020-07-29 20:33:17 +03:00
Ilmir Usmanov 4fb5f8603a Keep $continuation in LVT
in case of suspend functions and `this` is case of lambdas, since they
are used in async stack trace generation.
Update tests.
 #KT-40661 Open
2020-07-29 00:01:12 +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
Ilmir Usmanov 60875f96b4 Do not take LVT into account when calculating liveness of variables 2020-07-29 00:01:09 +02:00
Steven Schäfer 9d63412b3e JVM IR: Produce correct generic signatures for special bridge methods 2020-07-27 17:02:24 +02:00
Mark Punzalan 174576af61 ForLoopsLowering: Handle Sequence<*>.withIndex(). 2020-07-22 22:32:29 +02:00
Mark Punzalan b1ce21bc55 ForLoopsLowering: Reduce unnecessary temporary variables for the
"checked step" (check for a positive step arg) and "negated step"
(negate the step arg when the nested step is negative).
2020-07-22 22:32:29 +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
Ilmir Usmanov 697c8637ee For all int-like typed variables, use int as field type and coerce
it during spill-unspill.
Coerce int to boolean, otherwise, VerifyError is thrown on android
Completely rewrite SpilledVariableFieldTypesAnalysis... again,
but this time use BasicInterpreter
This way, the analysis both does not use SourceInterpreter and
is in line with the rest on analyses.
2020-07-01 17:26:47 +02:00
Dmitry Petrov d37b616e1f JVM_IR: Fix enum classes ABI
1. Enum entry fields don't have nullability annotations.

2. Enum class special methods (values, valueOf) are not 'final'
(although they probably should be, javac generates corresponding
methods without ACC_FINAL flag).

3. Enum class special methods don't have nullability annotations.

4. Don't generate synthetic accessor for enum entry class constructor.

KT-37019 KT-37020 KT-37021
2020-06-30 18:24:25 +03: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 ee6d432ced Add forgotten test files 2020-06-18 12:22:53 +03:00
Georgy Bronnikov 1bb3f60bad IR: use super qualifier in Java field accesses 2020-06-17 20:02:26 +03:00
Steven Schäfer 846fc13519 JVM IR: Fix inline class constructor ABI (KT-37013, KT-37015) 2020-06-16 09:23:58 +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
Alexander Udalov 77e479fda8 JVM IR: generate InnerClasses attribute for nested classes in annotation arguments
#KT-38853
2020-06-09 11:33:27 +02: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
Steven Schäfer 7ea71a17f0 JVM IR: Use language feature for inline class mangling rules 2020-05-29 19:54:09 +03:00
Dmitry Petrov a270ee094c Language feature for new inline class mangling rules (since 1.4) 2020-05-29 00:53:01 +03:00
Steven Schäfer dc0ef996b7 JVM IR: Implement the new inline class ABI 2020-05-28 18:00:35 +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
Dmitry Petrov c165b8d55c JVM: Update IR bytecode text and signature tests 2020-05-20 07:19:30 +03:00
Dmitry Petrov cf70c83ab7 JVM: Update tests 2020-05-20 07:19:29 +03: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 177967258b ForLoopsLowering: Eliminate construction/boxing/unboxing of UInt/ULong.
This needs further cleanup to encapsulate more logic into ProgressionType.
2020-05-13 13:54:35 +02:00
Mark Punzalan f249e7f5e9 ForLoopsLowering: Add additional bytecode text tests for optimization of
unsigned progressions.
2020-05-13 13:54:35 +02:00
Mark Punzalan 03ef3724f4 ForLoopsLowering: Add support for unsigned progressions. 2020-05-13 13:54:35 +02:00
Mads Ager 1f4a3b0d1c [JVM_IR] Avoid safe-call conversions from Byte? and Short? to Int? for
comparisons.

Having those conversions leads to unnecesary boxing and null checks.

This change does it only for JVM in the optimization lowering. It
is unclear to me if the other backends can get away with something
similar.
2020-05-08 11:39:30 +03:00
Dmitry Petrov 3143b15a17 Generate widening cast for Byte and Short to Int 2020-05-06 14:42:37 +03:00
Mads Ager 6257b32954 [JVM_IR] Avoid boxing when comparing primitive to object. 2020-05-01 17:53:34 +03:00
Mads Ager db17184cfd [JVM_IR] Avoid some boxing when comparing boxed primitives to primitives. 2020-05-01 13:14:20 +03: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
Mads Ager fed6272de4 [JVM_IR] Use ifne and ifeq for integer zero comparisons. 2020-04-28 16:27:10 +02:00
Mads Ager 8bc360fa0c Properly link properties and their getter/setters.
This allows removing a hack in the MethodSignatureMapper.

When introducing non-getter methods that dispatch to a getter
we have to be careful to use the right name.

DeepCopyIrTreeWithSymbols should create the link between new
properties and their new getter/setter.
2020-04-22 16:26:59 +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
Dmitry Petrov 9615b20e5d Box inline class return value in lambdas (including suspend lambdas) 2020-04-08 19:56:26 +03: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
Ilya Gorbunov 1c93911279 Make Double and Float known values constant
#KT-13887
2020-04-01 08:06:57 +03: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
Dmitry Petrov 9a95941ef3 JVM_IR: Rewrite '?.' and '?:' chains
This shortens code and avoids unnecessary boxing in some cases.
2020-03-26 12:19:25 +03:00