зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1370329 (part 1) - Clean up the profiler's RAII classes. r=mstange.
This patch does the following renamings, which increase consistency. - GeckoProfilerInitRAII -> AutoProfilerInit - GeckoProfilerThread{Sleep,Wake}RAII -> AutoProfilerThread{Sleep,Wake} - GeckoProfilerTracingRAII -> AutoProfilerTracing - AutoProfilerRegister -> AutoProfilerRegisterThread - ProfilerStackFrameRAII -> AutoProfilerLabel - nsJSUtils::mProfilerRAII -> nsJSUtils::mAutoProfilerLabel Plus a few other minor ones (e.g. local variables). The patch also add MOZ_GUARD_OBJECT macros to all the profiler RAII classes that lack them, and does some minor whitespace reformatting. --HG-- extra : rebase_source : 47e298fdd6f6b4af70e3357ec0b7b0580c0d0f50
This commit is contained in:
Родитель
b0a3a49ce8
Коммит
0be77baa96
|
@ -1431,8 +1431,8 @@ static void
|
|||
FireForgetSkippable(uint32_t aSuspected, bool aRemoveChildless,
|
||||
TimeStamp aDeadline)
|
||||
{
|
||||
GeckoProfilerTracingRAII
|
||||
tracer("CC", aDeadline.IsNull() ? "ForgetSkippable" : "IdleForgetSkippable");
|
||||
AutoProfilerTracing
|
||||
tracing("CC", aDeadline.IsNull() ? "ForgetSkippable" : "IdleForgetSkippable");
|
||||
PRTime startTime = PR_Now();
|
||||
FinishAnyIncrementalGC();
|
||||
bool earlyForgetSkippable =
|
||||
|
@ -1649,8 +1649,8 @@ nsJSContext::RunCycleCollectorSlice(TimeStamp aDeadline)
|
|||
return;
|
||||
}
|
||||
|
||||
GeckoProfilerTracingRAII
|
||||
tracer("CC", aDeadline.IsNull() ? "CCSlice" : "IdleCCSlice");
|
||||
AutoProfilerTracing
|
||||
tracing("CC", aDeadline.IsNull() ? "CCSlice" : "IdleCCSlice");
|
||||
|
||||
PROFILER_LABEL("nsJSContext", "RunCycleCollectorSlice",
|
||||
js::ProfileEntry::Category::CC);
|
||||
|
|
|
@ -136,7 +136,7 @@ nsJSUtils::ExecutionContext::ExecutionContext(JSContext* aCx,
|
|||
JS::Handle<JSObject*> aGlobal)
|
||||
:
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
mProfilerRAII("nsJSUtils::ExecutionContext", /* dynamicStr */ nullptr,
|
||||
mAutoProfilerLabel("nsJSUtils::ExecutionContext", /* dynamicStr */ nullptr,
|
||||
__LINE__, js::ProfileEntry::Category::JS),
|
||||
#endif
|
||||
mCx(aCx)
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
class MOZ_STACK_CLASS ExecutionContext {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// Register stack annotations for the Gecko profiler.
|
||||
mozilla::ProfilerStackFrameRAII mProfilerRAII;
|
||||
mozilla::AutoProfilerLabel mAutoProfilerLabel;
|
||||
#endif
|
||||
|
||||
JSContext* mCx;
|
||||
|
|
|
@ -326,7 +326,7 @@ ClientLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
|
|||
EndTransactionFlags)
|
||||
{
|
||||
PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::Rasterization);
|
||||
GeckoProfilerTracingRAII tracer("Paint", "Rasterize");
|
||||
AutoProfilerTracing tracing("Paint", "Rasterize");
|
||||
|
||||
Maybe<TimeStamp> startTime;
|
||||
if (gfxPrefs::LayersDrawFPS()) {
|
||||
|
@ -710,7 +710,7 @@ ClientLayerManager::StopFrameTimeRecording(uint32_t aStartIndex,
|
|||
void
|
||||
ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "ForwardTransaction");
|
||||
AutoProfilerTracing tracing("Paint", "ForwardTransaction");
|
||||
TimeStamp start = TimeStamp::Now();
|
||||
|
||||
// Skip the synchronization for buffer since we also skip the painting during
|
||||
|
|
|
@ -908,7 +908,7 @@ CompositorBridgeParent::SetShadowProperties(Layer* aLayer)
|
|||
void
|
||||
CompositorBridgeParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "Composite");
|
||||
AutoProfilerTracing tracing("Paint", "Composite");
|
||||
PROFILER_LABEL("CompositorBridgeParent", "Composite",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ LayerTransactionParent::RecvInitReadLocks(ReadLockArray&& aReadLocks)
|
|||
mozilla::ipc::IPCResult
|
||||
LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "LayerTransaction");
|
||||
AutoProfilerTracing tracing("Paint", "LayerTransaction");
|
||||
PROFILER_LABEL("LayerTransactionParent", "RecvUpdate",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ WebRenderBridgeParent::HandleDPEnd(const gfx::IntSize& aSize,
|
|||
const WrBuiltDisplayListDescriptor& dlDesc,
|
||||
const WebRenderScrollData& aScrollData)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "DPTransaction");
|
||||
AutoProfilerTracing tracing("Paint", "DPTransaction");
|
||||
UpdateFwdTransactionId(aFwdTransactionId);
|
||||
AutoClearReadLocks clearLocks(mReadLocks);
|
||||
|
||||
|
@ -838,7 +838,7 @@ WebRenderBridgeParent::SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArr
|
|||
void
|
||||
WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "CompositeToTraget");
|
||||
AutoProfilerTracing tracing("Paint", "CompositeToTraget");
|
||||
if (mPaused) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
|
|||
void* aCallbackData,
|
||||
EndTransactionFlags aFlags)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "RenderLayers");
|
||||
AutoProfilerTracing tracing("Paint", "RenderLayers");
|
||||
mPaintedLayerCallback = aCallback;
|
||||
mPaintedLayerCallbackData = aCallbackData;
|
||||
mTransactionIncomplete = false;
|
||||
|
@ -229,8 +229,8 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
|
|||
mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
|
||||
|
||||
{
|
||||
GeckoProfilerTracingRAII
|
||||
tracer("Paint", sync ? "ForwardDPTransactionSync":"ForwardDPTransaction");
|
||||
AutoProfilerTracing
|
||||
tracing("Paint", sync ? "ForwardDPTransactionSync":"ForwardDPTransaction");
|
||||
WrBridge()->DPEnd(builder, size.ToUnknownSize(), sync, mLatestTransactionId, scrollData);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ NotifyDidRender(layers::CompositorBridgeParentBase* aBridge,
|
|||
void
|
||||
RenderThread::UpdateAndRender(wr::WindowId aWindowId)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "Composite");
|
||||
AutoProfilerTracing tracing("Paint", "Composite");
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
|
||||
auto it = mRenderers.find(aWindowId);
|
||||
|
|
|
@ -58,7 +58,7 @@ void MessagePumpDefault::Run(Delegate* delegate) {
|
|||
PROFILER_LABEL("MessagePump", "Wait",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
{
|
||||
mozilla::GeckoProfilerThreadSleepRAII sleep;
|
||||
mozilla::AutoProfilerThreadSleep sleep;
|
||||
event_.Wait();
|
||||
}
|
||||
} else {
|
||||
|
@ -68,7 +68,7 @@ void MessagePumpDefault::Run(Delegate* delegate) {
|
|||
PROFILER_LABEL("MessagePump", "Wait",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
{
|
||||
mozilla::GeckoProfilerThreadSleepRAII sleep;
|
||||
mozilla::AutoProfilerThreadSleep sleep;
|
||||
event_.TimedWait(delay);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4585,7 +4585,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
+ [ Whitespace.NL,
|
||||
StmtDecl(Decl(Type.BOOL, sendok.name)),
|
||||
StmtBlock([
|
||||
StmtDecl(Decl(Type('GeckoProfilerTracingRAII'),
|
||||
StmtDecl(Decl(Type('AutoProfilerTracing'),
|
||||
'syncIPCTracer'),
|
||||
initargs=[ ExprLiteral.String("IPC"),
|
||||
ExprLiteral.String(self.protocol.name + "::" + md.prettyMsgName()) ]),
|
||||
|
|
|
@ -120,7 +120,7 @@ MainThreadInvoker::Invoke(already_AddRefed<nsIRunnable>&& aRunnable)
|
|||
/* static */ VOID CALLBACK
|
||||
MainThreadInvoker::MainThreadAPC(ULONG_PTR aParam)
|
||||
{
|
||||
GeckoProfilerThreadWakeRAII wake;
|
||||
AutoProfilerThreadWake wake;
|
||||
mozilla::HangMonitor::NotifyActivity(mozilla::HangMonitor::kGeneralActivity);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
auto runnable = reinterpret_cast<SyncRunnable*>(aParam);
|
||||
|
|
|
@ -3736,7 +3736,7 @@ void
|
|||
PresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent,
|
||||
bool aFlushOnHoverChange)
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "DispatchSynthMouseMove");
|
||||
AutoProfilerTracing tracing("Paint", "DispatchSynthMouseMove");
|
||||
RestyleManager* restyleManager = mPresContext->RestyleManager();
|
||||
uint32_t hoverGenerationBefore =
|
||||
restyleManager->GetHoverGeneration();
|
||||
|
|
|
@ -255,9 +255,9 @@ RestyleTracker::DoProcessRestyles()
|
|||
data->mRestyleHint, MarkerTracingType::START)));
|
||||
}
|
||||
|
||||
Maybe<GeckoProfilerTracingRAII> profilerRAII;
|
||||
Maybe<AutoProfilerTracing> tracing;
|
||||
if (profiler_feature_active(ProfilerFeature::Restyle)) {
|
||||
profilerRAII.emplace("Paint", "Styles", Move(data->mBacktrace));
|
||||
tracing.emplace("Paint", "Styles", Move(data->mBacktrace));
|
||||
}
|
||||
ProcessOneRestyle(element, data->mRestyleHint, data->mChangeHint,
|
||||
data->mRestyleHintData);
|
||||
|
@ -359,9 +359,9 @@ RestyleTracker::DoProcessRestyles()
|
|||
index++, count);
|
||||
LOG_RESTYLE_INDENT();
|
||||
|
||||
Maybe<GeckoProfilerTracingRAII> profilerRAII;
|
||||
Maybe<AutoProfilerTracing> tracing;
|
||||
if (profiler_feature_active(ProfilerFeature::Restyle)) {
|
||||
profilerRAII.emplace("Paint", "Styles", Move(currentRestyle->mBacktrace));
|
||||
tracing.emplace("Paint", "Styles", Move(currentRestyle->mBacktrace));
|
||||
}
|
||||
if (isTimelineRecording) {
|
||||
timelines->AddMarkerForDocShell(docShell, Move(
|
||||
|
|
|
@ -3539,7 +3539,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
|
|||
{
|
||||
PROFILER_LABEL("nsLayoutUtils", "PaintFrame::BuildDisplayList",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
GeckoProfilerTracingRAII tracer("Paint", "DisplayList");
|
||||
AutoProfilerTracing tracing("Paint", "DisplayList");
|
||||
|
||||
PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::DisplayList);
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ protected:
|
|||
|
||||
LOG("[%p] ticking drivers...", this);
|
||||
// RD is short for RefreshDriver
|
||||
GeckoProfilerTracingRAII tracer("Paint", "RefreshDriverTick");
|
||||
AutoProfilerTracing tracing("Paint", "RefreshDriverTick");
|
||||
|
||||
TickRefreshDrivers(jsnow, now, mContentRefreshDrivers);
|
||||
TickRefreshDrivers(jsnow, now, mRootRefreshDrivers);
|
||||
|
@ -1676,7 +1676,7 @@ nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime)
|
|||
mFrameRequestCallbackDocs.Clear();
|
||||
|
||||
if (!frameRequestCallbacks.IsEmpty()) {
|
||||
GeckoProfilerTracingRAII tracer("Paint", "Scripts");
|
||||
AutoProfilerTracing tracing("Paint", "Scripts");
|
||||
for (const DocumentFrameCallbacks& docCallbacks : frameRequestCallbacks) {
|
||||
// XXXbz Bug 863140: GetInnerWindow can return the outer
|
||||
// window in some cases.
|
||||
|
@ -1844,7 +1844,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
|||
RunFrameRequestCallbacks(aNowTime);
|
||||
|
||||
if (mPresContext && mPresContext->GetPresShell()) {
|
||||
Maybe<GeckoProfilerTracingRAII> tracingStyleFlush;
|
||||
Maybe<AutoProfilerTracing> tracingStyleFlush;
|
||||
AutoTArray<nsIPresShell*, 16> observers;
|
||||
observers.AppendElements(mStyleFlushObservers);
|
||||
for (uint32_t j = observers.Length();
|
||||
|
@ -1875,7 +1875,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
|||
}
|
||||
} else if (i == 1) {
|
||||
// This is the FlushType::Layout case.
|
||||
Maybe<GeckoProfilerTracingRAII> tracingLayoutFlush;
|
||||
Maybe<AutoProfilerTracing> tracingLayoutFlush;
|
||||
AutoTArray<nsIPresShell*, 16> observers;
|
||||
observers.AppendElements(mLayoutFlushObservers);
|
||||
for (uint32_t j = observers.Length();
|
||||
|
@ -2130,7 +2130,7 @@ nsRefreshDriver::FinishedWaitingForTransaction()
|
|||
if (mSkippedPaints &&
|
||||
!IsInRefresh() &&
|
||||
(ObserverCount() || ImageRequestCount())) {
|
||||
GeckoProfilerTracingRAII tracer("Paint", "RefreshDriverTick");
|
||||
AutoProfilerTracing tracing("Paint", "RefreshDriverTick");
|
||||
DoRefresh();
|
||||
}
|
||||
mSkippedPaints = false;
|
||||
|
|
|
@ -4725,7 +4725,7 @@ ScrollFrameHelper::ScrollEvent::WillRefresh(mozilla::TimeStamp aTime)
|
|||
void
|
||||
ScrollFrameHelper::FireScrollEvent()
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "FireScrollEvent");
|
||||
AutoProfilerTracing tracing("Paint", "FireScrollEvent");
|
||||
MOZ_ASSERT(mScrollEvent);
|
||||
mScrollEvent = nullptr;
|
||||
|
||||
|
|
|
@ -2108,7 +2108,7 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(nsDisplayListBuilder* aB
|
|||
}
|
||||
|
||||
{
|
||||
GeckoProfilerTracingRAII tracer("Paint", "LayerBuilding");
|
||||
AutoProfilerTracing tracing("Paint", "LayerBuilding");
|
||||
|
||||
if (doBeginTransaction) {
|
||||
if (aCtx) {
|
||||
|
|
|
@ -4631,7 +4631,7 @@ XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig)
|
|||
#endif
|
||||
|
||||
char aLocal;
|
||||
GeckoProfilerInitRAII profilerGuard(&aLocal);
|
||||
AutoProfilerInit profilerInit(&aLocal);
|
||||
|
||||
PROFILER_LABEL("Startup", "XRE_Main",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
|
|
|
@ -420,7 +420,7 @@ XRE_InitChildProcess(int aArgc,
|
|||
mozilla::LogModule::Init();
|
||||
|
||||
char aLocal;
|
||||
GeckoProfilerInitRAII profiler(&aLocal);
|
||||
AutoProfilerInit profilerInit(&aLocal);
|
||||
|
||||
PROFILER_LABEL("Startup", "XRE_InitChildProcess",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
|
@ -789,7 +789,7 @@ XRE_InitParentProcess(int aArgc,
|
|||
mozilla::LogModule::Init();
|
||||
|
||||
char aLocal;
|
||||
GeckoProfilerInitRAII profiler(&aLocal);
|
||||
AutoProfilerInit profilerInit(&aLocal);
|
||||
|
||||
ScopedXREEmbed embed;
|
||||
|
||||
|
|
|
@ -586,16 +586,16 @@ MOZ_THREAD_LOCAL(ThreadInfo*) TLSInfo::sThreadInfo;
|
|||
// also have a second TLS pointer directly to the PseudoStack. Here's why.
|
||||
//
|
||||
// - We need to be able to push to and pop from the PseudoStack in
|
||||
// ProfilerStackFrameRAII.
|
||||
// AutoProfilerLabel.
|
||||
//
|
||||
// - Those two functions are hot and must be defined in GeckoProfiler.h so they
|
||||
// - The class functions are hot and must be defined in GeckoProfiler.h so they
|
||||
// can be inlined.
|
||||
//
|
||||
// - We don't want to expose TLSInfo (and ThreadInfo) in GeckoProfiler.h.
|
||||
//
|
||||
// This second pointer isn't ideal, but does provide a way to satisfy those
|
||||
// constraints. TLSInfo manages it, except for the uses in
|
||||
// ProfilerStackFrameRAII.
|
||||
// AutoProfilerLabel.
|
||||
MOZ_THREAD_LOCAL(PseudoStack*) sPseudoStack;
|
||||
|
||||
// The name of the main thread.
|
||||
|
|
|
@ -84,7 +84,7 @@ using UniqueProfilerBacktrace =
|
|||
|
||||
// Enter a pseudo stack frame in this scope and associate it with an
|
||||
// additional string.
|
||||
// This macro generates an RAII object. This RAII object stores the str
|
||||
// This macro generates an RAII object. This RAII object stores the dynamicStr
|
||||
// pointer in a field; it does not copy the string. This means that the string
|
||||
// you pass to this macro needs to live at least until the end of the current
|
||||
// scope.
|
||||
|
@ -128,19 +128,19 @@ using UniqueProfilerBacktrace =
|
|||
|
||||
#define PROFILER_LABEL(name_space, info, category) \
|
||||
PROFILER_PLATFORM_TRACING(name_space "::" info) \
|
||||
mozilla::ProfilerStackFrameRAII \
|
||||
mozilla::AutoProfilerLabel \
|
||||
PROFILER_APPEND_LINE_NUMBER(profiler_raii)(name_space "::" info, nullptr, \
|
||||
__LINE__, category)
|
||||
|
||||
#define PROFILER_LABEL_FUNC(category) \
|
||||
PROFILER_PLATFORM_TRACING(PROFILER_FUNCTION_NAME) \
|
||||
mozilla::ProfilerStackFrameRAII \
|
||||
mozilla::AutoProfilerLabel \
|
||||
PROFILER_APPEND_LINE_NUMBER(profiler_raii)(PROFILER_FUNCTION_NAME, nullptr, \
|
||||
__LINE__, category)
|
||||
|
||||
#define PROFILER_LABEL_DYNAMIC(name_space, info, category, dynamicStr) \
|
||||
PROFILER_PLATFORM_TRACING(name_space "::" info) \
|
||||
mozilla::ProfilerStackFrameRAII \
|
||||
mozilla::AutoProfilerLabel \
|
||||
PROFILER_APPEND_LINE_NUMBER(profiler_raii)(name_space "::" info, dynamicStr, \
|
||||
__LINE__, category)
|
||||
|
||||
|
@ -406,7 +406,7 @@ PROFILER_FUNC(void* profiler_get_stack_top(), nullptr)
|
|||
class nsISupports;
|
||||
class ProfilerMarkerPayload;
|
||||
|
||||
// This exists purely for ProfilerStackFrameRAII. See the comment on the
|
||||
// This exists purely for AutoProfilerLabel. See the comment on the
|
||||
// definition in platform.cpp for details.
|
||||
extern MOZ_THREAD_LOCAL(PseudoStack*) sPseudoStack;
|
||||
|
||||
|
@ -471,9 +471,9 @@ namespace mozilla {
|
|||
// are stack-allocated, and so exist within a thread, and are thus bounded by
|
||||
// the lifetime of the thread, which ensures that the references held can't be
|
||||
// used after the PseudoStack is destroyed.
|
||||
class MOZ_RAII ProfilerStackFrameRAII {
|
||||
class MOZ_RAII AutoProfilerLabel {
|
||||
public:
|
||||
ProfilerStackFrameRAII(const char* aLabel, const char* aDynamicString,
|
||||
AutoProfilerLabel(const char* aLabel, const char* aDynamicString,
|
||||
uint32_t aLine, js::ProfileEntry::Category aCategory
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
{
|
||||
|
@ -488,7 +488,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
~ProfilerStackFrameRAII()
|
||||
~AutoProfilerLabel()
|
||||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
|
@ -515,50 +515,68 @@ void profiler_clear_js_context();
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class MOZ_RAII GeckoProfilerInitRAII {
|
||||
class MOZ_RAII AutoProfilerInit
|
||||
{
|
||||
public:
|
||||
explicit GeckoProfilerInitRAII(void* stackTop) {
|
||||
explicit AutoProfilerInit(void* stackTop
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_init(stackTop);
|
||||
}
|
||||
~GeckoProfilerInitRAII() {
|
||||
profiler_shutdown();
|
||||
}
|
||||
|
||||
~AutoProfilerInit() { profiler_shutdown(); }
|
||||
|
||||
private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class MOZ_RAII GeckoProfilerThreadSleepRAII {
|
||||
class MOZ_RAII AutoProfilerThreadSleep
|
||||
{
|
||||
public:
|
||||
GeckoProfilerThreadSleepRAII() {
|
||||
explicit AutoProfilerThreadSleep(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_thread_sleep();
|
||||
}
|
||||
~GeckoProfilerThreadSleepRAII() {
|
||||
profiler_thread_wake();
|
||||
}
|
||||
|
||||
~AutoProfilerThreadSleep() { profiler_thread_wake(); }
|
||||
|
||||
private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
// Temporarily wake up the profiling of a thread while servicing events such as
|
||||
// Asynchronous Procedure Calls (APCs).
|
||||
class MOZ_RAII GeckoProfilerThreadWakeRAII {
|
||||
class MOZ_RAII AutoProfilerThreadWake
|
||||
{
|
||||
public:
|
||||
GeckoProfilerThreadWakeRAII()
|
||||
explicit AutoProfilerThreadWake(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
|
||||
: mIssuedWake(profiler_thread_is_sleeping())
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (mIssuedWake) {
|
||||
profiler_thread_wake();
|
||||
}
|
||||
}
|
||||
~GeckoProfilerThreadWakeRAII() {
|
||||
|
||||
~AutoProfilerThreadWake()
|
||||
{
|
||||
if (mIssuedWake) {
|
||||
MOZ_ASSERT(!profiler_thread_is_sleeping());
|
||||
profiler_thread_sleep();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
bool mIssuedWake;
|
||||
};
|
||||
|
||||
class MOZ_RAII GeckoProfilerTracingRAII {
|
||||
class MOZ_RAII AutoProfilerTracing
|
||||
{
|
||||
public:
|
||||
GeckoProfilerTracingRAII(const char* aCategory, const char* aMarkerName,
|
||||
AutoProfilerTracing(const char* aCategory, const char* aMarkerName,
|
||||
UniqueProfilerBacktrace aBacktrace
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategory(aCategory)
|
||||
|
@ -569,7 +587,7 @@ public:
|
|||
TRACING_INTERVAL_START);
|
||||
}
|
||||
|
||||
GeckoProfilerTracingRAII(const char* aCategory, const char* aMarkerName
|
||||
AutoProfilerTracing(const char* aCategory, const char* aMarkerName
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategory(aCategory)
|
||||
, mMarkerName(aMarkerName)
|
||||
|
@ -578,7 +596,8 @@ public:
|
|||
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_START);
|
||||
}
|
||||
|
||||
~GeckoProfilerTracingRAII() {
|
||||
~AutoProfilerTracing()
|
||||
{
|
||||
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_END);
|
||||
}
|
||||
|
||||
|
@ -590,20 +609,22 @@ protected:
|
|||
|
||||
// Convenience class to register and unregister a thread with the profiler.
|
||||
// Needs to be the first object on the stack of the thread.
|
||||
class MOZ_STACK_CLASS AutoProfilerRegister final
|
||||
class MOZ_RAII AutoProfilerRegister final
|
||||
{
|
||||
public:
|
||||
explicit AutoProfilerRegister(const char* aName)
|
||||
explicit AutoProfilerRegister(const char* aName
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_register_thread(aName, this);
|
||||
}
|
||||
~AutoProfilerRegister()
|
||||
{
|
||||
profiler_unregister_thread();
|
||||
}
|
||||
|
||||
~AutoProfilerRegister() { profiler_unregister_thread(); }
|
||||
|
||||
private:
|
||||
AutoProfilerRegister(const AutoProfilerRegister&) = delete;
|
||||
AutoProfilerRegister& operator=(const AutoProfilerRegister&) = delete;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string.h>
|
||||
|
||||
// Note: profiler_init() has already been called in XRE_main(), so we can't
|
||||
// test it here. Likewise for profiler_shutdown(), and GeckoProfilerInitRAII
|
||||
// test it here. Likewise for profiler_shutdown(), and AutoProfilerInit
|
||||
// (which is just an RAII wrapper for profiler_init() and profiler_shutdown()).
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -375,7 +375,7 @@ TEST(GeckoProfiler, Markers)
|
|||
profiler_tracing("B", "A", Move(bt), TRACING_EVENT);
|
||||
|
||||
{
|
||||
GeckoProfilerTracingRAII tracing("C", "A");
|
||||
AutoProfilerTracing tracing("C", "A");
|
||||
|
||||
profiler_log("X"); // Just a specialized form of profiler_tracing().
|
||||
}
|
||||
|
@ -583,9 +583,9 @@ TEST(GeckoProfiler, PseudoStack)
|
|||
}
|
||||
|
||||
#if defined(MOZ_GECKO_PROFILER)
|
||||
ProfilerStackFrameRAII raii1("A", nullptr, 888,
|
||||
AutoProfilerLabel label1("A", nullptr, 888,
|
||||
js::ProfileEntry::Category::STORAGE);
|
||||
ProfilerStackFrameRAII raii2("A", dynamic.get(), 888,
|
||||
AutoProfilerLabel label2("A", dynamic.get(), 888,
|
||||
js::ProfileEntry::Category::NETWORK);
|
||||
ASSERT_TRUE(profiler_get_backtrace());
|
||||
#endif
|
||||
|
|
|
@ -396,7 +396,7 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
|||
// Block and wait for any posted application message
|
||||
mozilla::HangMonitor::Suspend();
|
||||
{
|
||||
GeckoProfilerThreadSleepRAII sleep;
|
||||
AutoProfilerThreadSleep sleep;
|
||||
WinUtils::WaitForMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -507,7 +507,7 @@ ReentrantMonitor::Wait(PRIntervalTime aInterval)
|
|||
nsresult rv;
|
||||
#if defined(MOZILLA_INTERNAL_API)
|
||||
{
|
||||
GeckoProfilerThreadSleepRAII sleep;
|
||||
AutoProfilerThreadSleep sleep;
|
||||
#endif //MOZILLA_INTERNAL_API
|
||||
|
||||
// give up the monitor until we're back from Wait()
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
{
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
GeckoProfilerThreadSleepRAII sleep;
|
||||
AutoProfilerThreadSleep sleep;
|
||||
#endif //MOZILLA_INTERNAL_API
|
||||
if (aInterval == PR_INTERVAL_NO_TIMEOUT) {
|
||||
mImpl.wait(*mLock);
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
GeckoProfilerThreadSleepRAII sleep;
|
||||
AutoProfilerThreadSleep sleep;
|
||||
#endif //MOZILLA_INTERNAL_API
|
||||
return PR_Wait(mReentrantMonitor, aInterval) == PR_SUCCESS ?
|
||||
NS_OK : NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче