Commit Graph

1739 Commits

Author SHA1 Message Date
Alexander Udalov cfd3d974d1 JVM IR: perform substitution in IrTypeSystemContext.getSubstitutedUnderlyingType 2019-08-05 21:27:20 +02:00
Alexander Udalov 908498a560 JVM IR: deduplicate exception message text in FunctionCodegen
See 37002748c8
2019-08-05 21:27:20 +02:00
Alexander Udalov 5f06c9e86c JVM IR: do not generate generic signature for $delegate field
See ee7bbbf530
2019-08-05 21:27:20 +02:00
Alexander Udalov 26346d88cc JVM IR: take IrFunction in IrTypeMapper.mapFunctionName/mapReturnType 2019-08-05 21:27:20 +02:00
Alexander Udalov 8c1b2a7f20 JVM IR: record DELEGATED_PROPERTIES slice for correct metadata serialization
This is needed in order to get rid of CodegenAnnotatingVisitor in JVM IR
2019-08-05 21:27:19 +02:00
Ilmir Usmanov d9caeca249 JVM_IR: Copy suspend lambda's attributes 2019-08-05 20:25:31 +03:00
Steven Schäfer 9182fe887e Fix inline class handling in DefaultParameterInjector 2019-08-05 16:48:18 +03:00
Mikhael Bogdanov 971d36837a JVM_IR. Don't generate annotations and signature on synthetic methods 2019-08-05 15:00:51 +02:00
Georgy Bronnikov 5d12603d73 JVM_IR: remove unused code 2019-08-04 01:35:05 +03:00
Georgy Bronnikov f9391ec790 Remove handling of default arguments from codegen 2019-08-04 01:35:05 +03:00
Georgy Bronnikov 4d50086d35 JVM_IR: reorder lowerings
Some lowerings have to come before DefaultParameterInjector.
2019-08-04 01:35:05 +03:00
Georgy Bronnikov 924fa6f9d3 JVM_IR: use DefaultParameterInjector 2019-08-04 01:35:05 +03:00
Ilmir Usmanov 06388b885c JVM_IR: Support suspend lambdas with receiver 2019-07-31 21:17:09 +03:00
Steven Schäfer 06274b1339 JVM_IR: Simplify RemoveDeclarationsThatWouldBeInlinedLowering 2019-07-31 11:18:44 +02:00
Steven Schäfer 93d414ac01 JVM_IR: Change CallableReferenceLowering to match the JVM backend
In particular, the JVM backend inlines the bodies of lambdas into the
generated lambda subclasses and stores bound receivers in the receiver
field of CallableReference. Both are required for reflection.
2019-07-31 11:18:44 +02:00
Steven Schäfer 917435a50c Extract IrBody.statements utility function 2019-07-31 11:18:44 +02:00
Steven Schäfer 509d257475 JVM_IR: Fixes to SyntheticAccessorLowering
This commit fixes the handling of accessors for super calls, changes the
naming scheme to avoid accessor name clashes and uses a more robust test
to determine the placement of accessors for protected static members.
2019-07-31 11:18:44 +02:00
Steven Schäfer 173f1fc7d1 Fix statement order in LocalDeclarationsLowering
Previously, the order of IrSetField statements in this lowering was
non-deterministic. This broke the inliner in the JVM backend which
expects statements to be in argument order.
2019-07-31 11:18:44 +02:00
Steven Schäfer c38fb27676 JVM_IR: Run CallableReferenceLowering before LocalDeclarationsLowering 2019-07-31 11:18:44 +02:00
Steven Schäfer 9816e62d08 JVM_IR: Fix inlining of interface methods 2019-07-31 11:18:44 +02:00
Dmitry Petrov bdec8b04e8 Minor: trim in RenderIrElementVisitor 2019-07-31 10:37:35 +03:00
pyos d715344639 psi2ir: precompute sort keys when generating members
On kotlinx.serialization, this improves the performace of the compiler
with -Xuse-ir by about 5% (average of 30 runs after 10 warmup runs:
3096 ms -> 2970 ms, minimum: 3037 ms -> 2884 ms). Flamegraphs for
comparison (careful, huge SVG images):

https://drive.google.com/open?id=1BlIFN4ivSKrXjY6vZ0xkZymwucGc7bSI
https://drive.google.com/open?id=1xIW2IvW7LMCaAe4P2dOGOG8nCcpWI9PW
2019-07-30 12:07:12 +02:00
Denis Zharkov 9c27abde7f [API Usage] Support type refinement from expect class to type aliases
It's necessary when expect class is actualized via typealias
To support it properly, we need to return AbbriviatedType instead of
SimpleTypeImpl, thus scopeFactory is not enough anymore
2019-07-30 12:41:37 +03:00
Dmitry Savvinov 1d61d75225 [Core API] Introduce KotlinType.refine
The most interesting part happens in SimpleType.refine, other types
either don't implement refinement at all (they return just 'this',
mainly it's some special types, like ErrorType and such) or implement
it trivially via recursion (those are "composite" types)

SimpleType.refine captures so-called refinement factory, which is essentially
an injected callback which tells how to reconstruct the type with new
(refined) memberScope.

We have to inject callback because we express quite different types with
SimpleTypeImpl, and some of them need different refinement logic.
Another possible implementation approach (more invasive one) would be
to extract those types in separate subtypes of KotlinType and implement
'refine' via overrides.

