Bug 1476405: Part 4 - Create nsThread wrappers whenever a thread is registered with the profiler. r?erahm,mstange draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 18 Jul 2018 22:39:38 -0700
changeset 821043 9144972b2bdcfb6239929c41df78cd443ed1e7b7
parent 821042 7922493a0d83901a17f9eb298de8c2f8050d8f3c
child 821044 cb8d820ea2d8d990742e11dbb0b3c8407e9335d5
push id116998
push usermaglione.k@gmail.com
push dateFri, 20 Jul 2018 20:53:25 +0000
reviewerserahm, mstange
bugs1476405
milestone63.0a1
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
tools/profiler/core/platform.cpp
--- 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()