Commit Graph

3126 Commits

Author SHA1 Message Date
Ivan Kylchik 32297c0f21 Serialize and deserialize const val's properly for K2 klib
#KT-57312 Fixed
2023-04-04 12:35:54 +00:00
Leonid Shalupov 7480befe32 Replace reflection-based compiler arguments copying with generated code
Using of Kotlin reflection for simple operations like bean management is very slow

First time initialization time: 261 ms for `copyBean(K2JVMCompilerArguments())`
Subsequent calls of `copyBean(K2JVMCompilerArguments())` take 1.7 ms per call

Unfortunately compiler argument handling is also used in Kotlin IntelliJ plugin
to parse facet settings. Big projects may have thousands of Kotlin facets

The same `ArgumentUtilsKt.copyProperties` frame is seen across various freezes:
IDEA-252440 2-3 minutes freeze on Kotlin project reimporting in last 203 eap
IDEA-253107 A lot of short freezes (1-3 sec) during Kotlin project development
KTIJ-23501 Make main run configuration detection lighter
KTIJ-22435 Unresponsive UI with 100% cpu

Reflection issue:
KT-56358 KClasses.getMemberProperties takes too much time

This commit replaces all reflection stuff with a simple code generation
Now `K2JVMCompilerArguments().clone()` goes to hard-to-measure time
2023-04-03 15:47:35 +02:00
Svyatoslav Kuzmich 02beaa1daa [Wasm] Add BuiltInsPlatform.WASM
Use it instead of BuiltInsPlatform.JS in klibs
2023-04-01 10:50:29 +00:00
Dmitriy Dolovov b7d0209e4b [PL] Disallow partial linkage when compiler is configured to produce KLIB
Partial linkage is intended for producing binaries, not libraries.
2023-03-31 18:29:44 +00:00
Dmitriy Dolovov 1fef48bb60 [PL] Log partial linkage messages at different severity
As specified in -Xpartial-linkage-loglevel CLI argument.
2023-03-31 18:29:44 +00:00
Kirill Rakhman f18591ffef [FIR] Fix IllegalStateException on broken import
#KT-55316 Fixed
2023-03-31 12:54:28 +00:00
Dmitriy Novozhilov 96e9d690a6 [CLI] Prohibit passing HMPP module structure with CLI arguments to metadata compiler
^KT-57644 Fixed
2023-03-31 09:59:52 +00:00
Dmitriy Novozhilov b9c61bbc60 [FIR] Properly setup dependant module data for metadata compilation
^KT-57377 Fixed
2023-03-31 09:59:51 +00:00
Dmitriy Dolovov 46ed6e5766 [PL] Change semantics of CLI parameter -Xpartial-linkage
This parameter accepts the name of the "mode" in which the partial linkage would work. Currently, only two options are supported: 'enable', 'disable'. But the list may be extended in the future as needed.

At the moment the 'disable' option is the default one. This will be changed in #KT-51447, #KT-51443.
2023-03-30 12:38:07 +00:00
Dmitriy Dolovov a450866db3 [PL] Commonize Native & JS compiler configuration keys 2023-03-30 12:38:07 +00:00
Dmitriy Dolovov 831611d577 [PL] Introduce new CLI parameter: -Xpartial-linkage-loglevel
The parameter controls the level of logs produced during the compile time by the partial linkage: 'info', 'warn' (default for now), and 'error'.
2023-03-30 12:38:06 +00:00
Vladimir Sukharev b9633375b4 [K2/N] KT-56030: Support Objective-C overloading by param names only
Merge-request: KT-MR-8901
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-30 09:37:57 +00:00
Leonid Shalupov 34c82011fc Remove copying of transient fields in argumentUtils
Current code in argumentUtils handles transient fields incorrectly
and copies them (not intended behaviour)

change is required for further work in arguments handling

