Commit Graph

460 Commits

Author SHA1 Message Date
Mikhail Glukhikh 66bbb9582c K1/K2: split incremental compilation tests properly (relates to KT-59171) 2023-07-19 09:34:58 +00:00
Ilya Goncharov e7e6fba81f [JS] Fix JS legacy incremental 2023-06-22 12:25:24 +00:00
Hung Nguyen 078356164b IC: Fix regression in detecting constants in KotlinClassInfo.kt
A constant is a static final field with non-null value. In a previous
commit (0b09be7), we accidentally removed the *non-null value*
filter when looking for constants in the bytecode.

This commit re-adds that filter to make sure the detection is correct.

Test: Added KotlinOnlyClasspathChangesComputerTest.testDelegatedProperties

^KT-58986: Fixed
2023-06-16 18:40:01 +00:00
Hung Nguyen ff612f15cf IC: Small cleanup in KotlinClassInfo.kt
This is to address the not-yet-resolved comments in
https://github.com/JetBrains/kotlin/pull/5127, plus a few other small
(non-functional) changes.

^KT-58986: In progress
2023-06-16 18:40:00 +00:00
Ivan Kylchik 0021a5f655 [K2] Save inlined java field into special InlineConstTracker 2023-06-14 19:02:39 +00:00
Alexander Udalov 60016d3e5b Remove obsolete compiler flag -Xuse-ir 2023-05-30 14:46:09 +00:00
Alexander Korepanov 6f7fc14695 [JS IR] Enable all K2 klib IC tests 2023-05-23 10:13:26 +00:00
Nikolay Lunyak d72a50b3f5 [FIR] KT-58065: Support LT in K2JsIrCompiler 2023-05-16 12:11:46 +00:00
Kirill Rakhman a50ae9db9d [FIR] Revert workaround for IC issue surfaced by KT-58335
#KT-28233
2023-05-16 09:20:57 +00:00
Hung Nguyen 0b09be73c6 New IC: Detect changes to class annotations
Both the new and old incremental compilation (IC) analysis rely on
Kotlin class metadata to detect a change.

However, Kotlin metadata currently doesn't contain info about
annotations (KT-57919), so the IC will not be able to detect a change
to them.

With this commit, we'll fix the new IC such that it can detect a change
to class annotations by not relying only on metadata.

We currently scope this fix to the new IC (cross-module analysis) first.
We'll fix this issue for within-module analysis later.

Performance: There seems to be no performance impact from this change.
Snapshotting the 400MB ideaIC-2022.1.4/app.jar takes 4.1s before and
after this change.

Test: Added ClasspathChangesComputerTest.testChangedAnnotations
^KT-58289: Fixed
2023-05-11 15:24:05 +00:00
Ivan Kylchik d83f6a40fb [K2] Revert commit Pass FirFile to metadata serialization
We will ignore this for now. It is quite painful to bring `FirFile`
in all necessary places.

#KT-57812
2023-05-11 08:22:14 +00:00
Ivan Kylchik 951e30b683 [K2] Pass FirFile to metadata serialization
This is needed to extract correct const value from `ConstValueProvider`.

#KT-57812
2023-05-11 08:22:13 +00:00
Hung Nguyen 37d6606852 IC: Load one class at a time when snapshotting classpath
Previously, when snapshotting the classpath with
`ClasspathEntrySnapshotTransform`, for each jar we load all classes
in memory at once. This was needed to detect inaccessible classes
(classes that don't impact incremental compilation and therefore
don't need to be snapshotted).

To reduce memory consumption, this commit updates the algorithm such
that we can now load one class at a time while still being able to
detect inaccessible classes.

In addition, we now read jar files with `java.util.zip.ZipFile` API
instead of `java.util.zip.ZipInputStream` to avoid current JDK bugs with
`ZipInputStream` (e.g., https://bugs.openjdk.org/browse/JDK-8298530).

^KT-57757 Fixed
^KT-57767 Fixed
2023-05-02 19:42:03 +00:00
Nikolay Lunyak 360d236b7e [FIR JS] KT-57601: Get rid of the builtin provider
In this example we get 2 variants of `kotlin/toString()`:
one coming from the KLib provider, and the
other coming from the builtins provider.
These are identical deserialized functions.

^KT-57601 Fixed
2023-04-25 11:29:34 +00:00
Nataliya.Valtman 2a391f7330 Move kotlin-build-statistic project to :compiler 2023-04-25 11:29:09 +00:00
nataliya.valtman e34dd043da Add minimal statistic report for JPS build
Fix build stat for gradle 8

#KT-56438 Fixed
2023-04-25 11:29:09 +00:00
Aleksei.Cherepanov 2e453051f9 Add cache comparator for incremental gradle tests
Add logic that rebuilds all sources after the last incremental round of each Gradle IC test and compares caches. The same was already implemented for JPS, but not for Gradle. After all rounds of incremental compilation are completed, another clean build from scratch is produced. All caches after the rebuild are compared with the caches of the last round of incremental compilation. This check is necessary because incremental compilation artifacts should depend on the state of the project, source files, and configuration, and not the chain of changes and incremental builds that led to this state. After the launch, there were several tests that did not satisfy the above conditions, and were muted  (KT-56681, KT-55195, KT-56242, KT-56698)

#KT-54991 In Progress
2023-04-24 14:54:45 +00:00
Aleksei.Cherepanov ae8428e8d0 Refactor Infrastructure of IC tests
1) Move root util functions to separate CompileRunnerUtils file from IncrementalJvmCompileRunner to leave the only class instance there and to separate util functions
2) Move TestLookupTracker from the abstract parent class location to a separate file as an implementation class
3) Small change naming of building functions just to clarify what they do
4) Some small code-style refactorings
2023-04-24 14:54:45 +00:00
Anton Bannykh c839fdca3e [JS IR] initial support for KLIB incremental compilation with K2 2023-04-23 14:47:48 +02:00
Yahor Berdnikau eb4e96a113 Add kotlin-build-tools-enum-compat workaround
It acts as a workaround for the case when build tools or dependencies
are compiled with latest 'kotlin-stdlib' version, but at a runtime older
 'kotlin-stdlib' is provided, which does not know about new
 `EnumEntries`.

 ^KT-57317 Fixed
