Commit Graph

2169 Commits

Author SHA1 Message Date
Mads Ager 6622846bc1 [JVM IR] Do not put destructuring params or underscores in LVT.
Putting them in the local variable table means that the debugger
needs to have special handling for parameters with specific names.
That forces us to generate mangled names for these.

Instead of also implementing the name mangling for FIR, this
change gets rid of the parameters from the LVT instead.
2021-11-02 15:13:14 +03:00
Dmitry Petrov 4f0c3c3c0d JVM_IR never generate setter synthetic accessor for 'val' field
KT-49316
2021-10-29 18:38:11 +03:00
Jinseong Jeon 2dc2a90755 Introduce an API to convert TypeConstructorMarker to TypeParameterMarker 2021-10-28 12:54:45 +03:00
Ilya Chernikov cb513ee333 IR: fix ACCIDENTAL_OVERRIDE reporting on annotation implementations 2021-10-27 22:17:42 +02:00
Ilya Chernikov ea1edc2bd9 Add equality to diagnostic context, simplifying deduplication 2021-10-27 22:17:41 +02:00
Ilya Chernikov fc176e9845 Refactor IR reporting and infrastructure 2021-10-27 22:17:41 +02:00
Ilya Chernikov 1e056a7aa8 Report IR errors via new diagnostic infrastructure 2021-10-27 22:17:40 +02:00
Ilmir Usmanov 7ec9d608cc Use original instead of lowered suspend function
as a key to view. Otherwise, SAM conversions will break.
 #KT-49294 Fixed
2021-10-26 14:14:12 +00:00
Ivan Kochurkin c13822a2c5 Optimize containsKey -> get pattern 2021-10-25 21:21:44 +03:00
Dmitry Petrov 6e9cbf52b1 JVM_IR make $deserializeLambda$ method synthetic 2021-10-23 11:21:26 +03:00
Dmitry Petrov 1dbbe22c8c JVM_IR serializable indy method references 2021-10-23 11:21:25 +03:00
Dmitry Petrov d5f6674d2d JVM_IR KT-49335 run RepeatedAnnotationLowering per module
Otherwise, we drop annotation constructors in AnnotationLowering,
which breaks RAL in case of annotation container declared in different
file.
2021-10-21 21:22:36 +03:00
Dmitry Petrov af18b10da9 JVM_IR KT-49203 generate stubs for not found classes 2021-10-15 12:15:49 +03:00
Dmitry Petrov 2a00def84e JVM_IR make proxy funs for inline and arrayOf funs non-synthetic 2021-10-13 16:07:53 +03:00
Alexander Udalov 357f3184bf JVM IR: fix the type of IrGetField
The `irGetField` utility uses the field's own type as the type of the
resulting expression. But the field's type does not make sense outside
of the place of declaration of the field if it references a generic type
parameter of the containing class. Using this non-sensical generic type
led, for example, to an error in Ieee754 intrinsic (KT-48648).

The type of the expression should be kept as is in
JvmPropertiesLowering, i.e. taken from `expression` which the lowering
is replacing with the field access.

 #KT-48648 Fixed
