Native: switch to "Native" thread state for some Obj-C runtime calls

A lot of calls to Objective-C runtime are potentially blocking. This
commit adds a number of thread state switches to ensure these Obj-C
runtime calls happen in "Native" thread state.

Also, remove a bunch of such functions from CallsChecker exclude list.
This commit is contained in:
Svyatoslav Scherbina
2022-07-27 12:14:48 +02:00
committed by Space
parent 2e8c25aeff
commit ad1b10cdb0
4 changed files with 15 additions and 14 deletions
@@ -135,6 +135,9 @@ void DisposeCString(char* cstring) {
}
ObjHeader* CreatePermanentStringFromCString(const char* nullTerminatedUTF8) {
// Note: this function can be called in "Native" thread state. But this is fine:
// while it indeed manipulates Kotlin objects, it doesn't in fact access _Kotlin heap_,
// because the accessed object is off-heap, imitating permanent static objects.
const char* end = nullTerminatedUTF8 + strlen(nullTerminatedUTF8);
size_t count = utf8::with_replacement::utf16_length(nullTerminatedUTF8, end);
size_t headerSize = alignUp(sizeof(ArrayHeader), alignof(char16_t));