[JS IR] Update IC depends graph after intrinsics loading

- Remove unused params from compilerWithIC wrapper.
- Move JsIrBackendContext creation logic into separate function
- Introduce and use compiler interface for IC infrastructure

On dirty rebuild we may reload IR from stdlib,
such reloading may affect files with intrinsics and builtins.
As soon as we load only exported symbols, we must track dependencies
for files with intrinsics or builtins as for others.
This patch implements the logic which updates dependencies for
the stdlib files after loading of intrinsics and builtins.

^KT-54323 Fixed
This commit is contained in:
Alexander Korepanov
2022-10-12 22:14:15 +00:00
committed by Space Team
parent 31ba1f1534
commit 7b2c125754
40 changed files with 628 additions and 170 deletions
@@ -0,0 +1,13 @@
class TestClass1 {
enum class TestEnum {
A, B
}
}
inline fun foo1(): List<Enum<*>> {
return TestClass1.TestEnum.values().toList()
}
inline fun foo2(): List<Enum<*>> {
return emptyList()
}
@@ -0,0 +1,23 @@
class TestClass1 {
enum class TestEnum {
A, B
}
}
class TestClass2 {
enum class TestEnum {
A, B, C
}
}
inline fun foo1(): List<Enum<*>> {
return TestClass1.TestEnum.values().toList()
}
inline fun foo2(): List<Enum<*>> {
return TestClass2.TestEnum.values().toList()
}
inline fun foo3(): List<Enum<*>> {
return emptyList()
}
@@ -0,0 +1,23 @@
class TestClass1 {
enum class TestEnum {
A, B
}
}
class TestClass3 {
enum class TestEnum {
A
}
}
inline fun foo1(): List<Enum<*>> {
return TestClass1.TestEnum.values().toList()
}
inline fun foo2(): List<Enum<*>> {
return emptyList()
}
inline fun foo3(): List<Enum<*>> {
return TestClass3.TestEnum.values().toList()
}
@@ -0,0 +1,11 @@
inline fun foo1(): List<Enum<*>> {
return emptyList()
}
inline fun foo2(): List<Enum<*>> {
return emptyList()
}
inline fun foo3(): List<Enum<*>> {
return emptyList()
}
@@ -0,0 +1,18 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
STEP 3:
updated exports: l1.kt
STEP 4:
modifications:
U : l1.4.kt -> l1.kt
modified ir: l1.kt
@@ -0,0 +1,12 @@
class TestClass100 {
enum class TestEnum {
A, B
}
}
fun testEnums(): List<Enum<*>> {
val enums1 = foo1()
val enums2 = foo2()
return TestClass100.TestEnum.values().toList() + enums1 + enums2
}
@@ -0,0 +1,12 @@
class TestClass2 {
enum class TestEnum {
A, B
}
}
fun testEnums(): List<Enum<*>> {
val enums1 = foo1()
val enums3 = foo3()
return TestClass2.TestEnum.values().toList() + enums1 + enums3
}
@@ -0,0 +1,19 @@
STEP 0:
dependencies: lib1
modifications:
U : l2.0.kt -> l2.kt
added file: l2.kt
STEP 1:
dependencies: lib1
updated imports: l2.kt
STEP 2:
dependencies: lib1
updated imports: l2.kt
STEP 3:
dependencies: lib1
modifications:
U : l2.3.kt -> l2.kt
modified ir: l2.kt
STEP 4:
dependencies: lib1
updated imports: l2.kt
@@ -0,0 +1,27 @@
fun box(stepId: Int): String {
val enums = testEnums()
when (stepId) {
0 -> if (enums.toString() != "[A, B, A, B]") return "Fail, got $enums"
1 -> if (enums.toString() != "[A, B, A, B, A, B, C]") return "Fail, got $enums"
2 -> if (enums.toString() != "[A, B, A, B]") return "Fail, got $enums"
3 -> if (enums.toString() != "[A, B, A, B, A]") return "Fail, got $enums"
4 -> if (enums.toString() != "[A, B]") return "Fail, got $enums"
else -> return "Unknown"
}
for (i1 in 0..enums.size - 1) {
for (i2 in 0..enums.size - 1) {
if (i1 == i2) {
continue
}
if (enums[i1] == enums[i2]) {
return "Fail eq2"
}
if (enums[i1] === enums[i2]) {
return "Fail eq3"
}
}
}
return "OK"
}
@@ -0,0 +1,5 @@
STEP 0:
dependencies: lib1, lib2
added file: m.kt
STEP 1..4:
dependencies: lib1, lib2
@@ -0,0 +1,5 @@
MODULES: lib1, lib2, main
STEP 0..4:
libs: lib1, lib2, main
dirty js: lib1, lib2, main