[K/N][New MM] Disallow getting thread data for detached threads

This patch fixes a performance degradation introduced by
99bd26c2ef (Switch thread states
in termination handlers).
This commit is contained in:
Ilya Matveev
2021-09-03 17:23:33 +07:00
committed by Space
parent 3a4e8e7a61
commit bfc4ff6343
9 changed files with 44 additions and 18 deletions
+7 -1
View File
@@ -389,11 +389,17 @@ namespace kotlin {
namespace mm {
// Returns the MemoryState for the current thread.
// If the memory subsystem isn't initialized for the current thread, returns nullptr.
// The current thread must be attached to the runtime.
// Try not to use it very often, as (1) thread local access can be slow on some platforms,
// (2) TLS gets deallocated before our thread destruction hooks run.
MemoryState* GetMemoryState() noexcept;
// TODO: Replace with direct access to ThreadRegistry when the legacy MM is gone.
// Checks if the current thread is attached to the runtime.
// This function accesses a TLS variable, so it must not be called from a thread destructor.
bool IsCurrentThreadRegistered() noexcept;
} // namespace mm
enum class ThreadState {