[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 +1 @@
fun foo0() = 42
fun foo0() = 42
@@ -1 +1 @@
fun foo1() = 24
fun foo1() = 24
@@ -1,7 +1,5 @@
STEP 0:
dependencies: stdlib
dirty: l1_0.kt, l1_1.kt
added file: l1_0.kt, l1_1.kt
STEP 1:
dependencies: stdlib
modifications:
D : l1_1.kt
@@ -1,2 +1 @@
fun qux0() = foo0()
fun qux0() = foo0()
@@ -1,2 +1 @@
fun qux1() = foo1()
fun qux1() = foo1()
@@ -1,7 +1,7 @@
STEP 0:
dependencies: stdlib, lib1
dirty: l2_0.kt, l2_1.kt
dependencies: lib1
added file: l2_0.kt, l2_1.kt
STEP 1:
dependencies: stdlib, lib1
dependencies: lib1
modifications:
D : l2_1.kt
@@ -1,4 +1,3 @@
fun box(): String {
if (qux0() != 42) return "Fail"
if (qux1() != 24) return "Fail"
@@ -1,4 +1,3 @@
fun box(): String {
if (qux0() != 42) return "Fail"
return "OK"
@@ -1,8 +1,8 @@
STEP 0:
dependencies: stdlib, lib1, lib2
dirty: m.kt
dependencies: lib1, lib2
added file: m.kt
STEP 1:
dependencies: stdlib, lib1, lib2
dependencies: lib1, lib2
modifications:
U : m.kt.new -> m.kt
dirty: m.kt
U : m.new.kt -> m.kt
modified ir: m.kt
@@ -1,8 +1,5 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
dirty js: stdlib, lib1, lib2, main
STEP 1:
STEP 0..1:
libs: lib1, lib2, main
dirty js: lib1, lib2, main