[JS IR] Perform optimizations on the generated JS code
The patch adopts and reuses the optimizations from the legacy backend. The optimizations remove useless temporary variables, statements and simplify generated JS code. The optimizations can be disabled by `-Xoptimize-generated-js=false`. Related to KT-51139
This commit is contained in:
committed by
Space Team
parent
84b5af3c89
commit
79d378f2bd
@@ -37,12 +37,9 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:19 box
|
||||
// test.kt:12 foo
|
||||
// test.kt:6 alternate
|
||||
// test.kt:7 alternate
|
||||
// test.kt:12 foo
|
||||
// test.kt:6 alternate
|
||||
// test.kt:7 alternate
|
||||
// test.kt:13 foo
|
||||
// test.kt:16 foo
|
||||
// test.kt:20 box
|
||||
// test.kt:20 box
|
||||
|
||||
+1
-2
@@ -32,5 +32,4 @@ fun box() {
|
||||
// test.kt:3 <init>
|
||||
// test.kt:11 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 box
|
||||
// test.kt:15 box
|
||||
// test.kt:15 box
|
||||
|
||||
+1
-4
@@ -36,7 +36,4 @@ fun box() {
|
||||
// test.kt:4 foo
|
||||
// test.kt:11 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 box
|
||||
// test.kt:13 box
|
||||
// test.kt:5 box
|
||||
// test.kt:15 box
|
||||
// test.kt:15 box
|
||||
|
||||
+1
-3
@@ -82,7 +82,6 @@ fun box() {
|
||||
// test.kt:16 box
|
||||
// test.kt:1 toString
|
||||
// test.kt:17 box
|
||||
// test.kt:17 box
|
||||
// test.kt:1 component1
|
||||
// test.kt:17 box
|
||||
// test.kt:1 component2
|
||||
@@ -108,7 +107,6 @@ fun box() {
|
||||
// test.kt:22 box
|
||||
// test.kt:6 toString
|
||||
// test.kt:23 box
|
||||
// test.kt:23 box
|
||||
// test.kt:1 component1
|
||||
// test.kt:23 box
|
||||
// test.kt:1 component2
|
||||
@@ -117,4 +115,4 @@ fun box() {
|
||||
// test.kt:5 <init>
|
||||
// test.kt:5 <init>
|
||||
// test.kt:5 <init>
|
||||
// test.kt:25 box
|
||||
// test.kt:25 box
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ inline fun getB(): Int {
|
||||
// test.kt:8 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:14 box
|
||||
// test.kt:4 box
|
||||
// test.kt:11 getA
|
||||
// test.kt:14 box
|
||||
// test.kt:8 box
|
||||
|
||||
+1
-7
@@ -40,13 +40,7 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:20 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:21 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:22 box
|
||||
// test.kt:22 box
|
||||
|
||||
@@ -56,23 +56,12 @@ fun nop() {}
|
||||
// test.kt:21 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:24 box
|
||||
// test.kt:3 box
|
||||
// test.kt:4 box
|
||||
// test.kt:30 nop
|
||||
// test.kt:24 box
|
||||
// test.kt:8 box
|
||||
// test.kt:28 box
|
||||
// test.kt:8 box
|
||||
// test.kt:24 box
|
||||
// test.kt:9 box
|
||||
// test.kt:7 box
|
||||
// test.kt:11 box
|
||||
// test.kt:30 nop
|
||||
// test.kt:24 box
|
||||
// test.kt:16 box
|
||||
// test.kt:27 box
|
||||
// test.kt:14 box
|
||||
// test.kt:19 box
|
||||
// test.kt:30 nop
|
||||
// test.kt:21 box
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ inline fun foo() = {
|
||||
// test.kt:6 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test1.kt:10 box
|
||||
// test.kt:5 box
|
||||
// test1.kt:9 box
|
||||
// test1.kt:7 box$lambda
|
||||
// test.kt:6 box
|
||||
|
||||
+1
-2
@@ -26,8 +26,7 @@ inline fun foo() = {
|
||||
// test.kt:7 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test1.kt:11 box
|
||||
// test.kt:5 box
|
||||
// test1.kt:10 box
|
||||
// test.kt:6 box
|
||||
// test1.kt:8 box$lambda
|
||||
// test.kt:7 box
|
||||
|
||||
+1
-2
@@ -44,8 +44,7 @@ fun baz(v:(() -> Unit)) {
|
||||
// test3.kt:15 baz
|
||||
// test1.kt:9 box$lambda
|
||||
// test3.kt:16 baz
|
||||
// test1.kt:12 box
|
||||
// test.kt:6 box
|
||||
// test1.kt:11 box
|
||||
// test.kt:7 box
|
||||
// test3.kt:15 baz
|
||||
// test1.kt:9 box$lambda
|
||||
|
||||
@@ -25,8 +25,4 @@ fun box(): String {
|
||||
// test.kt:13 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:8 box
|
||||
// test.kt:4 box
|
||||
// test.kt:10 box
|
||||
// test.kt:4 box
|
||||
// test.kt:13 box
|
||||
|
||||
@@ -30,8 +30,4 @@ fun box(): String {
|
||||
// test.kt:16 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:2 box
|
||||
// test.kt:3 box
|
||||
// test.kt:7 box
|
||||
// test.kt:10 box
|
||||
// test.kt:16 box
|
||||
|
||||
@@ -69,8 +69,5 @@ inline fun html(init: () -> Unit) {
|
||||
// 1.kt:33 box
|
||||
// 1.kt:36 box
|
||||
// 1.kt:37 box
|
||||
// 1.kt:37 box
|
||||
// 1.kt:41 box
|
||||
// test.kt:15 box
|
||||
// test.kt:19 box
|
||||
// test.kt:21 box
|
||||
|
||||
@@ -23,6 +23,5 @@ inline fun lookAtMe(f: () -> Int) {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:11 box
|
||||
// test.kt:6 box
|
||||
// test.kt:12 box
|
||||
// test.kt:8 box
|
||||
|
||||
@@ -26,5 +26,4 @@ fun box(): String {
|
||||
// test.kt:14 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:5 box
|
||||
// test.kt:14 box
|
||||
// test.kt:14 box
|
||||
|
||||
@@ -38,6 +38,4 @@ fun box(): String {
|
||||
// test.kt:10 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:3 box
|
||||
// test.kt:5 box
|
||||
// test.kt:6 box
|
||||
// test.kt:10 box
|
||||
|
||||
@@ -38,14 +38,12 @@ fun fail() : String {
|
||||
// test.kt:9 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:16 box
|
||||
// test.kt:4 box
|
||||
// test.kt:20 fail
|
||||
// test.kt:4 box
|
||||
// test.kt:13 checkEquals
|
||||
// test.kt:7 box
|
||||
// test.kt:20 fail
|
||||
// test.kt:16 box
|
||||
// test.kt:7 box
|
||||
// test.kt:13 checkEquals
|
||||
// test.kt:9 box
|
||||
|
||||
@@ -36,14 +36,12 @@ fun fail() : String {
|
||||
// test.kt:11 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:14 box
|
||||
// test.kt:6 box
|
||||
// test.kt:18 fail
|
||||
// test.kt:6 box
|
||||
// test.kt:3 execute
|
||||
// test.kt:9 box
|
||||
// test.kt:18 fail
|
||||
// test.kt:14 box
|
||||
// test.kt:9 box
|
||||
// test.kt:3 execute
|
||||
// test.kt:11 box
|
||||
|
||||
@@ -38,14 +38,8 @@ fun fail() : String {
|
||||
// test.kt:9 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:16 box
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:20 fail
|
||||
// test.kt:16 box
|
||||
// test.kt:7 box
|
||||
// test.kt:20 fail
|
||||
// test.kt:16 box
|
||||
// test.kt:8 box
|
||||
// test.kt:16 box
|
||||
// test.kt:9 box
|
||||
|
||||
@@ -38,10 +38,8 @@ fun fail() : String {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:12 box
|
||||
// test.kt:4 box
|
||||
// test.kt:16 fail
|
||||
// test.kt:7 box
|
||||
// test.kt:16 fail
|
||||
// test.kt:12 box
|
||||
// test.kt:7 box
|
||||
// test.kt:9 box
|
||||
|
||||
@@ -117,9 +117,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:5 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:12 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:21 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
@@ -127,9 +125,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:6 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:13 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:22 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
@@ -137,9 +133,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:7 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:14 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
@@ -147,9 +141,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:8 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:15 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:18 stringSwitch
|
||||
// test.kt:24 stringSwitch
|
||||
// test.kt:26 stringSwitch
|
||||
|
||||
@@ -100,9 +100,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:5 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:11 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:19 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
@@ -110,9 +108,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:6 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:12 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:20 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
@@ -120,9 +116,7 @@ fun box() {
|
||||
// test.kt:4 stringSwitch
|
||||
// test.kt:7 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:10 stringSwitch
|
||||
// test.kt:13 stringSwitch
|
||||
// test.kt:17 stringSwitch
|
||||
// test.kt:16 stringSwitch
|
||||
// test.kt:21 stringSwitch
|
||||
// test.kt:23 stringSwitch
|
||||
|
||||
@@ -26,7 +26,7 @@ suspend fun box() {
|
||||
// test.kt:9 doResume
|
||||
// test.kt:9 box$slambda
|
||||
// test.kt:9 doResume
|
||||
// test.kt:5 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:10 doResume
|
||||
// test.kt:12 doResume
|
||||
|
||||
@@ -18,6 +18,4 @@ fun box(): String {
|
||||
// test.kt:8 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:6 box
|
||||
// test.kt:8 box
|
||||
|
||||
@@ -52,18 +52,13 @@ fun box() {
|
||||
// test.kt:16 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:17 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:7 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:18 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:19 box
|
||||
|
||||
@@ -24,5 +24,4 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:4 box
|
||||
// test.kt:12 box
|
||||
|
||||
+1
-2
@@ -26,5 +26,4 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 box
|
||||
// test.kt:16 box
|
||||
|
||||
@@ -39,15 +39,9 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:15 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:16 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:18 box
|
||||
|
||||
@@ -58,22 +58,16 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:26 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:27 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:22 foo
|
||||
// test.kt:28 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:22 foo
|
||||
|
||||
@@ -26,5 +26,4 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 box
|
||||
|
||||
-14
@@ -73,24 +73,17 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:18 box
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
@@ -98,24 +91,17 @@ fun box() {
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:11 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:6 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:10 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:10 foo
|
||||
|
||||
@@ -122,50 +122,36 @@ fun box() {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:22 box
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:7 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:16 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:15 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:8 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:19 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:16 foo
|
||||
// test.kt:5 foo
|
||||
// test.kt:4 foo
|
||||
// test.kt:13 foo
|
||||
// test.kt:12 foo
|
||||
// test.kt:17 foo
|
||||
// test.kt:12 foo
|
||||
|
||||
@@ -73,27 +73,15 @@ fun nop() {}
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:3 box
|
||||
// test.kt:19 value
|
||||
// test.kt:4 box
|
||||
// test.kt:20 box
|
||||
// test.kt:5 box
|
||||
// test.kt:21 box
|
||||
// test.kt:6 box
|
||||
// test.kt:22 box
|
||||
// test.kt:7 box
|
||||
// test.kt:7 box
|
||||
// test.kt:28 nop
|
||||
// test.kt:20 box
|
||||
// test.kt:12 box
|
||||
// test.kt:21 box
|
||||
// test.kt:12 box
|
||||
// test.kt:20 box
|
||||
// test.kt:13 box
|
||||
// test.kt:26 box
|
||||
// test.kt:13 box
|
||||
// test.kt:21 box
|
||||
// test.kt:14 box
|
||||
// test.kt:25 box
|
||||
// test.kt:14 box
|
||||
// test.kt:14 box
|
||||
// test.kt:28 nop
|
||||
// test.kt:17 box
|
||||
// test.kt:17 box
|
||||
|
||||
Reference in New Issue
Block a user