ref https://jetbrains.team/im/review/3CCOfH4ffz5J?message=9fPd30T1rQz&channel=1y9ZTj2JB0aG
2023-03-29 20:20:02 +01:00
Simon Ogorodnik ae32eff543 KT-57154: Fix JRT-FS contents served for wrong JDK home on JDK 9+
If the compiler runtime JDK is 9+,
it will already contain JrtFileSystemProvider and won't use provided
classloader
In order to fix KT-57154 we need to provide "java.home" argument to
newFileSystem

In order to reduce the severity of the leak in KT-56789 we cache
instances of FileSystem itself forever
Otherwise, each invocation of newFileSystem on JDK 9+ will leak
classloader, which is created deep inside the JDK code

Add unit test for JRT-FS contents served through CoreJrtFs

Add Gradle Integration test to 
test if the daemon correctly reads JDK contents from the specified 
toolchain and not from its runtime JDK

^KT-57154
Regression test for ^KT-57077
2023-03-28 10:38:46 +00:00
Dmitriy Novozhilov 8ca7b32577 [FIR] Register type related extensions in libraries sessions
^KT-57140
2023-03-27 10:44:50 +00:00
Ivan Kylchik 5d5582d201 Move ignoreConstOptimizationErrors compiler key from jvm to common
#KT-56023
2023-03-24 15:55:03 +00:00
Ivan Kochurkin ee73e4774b [K2, MPP] Remove redundant expect declarations from klib metadata
^KT-57250 Fixed

Introduce flat Fir2IrActualizedResult

It contains output from Fir2Ir and IrActualizer
2023-03-24 14:48:26 +00:00
Dmitriy Dolovov 2a4d880037 [PL] Deep rework of the partial linkage
1. Leaving no unbound symbols in the IR tree, KT-54491:
   - All unbound symbols are bound to synthetic stub declarations
   - Improved detection of the root cause for every partially linked classifier
   - Improved error messages

2. Visibility valiation, KT-54469

3. Always check deserialized symbols:
   If the deserialized symbol mismatches the symbol kind at the call site in the deserializer then generate and reference another symbol with the same signature. In case PL is off, just throw IrSymbolTypeMismatchException.

4. Handle class inheritance violation:
   - Detect illegal inheritance (ex: inheriting from a final class)
   - Detect invalid constructor delegation (ex: delegating to another class than the direct superclass)
   - Simplification: Reduce the number of PartialLinkageCase subclasses
   - Reworked error message generation to have shorter and clearer messages

5. Handle class transformations and all known side-effects, examples:
   - nested <-> inner
   - class <-> enum/object
   - adding/removing subclasses of sealed class
   - adding/removing enum entries

6. Check direct instantiation of abstract class.
   Such instantiation could be possible if a class was non-abstract in the previous version of a library.

7. Handle unlinked annotations on declarations.
   Such annotations are removed from the IR. The appropriate compiler error message is produced for every individual case.

8. Handle value argument count mismatch at call sites

9. Handle calling suspend function from non-suspend context.
   This could happen if a suspen function was non-suspend in the previous version of a library.

10. Handle overriding inline callables.
    Only the leaf final callable can be marked with `inline`.

11. Detect illegal non-local returns from noinline/crossinline lambdas.
2023-03-23 10:24:27 +00:00
Ilya Chernikov 59b88f33b2 [K2, MPP] implement IR errors reporting and test infrastructure
Fix test data

^KT-56344 Fixed
2023-03-22 01:28:16 +00:00
Artem Kobzar 4da81b2b6e [K/JS] Remove an internal system property and replace it with the new compiler flag 2023-03-17 12:38:34 +00:00
Dmitriy Novozhilov 6af1c550b6 Update copyright 2023-03-16 15:16:32 +00:00
Dmitriy Novozhilov b6a41c6d93 [CLI] Extract classes of compiler configuration from :compiler:cli to the separate module
Those classes mainly include KotlinCoreEnvironment and its dependencies

This change is needed for two reasons:
1. Splitting of some common configuration of compiler from logic of CLI
    makes code structure more clean
