Bug 1476405: Part 4 - Create nsThread wrappers whenever a thread is registered with the profiler. r?erahm,mstange
This automatically gets us wrappers (and therefore memory statistics) for
Stylo threads, JS HelperThreads, and any other non-nsThread threads that we
already register with the profiler.
MozReview-Commit-ID: 8ZPjb0ojyWp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3286,16 +3286,21 @@ profiler_feature_active(uint32_t aFeatur
void
profiler_register_thread(const char* aName, void* aGuessStackTop)
{
DEBUG_LOG("profiler_register_thread(%s)", aName);
MOZ_ASSERT_IF(NS_IsMainThread(), Scheduler::IsCooperativeThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
+ // Make sure we have a nsThread wrapper for the current thread, and that NSPR
+ // knows its name.
+ (void) NS_GetCurrentThread();
+ NS_SetCurrentThreadName(aName);
+
PSAutoLock lock(gPSMutex);
void* stackTop = GetStackTop(aGuessStackTop);
locked_register_thread(lock, aName, stackTop);
}
void
profiler_unregister_thread()