forked from mirrors/gecko-dev
		
	Bug 1559000 - Enable/disable mozglue's AutoProfilerLabel when Base Profiler starts/stops - r=mstange
Now that Gecko Profiler only registers its entry&exit functions when running, and it ensures that Base Profiler is stopped beforehand, Base Profiler can now register its own entry&exit functions to capture labels before xpcom starts. Differential Revision: https://phabricator.services.mozilla.com/D34810 --HG-- extra : moz-landing-system : lando
This commit is contained in:
		
							parent
							
								
									84deee5fb4
								
							
						
					
					
						commit
						58334f8543
					
				
					 1 changed files with 25 additions and 0 deletions
				
			
		|  | @ -45,6 +45,7 @@ | ||||||
| // #include "memory_hooks.h"
 | // #include "memory_hooks.h"
 | ||||||
| #  include "mozilla/ArrayUtils.h" | #  include "mozilla/ArrayUtils.h" | ||||||
| #  include "mozilla/Atomics.h" | #  include "mozilla/Atomics.h" | ||||||
|  | #  include "mozilla/AutoProfilerLabel.h" | ||||||
| #  include "mozilla/Printf.h" | #  include "mozilla/Printf.h" | ||||||
| #  include "mozilla/Services.h" | #  include "mozilla/Services.h" | ||||||
| #  include "mozilla/StackWalk.h" | #  include "mozilla/StackWalk.h" | ||||||
|  | @ -2619,6 +2620,24 @@ Maybe<ProfilerBufferInfo> profiler_get_buffer_info() { | ||||||
|                                  ActivePS::Capacity(lock).Value()}); |                                  ActivePS::Capacity(lock).Value()}); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // This basically duplicates AutoProfilerLabel's constructor.
 | ||||||
|  | static void* MozGlueBaseLabelEnter(const char* aLabel, | ||||||
|  |                                    const char* aDynamicString, void* aSp) { | ||||||
|  |   ProfilingStack* profilingStack = AutoProfilerLabel::sProfilingStack.get(); | ||||||
|  |   if (profilingStack) { | ||||||
|  |     profilingStack->pushLabelFrame(aLabel, aDynamicString, aSp, | ||||||
|  |                                    ProfilingCategoryPair::OTHER); | ||||||
|  |   } | ||||||
|  |   return profilingStack; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // This basically duplicates AutoProfilerLabel's destructor.
 | ||||||
|  | static void MozGlueBaseLabelExit(void* sProfilingStack) { | ||||||
|  |   if (sProfilingStack) { | ||||||
|  |     reinterpret_cast<ProfilingStack*>(sProfilingStack)->pop(); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, | static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, | ||||||
|                                   double aInterval, uint32_t aFeatures, |                                   double aInterval, uint32_t aFeatures, | ||||||
|                                   const char** aFilters, uint32_t aFilterCount, |                                   const char** aFilters, uint32_t aFilterCount, | ||||||
|  | @ -2678,6 +2697,9 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   // Setup support for pushing/popping labels in mozglue.
 | ||||||
|  |   RegisterProfilerLabelEnterExit(MozGlueBaseLabelEnter, MozGlueBaseLabelExit); | ||||||
|  | 
 | ||||||
|   // At the very end, set up RacyFeatures.
 |   // At the very end, set up RacyFeatures.
 | ||||||
|   RacyFeatures::SetActive(ActivePS::Features(aLock)); |   RacyFeatures::SetActive(ActivePS::Features(aLock)); | ||||||
| } | } | ||||||
|  | @ -2782,6 +2804,9 @@ static MOZ_MUST_USE SamplerThread* locked_profiler_stop(PSLockRef aLock) { | ||||||
|   //   mozilla::profiler::install_memory_counter(false);
 |   //   mozilla::profiler::install_memory_counter(false);
 | ||||||
|   // #endif
 |   // #endif
 | ||||||
| 
 | 
 | ||||||
|  |   // Remove support for pushing/popping labels in mozglue.
 | ||||||
|  |   RegisterProfilerLabelEnterExit(nullptr, nullptr); | ||||||
|  | 
 | ||||||
|   // Stop sampling live threads.
 |   // Stop sampling live threads.
 | ||||||
|   const Vector<LiveProfiledThreadData>& liveProfiledThreads = |   const Vector<LiveProfiledThreadData>& liveProfiledThreads = | ||||||
|       ActivePS::LiveProfiledThreads(aLock); |       ActivePS::LiveProfiledThreads(aLock); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Gerald Squelart
						Gerald Squelart