Commit Graph

1024 Commits

Author SHA1 Message Date
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
Mads Ager baf1f56859 [JVM_IR] Rebase test of string concatenation codegen.
The JVM IR backend code seems saner to me. The string concatenation
lowering for JVM IR calls the stringPlus intrinsic if there are
only two arguments. That leads to a lot less code:

```
load string
load argument
box argument
call Intrinsics.stringPlus
```

instead of

```
allocate StringBuilder
call StringBuilder.<init>
load string
call StringBuilder.append
load argument
call StringBuilder.append
call StringBuilder.toString
```

This will lead to more boxing, but a lot smaller code. We still
use StringBuilders in JVM IR if there are more than two strings
being concatenated.
2020-03-23 16:42:53 +03:00
pyos 186302d84e JVM_IR: restore InnerClasses for objects in lambdas 2020-03-19 15:23:44 +01:00
Jinseong Jeon 2352b1fec5 JVM_IR: use fresh source map when generating lambda body for inline. 2020-03-19 08:28:38 +01:00
Dmitry Petrov ade18d144a KT-36810 Implement javaPrimitiveType intrinsic in JVM_IR 2020-03-17 22:56:45 +03:00
Dmitry Petrov 2851fab281 KT-36809 Implement javaObjectType intrinsic in JVM_IR 2020-03-17 22:56:45 +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
pyos 037b442e86 JVM_IR: do not explicitly initialize Refs to default values 2020-03-06 17:58:36 +03:00
pyos 13b04e63be JVM_IR: wrap inline class objects in unboxed refs 2020-03-06 17:58:36 +03:00
Georgy Bronnikov 8b559b20e2 Add a test for getOrDefault() bridge 2020-03-04 16:02:54 +03:00
Dmitry Petrov f678db2f89 KT-36813 Generate optimizable null checks in JVM_IR 2020-03-03 22:38:21 +03:00