[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
@@ -1,2 +1 @@
inline fun foo(a: Int) = a * 2
@@ -1,2 +1 @@
inline fun bar(b: Int) = b - 3
inline fun bar(b: Int) = b - 3
@@ -0,0 +1 @@
inline fun bar(b: Int) = b - 5
@@ -1,2 +0,0 @@
inline fun bar(b: Int) = b - 5
@@ -1,13 +1,10 @@
STEP 0:
dependencies: stdlib
dirty: l11.kt, l12.kt
added file: l11.kt, l12.kt
STEP 1:
dependencies: stdlib
modifications:
D : l12.kt
STEP 2:
dependencies: stdlib
modifications:
U : l12_n.kt.2 -> l12_n.kt
dirty: l12_n.kt
U : l12_n.2.kt -> l12_n.kt
added file: l12_n.kt
@@ -1,2 +1 @@
inline fun qux(x: Int, y: Int) = foo(x) + bar(y)
inline fun qux(x: Int, y: Int) = foo(x) + bar(y)
@@ -0,0 +1 @@
inline fun bar(b: Int) = b - 4
@@ -1,2 +0,0 @@
inline fun bar(b: Int) = b - 4
@@ -1,13 +1,14 @@
STEP 0:
dependencies: stdlib, lib1
dirty: l21.kt
dependencies: lib1
added file: l21.kt
STEP 1:
dependencies: stdlib, lib1
dependencies: lib1
modifications:
U : l22.kt.1 -> l22.kt
dirty: l21.kt, l22.kt
U : l22.1.kt -> l22.kt
added file: l22.kt
removed direct depends: l21.kt
STEP 2:
dependencies: stdlib, lib1
dependencies: lib1
modifications:
D : l22.kt
dirty: l21.kt
removed direct depends: l21.kt
@@ -1,2 +1 @@
inline fun dex(x: Int, y: Int) = qux(x * y, y - x)
inline fun dex(x: Int, y: Int) = qux(x * y, y - x)
@@ -1,3 +1,6 @@
STEP 0..2:
dependencies: stdlib, lib1, lib2
dirty: l3.kt
STEP 0:
dependencies: lib1, lib2
added file: l3.kt
STEP 1..2:
dependencies: lib1, lib2
updated inline imports: l3.kt
@@ -1,4 +1,3 @@
fun box(stepId: Int): String {
when (stepId) {
0 -> if (dex(4, 2) != 11) return "Fail"
@@ -1,3 +1,6 @@
STEP 0..2:
dependencies: stdlib, lib1, lib2, lib3
dirty: m.kt
STEP 0:
dependencies: lib1, lib2, lib3
added file: m.kt
STEP 1..2:
dependencies: lib1, lib2, lib3
updated inline imports: m.kt
@@ -1,8 +1,5 @@
MODULES: lib1, lib2, lib3, main
STEP 0:
libs: lib1, lib2, lib3, main
dirty js: stdlib, lib1, lib2, lib3, main
STEP 1..2:
STEP 0..2:
libs: lib1, lib2, lib3, main
dirty js: lib1, lib2, lib3, main