Remove unneeded zeroing TLS (#4480)
This commit is contained in:
committed by
Stanislav Erokhin
parent
1a97a6ca1a
commit
4297b521e4
@@ -1044,6 +1044,12 @@ task worker11(type: KonanLocalTest) {
|
||||
source = "runtime/workers/worker11.kt"
|
||||
}
|
||||
|
||||
standaloneTest("worker_threadlocal_no_leak") {
|
||||
disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build and pthreads.
|
||||
source = "runtime/workers/worker_threadlocal_no_leak.kt"
|
||||
flags = ['-g']
|
||||
}
|
||||
|
||||
task freeze0(type: KonanLocalTest) {
|
||||
enabled = (project.testTarget != 'wasm32') // No workers on WASM.
|
||||
goldValue = "frozen bit is true\n" +
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
@ThreadLocal
|
||||
var x = Any()
|
||||
|
||||
fun main() {
|
||||
val worker = Worker.start()
|
||||
|
||||
worker.execute(TransferMode.SAFE, {}) {
|
||||
println(x) // Make sure x is initialized
|
||||
}.result
|
||||
|
||||
worker.requestTermination().result
|
||||
}
|
||||
@@ -224,11 +224,6 @@ KBoolean Konan_Platform_isDebugBinary() {
|
||||
return KonanNeedDebugInfo ? true : false;
|
||||
}
|
||||
|
||||
void Kotlin_zeroOutTLSGlobals() {
|
||||
if (runtimeState != nullptr && runtimeState->memoryState != nullptr)
|
||||
InitOrDeinitGlobalVariables(DEINIT_THREAD_LOCAL_GLOBALS, runtimeState->memoryState);
|
||||
}
|
||||
|
||||
bool Kotlin_memoryLeakCheckerEnabled() {
|
||||
return g_checkLeaks;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ void Kotlin_deinitRuntimeIfNeeded();
|
||||
// Appends given node to an initializer list.
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
|
||||
// Zero out all Kotlin thread local globals.
|
||||
void Kotlin_zeroOutTLSGlobals();
|
||||
|
||||
bool Kotlin_memoryLeakCheckerEnabled();
|
||||
|
||||
bool Kotlin_cleanersLeakCheckerEnabled();
|
||||
|
||||
@@ -815,10 +815,6 @@ void* workerRoutine(void* argument) {
|
||||
if (worker->processQueueElement(true) == JOB_TERMINATE) break;
|
||||
} while (true);
|
||||
|
||||
// Runtime deinit callback could be called when TLS is already zeroed out, so clear memory
|
||||
// here explicitly. to make sure leak detector properly works.
|
||||
Kotlin_zeroOutTLSGlobals();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user