Commit Graph

487 Commits

Author SHA1 Message Date
Hung Nguyen 4e89dcf031 [IC] Refactor IC maps to reuse code and ensure consistency
The key changes include:
  - Top interface: `PersistentStorage`
  - Implementation:
      + `LazyStorage`
      + `InMemoryStorage`
  - Extended functionality:
      + `BasicMap`
      + `PersistentStorageAdapter`

 The remaining changes are small cleanups to adapt to the above key
 changes.

 Test: Existing tests (refactoring change)
 Bug: N/A (code cleanup)
2023-10-05 11:12:25 +00:00
Hung Nguyen 0d04b8783c [IC] Handle custom source set located outside project directory
To support build cache relocatability, we need to convert absolute paths
into relative paths before storing them in IC caches.

Before this commit, we computed relative paths based on the (root)
project directory and FAIL if some source files are located outside the
project directory.

With this commit, we will NOT FAIL in that case. This means relative
paths may start with "../". It's not "clean", but it can work.

Test: New test in BuildCacheRelocationIT
^KT-61852 Fixed
2023-09-21 14:39:52 +00:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Dmitriy Novozhilov a43cb721ba [FE] Convert ClassId.java to Kotlin 2023-09-21 12:40:43 +00:00
Ilya Chernikov e5ee364419 IC: Implement expect/actual tracking
fixes NewMultiplatformIT.testIncrementalCompilation
also #KT-61590 fixed
2023-09-19 15:46:30 +00:00
Mikhail Glukhikh 2dd9bdb89d Separate incremental JS legacy / standard incremental test fails 2023-09-19 15:46:29 +00:00
Aleksei.Cherepanov 39a0829f39 Fix Maven tests for K2
1) Update test data according to K2 compiler output
2) Finally switch logic of choosing compiler runner depends on language version instead of deprecated useK2 flag

#KT-60859 Fixed
2023-09-19 15:46:27 +00:00
Evgenii Mazhukin 30e49c0879 [IC] Refactoring - Remove obsolete forceExhaustiveWhen util 2023-09-15 12:03:40 +00:00
Alexander Udalov fd68b9f49c CLI: add -Xuse-ir-fake-override-builder
To be able to test IR fake override builder (KT-61514) outside of
compiler tests.
2023-09-13 15:01:52 +02:00
Mikhail Glukhikh b0b6a6a05a K1/K2: deduplicate/simplify the code around JVM CLI
Related to KT-61510, KT-61745
2023-09-08 13:20:47 +00:00
Alexander.Likhachev 53fde520d5 [Build] Add jUnit dependencies in testApiJUnit5 to the implementation configuration
Adding these dependencies to the `api` configuration pollutes classpath for each dependant modules even if it doesn't need them. Instead, the dependencies should be declared more granularly if they're required
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Anton Bannykh 387898056a [JS] Report K2 diagnostics before Fir2IR
^KT-60531 fixed
2023-08-31 12:15:08 +00:00
Anton Bannykh c09fa093fc [JS] set LV=1.9 in a K1 IC test 2023-08-24 16:00:54 +00:00
Kirill Rakhman 43180597fe [FIR] Fix generic sam conversion in call completion
#KT-60903 Fixed
2023-08-21 10:35:42 +00:00
Hung Nguyen 894ba9ab80 [IC] Relocatable IC caches for projects with custom buildDir
IC caches often contain file paths. To make them relocatable, we need
to convert these file paths into relative paths, relative to a base
directory.
  - If the file paths are source files, we can use the root project
    directory as base.
  - If the file paths are class files, we should use the classes
    directory as base (before this commit, we used the root project
    directory in both cases, that's why we hit KT-58547).

The key changes in this commit include:
  - RelocatableFileToPathConverter: converts paths to relative paths
  - IncrementalCompilationContext: contains 2 different path converters,
    one for source files and one for class files
  - SourceToOutputFilesMap: maps source files to class files using the
    above path converters
  - IncrementalCompilerRunner: creates the path converters based on file
    locations

Test: RelocatableFileToPathConverterTest unit test
      SourceToOutputFilesMapTest unit test
      BuildCacheRelocationIT.testCustomBuildDirectory integration test
^KT-58547 Fixed
2023-08-16 13:40:19 +00:00
Anton Bannykh 6a886e4c32 [JS] rename IC tests to easier distinguish between the K1/K2 variants 2023-08-11 15:46:51 +00:00
Anton Bannykh 962bfaca9c [JS] Support multimodule IC tests with K2
Includes supporting klib file generation.
2023-08-11 15:46:51 +00:00
Anton Bannykh d78f7bde6a [JS] set LV=1.9 for K1-specific IC tests
Otherwise they will actully run K2 after
the LV=2.0 migration.

^KT-60829 fixed
2023-08-10 22:37:16 +00:00
Ilya Gorbunov 69a87efdd9 js.tests: change paths to kotlin-stdlib-js.klib
Change the expected klib name of stdlib

KT-56106
2023-08-03 14:47:20 +00:00
Alexander.Likhachev 329fd6be45 [BT] Move ClassSnapshotGranularity to the Build Tools API module
#KT-57565 In Progress
2023-08-03 08:55:32 +00:00
Alexander.Likhachev 442d1cf711 [BT] Move ClassSnapshotGranularity to the Build Tools API package 2023-08-03 08:55:32 +00:00
Alexander.Likhachev b3677fa0ca [IC] Allow to not specify the modules info 2023-08-01 16:24:37 +00:00
Alexander.Likhachev e33611a88a [IC] Allow to not specify the build history file 2023-08-01 16:24:37 +00:00
Yan Zhulanow 7d88ade005 [fir2ir] Allow non-cached type parameters
In the IDE, there might come declarations from other files/modules
that we link against, but not compile. Type parameters are one of such
declaration kinds.
2023-07-28 16:05:34 +00:00
Ivan Kylchik 84159596bd [FIR] Pass diagnosticReporter in Fir2IrConfiguration
This parameter will be used to report diagnostics from constant
evaluator, in addition to report diagnostic from actualizer.
2023-07-27 22:50:21 +00:00
Nataliya.Valtman ed2dd4b2ae Split Gradle and JPS metrics
#KT-58026 In progress
2023-07-27 11:18:54 +00:00
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