2021-10-12 23:35:17 +02:00
Dmitry Petrov b946a284b0 JVM_IR move 'arrayOf' handling to JvmBuiltInsLowering
FunctionReferenceLowering creates calls to 'arrayOf' functions that
should be processed later.
2021-10-12 21:12:44 +03:00
Dmitry Petrov 27e5655480 JVM_IR minor: more JvmIrBuilder helpers 2021-10-12 21:12:43 +03:00
Ilmir Usmanov d0a70e5cc0 Minor. Use safe cast in isStaticInlineClassReplacementDelegatingCall 2021-10-12 15:09:07 +02:00
Dmitry Petrov b184c72e3d JVM_IR make proxy funs synthetic, fix some typos 2021-10-12 15:56:35 +03:00
Dmitry Petrov e0c2a2efd7 JVM_IR Minor: remove outdated TODO 2021-10-12 15:56:34 +03:00
Dmitry Petrov 005d3b1f6f JVM_IR pass reified type parameters in indy SAM conversion proxy 2021-10-12 15:56:33 +03:00
Dmitry Petrov 40fe67880b JVM_IR wrap function into a proxy if indy SAM-conversion becomes valid 2021-10-12 15:56:31 +03:00
Georgy Bronnikov a9ce25cf33 JVM_IR: only serialize inline functions themselves with -Xserialize-ir=inline 2021-10-11 11:53:30 +03:00
Georgy Bronnikov 4caa71538d JVM_IR: introduce modes for IR serialization
Instead of a Boolean flag -Xserialize-ir, use modes: none,inline,all.
In "inline" mode, only information needed to deserialize bodies of inline
functions is serialized.
In the "all" mode, all declarations are serialized completely.
2021-10-11 11:53:29 +03:00
Dmitry Petrov 146f0f4904 JVM_IR KT-41214 emit PermittedSubclasses on JDK17+ 2021-10-09 17:07:35 +03:00
Dmitry Petrov 27860ef008 JVM_IR KT-49136 don't optimize null checks on fields and calls 2021-10-08 08:55:24 +03:00
pyos 1c3a20fab9 JVM_IR: generate $suspendImpl in interfaces as public
The visibility was the cause of KT-44533; not generating `$suspendImpl`
at all makes `super` calls impossible.

^KT-49106 Fixed
2021-10-06 15:03:51 +02:00
Ilmir Usmanov 27081231d9 Use original instead of lowered function to retrieve toString-impl
in string concatenation lowering. Otherwise, inliner tries to get
body of already lowered function, failing.
 #KT-48284 Fixed
2021-10-06 11:12:26 +00:00
Dmitry Petrov 1dae2aca4c JVM_IR KT-48954 prohibit indy reference creation in some cases 2021-10-05 15:38:46 +03:00
pyos 337cbeded1 JVM_IR: do not move receivers on functions with inline class parameters
^KT-48993 Fixed
2021-10-05 13:34:32 +02:00
Georgy Bronnikov 41e38d5a1a JVM_IR: move serialized IR to a separate annotation 2021-10-02 00:56:46 +03:00
pyos 73adcd7b62 JVM_IR: copy code from JvmDefaultParameterInjector to JvmTailrecLowering
Some weird edge case for inline classes wrapping primitives?
2021-10-01 14:37:55 +02:00
pyos 2afab62dae JVM_IR: optimize tailrec calls in inline lambdas
^KT-48600 Fixed
2021-10-01 14:37:54 +02:00
pyos 7c63d50d1c IR: create more temporary vals when optimizing tailrec calls
This is needed so that SharedVariablesLowering doesn't get confused, and
SharedVariablesLowering should run after TailrecLowering to properly
optimize tailrec calls in inline lambdas.
2021-10-01 14:37:54 +02:00
Dmitry Petrov aea2db97c5 JVM_IR simplify null check on trivially initialized vals only 2021-10-01 14:31:48 +03:00
Alexander Udalov 31ba7f24b1 JVM IR: fix generic signatures of suspend function references
Using `kotlin.jvm.functions.Function{n+1}` (via
`getJvmSuspendFunctionClass`) for suspend functions was wrong in the
function reference lowering, because we didn't adapt the parameter types
by transforming the last type to Continuation and adding Object, and
generic signature ended up being incorrect.

Actually there was no need to use `kotlin.jvm.functions.Function{n+1}`
at all. We can just use the built-in
`kotlin.coroutines.SuspendFunction{n}` as a supertype, and it will be
mapped correctly later in codegen. It's not even needed to add the
`kotlin.coroutines.jvm.internal.SuspendFunction` marker manually, since
it's also handled by the codegen (see `IrTypeMapper.mapClassSignature`).

 #KT-48732 Fixed
