175 Commits

Author SHA1 Message Date
Ilya Chernikov 1989e8f094 IC tests: add infrastructure for K1/K2 lookups comparison
Adapt lookup tests to allow running K1 and K2 on the same testdata
and compare the lookups recorded.
2024-03-12 11:38:06 +00:00
Timofey Solonin bba39dd4fe Add an IT for publication of multiplatform resources in Android target
^KT-65540
2024-02-28 10:37:16 +00:00
Timofey Solonin 7e9e064748 Add an IT for publication of multiplatform resources in a jvm target
^KT-65540
2024-02-27 14:04:51 +00:00
Evgenii Mazhukin ee3119e9d2 [KGP] Introduce Incremental Compilation Feature Toggles
Makes it easier to introduce a Gradle property for configuring
IncrementalCompilerRunner.

^KT-64513 Fixed
^KT-63837 In Progress


Merge-request: KT-MR-13671
Merged-by: Evgenii Mazhukin <evgenii.mazhukin@jetbrains.com>
2023-12-27 13:43:54 +00:00
Hung Nguyen ecbf69504a [IC] Add back flush() API to PersistentStorage
In commit 4e89dcf, we removed `flush()` from `PersistentStorage`
(previously called `LazyStorage`) because it is not used in Gradle
builds.

However, `flush()` is still used in JPS builds, so we need to add that
API back in this commit.

#KT-62486 Fixed

Co-authored-by: Hung Nguyen <hungnv@google.com>


Merge-request: KOTLIN-MR-796
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-10-16 18:30:47 +00:00
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
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
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
Troels Bjerre Lund 111bb461a9 CLI: Change kotlin reflection to java reflection
The command line argument parser is using between 0.25s and 0.5s
(depending on platform) on finding annotated properties. This fix
replaces the slow kotlin reflection with java reflection, which is an
order of magnitude faster.

 #KT-58183 Fixed
2023-06-27 08:34:40 +00:00
Sebastian Sellmair 082a38216d [CLI] argumentsToStrings: Add 'compactArgumentValues' option
Passing 'false' will pass Array or List based arguments multiple times
instead of using the Delimiter.

eg:
compactArgumentValues = true:
"-cp", "library1;library2;library3"

compactArgumentValues = false:
"-cp", "library1", "-cp", -"library2", "-cp", "library3"

Using compactArgumentValues = false can be beneficial
when the many compiler arguments are held in memory.
In this case the raw arguments can intern individual string values, which
is highly effective when the arguments refer to files on disk.