2. There is a need to add dependency on `:analysis:analysis-api-standalone`
    to `:compiler:cli`, because FIR analogue of AnalysysHandlerExtension uses
    services from it. But the problems is that standalone AA itself depends
    on classes for compiler configuration, which leads to circular
    dependency between those modules. Extracting configuration to
    `:compiler:cli-base` solves the problem
2023-03-16 15:16:32 +00:00
Artem Kobzar 948c511284 [K/JS] Rework ES modules part with squashed JsImport and right renaming strategy inside import/export statements 2023-03-16 10:28:39 +00:00
Alexander Korepanov e3402fcc87 [K2 JS] Do not load transitive dependencies for building K2/JS klibs
^KT-57262 Fixed
2023-03-15 10:49:54 +00:00
Ivan Kylchik 1c210822ea Add new configuration key that can enable IR inlining for JVM 2023-03-14 20:47:41 +00:00
Alexander Udalov 4f380e876c Deprecate ClassBuilderInterceptorExtension
ClassGeneratorExtension is supposed to be used instead.
2023-03-13 13:54:06 +01:00
Alexander Udalov fba5b96bef JVM IR: introduce ClassGeneratorExtension
This is a low-level extension point for Kotlin/JVM, which is supposed to
be used instead of ClassBuilderInterceptorExtension.

 #KT-54758 Fixed
 #KT-56814 Fixed
2023-03-13 13:51:52 +01:00
Alexander Udalov b1d109e7a3 JVM IR: do not use JvmDeclarationOrigin in duplicate signatures
Apparently the client code which reports errors only meaningfully uses
the `descriptor` field of `JvmDeclarationOrigin` in case of JVM IR.
2023-03-13 13:51:52 +01:00
Nikolay Krasko 57934a6870 Revert "Revert "[K2/N] KT-57026, KT-57208: Adjust Native & JS test infrastructures for MPP testing""
This reverts commit c0c692844e.
2023-03-10 14:24:49 +01:00
Nikolay Krasko c0c692844e Revert "[K2/N] KT-57026, KT-57208: Adjust Native & JS test infrastructures for MPP testing"
This reverts commit 6964121c15.
2023-03-10 13:14:10 +00:00
Igor Chevdar f442936320 [K/N] Build per-file caches in parallel 2023-03-10 11:05:54 +00:00
Alexander Korepanov 2cad26f4cc [JS IR] Use cacheable ZIP file system accessor in JS IR BE
Related to KT-51712
2023-03-10 09:38:52 +00:00
Vladimir Sukharev 6964121c15 [K2/N] KT-57026, KT-57208: Adjust Native & JS test infrastructures for MPP testing
Merge-request: KT-MR-9081
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-09 18:56:30 +00:00
Alexander Korepanov bd3eb81aee [JS FIR] Use FIR in JS IR invalidation tests
Related to KT-56740
2023-03-08 13:18:15 +00:00
Ilya Chernikov 54218eb77d FIR LT: fix column calculation with crlf line endings
#KT-57117 fixed
also:
- refactor the position finder (mostly for testability)
- add testing of position finder to the testLightTreeReadLineEndings
- refactor the test for readability
- add mixed line ending scenario
2023-03-08 10:18:05 +00:00
Yahor Berdnikau 5ddd60a015 Add '-progressive' option into Gradle compiler options DSL
^KT-53923 Fixed
2023-03-07 17:32:20 +00:00
Yahor Berdnikau 174f39aa46 Add '-opt-in' option into Gradle compiler options DSL
^KT-53924 Fixed
2023-03-07 09:40:09 +00:00
Johan Bay 349a6b6e82 Introduce flag for bitcode to native compilation
This enables splitting the compilation pipeline into multiple
invocations of the compiler.
2023-03-04 16:13:42 +00:00
Yan Zhulanow c604577132 Embed DefaultErrorMessages extension list (KT-57102)
Normally, 'DefaultErrorMessages' extensions should only be loaded
from the main compiler JAR. However, in the in-process JPS build,
there are two versions of the compiler classes in the process, and
'ClassLoader's there are not fully isolated.

