Commit Graph

374 Commits

Author SHA1 Message Date
Alexander Udalov d50cf81e42 Remove tests on incremental compilation with old JVM backend
#KT-48532 Fixed
2022-09-16 00:16:31 +02:00
Alexander Korepanov 09add47777 [JS IR] Trigger klib rebuild after removing a dependency
^KT-50503 Fixed
2022-09-15 10:56:41 +00:00
Vladimir Sukharev c8864369fd Use main class as test generator name
Merge-request: KT-MR-7031
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-09-09 12:51:18 +00:00
Nikita Bobko 2a4f3f41aa 2/5 Replace source dependency on kotlin-reflect with binary dependency
Review: https://jetbrains.team/p/kt/reviews/6753

Meaningful semantic change was splitted into 5 commits to simplify the
change review. Sinle commit would be too big.

Why replace source to binary: to get rid of kotlin-reflect in Kotlin
plugin artifact KTIJ-22276

Note: Kotlin Maven artifacts (./gradlew publish) changed their
dependency on kotlin-reflect
2022-08-22 15:43:49 +02:00
Hung Nguyen bd085495bd New IC: Add tests for constants-in-companion-objects impact computation
^KT-53266 Fixed
2022-08-11 16:01:26 +02:00
Hung Nguyen 2ad047340f New IC: Add constants-in-companion-objects impact computation
When computing impacted symbols of changed symbols, previously we
considered only the supertypes-inheritors type of impact, which is the
most common type. This commit adds the constants-in-companion-objects
type of impact to address KT-53266.

We've also cleaned up impact computation to make it easier to add new
types of impact in the future.

^KT-53266 In progress
2022-08-11 16:01:25 +02:00
Hung Nguyen 3f0a93d6dd New IC: Reorganize test data directories
to make it easier to add new tests

^KT-53266 In progress
2022-08-11 16:01:24 +02:00
Dmitry Gridin 4ceb170917 regenerate tests 2022-08-05 14:12:41 +02:00
Hung Nguyen 98349411fb Always compile non-incrementally if incremental state is missing
Test: Updated IncrementalCompilationClasspathSnapshotJvmMultiProjectIT.
        .testMissingIncrementalState

^KT-53231 Fixed
2022-08-05 07:45:24 +00:00
Hung Nguyen e006a7af57 Shrink snapshots non-incrementally after fallback
If incremental compilation fails, we currently fall back to
non-incremental compilation. When that happens, it would be incorrect to
shrink classpath snapshot incrementally, so this commit makes sure we'll
shrink classpath snapshot non-incrementally in that case.

^KT-53231 In progress
2022-08-05 07:45:22 +00:00
Mikhail Glukhikh 9add6f3d55 K2: add more accurate & more automatic control of diagnostic suppression
#KT-51363 Fixed
2022-07-22 11:35:26 +00:00
Dmitriy Novozhilov 928416c9c5 [CLI] Introduce new compiler arguments for registering compiler plugins
With new syntax each plugin should be registered in separate argument with syntax
`-Xcompiler-plugin=classpath1,classpath2[=argument1=value1,argument2=value2]`
2022-07-20 09:07:26 +00:00
Hung Nguyen 5b6afef67d Rename ICReporter.report/reportVerbose to info/debug
to make it clear what severity levels they are mapped to.

^KT-52839 Fixed
2022-07-15 10:48:34 +00:00
Hung Nguyen e01c2bc651 Warn in Gradle log when incremental compilation fails
When incremental compilation fails, we currently log it at the `debug`
level (and fall back to non-incremental compilation). This commit will
change it to `warning` so that we can get more user reports, which will
allow us to fix the root cause.

Also make sure the warning includes a stack trace.

Additionally, let ReportSeverity.fromCode() return a non-null value
or throw an exception otherwise as that case is not expected.

