Commit Graph

878 Commits

Author SHA1 Message Date
Dmitriy Novozhilov d1fd1da56f Rename Visibility to DescriptorVisibility 2020-09-04 11:07:42 +03:00
Roman Artemev c7b57c0fb3 [IR] Use only empty constructor to create WrappedDescriptor 2020-09-01 17:08:11 +03:00
Roman Artemev fd88914cf9 [IR] Remove some descriptor usage from Common/JS/JVM backends
- replace descriptor-based builders with pure IR ones
 - fix matchers
 - fix Ir2Js
 - rewrite some inliner-helpers to pure-IR implementations
2020-09-01 17:08:11 +03:00
Roman Artemev 4dca3715fa [JS IR | IR] Implement error element lowering to support compilation with errors 2020-09-01 14:53:08 +03:00
Igor Chevdar 5e71068e61 [IR] Handled degenerate cases of IrStringConcatenation
It is not needed to create StringBuilder if the number of values
being concatenated is 0 or 1
2020-09-01 11:34:17 +05:00
Alexander Udalov 1e712f8398 IR: remove IrElementVisitorVoidWithContext
It was only used as a superclass in IrInlineReferenceLocator and
LocalDeclarationsLowering. In both cases it's clearer and more optimal
to pass the necessary data via the visitor 'data' variable.
2020-08-31 12:47:54 +02:00
Igor Chevdar ab54e43b00 [IR] Commonized SAM equals/hashCode builder 2020-08-31 12:01:29 +05:00
Steven Schäfer b02f0f0a25 JVM IR: Fix compilation of nested inner classes 2020-08-28 20:03:19 +02:00
Dmitriy Novozhilov a764732020 Rename KotlinBuiltInsNames to StandardNames 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov 7a7fe77b8e Move static constants with builtin names to :core:descriptors.common module 2020-08-25 10:31:36 +03:00
Mark Punzalan a9359eb530 RangeContainsLowering: Handle unsigned ranges. 2020-08-21 21:15:27 +02:00
Mark Punzalan ceba9f231d RangeContainsLowering: Fix bug in additional condition order for
`until` ranges.
2020-08-21 21:15:27 +02:00
Mark Punzalan 60a2f7d03f RangeContainsLowering: Handle Comparable ranges. 2020-08-21 21:15:27 +02:00
Mark Punzalan 1c1b1b4b0f Initial version of RangeContainsLowering, which optimizes calls to
contains() on ClosedRanges.
2020-08-21 21:15:27 +02:00
Dmitry Petrov 8f0aecce58 JVM_IR: KT-40330 Unify field names for captured 'this' with JVM
NB some cases such as captured extension receiver for an extension
lambda are not supported yet; to be discussed, to what extent should we
actually follow JVM code shape here.
2020-08-19 11:07:41 +03:00
Alexander Udalov a810dbb41b IR: fix compiler warnings 2020-08-18 10:33:25 +02:00
Alexander Udalov 9b94e073af Fix warnings related to OptIn/UseExperimental 2020-08-17 21:18:19 +02:00
Alexander Udalov 256f4449ce IR: annotate obsolete API in IrPluginContext with ObsoleteDescriptorBasedAPI 2020-08-17 21:18:19 +02:00
Alexander Udalov 9961bd1fe1 IR: remove unneeded casts after making IrCall's symbol a simple function 2020-08-17 21:18:17 +02:00
Steven Schäfer 0328fcaf5d JVM IR: Avoid IMPLICIT_NOTNULL checks on special bridge methods
...with dynamic type checks, except for the `@PlatformDependent`
methods, for which the JVM backend adds null checks.
2020-08-14 21:59:33 +02:00
Alexander Udalov 469b164555 IR: minor optimizations to IR validation 2020-08-14 21:55:37 +02:00
Alexander Udalov 9607414cf1 IR: make allOverridden return Set instead of Sequence, move to IrUtils
This doesn't hurt performance, but improves stack traces, in particular
in JVM's BridgeLowering.
2020-08-14 21:55:37 +02:00
Alexander Udalov adcfbdec24 JVM IR: optimize special method / signature computation in BridgeLowering
First of all, put method signature caches of BridgeLowering into
JvmBackendContext. Since method hierarchies can span several files, and
a new instance of BridgeLowering is created to lower each file, keeping
them cached for the whole module makes BridgeLowering faster.

Also, do not attempt to compute special bridges if the method is
irrelevant, which can be deduced by its name. With this optimization,
the special method cache is no longer needed.

