Move main thread check to legacy mm (#4483)

This commit is contained in:
Alexander Shabalin
2020-10-30 11:14:01 +03:00
committed by Stanislav Erokhin
parent 14526e57bc
commit 8dc5b95337
8 changed files with 32 additions and 24 deletions
@@ -41,4 +41,5 @@ void EnsureDeclarationsEmitted() {
ensureUsed(CheckLifetimesConstraint);
ensureUsed(FreezeSubgraph);
ensureUsed(FreezeSubgraph);
ensureUsed(CheckGlobalsAccessible);
}
@@ -254,6 +254,8 @@ bool IsForeignRefAccessible(ObjHeader* object, ForeignRefContext context);
// and there's nothing else keeping the object alive.
void AdoptReferenceFromSharedVariable(ObjHeader* object);
void CheckGlobalsAccessible();
#ifdef __cplusplus
}
#endif
@@ -69,7 +69,6 @@ KBoolean g_checkLeakedCleaners = KonanNeedDebugInfo;
constexpr RuntimeState* kInvalidRuntime = nullptr;
THREAD_LOCAL_VARIABLE RuntimeState* runtimeState = kInvalidRuntime;
THREAD_LOCAL_VARIABLE int isMainThread = 0;
inline bool isValidRuntime() {
return ::runtimeState != kInvalidRuntime;
@@ -88,7 +87,6 @@ RuntimeState* initRuntime() {
bool firstRuntime = atomicAdd(&aliveRuntimesCount, 1) == 1;
// Keep global variables in state as well.
if (firstRuntime) {
isMainThread = 1;
konan::consoleInit();
#if KONAN_OBJC_INTEROP
Kotlin_ObjCExport_initialize();
@@ -151,11 +149,6 @@ void Kotlin_deinitRuntimeIfNeeded() {
}
}
void CheckIsMainThread() {
if (!isMainThread)
ThrowIncorrectDereferenceException();
}
KInt Konan_Platform_canAccessUnaligned() {
#if KONAN_NO_UNALIGNED_ACCESS
return 0;