^KT-52839 In Progress
2022-07-15 10:48:34 +00:00
Alexander Likhachev 5cae57cf28 [IC] Flush incremental caches on close
#KT-53168 Fixed
2022-07-14 12:55:30 +00:00
Aleksei.Cherepanov 0950205a47 [IC] Add test for lookups flushing
#KT-53168
2022-07-14 12:55:29 +00:00
Alexander Likhachev 18560db373 [IC] Remove unused variable declaration
Previously it was introduced to make `when` exhaustive, but now all the `when` operators on enums are exhaustive
2022-07-13 19:40:47 +00:00
Mikhail Glukhikh 7bbd8d3b95 FIR2IR entry points: don't create JvmDescriptorMangler if not needed 2022-07-13 13:11:49 +00:00
Andrey Uskov 5ba3053e00 [IC] Do not report recompilation of non-existing files 2022-07-12 05:53:10 +00:00
Andrey Uskov 0b7244280f Disable expect-actual tests for fir
FIR currently does not support MPP, thus IC tests involving expect-
actuals, should be disabled.
2022-07-12 05:53:10 +00:00
Andrey Uskov 318d955d64 [IC] Add tests for sealed classes (KT-45474) 2022-07-12 05:53:09 +00:00
Andrey Uskov 21e762458e [IC] Fixed IC for when expressions involving sealed interfaces
#KT-45474 Fixed
2022-07-12 05:53:09 +00:00
Mikhail Glukhikh 45eb9238b3 Fir2IrClassifierStorage: don't calculate signature in registerClass 2022-07-06 10:02:09 +00:00
Hung Nguyen 46c769deb6 [IC] Fix fallback logic in IncrementalCompilerRunner
The current logic works as follows:
- Try either incremental compilation or non-incremental compilation
- If the above (or any of its surrounding work) fails, fall back to
  non-incremental compilation

This means we may perform non-incremental compilation twice.

This commit will fix that logic so that we fall back to non-incremental
compilation only if *incremental compilation* fails.

A nice consequence of this change is that it also resolves the critical
bugs described at KT-52669 (which occur because the current logic is
flawed).

#KT-52669 Fixed
2022-06-28 12:47:11 +00:00
Alexander Udalov ec9d929532 Remove dependency of fir2ir:jvm-backend on backend.jvm.entrypoint
Extract JvmIrDeserializer(Impl), similarly to the existing
JvmIrSerializer(Impl). Remove `allowErrorNodes` which is always false
anyway.
2022-06-13 12:35:51 +00:00
Hung Nguyen 08e6eb07c1 [New IC] Reduce memory usage of classpath snapshot cache
- Remove soft references that are too old.
 - Compute memory usage based on Runtime.totalMemory() instead of
   Runtime.maxMemory() as the latter is not reliable.
 - Remove debug logs that haven't proved to be useful.
 - Collect metrics on the number of cache hits (in addition to cache
   misses).

#KT-52329 In Progress

[New IC] Reduce memory usage of classpath snapshot cache

Use object interning for commonly shared objects. These include:
  - supertypes of classes
  - package names of classes

One experiment showed that with the above optimization, memory usage was
reduced from 660 MB down to 280 MB (+ 4 MB for the interning pool).

More aggressive object interning didn't reduce memory usage much
further, but would increase interning overhead and code complexity, so
we didn't do this to more objects.

Note that this commit optimizes the size of classpath snapshots in
memory, not their serialized data on disk. (I attempted the latter,
but the size was only reduced from 160 MB down to 130 MB, while the code
complexity became much higher as multiple interning pools would need to
be stored to disk and later loaded from disk, each per classpath entry
snapshot or shrunk classpath snapshot.)

#KT-52329 Fixed
2022-05-25 12:59:20 +03:00
Georgy Bronnikov ffe1615e9c Fir: simplify IrBuiltInsOverFir 2022-05-19 12:02:42 +02:00
Georgy Bronnikov e0c175bb50 Fir2Ir: remove symbolTable as separate component from FirResult
It's already in components.
2022-05-19 12:02:41 +02:00
Georgy Bronnikov 13d4d60afa Fir2Ir: pass Fir2IrExtensions to backend 2022-05-19 12:02:41 +02:00
nataliya.valtman dcdd1cd14e KT-49780 Do not clean outputs after cache corruption 2022-05-17 08:47:23 +00:00
Simon Ogorodnik 58885a1b07 KT-52217 Rename 'use-fir' to 'use-k2', update message 2022-04-28 15:42:42 +00:00
Hung Nguyen 9eb3c7ed76 [New IC] Optimize Java class snapshotting with ASM ClassWriter
To snapshot a Java class (+ its fields and methods), previously we used
Gson to serialize a class field/method to a string via reflection, and
hash that string.