This brings BridgeLowering time from 3.8% down to 1.5% of all compiler
time on a sample project.
2020-08-14 21:55:37 +02:00
Alexander Udalov 6db5ad7310 IR: remove cast to IrStatement in IrDeclarationBase.transform
Default implementation of `IrStatement.transform` contained a cast to
`IrStatement`. Since almost all IR elements inherit from IrStatement,
this implementation was used in many subclasses. However, checkcast to
interface is slow and this place was indeed noticeable in the profiler
snapshot. Since not that many places really expected to get IrStatement
out of IrStatement.transform, introduce a new method
`transformStatement` that does this cast, and use it in all those
places. Meanwhile, most implementations will use the IrElement's
implementation of `transform` which merely invokes `accept` without
casts.
2020-08-14 21:55:37 +02:00
Alexander Udalov fb8e39a621 IR: optimize transformation of declarations/statements lists in-place
Also, inherit IrDeclarationBase from IrElementBase to be able to use a
cast to IrElementBase, which is faster than a cast to IrElement or
IrDeclaration.
2020-08-14 21:55:36 +02:00
Georgy Bronnikov 18ae665d41 IR: make IrCall take IrSimpleFunctionSymbol 2020-08-12 16:31:31 +03:00
Alexander Udalov ba7ff36274 IR: make IrDeclarationReference and subtypes classes 2020-08-11 14:41:56 +02:00
Alexander Udalov 9aa7da44e2 IR: remove IrTerminalExpressionBase, Ir{Terminal,}DeclarationReferenceBase
Implement no-op acceptChildren/transformChildren in the base class
IrExpressionBase instead. This doesn't change behavior because all other
implementations of acceptChildren/transformChildren are not affected.
2020-08-11 14:41:55 +02:00
Alexander Udalov e3dfd5fb49 IR: push down implementations of startOffset/endOffset/type/...
Do not store these as properties in IrElementBase, IrExpressionBase and
similar classes. This helps to reduce boilerplate in implementations
(just "override val" in the constructor, instead of taking a parameter
and passing it to the superclass), and also slightly optimizes memory in
cases where the value is trivial (UNDEFINED_OFFSET, 0, etc) and thus
does not need to be stored.
2020-08-11 14:41:54 +02:00
Georgy Bronnikov 7f4df19dd1 JVM_IR: reorganize throw... functions in Symbols 2020-08-11 10:54:29 +03:00
Georgy Bronnikov dafcdc527d IR: propagate original declaration info via attributeOwnerId
For IrProperty, IrSimpleFunction we need to pass information about
original declaration to JVM_IR codegen. Instead of descriptors, use
the attributeOwnerId field.
2020-08-10 10:16:23 +03:00
Georgy Bronnikov 04d93dfbce IR: move containerSource from descriptor to IrFunction, IrProperty 2020-08-10 10:16:23 +03:00
Alexander Udalov e4cd7cdbcf IR: remove unused code, cleanup 2020-08-06 17:08:04 +02:00
Alexander Udalov b30b2e0179 IR: minor, render duplicate IR node in checker 2020-08-06 17:08:04 +02:00
Alexander Udalov 8db1c3611b IR: introduce abstract class IrDeclarationBase
The main purpose of this class is to improve performance of IR visitors
and transformers. `IrElementVisitor.visitDeclaration` now takes
IrDeclarationBase as a parameter, and therefore the call to `accept`
there is now a virtual class call, instead of an interface call.
2020-08-06 17:08:04 +02:00
Mark Punzalan 2cfd776092 ForLoopsLowering: Assume step == 1 for *Range (e.g., IntRange) and
handle accordingly (e.g., do not read `step` property).
2020-07-29 20:44:51 +02:00
Alexander Udalov 687d13a320 IR: cleanup expression implementations
Remove unused constructors with descriptors, minimize usages of
secondary constructors and make some properties non-lateinit, fix some
inspections.
2020-07-28 20:05:58 +02:00
Alexander Udalov 0d605a6b7f IR: create IrBlockBody via IrFactory 2020-07-28 12:05:24 +02:00
Alexander Udalov 9ad4a754ce IR: create IrExpressionBody via IrFactory 2020-07-28 12:05:24 +02:00
Alexander Udalov d1dc938a5d IR: use IrFactory in IR builders 2020-07-28 12:05:24 +02:00
Alexander Udalov 898dd20a9e IR: use IrFactory in misc utils 2020-07-28 12:05:23 +02:00
Alexander Udalov c6a127e87e IR: introduce IrFactory
This is needed to refactor IrPersistingElementBase-based implementations
into another module, to use it in JS IR.
2020-07-28 12:05:23 +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 132960a695 ForLoopsLowering: Eliminate use of @ObsoleteDescriptorBasedAPI. 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
Mark Punzalan 291d62f653 ForLoopsLowering: Move handlers to sub-package and separate files. 2020-07-22 22:32:29 +02:00
Dmitry Petrov 1272162a7f JVM_IR: generate "safe" names for functions in init blocks 2020-07-22 19:49:48 +03:00
Roman Artemev edab3e3ba9 [PLUGIN API] Add referenceTypeAlias API to IrPluginContext
- attempt to fix KT-40193
2020-07-21 18:38:33 +03:00
Roman Artemev c4b4912a71 Revert "[PLUGIN API] Make referenceClass resolve type aliases too" 2020-07-21 18:38:32 +03:00