Commit Graph

5907 Commits

Author SHA1 Message Date
Ilya Muradyan 6917ff7d2a [scripting] Move earlierScripts to the frontend descriptor
^KT-20488 fixed
2021-11-30 09:11:59 +03:00
Mads Ager 8255118204 [JVM] Do not extend local ranges across control-flow merges.
The coroutine method transformer extends the range of locals
across code where the local is not live when it is safe to do
so. However, it only bailed out for one case of control-flow
merging, namely backwards branches for loops. That is not
sufficient as there can be control flow merges without loops
where the local is only defined on one control-flow path.

This change generalizes the bailout to any control-flow merge.

^KT-49834 Fixed
2021-11-23 13:49:45 +01:00
Dmitry Petrov e525e25518 JVM KT-47851 fix redundant checkcast elimination 2021-11-20 23:29:19 +03:00
Alexander Udalov 59c5dddc88 Remove unused PrecomputedSuppressCache 2021-11-18 23:17:34 +01:00
Dmitriy Novozhilov 93378b1a04 [FE 1.0] Resolve private constructors of sealed classes same as for regular classes
^KT-44866
^KT-49729
2021-11-18 13:54:05 +03:00
Alexander Udalov a7fef487c1 JVM IR: fix support of cyclic module dependencies
Previous episode was at 987a3460 (KT-45915).

Apparently, it's not enough to run psi2ir for all modules, and then
backend for all modules. If there are several modules in the chunk, IR
in any one of them can reference IR of any other one after psi2ir.

So we would end up in a situation where we're running codegen for the
first module, but the second module is completely unlowered. This would
break some assumptions in the codegen, for example in KT-49575, codegen
would see a reference to a top-level function from another module, and
would fail because the function has no containing class (since file
facades have not been generated yet!), and thus must be an intrinsic,
yet no such intrinsic is known to the codegen.

The solution is to run lowerings first on all modules, and then run
codegen on all modules. The kind of error explained above shouldn't be
possible anymore, because lowerings have to deal both with lowered and
unlowered code from other files all the time, so lowerings can't assume
that reference from other module is lowered either (or unlowered).

The code is not very nice, but hopefully it can be improved as soon as
we get rid of the old JVM backend (and maybe later with the migration to
FIR too).

 #KT-49575 Fixed
2021-11-16 20:20:20 +01:00
Alexander Udalov 850d76f6bf Remove error on annotated types as arguments to typeOf
Instead, document that `KType.annotations` returns an empty list for
types created with `typeOf`. Annotations might be supported in the
future.

 #KT-49573 Fixed
 #KT-29919
2021-11-16 15:02:50 +01:00
Dmitry Petrov 9a4cff0dc7 JVM KT-49548 progression iterators can be tainted 2021-11-10 19:37:24 +03:00
Ilya Chernikov 932eab8dfc Implement semi-lazy PSI-based suppress cache for IR
calculates suppressions per root (KtFile) basis on demand.
2021-10-27 22:17:42 +02:00
Ilya Chernikov 1e056a7aa8 Report IR errors via new diagnostic infrastructure 2021-10-27 22:17:40 +02:00
Ivan Kochurkin c13822a2c5 Optimize containsKey -> get pattern 2021-10-25 21:21:44 +03:00
Dmitry Petrov c441980c74 JVM_IR don't move inplace arguments with variable stores
KT-49370
KT-49407
2021-10-25 20:11:42 +03:00
Dmitriy Novozhilov f7bb55433d Add LanguageVersion and ApiVersion for 1.8 2021-10-25 12:54:10 +03:00
Ilmir Usmanov f760cd6736 Make CHECKCAST Object not break tail-call optimization
Since CHECKCAST Object does nothing for return value of suspend
function - the function returns references only, this is safe.
 #KT-49157 Fixed
