diff --git a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/SimpleBridgeGeneratorImpl.kt b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/SimpleBridgeGeneratorImpl.kt index a378a3d5548..675342353e7 100644 --- a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/SimpleBridgeGeneratorImpl.kt +++ b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/SimpleBridgeGeneratorImpl.kt @@ -123,7 +123,8 @@ class SimpleBridgeGeneratorImpl( val externCPrefix = if (libraryForCStubs.language == Language.CPP) "extern \"C\" " else "" val functionName = pkgName.replace(INVALID_CLANG_IDENTIFIER_REGEX, "_") + "_$kotlinFunctionName" if (independent) kotlinLines.add("@" + topLevelKotlinScope.reference(KotlinTypes.independent)) - kotlinLines.add("@SymbolName(${functionName.quoteAsKotlinLiteral()})") + // TODO: this should be separate annotation + kotlinLines.add("@GCUnsafeCall(${functionName.quoteAsKotlinLiteral()})") "$externCPrefix$cReturnType $functionName ($joinedCParameters)" } } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt index 3a2fb3c0bd3..5a616c8c078 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt @@ -581,7 +581,7 @@ private fun KotlinStubs.createFakeKotlinExternalFunction( ) bridge.annotations += buildSimpleAnnotation(irBuiltIns, UNDEFINED_OFFSET, UNDEFINED_OFFSET, - symbols.symbolName.owner, cFunctionName) + symbols.gcUnsafeCall.owner, cFunctionName) if (isObjCMethod) { val methodInfo = signature.getObjCMethodInfo()!! diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt index bd1e546f2be..f5d6a697067 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt @@ -130,8 +130,9 @@ private fun createKotlinBridge( isInfix = false ) if (isExternal) { + // TODO this should be separate annotation bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset, - stubs.symbols.symbolName.owner, cBridgeName) + stubs.symbols.gcUnsafeCall.owner, cBridgeName) bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset, stubs.symbols.filterExceptions.owner, foreignExceptionMode.value) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index 15ca02ebf0d..5fbb8c106c4 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -110,6 +110,7 @@ internal class KonanSymbols( val arrayList = symbolTable.referenceClass(getArrayListClassDescriptor(context)) val symbolName = topLevelClass(RuntimeNames.symbolNameAnnotation) + val gcUnsafeCall = topLevelClass(KonanFqNames.gcUnsafeCall) val filterExceptions = topLevelClass(RuntimeNames.filterExceptions) val exportForCppRuntime = topLevelClass(RuntimeNames.exportForCppRuntime) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 33461d9fc17..f961a4f948b 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -2487,7 +2487,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map