Commit Graph

3043 Commits

Author SHA1 Message Date
Roman Artemev 66543131c2 [IR] Add referenceScript to SymbolTable 2020-05-12 14:29:52 +03:00
Alexander Udalov 91ef053fbc IR: keep local scope with counter maps across LDL invocations
Since LocalDeclarationsLowering is a BodyLoweringPass, local
functions inside one declaration are handled independently of local
functions in the other declaration. This can lead to name clashes, in
case a local function with the same name and signature is declared in
overloads in the same container, which results in a signature clash
error in JVM IR.

The issue became more common with the introduction of adapted function
references, where psi2ir generates a local adapter-function with a
predefined name, which can easily clash with another reference to the
same target in an overload. This led to a compilation error when
bootstrapping Kotlin with JVM IR, for example in GradleIRBuilder.kt
where there are a lot of references to the same function.
2020-05-08 14:33:34 +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
Steven Schäfer 821aca984b JVM IR: Take superQualifierSymbols into account when lowering inline classes 2020-05-07 11:44:09 +02:00
Alexander Udalov 7a369b3a6a Mark PureIrGenerationExtension as deprecated to prevent more usages
The IR plugin extension mechanism is being reworked and in the new
scheme, this new extension point won't be necessary.
2020-05-06 22:51:32 +02:00
Steven Schäfer 7cad2be329 IR: Add an extension point after IR construction
The existing IrGenerationExtension is in the middle of IR construction
and basically requires plugins to work with the (deprecated) descriptors.

Since there are plans to change the IR extension point it makes sense to
introduce a temporary work-around to allow pure IR plugins to be
developed now, which could be ported to a more permanent API later.
2020-05-06 22:51:12 +02:00
Dmitry Petrov 3143b15a17 Generate widening cast for Byte and Short to Int 2020-05-06 14:42:37 +03:00
Jinseong Jeon deb8e1f9db IR: cleanup unused implementation in WrappedDescriptors
This is partial revert of 08ca6f5, which set metadata field of IR
symbols during FIR2IR conversion, triggering some paths in IR
codegen to use wrapped descriptors copy builder and others to
serialize. Now FIR element-based metadata serialization is in,
those additions were not needed anymore.
2020-05-06 13:10:07 +03:00
Alexander Udalov 54f9f130e2 Do not generate references as adapted with -Xno-optimized-callable-references
The reason for this is that this flag is used right now in 'cli-common'
to workaround the problem that this module is compiled with API version
1.4, but runs with stdlib of version 1.3 (bundled to Gradle). The same
problem would appear with adapted function references, since we use
kotlin/jvm/internal/AdaptedFunctionReference in the bytecode, only
available since 1.4.

The fix is to generate adapted references in this case as subclasses of
the already existing kotlin/jvm/internal/FunctionReference. This can
change behavior in some extreme corner cases (because such references
can now be observed to have reflection capabilities), but it's an -X
argument anyway.

