[JS IR] Rework incremental cache invalidation

Replace loading the whole world IR with loading only exported (reachable) IR.

 For that purpose the direct and inverse dependency graph is used.
 It is stored in a cache directory and the cache updater keeps it up to date.
 If after loading it is found that other files must be also implicitly rebuilt
 (see rebuilt reasons below), IR for that files also will be loaded.
 This algorithm repeats until the number of implicitly rebuilt files is not 0.

 More rebuilt reasons (dirty state) have been added:
  - added file: this is a new file;
  - modified ir: ir of the file has been updated;
  - updated exports: exports from the file have been added or removed
    (e.g. a function has been used from another file);
  - updated inline imports: imported inline function has been modified
    (transitively);
  - removed inverse depends: a dependent file has been removed;
  - removed direct depends: a dependency file has been removed;
  - removed file: this file has been removed.

 Incremental cache tests has been refactored:
  - The supporting of all rebuilt reasons (dirty states) has been added;
  - New file name format "*.$suffix.kt" for the test steps has been allowed,
    so the syntax highlight works now;
  - Explicit stdlib dependency usage has been removed.
This commit is contained in:
Alexander Korepanov
2022-05-04 11:56:25 +03:00
committed by Space
parent f003f19e1d
commit 9e780afdca
439 changed files with 2904 additions and 1988 deletions
@@ -0,0 +1,3 @@
fun f1() = "${f1_1()} ${f2_1()} ${f3_1()}"
fun f2() = "empty"
@@ -0,0 +1,3 @@
fun f1() = "${f1_1()} ${f2_1()} ${f3_1()}"
fun f2() = f1_2()
@@ -0,0 +1,7 @@
fun f1_1() = "f1_1"
fun f1_2() = f2_2()
fun f1_3() = f2_3()
fun f1_4() = "something"
@@ -0,0 +1,5 @@
fun f2_1() = "f2_1"
fun f2_2() = f3_2()
fun f2_3() = f3_3()
@@ -0,0 +1,5 @@
fun f3_1() = "f3_1"
fun f3_2() = f1_3()
fun f3_3() = f1_4()
@@ -0,0 +1,19 @@
STEP 0:
modifications:
U : f.0.kt -> f.kt
added file: f.kt, f1.kt, f2.kt, f3.kt
STEP 1:
modifications:
U : f.1.kt -> f.kt
modified ir: f.kt
updated exports: f1.kt, f2.kt, f3.kt
STEP 2:
modifications:
U : f.0.kt -> f.kt
modified ir: f.kt
updated exports: f1.kt, f2.kt, f3.kt
STEP 3:
modifications:
U : f.1.kt -> f.kt
modified ir: f.kt
updated exports: f1.kt, f2.kt, f3.kt
@@ -0,0 +1,14 @@
fun box(stepId: Int): String {
when (stepId) {
0, 2 -> {
if (f1() != "f1_1 f2_1 f3_1") return "Fail f1"
if (f2() != "empty") return "Fail f2"
}
1, 3 -> {
if (f1() != "f1_1 f2_1 f3_1") return "Fail f1"
if (f2() != "something") return "Fail f2"
}
else -> return "Unknown"
}
return "OK"
}
@@ -0,0 +1,5 @@
STEP 0:
dependencies: lib1
added file: m.kt
STEP 1..3:
dependencies: lib1
@@ -0,0 +1,8 @@
MODULES: lib1, main
STEP 0:
libs: lib1, main
dirty js: lib1, main
STEP 1..3:
libs: lib1, main
dirty js: lib1