[K/JS] Fix coroutines but turn back the fix for coroutines intrinsics intercepted and releaseIntercepted
This commit is contained in:
+3
-2
@@ -34,7 +34,8 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
* TODO: consider making this visitor non-recursive to make it more general.
|
||||
*/
|
||||
abstract class AbstractValueUsageTransformer(
|
||||
protected val irBuiltIns: IrBuiltIns
|
||||
protected val irBuiltIns: IrBuiltIns,
|
||||
private val replaceTypesInsideInlinedFunctionBlock: Boolean = false
|
||||
) : IrElementTransformerVoid() {
|
||||
|
||||
protected open fun IrExpression.useAs(type: IrType): IrExpression = this
|
||||
@@ -120,7 +121,7 @@ abstract class AbstractValueUsageTransformer(
|
||||
}
|
||||
|
||||
override fun visitContainerExpression(expression: IrContainerExpression): IrExpression {
|
||||
if (expression is IrInlinedFunctionBlock) {
|
||||
if (!replaceTypesInsideInlinedFunctionBlock && expression is IrInlinedFunctionBlock) {
|
||||
expression.transformChildrenVoid(this)
|
||||
return expression
|
||||
}
|
||||
|
||||
@@ -429,8 +429,7 @@ private val innerClassConstructorCallsLoweringPhase = makeIrModulePhase<JsIrBack
|
||||
private val suspendFunctionsLoweringPhase = makeIrModulePhase(
|
||||
::JsSuspendFunctionsLowering,
|
||||
name = "SuspendFunctionsLowering",
|
||||
description = "Transform suspend functions into CoroutineImpl instance and build state machine",
|
||||
prerequisite = setOf(returnableBlockLoweringPhase)
|
||||
description = "Transform suspend functions into CoroutineImpl instance and build state machine"
|
||||
)
|
||||
|
||||
private val addContinuationToNonLocalSuspendFunctionsLoweringPhase = makeIrModulePhase(
|
||||
@@ -642,7 +641,7 @@ private val inlineClassUsageLoweringPhase = makeIrModulePhase(
|
||||
)
|
||||
|
||||
private val autoboxingTransformerPhase = makeIrModulePhase<JsIrBackendContext>(
|
||||
::AutoboxingTransformer,
|
||||
{ AutoboxingTransformer(it, replaceTypesInsideInlinedFunctionBlock = true) },
|
||||
name = "AutoboxingTransformer",
|
||||
description = "Insert box/unbox intrinsics"
|
||||
)
|
||||
@@ -827,7 +826,6 @@ val loweringList = listOf<SimpleNamedCompilerPhase<JsIrBackendContext, IrModuleF
|
||||
enumUsageLoweringPhase,
|
||||
externalEnumUsageLoweringPhase,
|
||||
enumEntryRemovalLoweringPhase,
|
||||
returnableBlockLoweringPhase,
|
||||
suspendFunctionsLoweringPhase,
|
||||
propertyReferenceLoweringPhase,
|
||||
interopCallableReferenceLoweringPhase,
|
||||
@@ -835,6 +833,7 @@ val loweringList = listOf<SimpleNamedCompilerPhase<JsIrBackendContext, IrModuleF
|
||||
addContinuationToNonLocalSuspendFunctionsLoweringPhase,
|
||||
addContinuationToLocalSuspendFunctionsLoweringPhase,
|
||||
addContinuationToFunctionCallsLoweringPhase,
|
||||
returnableBlockLoweringPhase,
|
||||
rangeContainsLoweringPhase,
|
||||
forLoopsLoweringPhase,
|
||||
primitiveCompanionLoweringPhase,
|
||||
|
||||
+6
-2
@@ -31,7 +31,10 @@ import org.jetbrains.kotlin.ir.util.render
|
||||
|
||||
// Copied and adapted from Kotlin/Native
|
||||
|
||||
abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) : AbstractValueUsageTransformer(context.irBuiltIns),
|
||||
abstract class AbstractValueUsageLowering(
|
||||
val context: JsCommonBackendContext,
|
||||
replaceTypesInsideInlinedFunctionBlock: Boolean = false
|
||||
) : AbstractValueUsageTransformer(context.irBuiltIns, replaceTypesInsideInlinedFunctionBlock),
|
||||
BodyLoweringPass {
|
||||
|
||||
val icUtils = context.inlineClassesUtils
|
||||
@@ -120,7 +123,8 @@ abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) :
|
||||
)
|
||||
}
|
||||
|
||||
class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsageLowering(context) {
|
||||
class AutoboxingTransformer(context: JsCommonBackendContext, replaceTypesInsideInlinedFunctionBlock: Boolean = false) :
|
||||
AbstractValueUsageLowering(context, replaceTypesInsideInlinedFunctionBlock) {
|
||||
private var processingReturnStack = mutableListOf<IrReturn>()
|
||||
|
||||
private fun IrExpression.useReturnableExpressionAsType(expectedType: IrType): IrExpression {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
|
||||
+2
@@ -36,5 +36,7 @@ suspend fun box() {
|
||||
// test.kt:12 doResume:
|
||||
// test.kt:8 h: $completion=Coroutine
|
||||
// test.kt:4 doResume:
|
||||
// test.kt:5 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
|
||||
|
||||
@@ -68,6 +68,5 @@ suspend fun box() {
|
||||
// test.kt:12 <get-a>:
|
||||
// test.kt:38 doResume:
|
||||
// test.kt:38 doResume:
|
||||
// test.kt:38 doResume:
|
||||
// test.kt:27 doResume:
|
||||
// test.kt:28 doResume: a=Unit
|
||||
|
||||
-1
@@ -71,6 +71,5 @@ suspend fun box() {
|
||||
// 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:39 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
|
||||
|
||||
@@ -42,6 +42,5 @@ suspend fun box() {
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:31 doResume:
|
||||
// test.kt:31 doResume:
|
||||
// test.kt:31 doResume:
|
||||
// test.kt:22 doResume:
|
||||
// test.kt:23 doResume: a=Unit
|
||||
|
||||
Vendored
-1
@@ -103,6 +103,5 @@ suspend fun box() {
|
||||
// test.kt:7 id: obj=5:number
|
||||
// test.kt:45 doResume: b=2:number, e=5:number
|
||||
// test.kt:45 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:37 doResume: b=2:number, e=5:number, result=Unit
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
|
||||
var demoCallCounter = 0
|
||||
|
||||
+1
-1
@@ -15,4 +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_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
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user