[K/N] Add lowered suspend function mangling to avoid clashes
This commit is contained in:
committed by
Space Team
parent
2d4c94a115
commit
95eaf3d234
+1
@@ -21,6 +21,7 @@ enum class MangleConstant(val prefix: Char, val separator: Char, val suffix: Cha
|
|||||||
const val ERROR_MARK = "<ERROR CLASS>"
|
const val ERROR_MARK = "<ERROR CLASS>"
|
||||||
const val ERROR_DECLARATION = "<ERROR DECLARATION>"
|
const val ERROR_DECLARATION = "<ERROR DECLARATION>"
|
||||||
const val STATIC_MEMBER_MARK = "#static"
|
const val STATIC_MEMBER_MARK = "#static"
|
||||||
|
const val SUSPEND_FUNCTION_MARK = "#suspend"
|
||||||
const val TYPE_PARAMETER_MARKER_NAME = "<TP>"
|
const val TYPE_PARAMETER_MARKER_NAME = "<TP>"
|
||||||
const val TYPE_PARAMETER_MARKER_NAME_SETTER = "<STP>"
|
const val TYPE_PARAMETER_MARKER_NAME_SETTER = "<STP>"
|
||||||
const val BACKING_FIELD_NAME = "<BF>"
|
const val BACKING_FIELD_NAME = "<BF>"
|
||||||
|
|||||||
+5
@@ -28,6 +28,7 @@ abstract class IrMangleComputer(protected val builder: StringBuilder, private va
|
|||||||
private var isRealExpect = false
|
private var isRealExpect = false
|
||||||
|
|
||||||
open fun IrFunction.platformSpecificFunctionName(): String? = null
|
open fun IrFunction.platformSpecificFunctionName(): String? = null
|
||||||
|
open fun IrFunction.platformSpecificFunctionMarks(): List<String> = emptyList()
|
||||||
|
|
||||||
open fun IrFunction.specialValueParamPrefix(param: IrValueParameter): String = ""
|
open fun IrFunction.specialValueParamPrefix(param: IrValueParameter): String = ""
|
||||||
|
|
||||||
@@ -112,6 +113,10 @@ abstract class IrMangleComputer(protected val builder: StringBuilder, private va
|
|||||||
builder.appendSignature(MangleConstant.STATIC_MEMBER_MARK)
|
builder.appendSignature(MangleConstant.STATIC_MEMBER_MARK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platformSpecificFunctionMarks().forEach {
|
||||||
|
builder.appendSignature(it)
|
||||||
|
}
|
||||||
|
|
||||||
extensionReceiverParameter?.let {
|
extensionReceiverParameter?.let {
|
||||||
if (!it.isHidden) {
|
if (!it.isHidden) {
|
||||||
builder.appendSignature(MangleConstant.EXTENSION_RECEIVER_PREFIX)
|
builder.appendSignature(MangleConstant.EXTENSION_RECEIVER_PREFIX)
|
||||||
|
|||||||
+10
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.kotlin.backend.konan.serialization
|
package org.jetbrains.kotlin.backend.konan.serialization
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.KotlinExportChecker
|
import org.jetbrains.kotlin.backend.common.serialization.mangle.KotlinExportChecker
|
||||||
|
import org.jetbrains.kotlin.backend.common.serialization.mangle.MangleConstant
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.MangleMode
|
import org.jetbrains.kotlin.backend.common.serialization.mangle.MangleMode
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.DescriptorBasedKotlinManglerImpl
|
import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.DescriptorBasedKotlinManglerImpl
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.DescriptorExportCheckerVisitor
|
import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.DescriptorExportCheckerVisitor
|
||||||
@@ -76,6 +77,11 @@ abstract class AbstractKonanIrMangler(private val withReturnType: Boolean) : IrB
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun IrFunction.platformSpecificFunctionMarks(): List<String> = when (origin) {
|
||||||
|
IrDeclarationOrigin.LOWERED_SUSPEND_FUNCTION -> listOfSuspendFunctionMark
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
override fun IrFunction.specialValueParamPrefix(param: IrValueParameter): String {
|
override fun IrFunction.specialValueParamPrefix(param: IrValueParameter): String {
|
||||||
// TODO: there are clashes originating from ObjectiveC interop.
|
// TODO: there are clashes originating from ObjectiveC interop.
|
||||||
// kotlinx.cinterop.ObjCClassOf<T>.create(format: kotlin.String): T defined in platform.Foundation in file Foundation.kt
|
// kotlinx.cinterop.ObjCClassOf<T>.create(format: kotlin.String): T defined in platform.Foundation in file Foundation.kt
|
||||||
@@ -84,6 +90,10 @@ abstract class AbstractKonanIrMangler(private val withReturnType: Boolean) : IrB
|
|||||||
|
|
||||||
return if (this.hasObjCMethodAnnotation || this.hasObjCFactoryAnnotation || this.isObjCClassMethod()) "${param.name}:" else ""
|
return if (this.hasObjCMethodAnnotation || this.hasObjCFactoryAnnotation || this.isObjCClassMethod()) "${param.name}:" else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val listOfSuspendFunctionMark = listOf(MangleConstant.SUSPEND_FUNCTION_MARK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ suspend fun suspendForever(): Int = suspendCoroutineUninterceptedOrReturn {
|
|||||||
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:$fooCOROUTINE
|
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:$fooCOROUTINE
|
||||||
|
|
||||||
// CHECK-NOT: ; Function Attrs: {{.*}}noreturn
|
// CHECK-NOT: ; Function Attrs: {{.*}}noreturn
|
||||||
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#foo(){}kotlin.Nothing"
|
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#foo#suspend(kotlin.coroutines.Continuation<kotlin.Nothing>){}kotlin.Any"
|
||||||
suspend fun foo(): Nothing {
|
suspend fun foo(): Nothing {
|
||||||
suspendForever()
|
suspendForever()
|
||||||
throw Error()
|
throw Error()
|
||||||
|
|||||||
Reference in New Issue
Block a user