[K/N] Use @Escapes for all external funs with escaping arguments
This commit is contained in:
committed by
Space Team
parent
8d81fd6647
commit
4e6451c25e
@@ -6,9 +6,11 @@
|
||||
package kotlinx.cinterop
|
||||
|
||||
import kotlin.native.*
|
||||
import kotlin.native.internal.Escapes
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
|
||||
@GCUnsafeCall("Kotlin_Interop_createStablePointer")
|
||||
@Escapes(0b01) // any escapes into stable ref.
|
||||
internal external fun createStablePointer(any: Any): COpaquePointer
|
||||
|
||||
@GCUnsafeCall("Kotlin_Interop_disposeStablePointer")
|
||||
|
||||
@@ -62,6 +62,7 @@ internal fun CPointer<*>.cPointerToString() = "CPointer(raw=$rawValue)"
|
||||
*/
|
||||
@ExperimentalForeignApi
|
||||
@TypedIntrinsic(IntrinsicType.INTEROP_STATIC_C_FUNCTION)
|
||||
// function is static, so it's never heap allocated anyway; no need to use @Escapes
|
||||
public external fun <R> staticCFunction(@VolatileLambda function: () -> R): CPointer<CFunction<() -> R>>
|
||||
|
||||
@ExperimentalForeignApi
|
||||
|
||||
@@ -6,11 +6,7 @@ package kotlin.native
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.concurrent.InvalidMutabilityException
|
||||
import kotlin.native.internal.ExportForCppRuntime
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
import kotlin.native.internal.UnhandledExceptionHookHolder
|
||||
import kotlin.native.internal.runUnhandledExceptionHook
|
||||
import kotlin.native.internal.ReportUnhandledException
|
||||
import kotlin.native.internal.*
|
||||
|
||||
/**
|
||||
* Initializes Kotlin runtime for the current thread, if not inited already.
|
||||
@@ -80,6 +76,7 @@ public fun getUnhandledExceptionHook(): ReportUnhandledExceptionHook? {
|
||||
@ExperimentalNativeApi
|
||||
@SinceKotlin("1.6")
|
||||
@GCUnsafeCall("Kotlin_processUnhandledException")
|
||||
@Escapes(0b01) // throwable may be passed to the user code via unhandled exception hook.
|
||||
public external fun processUnhandledException(throwable: Throwable): Unit
|
||||
|
||||
/*
|
||||
@@ -91,6 +88,7 @@ public external fun processUnhandledException(throwable: Throwable): Unit
|
||||
@ExperimentalNativeApi
|
||||
@SinceKotlin("1.6")
|
||||
@GCUnsafeCall("Kotlin_terminateWithUnhandledException")
|
||||
// No need to mark throwable as @Escapes because this function never returns.
|
||||
public external fun terminateWithUnhandledException(throwable: Throwable): Nothing
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,14 +6,11 @@
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.DescribeObjectForDebugging
|
||||
import kotlin.native.internal.ExportForCppRuntime
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
import kotlin.native.internal.InternalForKotlinNative
|
||||
import kotlin.native.internal.debugDescription
|
||||
import kotlin.native.identityHashCode
|
||||
import kotlin.reflect.KClass
|
||||
import kotlinx.cinterop.*
|
||||
import kotlinx.cinterop.CPointer
|
||||
import kotlinx.cinterop.CFunction
|
||||
import kotlinx.cinterop.ExperimentalForeignApi
|
||||
import kotlin.native.internal.*
|
||||
|
||||
@GCUnsafeCall("Kotlin_Any_isShareable")
|
||||
@FreezingIsDeprecated
|
||||
@@ -38,7 +35,7 @@ external internal fun waitForAnyFuture(versionToken: Int, millis: Int): Boolean
|
||||
@ObsoleteWorkersApi
|
||||
external internal fun versionToken(): Int
|
||||
|
||||
@kotlin.native.internal.ExportForCompiler
|
||||
@ExportForCompiler
|
||||
@ObsoleteWorkersApi
|
||||
internal fun executeImpl(worker: Worker, mode: TransferMode, producer: () -> Any?,
|
||||
job: CPointer<CFunction<*>>): Future<Any?> =
|
||||
@@ -46,6 +43,7 @@ internal fun executeImpl(worker: Worker, mode: TransferMode, producer: () -> Any
|
||||
|
||||
@GCUnsafeCall("Kotlin_Worker_startInternal")
|
||||
@ObsoleteWorkersApi
|
||||
@Escapes(0b10) // name is stored in the Worker instance.
|
||||
external internal fun startInternal(errorReporting: Boolean, name: String?): Int
|
||||
|
||||
@GCUnsafeCall("Kotlin_Worker_currentInternal")
|
||||
@@ -63,6 +61,7 @@ external internal fun executeInternal(
|
||||
|
||||
@GCUnsafeCall("Kotlin_Worker_executeAfterInternal")
|
||||
@ObsoleteWorkersApi
|
||||
@Escapes(0b10) // operation escapes into stable ref.
|
||||
external internal fun executeAfterInternal(id: Int, operation: () -> Unit, afterMicroseconds: Long): Unit
|
||||
|
||||
@GCUnsafeCall("Kotlin_Worker_processQueueInternal")
|
||||
|
||||
@@ -11,6 +11,7 @@ import kotlinx.cinterop.ExperimentalForeignApi
|
||||
|
||||
@GCUnsafeCall("Kotlin_WorkerBoundReference_create")
|
||||
@ObsoleteWorkersApi
|
||||
@Escapes(0b01) // value escapes into stable ref.
|
||||
external private fun createWorkerBoundReference(value: Any): NativePtr
|
||||
|
||||
@GCUnsafeCall("Kotlin_WorkerBoundReference_deref")
|
||||
|
||||
@@ -281,6 +281,7 @@ public class ObjCErrorException(
|
||||
@PublishedApi
|
||||
@GCUnsafeCall("Kotlin_ObjCExport_trapOnUndeclaredException")
|
||||
@ExportForCppRuntime
|
||||
// No need to mark throwable as @Escapes because this function actually never returns.
|
||||
internal external fun trapOnUndeclaredException(exception: Throwable)
|
||||
|
||||
@ExportForCppRuntime
|
||||
|
||||
@@ -122,5 +122,6 @@ private class CleanerImpl(
|
||||
|
||||
|
||||
@GCUnsafeCall("CreateStablePointer")
|
||||
@Escapes(0b01) // obj escapes into stable ref.
|
||||
external private fun createStablePointer(obj: Any): NativePtr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user