[K/JS] Process JS-specific returnable blocks before the state machine building
^KT-60785 Fixed ^KT-63207 Fixed
This commit is contained in:
@@ -429,7 +429,8 @@ private val innerClassConstructorCallsLoweringPhase = makeIrModulePhase<JsIrBack
|
|||||||
private val suspendFunctionsLoweringPhase = makeIrModulePhase(
|
private val suspendFunctionsLoweringPhase = makeIrModulePhase(
|
||||||
::JsSuspendFunctionsLowering,
|
::JsSuspendFunctionsLowering,
|
||||||
name = "SuspendFunctionsLowering",
|
name = "SuspendFunctionsLowering",
|
||||||
description = "Transform suspend functions into CoroutineImpl instance and build state machine"
|
description = "Transform suspend functions into CoroutineImpl instance and build state machine",
|
||||||
|
prerequisite = setOf(returnableBlockLoweringPhase)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val addContinuationToNonLocalSuspendFunctionsLoweringPhase = makeIrModulePhase(
|
private val addContinuationToNonLocalSuspendFunctionsLoweringPhase = makeIrModulePhase(
|
||||||
@@ -826,6 +827,7 @@ val loweringList = listOf<SimpleNamedCompilerPhase<JsIrBackendContext, IrModuleF
|
|||||||
enumUsageLoweringPhase,
|
enumUsageLoweringPhase,
|
||||||
externalEnumUsageLoweringPhase,
|
externalEnumUsageLoweringPhase,
|
||||||
enumEntryRemovalLoweringPhase,
|
enumEntryRemovalLoweringPhase,
|
||||||
|
returnableBlockLoweringPhase,
|
||||||
suspendFunctionsLoweringPhase,
|
suspendFunctionsLoweringPhase,
|
||||||
propertyReferenceLoweringPhase,
|
propertyReferenceLoweringPhase,
|
||||||
interopCallableReferenceLoweringPhase,
|
interopCallableReferenceLoweringPhase,
|
||||||
@@ -833,7 +835,6 @@ val loweringList = listOf<SimpleNamedCompilerPhase<JsIrBackendContext, IrModuleF
|
|||||||
addContinuationToNonLocalSuspendFunctionsLoweringPhase,
|
addContinuationToNonLocalSuspendFunctionsLoweringPhase,
|
||||||
addContinuationToLocalSuspendFunctionsLoweringPhase,
|
addContinuationToLocalSuspendFunctionsLoweringPhase,
|
||||||
addContinuationToFunctionCallsLoweringPhase,
|
addContinuationToFunctionCallsLoweringPhase,
|
||||||
returnableBlockLoweringPhase,
|
|
||||||
rangeContainsLoweringPhase,
|
rangeContainsLoweringPhase,
|
||||||
forLoopsLoweringPhase,
|
forLoopsLoweringPhase,
|
||||||
primitiveCompanionLoweringPhase,
|
primitiveCompanionLoweringPhase,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
|
||||||
import helpers.*
|
import helpers.*
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|
||||||
|
|||||||
-2
@@ -36,7 +36,5 @@ suspend fun box() {
|
|||||||
// test.kt:12 doResume:
|
// test.kt:12 doResume:
|
||||||
// test.kt:8 h: $completion=$boxCOROUTINE$0
|
// test.kt:8 h: $completion=$boxCOROUTINE$0
|
||||||
// test.kt:4 doResume:
|
// test.kt:4 doResume:
|
||||||
// test.kt:5 doResume: x=41:number
|
|
||||||
// test.kt:4 doResume: x=41:number
|
// test.kt:4 doResume: x=41:number
|
||||||
// test.kt:5 doResume: x=41:number, x=41:number
|
|
||||||
// test.kt:19 doResume: x=41:number, x=41:number
|
// test.kt:19 doResume: x=41:number, x=41:number
|
||||||
|
|||||||
@@ -68,5 +68,6 @@ suspend fun box() {
|
|||||||
// test.kt:12 <get-a>:
|
// test.kt:12 <get-a>:
|
||||||
// test.kt:38 doResume:
|
// test.kt:38 doResume:
|
||||||
// test.kt:38 doResume:
|
// test.kt:38 doResume:
|
||||||
|
// test.kt:38 doResume:
|
||||||
// test.kt:27 doResume:
|
// test.kt:27 doResume:
|
||||||
// test.kt:28 doResume: a=Unit
|
// test.kt:28 doResume: a=Unit
|
||||||
|
|||||||
+1
@@ -71,5 +71,6 @@ suspend fun box() {
|
|||||||
// test.kt:7 id: obj=2:number
|
// test.kt:7 id: obj=2:number
|
||||||
// test.kt:38 doResume: c=1:number, b=2:number
|
// test.kt:38 doResume: c=1:number, b=2:number
|
||||||
// test.kt:38 doResume: c=1:number, b=2:number
|
// test.kt:38 doResume: c=1:number, b=2:number
|
||||||
|
// test.kt:39 doResume: c=1:number, b=2:number
|
||||||
// test.kt:30 doResume: c=1:number, b=2:number
|
// test.kt:30 doResume: c=1:number, b=2:number
|
||||||
// test.kt:31 doResume: c=1:number, b=2:number, a=Unit
|
// test.kt:31 doResume: c=1:number, b=2:number, a=Unit
|
||||||
|
|||||||
@@ -42,5 +42,6 @@ suspend fun box() {
|
|||||||
// EXPECTATIONS JS_IR
|
// EXPECTATIONS JS_IR
|
||||||
// test.kt:31 doResume:
|
// test.kt:31 doResume:
|
||||||
// test.kt:31 doResume:
|
// test.kt:31 doResume:
|
||||||
|
// test.kt:31 doResume:
|
||||||
// test.kt:22 doResume:
|
// test.kt:22 doResume:
|
||||||
// test.kt:23 doResume: a=Unit
|
// test.kt:23 doResume: a=Unit
|
||||||
|
|||||||
Vendored
+1
@@ -103,5 +103,6 @@ suspend fun box() {
|
|||||||
// test.kt:7 id: obj=5:number
|
// test.kt:7 id: obj=5:number
|
||||||
// test.kt:44 doResume: b=2:number, e=5:number
|
// test.kt:44 doResume: b=2:number, e=5:number
|
||||||
// test.kt:44 doResume: b=2:number, e=5:number
|
// test.kt:44 doResume: b=2:number, e=5:number
|
||||||
|
// test.kt:45 doResume: b=2:number, e=5:number
|
||||||
// test.kt:33 doResume: b=2:number, e=5:number
|
// test.kt:33 doResume: b=2:number, e=5:number
|
||||||
// test.kt:37 doResume: b=2:number, e=5:number, result=Unit
|
// test.kt:37 doResume: b=2:number, e=5:number, result=Unit
|
||||||
|
|||||||
+6
@@ -962,6 +962,12 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
|||||||
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendLambdaWithValueClass.kt")
|
||||||
|
public void testSuspendLambdaWithValueClass() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/coroutines/suspendLambdaWithValueClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("suspendMethodWithSuperCall.kt")
|
@TestMetadata("suspendMethodWithSuperCall.kt")
|
||||||
public void testSuspendMethodWithSuperCall() throws Exception {
|
public void testSuspendMethodWithSuperCall() throws Exception {
|
||||||
|
|||||||
+6
@@ -962,6 +962,12 @@ public class FirJsES6BoxTestGenerated extends AbstractFirJsES6BoxTest {
|
|||||||
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendLambdaWithValueClass.kt")
|
||||||
|
public void testSuspendLambdaWithValueClass() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/coroutines/suspendLambdaWithValueClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("suspendMethodWithSuperCall.kt")
|
@TestMetadata("suspendMethodWithSuperCall.kt")
|
||||||
public void testSuspendMethodWithSuperCall() throws Exception {
|
public void testSuspendMethodWithSuperCall() throws Exception {
|
||||||
|
|||||||
+6
@@ -962,6 +962,12 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
|||||||
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendLambdaWithValueClass.kt")
|
||||||
|
public void testSuspendLambdaWithValueClass() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/coroutines/suspendLambdaWithValueClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("suspendMethodWithSuperCall.kt")
|
@TestMetadata("suspendMethodWithSuperCall.kt")
|
||||||
public void testSuspendMethodWithSuperCall() throws Exception {
|
public void testSuspendMethodWithSuperCall() throws Exception {
|
||||||
|
|||||||
+6
@@ -962,6 +962,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
runTest("js/js.translator/testData/box/coroutines/suspendInvokeWithSuspendKlassRef.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("suspendLambdaWithValueClass.kt")
|
||||||
|
public void testSuspendLambdaWithValueClass() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/coroutines/suspendLambdaWithValueClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("suspendMethodWithSuperCall.kt")
|
@TestMetadata("suspendMethodWithSuperCall.kt")
|
||||||
public void testSuspendMethodWithSuperCall() throws Exception {
|
public void testSuspendMethodWithSuperCall() throws Exception {
|
||||||
|
|||||||
-2
@@ -1,8 +1,6 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// EXPECTED_REACHABLE_NODES: 1292
|
// EXPECTED_REACHABLE_NODES: 1292
|
||||||
// KT-60785
|
// KT-60785
|
||||||
// Ignored until the rr/vgrechko/accidental-reification-2 will be merged
|
|
||||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
|
||||||
|
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
// WITH_COROUTINES
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
import helpers.*
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(object : Continuation<Unit> {
|
||||||
|
override val context = EmptyCoroutineContext
|
||||||
|
override fun resumeWith(result: Result<Unit>) {
|
||||||
|
result.getOrThrow()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a: suspend () -> Unit = {
|
||||||
|
mapOf(
|
||||||
|
0x0000000000000000UL to 0x0000000000000000UL
|
||||||
|
).forEach { (base: ULong) ->
|
||||||
|
0x0000000000000000UL.ror(2)
|
||||||
|
base.ror(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val b: () -> Unit = {
|
||||||
|
mapOf(
|
||||||
|
0x0000000000000000UL to 0x0000000000000000UL
|
||||||
|
).forEach { (base: ULong) ->
|
||||||
|
0x0000000000000000UL.ror(2)
|
||||||
|
base.ror(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder {
|
||||||
|
a()
|
||||||
|
b()
|
||||||
|
}
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun ULong.ror(shift: Int): ULong = this shr shift
|
||||||
+1
-2
@@ -15,5 +15,4 @@ suspend fun bar(): Unit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LINES(JS): 39 4 4 4 7 5 5 45 45 5 93 45 5 5 6 4 4 4 9 15 9 9 9 * 9 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14 * 9 15 9 9 9 9
|
// LINES(JS): 39 4 4 4 7 5 5 45 45 5 93 45 5 5 6 4 4 4 9 15 9 9 9 * 9 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14 * 9 15 9 9 9 9
|
||||||
// LINES(JS_IR): 4 4 * 93 3 45 45 7 7 6 9 9 * 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 14 14 15 15
|
// LINES(JS_IR): 4 4 * 9 9 * 4 * 4 * 19 5 5 * 19 * 19 19 * 19 19 * 6 6 * 19 * 19 * 4 * 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 14 14 15 15
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user