Another option would be to introduce another compiler argument
specifically for this, but it looks like it would only complicate things
without much benefit.
2020-05-04 13:24:53 +02: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 df4f1365ec PSI2IR: support SAM conversion to substituted types
i.e. in arguments to `f(T x)` where `T` is a type parameter bound to a
SAM type.
2020-04-29 18:50:40 +03:00
Dmitry Petrov d9fd51c608 JVM_IR: basic suspend conversion on argument test passed 2020-04-29 18:28:05 +03:00
Alexander Udalov 9fa8e009c6 Support equals/hashCode for fun interfaces in JVM and JVM_IR
#KT-33455 Fixed
2020-04-29 12:15:50 +02:00
Alexander Udalov de461dd9a5 Minor, extract function in FunctionReferenceLowering
Also simplify the expectedArity computation a few lines above.
2020-04-29 12:15:50 +02:00
Dmitry Petrov f9bb07e128 JVM_IR: generate flags for adapted function references 2020-04-29 00:55:52 +03:00
Georgy Bronnikov 1e8a660fda IR: use default parameters in Ir...Impl constructors 2020-04-28 18:19:46 +03:00
Georgy Bronnikov 9561cc8270 JVM_IR: JvmNameProvider 2020-04-28 18:19:46 +03:00
Georgy Bronnikov 52df54ae49 IR: add NameProvider 2020-04-28 18:19:46 +03:00
Georgy Bronnikov 82d55e1a67 Minor: remove unused parameters, reformat code 2020-04-28 18:19:46 +03:00
Steven Schäfer b6b8dd1eab JVM IR: Avoid unnecessary CHECKCASTs in enum classes 2020-04-28 16:31:13 +02:00
Steven Schäfer cb3a4727cf JVM IR: Optimize field initializers in secondary constructors 2020-04-28 16:27:54 +02:00
Mads Ager fed6272de4 [JVM_IR] Use ifne and ifeq for integer zero comparisons. 2020-04-28 16:27:10 +02:00
Alexander Udalov 94346e8a03 Add JVM target bytecode version 14
#KT-38413 Fixed
2020-04-28 13:00:23 +02:00
Dmitry Petrov 802372ceff PSI2IR: suspend conversion on arbitrary arguments 2020-04-28 12:41:56 +03:00
Mikhail Glukhikh 34ae35b2aa Move FirJvmClassCodegen inside fir:fir2ir:jvm-backend #KT-38156 Fixed
This removes dependency of IR JVM backend from FIR
2020-04-28 07:35:13 +03:00
Mikhail Glukhikh dbd4cecff6 FIR serializer: accept FirClass instead of IrClass to get rid of IR deps 2020-04-28 07:35:12 +03:00
Mikhail Glukhikh f98c73cb30 [FIR] Support FirMetadataSource.File in FIR2IR & serializer (KT-38156) 2020-04-28 07:35:04 +03:00
Mikhail Glukhikh c2c85365e6 Use FIR metadata in FIR2IR data class member generator (KT-38156) 2020-04-28 07:34:59 +03:00
Mikhail Glukhikh c6c848f929 Introduce & use FirJvmSerializerExtension & FirBasedClassCodegen
#KT-38156 In Process
2020-04-28 07:34:56 +03:00
Mikhail Glukhikh 7ae98485b8 IR: separate ClassCodegen & DescriptorBasedClassCodegen 2020-04-28 07:34:55 +03:00
Mikhail Glukhikh 03be3c108a [FIR2IR] Introduce FirMetadataSource and use it (KT-38156) 2020-04-28 07:34:52 +03:00
Dmitry Petrov c7a96810bf JVM: Suspend conversion for function references 2020-04-27 21:02:37 +03:00
Dmitry Petrov 6b9a7464f5 PSI2IR: Support suspend conversion for function references 2020-04-27 21:02:37 +03:00
Anton Bannykh 442331acc9 IR JS: support findAssociatedObject feature (KT-37418 fixed) 2020-04-27 17:23:19 +03:00
Denis Zharkov 534ff58d9c Minor. Introduce constant JVM_THROWS_ANNOTATION_FQ_NAME
KT-35468
2020-04-26 23:08:18 +03:00
pyos 887165a23b JVM_IR: avoid copying when optimizing ?:/?. 2020-04-24 21:00:07 +03:00
Alexander Udalov 2815bb88c2 Remove unnecessary dependency of 'fir2ir' on 'ir.backend.common'
Move some lookup utilities which are used in
`OperatorExpressionGenerator`, to 'ir.tree'.
2020-04-23 23:16:29 +02:00
Georgy Bronnikov 565874b3a0 Pass along type in IfNullExpressionFusionLowering 2020-04-23 18:18:34 +03:00
Alexander Udalov 025d1ca64d psi2ir: rework representation of bound adapted function references
This fixes the problem in JVM IR backend which didn't pass bound
receiver value of an adapted function reference to the superclass
(kotlin/jvm/internal/AdaptedFunctionReference), which caused equals to
work incorrectly on such references (see changes in box tests).

Previously, bound adapted function reference was represented as
IrFunctionExpression to an adapter function which calls the callee. The
value of the bound receiver in that case could only be found in the body
of that adapter function. This is not very convenient, so this change
makes psi2ir produce a block of the adapter function + reference to it.
The bound receiver value is then found in the reference. This is
basically similar to what ProvisionalFunctionExpressionLowering is doing
for all function expressions. And since this IR structure is already
supported in FunctionReferenceLowering, the problem in the JVM IR is
fixed without any additional modifications.

However, inliners do not support this IR structure yet, see KT-38535 and
KT-38536.
2020-04-23 16:47:23 +02:00
Alexander Udalov 22bf23025a Minor, workaround IDE exception KT-38521 2020-04-23 16:46:32 +02:00
Mark Punzalan b74652aa5b [FIR] Use ieee754equals for floating-point equality operations 2020-04-23 11:50:54 +03:00
Mads Ager eec3263518 [psi2ir] Properly link corresponding property symbols.
Do not rely on PatchDeclarationParents to do so.
2020-04-22 16:26:59 +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 3bb32941a0 IR: bugfix in KotlinNothingValueExceptionLowering 2020-04-21 21:00:16 +03:00
Sergey Bogolepov 0ed0152ee0 [Linker] Add option to control scope of DescriptorByIdSignatureFinder
Currently DescriptorByIdSignatureFinder performs lookup of descriptor
not only in the given module but also in its dependencies.
This behaviour is incorrect if we have some kind of
relation (e.g. mapping) between moduleDescriptor and found descriptor.
Thus, we add a handle to control search scope.
2020-04-21 19:09:07 +07:00
Dmitry Petrov 05cb0e8994 KNVE: support in JVM_IR and JS_IR 2020-04-20 20:07:52 +03:00
Georgy Bronnikov 2c4fcebfec IR: handle adapted bound references 2020-04-18 20:31:57 +03:00
Jinseong Jeon 9f1ecadd65 IR: more consolidation of synthetic member generation for data class. 2020-04-17 12:38:38 +03:00
Georgy Bronnikov 41a28bde5c JVM_IR: repair synthetic accessors to fields 2020-04-16 15:08:11 +03:00