'ServiceManager' loads extensions from both 'META-INF' locations. If
the JPS plugin bundles newer compiler components, newly appeared
'DefaultErrorMessages' extensions will be loaded from the JPS (parent)
'ClassLoader', causing an exception.

Such a problem appeared with 'DefaultErrorMessagesWasm':

- - - - -
java.util.ServiceConfigurationError:
org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages$Extension: org.jetbrains.kotlin.wasm.resolve.diagnostics.DefaultErrorMessagesWasm not a subtype
- - - - -
2023-03-04 06:38:34 +00:00
Ivan Kochurkin de5b475f7a [FIR] Use KlibBasedSymbolProvider in FirCommonSessionFactory
Unify logic of KLib resolving (Common and JS)

^KT-56354 Fixed
2023-03-03 20:58:24 +00:00
Ivan Kochurkin d829f8b684 [FIR] Drop using of JavaSymbolProvider and OptionalAnnotationClassesProvider in FirCommonSessionFactory
Drop using of all Java stuff inside FirCommonSessionFactory

^KT-56063
2023-03-03 20:58:24 +00:00
Sebastian Sellmair b90207edb9 [Gradle] Rename -Xdepends-on to -Xfragment-refines and use ':' for -Xfragment-sources instead of ';'
^KT-56210 Verification Pending
2023-03-01 16:30:44 +00:00
Sebastian Sellmair 21bf497830 [CLI] Replace K2 -Xmodule by -Xfragments and -Xfragment-sources
KT-56210
2023-03-01 16:30:41 +00:00
Dmitriy Novozhilov e0fa1e64b9 [FIR] Properly setup java parser version for CLI pipeline with light tree
^KT-56549 Fixed
2023-02-28 09:17:41 +00:00
Ilya Chernikov cecf22e035 Fix application environment keepalive handling
The previous changes to the disposer registration changes introduced a
weird problem exposed in the Gradle (test?) environment, that caused
a performance regression - it seems that keep alive system property
in that setting was cleared at the time the disposer was called, causing
app env disposal when keeping it alive was expected.
This fix captures property value at the moment of disposer registration,
making it similar in that respect to the previous variant and avoiding
the performance degradation.
#KT-56992 fixed
2023-02-28 08:08:09 +00:00
Svyatoslav Kuzmich 54a45c49f8 [Wasm] Add Wasm platform and K1 FE infrastructure 2023-02-24 01:05:23 +01:00
Simon Ogorodnik 253cdb1b8f KT-56789: Fix memory leak in CoreJrtFileSystem
CoreJrtFileSystem uses JrtFileSystemProvider provider to read contents
of jrt-fs from JDK
Implementation of FileSystems.newFileSystem causes metaspace memory leak
that wasn't fixed until JDK 17, see
https://bugs.openjdk.java.net/browse/JDK-8260621

When FileSystems.newFileSystem used to create jrt-fs on JDK9 with
provided java.home value it creates new ClassLoader under-the-hood,
which subsequently leaks due to aforementioned bug

Remove conditional usage of `java.home` + FileSystems.newFileSystem and
switch to use jrt-fs classloader cache regardless of
compiler runtime JDK to reduce classloader leaks

^KT-56789
2023-02-23 15:55:24 +00:00
Dmitriy Novozhilov 331cc1465a [FE] Properly parse java class name from sources if java class has annotations
^KT-56847 Fixed
2023-02-23 12:14:15 +00:00
Yahor Berdnikau 96316a4016 Generate KotlinNativeCompilerOptions Gradle DSL
^KT-53108 In Progress
2023-02-22 13:02:59 +00:00
Alexander Korepanov e107de6f36 [JS IR] Use a guard file for preventing incremental caches corruption
If a developer interrupts (kill gradle process) a compilation process or
 an internal error interrupts the compilation process,
 the incremental cache files may be corrupted.
 The patch creates a special guard file, which allows detecting
 if the previous compilation was not successful,
 and in case of any issues drops the incremental cache files.

^KT-56581 Fixed
2023-02-20 13:14:30 +00:00