KTIJ-24976
2023-04-06 16:03:04 +00:00
Sebastian Sellmair d07b1b6502 [CLI] Implement CommonToolArguments.toStringList (to replace convertArgumentsToStringList`)
KTIJ-24976
2023-04-06 16:03:02 +00:00
Alexander.Likhachev 8bb0c5135b [IC] Add unit tests for InMemoryStorageWrapper
#KT-56052 Fixed
2023-03-07 16:19:25 +00:00
Alexander.Likhachev ca8d0bd100 [IC] Add unit tests for resetting in-memory caches wrappers in a transaction
#KT-56052 In Progress
2023-03-07 16:19:23 +00:00
Alexander.Likhachev 04a5c7761c [IC] Add unit tests for CachesManager closing in transaction
#KT-56052 In Progress
2023-03-07 16:19:23 +00:00
Alexander.Likhachev 493da2a8b4 [IC] Rename DummyCompilationTransaction -> NonRecoverableCompilationTransaction 2023-03-07 16:19:21 +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
Roman Efremov 3c5e556ba6 Add "hasEnumEntries" flag to class metadata
With this flag we can distinguish enum classes that have `entries`
property in the compiled bytecode (see `LanguageFeature.EnumEntries`).
This is needed to be able to understand in the frontend whether
`entries` can be called for that class. For Native and JS, this is
currently not possible even if the feature is enabled, but the class
was compiled with disabled feature.

^KT-53929 Fixed
2023-01-23 12:50:14 +01:00
Alexander.Likhachev 581bc89849 [IC] Introduce ICContext to simplify configuration propagation to caches
#KT-49785 In Progress
2023-01-17 22:15:56 +00:00
Alexander Likhachev 40a901caa1 [IC] Add unit tests for TransactionOutputsRegistrar
#KT-49785 In Progress
2023-01-17 22:15:55 +00:00
Alexander Likhachev 1f2eb4c9fe [IC] Add unit tests for CompilationTransaction
#KT-49785 In Progress
2023-01-17 22:15:54 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Pavel Kunyavskiy 17e9a6a781 [klib] Fix serialization of missing annotations
^KT-42490
^KT-44625
2022-12-20 20:06:51 +00:00
Aleksei.Cherepanov 26e7c29a91 [JPS] Rebuild module on facet change
The logic of detecting changes in Kotlin facets was changed from "Include selected fields" to "Include all compiler arguments and exclude selected". This will help to avoid multiple IC issues when new change-sensitive compiler arguments will be added

(#KTIJ-17137, #KT-51536, #KTIJ-17170, #KTIJ-17300, #KT-47983) Fixed

Merge-request: KT-MR-7455
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2022-10-26 09:45:27 +00:00
Aleksei.Cherepanov e0029b14ee Rebuild module on plugin classpaths change
Add another one reason for rebuild: if pluginClasspaths was changed or even its jar content, module will be marked for rebuild

Merge-request: KT-MR-5839
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2022-04-18 11:06:15 +00:00
Ilya Chernikov c4a29651b0 FIR IC: fix test with behavior different from non-tight cycle variants 2022-03-30 08:34:51 +00:00
Ilya Chernikov 5abdf93d3b IC: Add IC test with fix on rename file with only class inside
"fails" on JS and JPS tests - the IC logic there is less precise.
2022-03-30 08:32:17 +00:00
Evgeniy.Zhelenskiy 28bf83ceac [IR] Unite inline class and multi-field value class representation
#KT-1179
2022-03-24 11:38:43 +00:00
Evgeniy.Zhelenskiy 282ab398c6 [IR] Generify lowerings
#KT-1179
2022-03-24 11:38:42 +00:00
nataliya.valtman c38dd1c004 Fix unstable testIncrementalCompilationAfterCacheHit test 2022-03-14 20:08:14 +03:00
Anastasiya Shadrina d47cf315e7 [Metadata] Add context receivers to metadata.proto
[Tests] Add JvmVersionRequirementTest
2021-12-02 20:24:20 +03:00
Hung Nguyen 6bee7948e7 KT-45777: Don't compute snapshots for inaccessible classes
Also visit a class file with ASM once to extract all information we need
in advance, instead of visiting the class file each time some piece of
info is needed.
2021-11-30 13:59:14 +03:00
Hung Nguyen f52be5f471 KT-45777: Move classpath diffing to incremental Kotlin compiler (2/2)
as we need access to the lookup tracker to compute classpath changes
more efficiently and reduce the size of the saved classpath snapshot.

The previous commit only changed the files' paths, this
commit actually updates the files' contents.

Note that classpath snapshotting still happens in Gradle artifact
transforms. (However, the previous commit also moved the code for
classpath snapshotting together with the code for classpath diffing as
they are closely related.)
2021-11-30 13:59:13 +03:00
Hung Nguyen bd7c2ae6d7 KT-45777: Snapshot Java classes using ASM analysis directly
This is faster than the current approach which creates
`JavaClassDescriptor`s, converts them to protos, and then snapshots
these protos.

- Refactor unit tests to faciliate further changes
- moves test data to a directory that matches the tests' package name
- moves expected snapshots to a separate directory
- adds public and private fields/properties to sample class
- Compute changes between ASM-based Java class snapshots
- Don't collect members of an added Java class as changes
as it's enough to report the name of the added Java class as changed (we
also do that for added Kotlin classes and Kotlin/Java removed classes).
- Add unit tests for impact analysis in advance
- Compute impacted symbols of changed symbols
Also do not collect added classes/class members as they don't impact
recompilation.
-Use ClassId when computing Java class changes
It is more precise than JvmClassName, which can be ambiguous around the
`$` character (e.g., ClassId "com/example/A$B.C" and "com/example/A.B$C"
both have the same JvmClassName "com/example/A$B$C").
- Compute impacted set of changed symbols across Kotlin and Java
- Add unit tests for impact analysis across Kotlin and Java
- Compute supertypes of Kotlin classes during snapshotting
- Handle inner classes when computing list of changed symbols.
For the reported symbols, always check all options:
class member, inner class, top level class, top level member.

Test: IncrementalJavaChangeClasspathSnapshotIT.testAddingInnerClass
2021-11-09 13:57:56 +03:00
Hung Nguyen a342c81a9f KT-45777: Take snapshots and compute changes for Java classes
Create `JavaClassDescriptor`s for Java classes
Ignore anonymous and synthetic classes
as they can't impact recompilation.
Clean up handling of local and anonymous classes

Bug: KT-45777
Test: New JavaClassDescriptorCreatorTest
2021-09-01 13:29:17 +03:00
Alexander Udalov 8b44b69982 Minor, add definitelyNonNull type flag in metadata as a comment 2021-08-24 12:28:31 +02:00
pyos 6a3c79bb9e JVM: support on-the-fly generation of property delegates in metadata
Optimizations may remove the `x$delegate` field, in which case there
should be a `getX$delegate` method to reconstruct the value if needed
due to a call to `KProperty{0,1,2}.getDelegate`. We need to know the
signature of this method somehow.
2021-07-12 22:38:43 +02:00
Vladimir Ivanov 61883ee878 Exclude kdoc related stuff from proto comparison in IC (#4283) 2021-04-07 17:16:06 +03:00
Ilya Chernikov f8d50d585d FIR: Implement lookup tracking 2021-03-24 21:24:18 +01:00
Ilya Chernikov 7d29ae7cce FIR: add incremental compilation tests 2021-03-24 21:24:18 +01:00
Alexander Udalov ea01c97a8e Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.
2021-03-23 11:45:22 +01:00
Alexander Udalov f350e9dacb Fix rendering of metadata of multifile facades in classFilesComparison.kt
Multifile facades (class files with header kind MULTIFILE_CLASS) have
the list of their parts in the d1 field (KotlinClassHeader.data), not
some byte-encoded protobuf message which this code was trying to
deserialize previously.
2021-01-28 13:19:27 +03:00
Roman Artemev 350ff8033d [IC KLIB] Replace JS IR build log with KLIB build log for klib compialtion
- fix test data
2021-01-26 19:23:25 +03:00
Roman Artemev 380225e0cb [KLIB IC] Support special klib-build.log in IC test infrastructure 2021-01-26 19:23:23 +03:00
Dmitriy Novozhilov af94bcebea [IDE] Propagate KotlinFacetSettings version and completely drop isReleaseCoroutines flag
Also this commit removes number of tests related to support
  experimental coroutines
2021-01-12 16:47:55 +03:00
nataliya.valtman e9669bf5cb fix unstable IncrementalFileToPathConverterTest tests 2020-10-28 12:33:03 +03:00
nataliya.valtman e1a380ec95 KT-34862 use relative path for incremental build cache 2020-10-27 10:45:06 +03:00
Mads Ager 8d791ca98e [IR] Update naming, but not binary format for IrSetValue. 2020-10-06 21:47:29 +02:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00