We now use an ASM ClassWriter to write a placeholder class containing
the field/method of interest and hash the bytecode of that class.

One experiment showed that this new approach is ~10 times faster than
the previous approach (140s down to 16s when snapshotting 600 jars).

Test: Updated expectation files for JavaClassSnapshotterTest unit tests
      + Existing integration tests to prevent regression

^KT-52141 In Progress
2022-04-27 15:26:26 +00:00
Hung Nguyen 6d3e679a59 Implement cache eviction for classpath snapshot cache
Implement an in-memory cache that uses a combination of strong
references and `SoftReference`s so that it adapts to memory
availability.

Cache eviction is currently performed after loading a classpath snapshot
(this can be changed later if necessary).

Evicted cache entries' values will be converted from strong references
into `SoftReference`s so that they can still be used for as long as the
JVM allows them.

There are 2 types of cache eviction:
  - Least recently used: Oldest entries will be evicted
  - Memory usage limit: If memory is limited, all entries will be
    evicted

Test: Added InMemoryCacheWithEvictionTest unit test

^KT-51978 In Progress
2022-04-21 17:34:01 +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 f2ddac3ece IC: Adopt IC compilation for case then runCompiler adds some dirty files
as it is the case for Fir IC compilation.
2022-03-30 08:34:44 +00:00
Ilya Chernikov 03cbfea737 FIR LT: Introduce source file abstraction, carry it from parsing to IR
along with source lines mapping, allows to "emulate" usage of the
PSI files which allows to extract source file and line mapping info
on every stage from source element.
It makes sense to use this mapping for the error reporting too.
2022-03-30 08:34:30 +00:00
Ilya Chernikov 973273c6c6 FIR CLI: count lines/files and report events to perfman 2022-03-30 08:33:11 +00:00
Ilya Chernikov f89765eb33 Make JDK classpath roots configuration explicit...
instead of relying on the "configuration files" parameter.
(in the process of migration from KotlinCoreEnvironment).
2022-03-30 08:32:56 +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
Ilya Chernikov 3220900abe FIR: add tests for IC with LT and new CLI pipeline 2022-03-30 08:32:10 +00:00
Ilya Chernikov a239f02a30 Add cli argumens for FIR "tight" IC and LightTree usage 2022-03-30 08:32:03 +00:00
Ilya Chernikov 9e32188938 FIR LT: add syntax error reporting to LT2Fir
use it in the new pipeline
2022-03-30 08:31:56 +00:00
Ilya Chernikov 275135a1b2 FIR: extend cli pipeline with incremental compilation logic
use it in the IncrementalCompilationRunner
2022-03-30 08:31:10 +00:00
Hung Nguyen bd8f49c5d6 KT-45777: Count cache misses when loading classpath snapshot
to get more insights into the build performance of that step.

^KT-45777 In Progress
2022-03-29 11:36:41 +00:00
Hung Nguyen f23e66a6e2 KT-45777: Replace EmptyICReporter with DoNothingICReporter
to be more consistent (every *Reporter has a DoNothing*Reporter).

^KT-45777 In Progress
2022-03-29 11:36:41 +00:00
Hung Nguyen d70dbf3146 KT-45777: Add debug log messages for classpath snapshot feature
Also clean up classpath snapshot shrinking a bit to make it clearer.

^KT-45777 In Progress
2022-03-29 11:36:40 +00:00
nataliya.valtman c38dd1c004 Fix unstable testIncrementalCompilationAfterCacheHit test 2022-03-14 20:08:14 +03:00
Ilya Chernikov aa0386276d Fix FIR incremental compilation failure with inlines and lambdas
#KT-51546 fixed
2022-03-14 13:37:50 +03:00
Hung Nguyen 5f1cf34c79 KT-45777: Take coarse-grained snapshots of external libraries
to reduce the size of the snapshots.

- Track metrics for Gradle classpath snapshot artifact transform
- Format size metrics so it's more readable

^KT-45777 In Progress
2022-03-11 17:44:25 +01:00
Hung Nguyen aaef41cf64 KT-45777: Clean up handling around LookupSymbols and ProgramSymbols
Make it clearer and more efficient.

^KT-45777 In Progress
2022-03-07 19:05:09 +03:00