2021-10-11 06:40:26 +00:00
Dmitry Petrov cc885f9b24 JVM don't remove NOP starting a try-catch block 2021-09-29 19:14:37 +03:00
Dmitry Petrov ca7ee75f88 JVM replace redundant GOTOs with NOPs to preserve debugging behavior 2021-09-29 19:14:33 +03:00
Dmitry Petrov 0a67ab54fe JVM_IR more compact safe call chains (almost as old BE) 2021-09-29 19:14:32 +03:00
Victor Petukhov 764361bc42 Format and remove unused imports and variables 2021-09-27 16:12:22 +03:00
Victor Petukhov 3696bebb48 Introduce NewCallableReferenceResolvedCall and commonize other logic under NewAbstractResolvedCall 2021-09-27 16:12:17 +03:00
Victor Petukhov a264cbfe7d Move CallUtil.kt under the resolve.util package 2021-09-27 16:12:01 +03:00
Victor Petukhov 1635bcad10 Move CallResolverUtil.kt under the resolve.util package 2021-09-27 16:12:00 +03: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
Ilmir Usmanov 91491eef06 Fixup end label of local variable if it is before start label
In that case, put end label to next label after start label.
2021-09-20 21:29:58 +00:00
pyos ade9f5a1e8 JVM: rename a couple ValueKinds to make their purpose clearer 2021-09-20 19:29:44 +02:00
Alexander Udalov 987a346015 JVM IR: support cyclic module dependencies
The only way to make the compiler compile several modules with a
dependency loop is via the "build file", given by -Xbuild-file and used
in the JPS (IntelliJ built-in build system) plugin.

For the old frontend/backend it works like this: we _analyze_ sources of
all modules once, as if it's one big module, and then for each module,
we _generate_ (invoke backend) only sources of that module. Backend
needs to be invoked separately per-module because every module has its
own destination directory specified in the build file.

For JVM IR, this separation into just two steps, analyze and generate,
was problematic because there's psi2ir, which works like frontend, in
that it needs the global analysis result to be able to create and link
IR correctly. So, in case of JVM IR, we need to run psi2ir on the whole
module after analysis and before generation.

In this change, psi2ir is run on the whole module via
`CodegenFactory.convertToIr` (which does nothing in the old backend),
and then parts of the resulting IR module are extracted according to the
original separation of the combined module into individual modules via
`getModuleChunkBackendInput` by matching IrFile against KtFile. And
then, backend is run for each such module.

 #KT-45915 Fixed
 #KT-48668 Fixed
2021-09-17 17:39:49 +02:00
Alexander Udalov 5d6ca27c93 JVM IR: introduce CodegenFactory.convertToIr
The steps of psi2ir and JVM backend need to be separated in the API
because in case of cyclic module dependencies (which are allowed in JPS)
psi2ir should be run first on all sources, and then JVM backend on each
module separately. `CodegenFactory.convertToIr` does nothing in the old
backend.

Also, move the ignoreErrors to GenerationState for simplicity.
2021-09-17 17:39:48 +02:00
Ilmir Usmanov 9e4f234941 Minor. Add space after when
Co-authored-by: Louis CAD <louis.cognault@gmail.com>
2021-09-15 22:28:32 +02:00
Ilmir Usmanov 755b92b0e9 Document coroutines codegen. Remove mentions of experimental coroutines 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 4d1545d522 More minor changes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 6a150fffe6 Minor spelling changes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov de3ffc4a89 Remove obsolete FIXME 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 0372d9050a Clarify tail-call optimization for functions returning Unit
Review fixes.
2021-09-15 22:28:32 +02:00
Ilmir Usmanov 1cdae75dc3 Document coroutines codegen: debug 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 995062cb19 Document coroutines codegen: callable references
returning inline classes
2021-09-15 22:28:32 +02:00
Ilmir Usmanov fce06305b9 Document coroutines codegen: inliner part 3: returning inline classes
Update the information, mention, that there are two markers, not just
one
2021-09-15 22:28:32 +02:00
Ilmir Usmanov 7d41451fba Document coroutines codegen: inliner part 3: minor grammar fixes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov a736d4fef1 Document coroutines codegen: callable references 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 3276ef6cf8 Document coroutines codegen: Returning Inline Classes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 25af290266 Document coroutines codegen: inliner part 3: crossroutines 2021-09-15 22:28:32 +02:00
Ilmir Usmanov ddaab2c2bb Document coroutines codegen: inliner part 2 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 771b0c006f Document coroutines codegen: inliner part 1 2021-09-15 22:28:32 +02:00
Ilmir Usmanov e2c5f9d245 Document coroutines codegen: functions 2021-09-15 22:28:32 +02:00
Ilmir Usmanov a8aac955d9 Document coroutines codegen: split long lines 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 7263b6e5d6 Document coroutines codegen: rest of suspend lambda 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 0814c5cc93 Document coroutines codegen: superclasses 2021-09-15 22:28:32 +02:00
Ilmir Usmanov bfd0291572 Document coroutines codegen: interception 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 8b604b8ce1 Document coroutines codegen: intrinsics part 2 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 611c1b1a38 Document coroutines codegen: intrinsics 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 0943a31675 Document coroutines codegen: spilling 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 57e69202e8 Document coroutines codegen: resume with exception 2021-09-15 22:28:32 +02:00