[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
@@ -22,7 +22,6 @@ fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box:
|
||||
// test.kt:5 box: a=1:number
|
||||
// test.kt:5 box: a=1:number
|
||||
// test.kt:6 box: a=0:number
|
||||
// test.kt:7 box: a=0:number
|
||||
// test.kt:8 box: a=0:number
|
||||
|
||||
@@ -17,6 +17,5 @@ fun box(): String {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:5 box:
|
||||
// test.kt:7 box: p=kotlin.Pair
|
||||
// test.kt:7 box: p=kotlin.Pair
|
||||
// test.kt:7 box: p=kotlin.Pair, o="O":kotlin.String
|
||||
// test.kt:9 box: p=kotlin.Pair, o="O":kotlin.String, k="K":kotlin.String
|
||||
|
||||
-1
@@ -36,7 +36,6 @@ fun box(): String {
|
||||
// test.kt:2 <init>: x="X":kotlin.String, y="Y":kotlin.String
|
||||
// test.kt:2 <init>: x="X":kotlin.String, y="Y":kotlin.String
|
||||
// test.kt:14 box: p=MyPair
|
||||
// test.kt:14 box: p=MyPair
|
||||
// test.kt:4 component1:
|
||||
// test.kt:14 box: p=MyPair, o="O":kotlin.String
|
||||
// test.kt:8 component2:
|
||||
|
||||
Vendored
-1
@@ -44,7 +44,6 @@ fun box(): String {
|
||||
// test.kt:4 <init>: x="X":kotlin.String, y="Y":kotlin.String
|
||||
// test.kt:4 <init>: x="X":kotlin.String, y="Y":kotlin.String
|
||||
// test.kt:4 <init>: x="X":kotlin.String, y="Y":kotlin.String
|
||||
// test.kt:23 box: p=MyPair
|
||||
// test.kt:18 box: p=MyPair
|
||||
// test.kt:6 component1:
|
||||
// test.kt:20 box: p=MyPair, o="O":kotlin.String
|
||||
|
||||
@@ -30,7 +30,6 @@ fun box(): String {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:6 box:
|
||||
// test.kt:15 box: p=kotlin.Pair
|
||||
// test.kt:10 box: p=kotlin.Pair
|
||||
// test.kt:12 box: p=kotlin.Pair, o="O":kotlin.String
|
||||
// test.kt:17 box: p=kotlin.Pair, o="O":kotlin.String, k="K":kotlin.String
|
||||
|
||||
-1
@@ -17,6 +17,5 @@ fun box(): String {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:5 box:
|
||||
// test.kt:7 box: p=kotlin.Triple
|
||||
// test.kt:7 box: p=kotlin.Triple
|
||||
// test.kt:7 box: p=kotlin.Triple, o="O":kotlin.String
|
||||
// test.kt:9 box: p=kotlin.Triple, o="O":kotlin.String, k="K":kotlin.String
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ fun box(): String {
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:6 box:
|
||||
// test.kt:17 box: p=kotlin.Triple
|
||||
// test.kt:12 box: p=kotlin.Triple
|
||||
// test.kt:14 box: p=kotlin.Triple, o="O":kotlin.String
|
||||
// test.kt:19 box: p=kotlin.Triple, o="O":kotlin.String, k="K":kotlin.String
|
||||
|
||||
@@ -20,9 +20,6 @@ fun box() {
|
||||
// test.kt:5 box:
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap, a="1":kotlin.String
|
||||
// test.kt:7 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
// test.kt:6 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
// test.kt:9 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
|
||||
@@ -43,9 +43,6 @@ fun box() {
|
||||
// test.kt:5 box:
|
||||
// test.kt:15 box: map=kotlin.collections.HashMap
|
||||
// test.kt:15 box: map=kotlin.collections.HashMap
|
||||
// test.kt:15 box: map=kotlin.collections.HashMap
|
||||
// test.kt:10 box: map=kotlin.collections.HashMap
|
||||
// test.kt:12 box: map=kotlin.collections.HashMap, a="1":kotlin.String
|
||||
// test.kt:18 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
// test.kt:15 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
// test.kt:20 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
// test.kt:20 box: map=kotlin.collections.HashMap, a="1":kotlin.String, b="23":kotlin.String
|
||||
|
||||
@@ -36,8 +36,7 @@ fun box() {
|
||||
// test.kt:5 box:
|
||||
// test.kt:11 box: map=kotlin.collections.HashMap
|
||||
// test.kt:11 box: map=kotlin.collections.HashMap
|
||||
// test.kt:11 box: map=kotlin.collections.HashMap
|
||||
// test.kt:14 box: map=kotlin.collections.HashMap, e=kotlin.collections.AbstractMutableMap.SimpleEntry
|
||||
// test.kt:14 box: map=kotlin.collections.HashMap, e=kotlin.collections.AbstractMutableMap.SimpleEntry
|
||||
// test.kt:11 box: map=kotlin.collections.HashMap, e=kotlin.collections.AbstractMutableMap.SimpleEntry
|
||||
// test.kt:16 box: map=kotlin.collections.HashMap, e=kotlin.collections.AbstractMutableMap.SimpleEntry
|
||||
// test.kt:16 box: map=kotlin.collections.HashMap, e=kotlin.collections.AbstractMutableMap.SimpleEntry
|
||||
|
||||
@@ -24,7 +24,5 @@ fun box() {
|
||||
// test.kt:8 box:
|
||||
// test.kt:2 <init>:
|
||||
// test.kt:4 box: a=A
|
||||
// test.kt:9 box: a=A
|
||||
// test.kt:10 box: a=A, y=1:number
|
||||
// test.kt:10 box: a=A, y=1:number
|
||||
// test.kt:11 box: a=A, y=2:number
|
||||
|
||||
+1
-2
@@ -81,8 +81,7 @@ fun box() {
|
||||
// a.kt:6 exclamate: s="Jesse":kotlin.String
|
||||
// test.kt:52 box: jesse="Jesse":kotlin.String, walter1="Walter!":kotlin.String, jesse1="Jesse!":kotlin.String
|
||||
// a.kt:6 exclamate: s="Jesse!":kotlin.String
|
||||
// a.kt:29 box: jesse="Jesse":kotlin.String, walter1="Walter!":kotlin.String, jesse1="Jesse!":kotlin.String
|
||||
// a.kt:22 value:
|
||||
// test.kt:63 box: jesse="Jesse":kotlin.String, walter1="Walter!":kotlin.String, jesse1="Jesse!":kotlin.String
|
||||
// test.kt:59 localFun: hello="hello":kotlin.String, world="world":kotlin.String
|
||||
// test.kt:64 box: jesse="Jesse":kotlin.String, walter1="Walter!":kotlin.String, jesse1="Jesse!":kotlin.String
|
||||
// test.kt:64 box: jesse="Jesse":kotlin.String, walter1="Walter!":kotlin.String, jesse1="Jesse!":kotlin.String
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ suspend fun box() {
|
||||
// test.kt:10 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:9 box: $completion=EmptyContinuation
|
||||
// test.kt:10 box: $completion=EmptyContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:9 box: $completion=EmptyContinuation
|
||||
// test.kt:5 foo: $completion=EmptyContinuation
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ suspend fun box() {
|
||||
// test.kt:15 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
// test.kt:15 box: $completion=EmptyContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ suspend fun box() {
|
||||
// test.kt:10 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:9 box: $completion=EmptyContinuation
|
||||
// test.kt:10 box: $completion=EmptyContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:9 box: $completion=EmptyContinuation
|
||||
// test.kt:6 foo: <this>=A, $completion=EmptyContinuation
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ suspend fun box() {
|
||||
// test.kt:13 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:12 box: $completion=EmptyContinuation
|
||||
// test.kt:13 box: $completion=EmptyContinuation
|
||||
// test.kt:12 box: $completion=EmptyContinuation
|
||||
// test.kt:6 doResume:
|
||||
// test.kt:4 foo: $completion=$foo1COROUTINE$0
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ suspend fun box() {
|
||||
// test.kt:15 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
// test.kt:15 box: $completion=EmptyContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
|
||||
@@ -42,7 +42,7 @@ suspend fun box() = foo(A()) { (x_param, _, y_param) ->
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:12 box: $completion=EmptyContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:12 box: $completion=EmptyContinuation
|
||||
// test.kt:14 box: $completion=EmptyContinuation
|
||||
// test.kt:12 box$slambda:
|
||||
// test.kt:12 box: $completion=EmptyContinuation
|
||||
// test.kt:10 foo: a=A, block=Function2, $completion=EmptyContinuation
|
||||
|
||||
@@ -66,7 +66,6 @@ fun box() {
|
||||
// test.kt:9 compute: y=42:number, i=0:number, z=32:number
|
||||
// test.kt:9 compute: y=42:number, i=0:number, z=32:number
|
||||
// test.kt:9 compute: y=42:number, i=0:number, z=32:number, j=0:number
|
||||
// test.kt:10 compute: y=42:number, i=0:number, z=32:number, j=0:number
|
||||
// test.kt:24 compute: y=42:number, i=0:number, z=32:number, j=0:number
|
||||
// test.kt:28 compute: y=42:number, i=0:number, z=32:number, j=0:number
|
||||
// test.kt:29 compute: y=42:number, i=0:number, z=32:number, j=0:number, s2="OK":kotlin.String
|
||||
|
||||
@@ -66,9 +66,6 @@ fun box() {
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:4 <init>: x=1:number
|
||||
// test.kt:4 <init>: x=1:number, y="":kotlin.String
|
||||
// test.kt:4 <init>: x=1:number, y="":kotlin.String, z=48:number
|
||||
@@ -78,7 +75,6 @@ fun box() {
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:8 <init properties test.kt>:
|
||||
// test.kt:12 box:
|
||||
// test.kt:4 <init>: x=1:number
|
||||
// test.kt:4 <init>: x=1:number, y="":kotlin.String
|
||||
|
||||
Reference in New Issue
Block a user