2023-04-21 14:57:17 +00:00
Ivan Kylchik 0b70b7904d [K2] Create and add EvaluatedConstTracker in configuration 2023-04-19 13:52:43 +00:00
Ivan Kylchik fe989d0ba7 [K2] Add languageVersionSettings to Fir2IrConfiguration class 2023-04-19 13:52:42 +00:00
Ivan Kylchik e16231104e [K2] Add Fir2IrConfiguration class to store configuration parameters
One example of such parameter is `linkViaSignatures`. There is
`Psi2IrConfiguration` as an analog for K1.
2023-04-19 13:52:41 +00:00
Ivan Kylchik 525098dea6 [K2] Unbind fir:fir2ir:jvm-backend from other non jvm modules 2023-04-19 13:52:41 +00:00
Sebastian Sellmair 5d0bf2de24 [CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2

Reverts:
- 9dcd40d7b7
- fb66764c4d

KTIJ-25227
2023-04-18 09:18:10 +00:00
Ivan Kochurkin 3a60b30dae Minor: IrActualizationResult -> IrActualizedResult 2023-04-17 19:55:35 +00:00
Sebastian Sellmair 9dcd40d7b7 [CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE

KTIJ-24976
2023-04-06 16:03: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
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
hungvietnguyen 4f3244fb78 IC: Compute symbols impacted by classpath changes (#5111)
IC: Compute symbols impacted by classpath changes

Incremental compilation has 4 key steps:
  1. Compile changed/impacted files
  2. Detect symbols that have changed after compiling
  3. Detect symbols that are impacted by the changed symbols
  4. Based on the changed-or-impacted symbols, identify files that need
     to be recompiled. Go back to step 1.

Normally, step 2 and 3 are done together when the changed symbols
and impacted symbols are in the same module.

However, if the changed symbols and impacted symbols are in different
modules (e.g., a `Subclass` in lib1 extends a `Superclass` in lib2),
we currently do not compute symbols in the current module that are
impacted by changes in another module (step 3 above).

This is the case for both the new IC and the old IC.

In this commit, we will compute impacted symbols for the new IC. We can
fix the old IC later if necessary (they can't be fixed together easily).

Test: Added BaseIncrementalCompilationMultiProjectIT.testChangeInterfaceInLib
^KT-56197 Fixed
2023-03-21 13:12:15 +01: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
Yahor Berdnikau dfec9efbb0 Add JVM project level compiler options DSL
These options are used as initial convention values for compilerOptions
in target compilations.

^KT-57159 In Progress
2023-03-15 15:39:08 +00:00
Aleksei.Cherepanov 6471624d0c [Gradle] Disable usePreciseJavaTracking flag for K2
Historically flag was enabled for Gradle projects, but we don't have fir-based JavaTracker for the K2 compiler for now, so we need to use a fallback strategy.
Note: it was disabled for tests with K2
Note2: after adding a fir-based java classes tracker this value should be set to true (KT-57147)

#KT-56886 Fixed

Merge-request: KT-MR-9053
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-03-09 13:41:25 +00:00
Alexander.Likhachev 4d080c1a82 [IC] Register last-build.bin file in a transaction
KT-55995 Related
2023-03-07 16:19:24 +00:00
Alexander.Likhachev 493da2a8b4 [IC] Rename DummyCompilationTransaction -> NonRecoverableCompilationTransaction 2023-03-07 16:19:21 +00:00
Alexander.Likhachev 25a3dcf3d1 [IC] Make CompilationTransaction to be able to close CachesManager 2023-03-07 16:19:21 +00:00
Alexander.Likhachev 3ed651a7a6 [Gradle] Add a property to control if the IC caches in-memory wrapper is enabled
#KT-56052 In Progress
2023-03-07 16:19:20 +00:00
Yahor Berdnikau 0cad069522 [Build] Pin api and language level to 1.8 in Kotlin compiler modules used by KGP
This is required to be able to compile KGP and it's dependencies which
set LV to 1.4 when repo will use LV 1.9. This caused by the change how
enums are compiled (KT-48872).
2023-02-18 13:26:54 +00:00
Dmitriy Novozhilov 79e4df72bf [CLI] Introduce utilities for creating FirSession hierarchy in CLI for all platforms
Also support session creation and compilation for HMPP projects

^KT-56209 Fixed
2023-02-17 11:08:51 +00:00
Dmitriy Novozhilov d4bb740a62 [CLI] Store information about HMPP module for source files 2023-02-17 11:08:50 +00:00
Aleksei.Cherepanov f640a7be2e Add the possibility to mute Gradle IC tests by folder
If you need to mute a test for Gradle IC, the only way is to add exclude pattern and regenerate tests aka remove unnecessary tests. But the filter is absolute, so if you have the same test name in different subfolders (e.g. `pureKotlin/classRemoved/` and `classHierarchyAffected/classRemoved`) you cannot disable only one of them. This commit adds logic to specify which name pattern in which subfolder should be excluded
2023-02-15 18:33:27 +00:00
Svyatoslav Scherbina cf4934f539 [FIR2IR] Make convertToIrAndActualize() more reusable across backends 2023-02-07 14:16:30 +00:00
Ivan Kochurkin 0f9107c153 [FIR2IR] Remove passing excess arguments to jvm backend functions and classes
generateModuleInFrontendIRMode, runBackend

FirJvmBackendExtension, ModuleCompilerIrBackendInput
2023-02-01 11:42:45 +00:00
Aleksei.Cherepanov 090a58ccc4 Change allConstants test
Currently, FIR compilation of `const val b: Byte = 50 + 50` shows an error, but old compiler doesn't (it shows only warning). Since this is an incremental test, it should not be affected by compiler errors, but should only test for .kt usage without recompilation.

#KT-54991 In Progress
2023-01-30 13:45:39 +00:00
Aleksei.Cherepanov a0fa438735 Revert "FIR IC: fix test with behavior different from non-tight cycle variants"
This reverts commit c4a29651 as it is no longer needed after IC fix: `5ba3053e` "[IC] Do not report recompilation of non-existing files", because now fix-ic-build.log duplicates the main build.log

#KT-54991 In Progress
2023-01-30 13:45:38 +00:00
Aleksei.Cherepanov 848e1001f8 Add test for IC issue with typealias
If typealias is defined in a separate file, then after changing some base types, an incremental compilation of Kotlin could not find all affected files, because of lack of information, which it can not get on the class file analyzing phase. FIR provides a new approach to IC compilation: now we can run the frontend several times, which allows us to obtain all necessary information and use it to mark all affected files for recompilation.
Relates to KT-54991

#KT-28233 Fixed
2023-01-30 13:45:37 +00:00
Ilya Goncharov 1150ec6882 [JS] Implementation dependencies for JS klibs
^KT-56158 fixed
2023-01-27 13:31:59 +00:00
nataliya.valtman 3aade8ad95 Mark removed source file as deleted for compiler
#KT-55905 Fixed
2023-01-25 09:43:10 +00:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
hungvietnguyen f172c50f27 New IC: Ignore LookupSymbols that refer to file facades (#5069)
A LookupSymbol should only refer to either a class, a class member, or a
package member.

When a LookupSymbol refers to a file facade (e.g.,
LookupSymbol(name="FooKt", scope="com.example")), it is redundant as it
doesn't impact the IC analysis to find files to recompile.

Previously, the new IC (ClasspathChangesComputer) would fail when
detecting that IncrementalJvmCache reported these redundant
LookupSymbols. With this change, the new IC will just ignore them.

Note: A better approach would be to fix IncrementalJvmCache to not
report these LookupSymbols, but it will require some significant
cleanup/refactoring work, so we can consider it later.

Test: New KotlinOnlyClasspathChangesComputerTest.testRenameFileFacade
^KT-55021 Fixed
2023-01-19 12:21:29 +01:00