JVM IR: Mangle names of $$forInline functions
This commit is contained in:
committed by
Alexander Udalov
parent
7cc06489dd
commit
dad10e94aa
Generated
+5
@@ -1453,6 +1453,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/effectivelyInlineOnly.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("internalInlineSuspend.kt")
|
||||
public void testInternalInlineSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/internalInlineSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mergeLvt.kt")
|
||||
public void testMergeLvt() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/mergeLvt.kt");
|
||||
|
||||
+4
-2
@@ -98,8 +98,10 @@ internal fun IrFunction.suspendForInlineToOriginal(): IrSimpleFunction? {
|
||||
origin != JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE
|
||||
) return null
|
||||
return parentAsClass.declarations.find {
|
||||
it is IrSimpleFunction && it.attributeOwnerId == (this as IrSimpleFunction).attributeOwnerId &&
|
||||
it.name.asString() + FOR_INLINE_SUFFIX == name.asString()
|
||||
// The function may not be named `it.name.asString() + FOR_INLINE_SUFFIX` due to name mangling,
|
||||
// e.g., for internal declarations. We check for a function with the same `attributeOwnerId` instead.
|
||||
// This is copied in `AddContinuationLowering`.
|
||||
it is IrSimpleFunction && it.attributeOwnerId == (this as IrSimpleFunction).attributeOwnerId
|
||||
} as IrSimpleFunction?
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower
|
||||
if (flag.capturesCrossinline || function.isInline) {
|
||||
result += context.irFactory.buildFun {
|
||||
containerSource = view.containerSource
|
||||
name = Name.identifier(view.name.asString() + FOR_INLINE_SUFFIX)
|
||||
name = Name.identifier(context.methodSignatureMapper.mapFunctionName(view) + FOR_INLINE_SUFFIX)
|
||||
returnType = view.returnType
|
||||
modality = view.modality
|
||||
isSuspend = view.isSuspend
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
suspend fun f() {}
|
||||
|
||||
internal inline suspend fun g() {
|
||||
f()
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
// 1 public final g\$test_module\(Lkotlin/coroutines/Continuation;\)Ljava/lang/Object;
|
||||
// 1 private final g\$test_module\$\$forInline\(Lkotlin/coroutines/Continuation;\)Ljava/lang/Object;
|
||||
// 0 g\$\$forInline
|
||||
+5
@@ -1443,6 +1443,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/effectivelyInlineOnly.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("internalInlineSuspend.kt")
|
||||
public void testInternalInlineSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/internalInlineSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mergeLvt.kt")
|
||||
public void testMergeLvt() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/mergeLvt.kt");
|
||||
|
||||
+5
@@ -1453,6 +1453,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/effectivelyInlineOnly.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("internalInlineSuspend.kt")
|
||||
public void testInternalInlineSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/internalInlineSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mergeLvt.kt")
|
||||
public void testMergeLvt() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/coroutines/mergeLvt.kt");
|
||||
|
||||
Reference in New Issue
Block a user