[IR] Support const optimizations for JS backend

This commit is contained in:
Ivan Kylchik
2023-05-29 00:19:47 +02:00
committed by Space Team
parent abbafc0b2a
commit d3d28783c5
22 changed files with 292 additions and 32 deletions
@@ -1,6 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6
// WITH_STDLIB
fun <T> T.id() = this
@@ -1,6 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6
// WITH_STDLIB
fun <T> T.id() = this
@@ -1,6 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6
fun <T> T.id() = this
enum class EnumClass {
@@ -1,5 +1,6 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
fun <T> T.id() = this
@@ -1,5 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
fun <T> T.id() = this
const val trueVal = <!EVALUATED("true")!>true<!>
@@ -1,6 +1,8 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6
fun <T> T.id() = this
class A(val OK: Int, val somePropertyWithLongName: String) {
@@ -1,15 +1,18 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
// WITH_STDLIB
fun <T> T.id() = this
fun someSideEffect(value: Any?) = {}
class A {
val a = ""
fun b() = ""
init {
println("A init")
someSideEffect("A init")
}
fun test() {
@@ -1,6 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6
// FILE: 1.kt
@@ -1,5 +1,7 @@
// !LANGUAGE: +IntrinsicConstEvaluation
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
var result = "Fail"
object O {