Commit Graph

9 Commits

Author SHA1 Message Date
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 d2193f3873 KT-45777: Allow 2 levels of granularity when tracking changes
1. CLASS_LEVEL: allows tracking whether a .class file has changed
     without tracking what specific parts of the .class file (e.g.,
     fields or methods) have changed.

  2. CLASS_MEMBER_LEVEL: allows tracking not only whether a .class file
     has changed but also what specific parts of the .class file (e.g.,
     fields or methods) have changed.

 The idea is that for better performance we will use CLASS_LEVEL for
 classpath entries that are usually unchanged, and CLASS_MEMBER_LEVEL
 for classpath entries that are frequently changed. We'll work out the
 specifics in a following commit after some measurements.

Support running kotlinc on Windows in ClasspathSnapshotTestCommon
Also add tests for different Kotlin class kinds.
Add unit tests for CLASS_LEVEL snapshotting and diffing

Test: Updated ClasspathSnapshotterTest + ClasspathChangesComputerTest
Add ClasspathChangesComputerTest.testMixedClassSnapshotGranularities
2022-02-17 10:46:19 +03:00
Hung Nguyen 9a995af0df KT-44741: Improve handling of constants defined in companion objects 2021-12-24 18:31:49 +03:00
Hung Nguyen a900f2b66d KT-45777: Reorganize unit test data for classpath snapshot feature
to make it easier to add more tests in the next commits.

- Add unit tests for constants and inline functions

Also add tests for different kinds of Kotlin classes: CLASS,
FILE_FACADE, MULTIFILE_CLASS.

-Add unit test for nested classes

Also remove the existing integration test for nested classes to keep the
integration tests focused on the key scenarios while unit tests will
cover the corner cases.

Ignore inline functions that are private
2021-12-24 18:31:49 +03:00
Hung Nguyen 586fa8af64 KT-45777: Shrink classpath snapshot incrementally
Currently, we shrink classpath snapshots at 2 steps:
  - Classpath diffing: Shrink the current classpath snapshot against
    the previous lookup symbols
  - Classpath snapshot saving: Shrink the current classpath snapshot
    against the current lookup symbols

With this commit, the shrinking at the second step is now incremental.
The shrinking at the first step is still non-incremental.
2021-12-14 13:10:08 +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 dfaf195e1d KT-45777: Move classpath diffing to incremental Kotlin compiler (1/2)
This commit only changes the files' paths, the next commit will update
the files' contents.

See the next commit for more context.
2021-11-30 13:59:12 +03:00
Alexey Tsvetkov c1812d7d92 Move IC tests to compiler
Fixing IC after moving it from Gradle to the compiler in commit f40a3eff20
2016-12-19 22:55:19 +03:00