Native: don't dispatch release for null Obj-C refs to the main thread
Currently, if a Kotlin object happens to have null for an associated object but FLAGS_RELEASE_ON_MAIN_QUEUE flag set, GC will dispatch Kotlin_ObjCExport_releaseAssociatedObject(null) to the main thread anyway. This couldn't happen before, but can now, with disposeObjCObject. The commit prevents this, by moving the null check out from Kotlin_ObjCExport_releaseAssociatedObject to call sites. ^KT-59134
This commit is contained in:
committed by
Space Team
parent
1bf3d55bdf
commit
063e7258ee
@@ -107,11 +107,10 @@ ALWAYS_INLINE void send_releaseAsAssociatedObject(void* associatedObject) {
|
||||
} // namespace
|
||||
|
||||
extern "C" ALWAYS_INLINE void Kotlin_ObjCExport_releaseAssociatedObject(void* associatedObject) {
|
||||
if (associatedObject != nullptr) {
|
||||
// May already be in the native state if was scheduled on the main queue.
|
||||
NativeOrUnregisteredThreadGuard guard(/*reentrant=*/ true);
|
||||
send_releaseAsAssociatedObject(associatedObject);
|
||||
}
|
||||
RuntimeAssert(associatedObject != nullptr, "Kotlin_ObjCExport_releaseAssociatedObject(nullptr)");
|
||||
// May already be in the native state if was scheduled on the main queue.
|
||||
NativeOrUnregisteredThreadGuard guard(/*reentrant=*/ true);
|
||||
send_releaseAsAssociatedObject(associatedObject);
|
||||
}
|
||||
|
||||
extern "C" id Kotlin_ObjCExport_convertUnitToRetained(ObjHeader* unitInstance) {
|
||||
|
||||
Reference in New Issue
Block a user