The most meaningful callbacks are injected from
'AbstractClassDescriptor.defaultType' and from 'KotlinTypeFactory'.
2019-07-30 12:41:37 +03:00
Steven Schäfer 3ce731cf7c Avoid eager deserialization of array classes in ArrayConstructorLowering 2019-07-30 10:35:00 +02:00
Igor Chevdar e575ca4f53 [IR] Fixed parents during constructors moving 2019-07-29 16:18:15 +03:00
Georgy Bronnikov 3729c4e770 JVM: simplify choice of wrapped receiver descriptors 2019-07-26 11:57:51 +03:00
Georgy Bronnikov f66b475867 Create wrapped receiver descriptors where needed 2019-07-24 20:25:47 +03:00
Alexander Udalov 1f36f60f43 JVM IR: remove CrIrType, use class container in callable reference lowerings
This is possible now because after 3a9b94235f, 0423d0f41e and
5341de253f, all top level functions/properties in sources and in
binaries have a corresponding containing facade class
2019-07-23 16:39:38 +02:00
Igor Chevdar c4da5cb95c [IR] Added IrType.isKSuspendFunction() 2019-07-23 19:16:46 +05:00
Alexander Udalov 35e4295e16 IR: deduplicate code in DeepCopyWithWrappedDescriptors/DeepCopyIrTreeWithDescriptors 2019-07-22 19:47:25 +02:00
Alexander Udalov 96efae2b48 IR: fix endless recursion in IrTypeSystemContext.isMarkedNullable 2019-07-22 19:47:25 +02:00
Mikhael Bogdanov 74e49d91ca Proper implement 'classForImplicitThis' 2019-07-22 10:35:03 +02:00
Dmitry Petrov 127be9be03 psi2ir: Fix KT-30796 ErrorType for '?:' in OI 2019-07-22 09:46:21 +03:00
Dmitry Petrov dd3f8ecaac IR BE Common: Provisional IrFunctionExpression lowering
Transforms IrFunctionExpression elements to local function references,
as it was done before IrFunctionExpression introduction.
2019-07-19 11:36:19 +03:00
Dmitry Petrov 92984b2626 Serialize/deserialize IrFunctionExpression 2019-07-19 11:36:19 +03:00
Dmitry Petrov ffd9b45ef3 IrFunctionExpression: add 'origin'
This is actually either a LAMBDA or an ANONYMOUS_FUNCTION.
Not quite sure if it's really required, but some tools such as IR-based
decompiler might require this information.
2019-07-19 11:36:19 +03:00
Dmitry Petrov ed2b4a8bec Introduce IrFunctionExpression IR element
Use it to represent proper function expressions (lambdas and anonymous
functions).
2019-07-19 11:36:18 +03:00
Igor Chevdar 4bad92d28c Fixed bug in LateinitLowering 2019-07-18 17:08:11 +03:00
Alexander Udalov 5341de253f JVM IR: run FileClass & ExpectDeclarationsRemoving phases on whole module
Since we now generate file classes even for IR loaded from dependencies
(see 3a9b94235f) to simplify code in certain lowerings, it makes sense
to do that for all source files together before any meaningful
lowerings. The easiest way to do so is to make FileClassLowering a
module-wide phase.

ExpectDeclarationsRemoveLowering is now also a module-wide phase because
it needs to be run before FileClassLowering (to avoid producing empty
facades for files that only contain `expect` declarations)
2019-07-17 18:15:02 +02:00
Alexander Udalov e867830eab JVM IR: inline JvmBackend, JvmCodegen 2019-07-17 18:15:02 +02:00
Alexander Udalov 9d639bc9a4 Minor, remove code duplication in WrappedDescriptors 2019-07-17 18:15:01 +02:00
Georgy Bronnikov 0423d0f41e JVM_IR: specify facadeClassGenerator properly in Psi2IrTranslator 2019-07-17 18:15:01 +02:00
Alexander Udalov 9595c815f1 JVM IR: invent names for SAM wrapper classes
Similarly to how it's done for callable references. This is needed for
IrTypeMapper to be able to correctly compute the name of the SAM wrapper
IrClass without resorting to the name of the underlying descriptor
(computed in CodegenAnnotatingVisitor)
2019-07-17 13:55:37 +02:00
Alexander Udalov a15575d546 JVM IR: do not use KotlinTypeMapper in IrTypeMapper.mapType 2019-07-17 13:55:37 +02:00
Alexander Udalov 1e16c0a447 JVM IR: minimize public API of IrTypeMapper 2019-07-17 13:55:37 +02:00
Alexander Udalov 59ce76e9fd JVM IR: do not use misleading names for callable reference classes
The real JVM name is invented in InventNamesForLocalClasses and will be
used by the codegen when generating the actual class
2019-07-17 13:55:36 +02:00
Alexander Udalov 29fa1793d3 JVM IR: add InventNamesForLocalClasses pass 2019-07-17 13:55:36 +02:00
Alexander Udalov 529efff8cb IR: introduce IrAttributeContainer
This is useful to store data that must be kept when the element is
transformed, such as names of local/anonymous classes and
EnclosingMethod values on JVM which are computed before any lowerings.

For now, this is implemented very conservatively: the only field
`attributeOwnerId` which can be used in BackendContext implementation as
a key in the map
2019-07-17 13:55:36 +02:00
Alexander Udalov bd8c09bfb5 JVM IR: move CollectionToArray creation to JvmSymbols
Also simplify it to use IR builder DSL
2019-07-17 13:55:35 +02:00