2021-10-01 12:43:00 +02:00
Dmitry Petrov 7e86f5dcd9 JVM_IR don't use Intrinsics.stringPlus for 2-argument concatenation 2021-10-01 02:59:52 +03:00
Mads Ager b61389f6f9 [JVM IR] Do not generate clinit as enclosing method.
The JVM and newer Android runtimes treats that the same as if
there is no enclosing method. However, older Android runtimes
for Android 5 and 6 throw exceptions on reflective access
and even older runtimes have different behavior. To avoid
those issues, exclude <clinit> from enclosing method attributes.

^ KT-48754 Fixed
2021-09-30 23:02:43 +02:00
Alexander Udalov b821b26cfe JVM IR: do not try to optimize casts in TypeOperatorLowering
In case the cast value is used as a receiver to a private method call,
the cast is actually necessary, see KT-48927. Also, this optimization
has backfired once already (see kt48659_identityEqualsWithCastToAny.kt).
It seems that the best way to optimize these casts is not to generate
them in the first place, and/or use bytecode postprocessing.

Apparently the only kind of casts which need to be eliminated are those
which occur on an inline class to its supertype. Otherwise the
unsafe-coerce intrinsic is inserted at the incorrect place, and several
tests fail (uncastInlineClassToAnyAndBack.kt, genericOverride.kt,
classGenericOverride.kt).

 #KT-48927 Fixed
2021-09-30 13:32:36 +02:00
Dmitry Petrov 86b3ea09c2 JVM_IR handle @EnhancedNullability types in null check simplification 2021-09-29 19:14:38 +03:00
Dmitry Petrov 9325660f06 JVM_IR fold safe calls and elvises 2021-09-29 19:14:36 +03:00
Dmitry Petrov 7370d096ee JVM_IR recognize safe calls and elvises in arbitrary IR 2021-09-29 19:14:34 +03:00
Dmitry Petrov 0a67ab54fe JVM_IR more compact safe call chains (almost as old BE) 2021-09-29 19:14:32 +03:00
pyos 255e94e961 JVM_IR: add IrInstanceInitializerCall to suspend lambda constructors 2021-09-29 16:25:43 +02:00
pyos e1520c61da IR: use parameters for captures in field/instance initializers
val y = 1
    object { val x = y }
  ->
    class XKt$1(`$y`: Int) { val x: Int = `$y` }

Note that `$y` is not stored in a field because it's not used outside
the primary constructor.

One exception is captured inline parameters on the JVM backend, as the
bytecode inliner uses field assignment instructions (setfield) to locate
them; removing the field is thus not possible.
2021-09-29 16:25:43 +02:00
Vyacheslav Gerasimov ab146bd6d4 Build: Fix deprecated Gradle configurations usages
for migration to Gradle 7+ #KTI-559
2021-09-26 18:28:44 +03:00
Dmitry Petrov 9799ad7bd8 Make optimized loop over unsigned array, indices, withIndex JVM-specific 2021-09-24 12:12:43 +03:00
Pavel Kunyavskiy 773c82ae48 Refactor AnnotationImplementationLowering
- Replaced UNDEFINED_OFFSET with SYNTHETIC_OFFSET, it's required by
  Native backend codegen
- Fixed missing overridden symbols
- Enforce adding fakeoverrides for members not overridden by backend
- Support more points for platform customisation
2021-09-23 06:59:32 +00:00
Steven Schäfer 1eb9a5a86d JVM IR: Don't generate bridges for default argument stubs (KT-46389) 2021-09-22 18:45:54 +02:00
Aleksei.Cherepanov 47a1dd27dd Fix after review KT-CR-4441 of cc5382b3
Simplify API of InlineConstTracker
In ConstLowering: Move transformer logic to another class to avoid mutable state. Avoid marking all files in module as module. Support of inner classes.

#KT-46506 Fixed
2021-09-22 01:55:18 +03:00