2013-07-11 08:27:04 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef PROFILER_MARKERS_H
|
|
|
|
#define PROFILER_MARKERS_H
|
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2014-05-24 20:14:14 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2017-05-07 23:38:50 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2014-09-05 23:39:59 +04:00
|
|
|
|
2017-05-07 23:38:50 +03:00
|
|
|
#include "nsString.h"
|
2017-01-06 17:21:01 +03:00
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
|
2017-05-03 02:13:49 +03:00
|
|
|
#include "js/Utility.h"
|
2017-01-19 00:06:59 +03:00
|
|
|
#include "gfxASurface.h"
|
|
|
|
|
2014-09-05 23:39:59 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2013-07-11 08:27:04 +04:00
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
class SpliceableJSONWriter;
|
|
|
|
class UniqueStacks;
|
|
|
|
|
2013-07-11 08:27:04 +04:00
|
|
|
/**
|
|
|
|
* This is an abstract object that can be implied to supply
|
|
|
|
* data to be attached with a profiler marker. Most data inserted
|
|
|
|
* into a profile is stored in a circular buffer. This buffer
|
|
|
|
* typically wraps around and overwrites most entries. Because
|
|
|
|
* of this, this structure is designed to defer the work of
|
|
|
|
* prepare the payload only when 'preparePayload' is called.
|
|
|
|
*
|
|
|
|
* Note when implementing that this object is typically constructed
|
|
|
|
* on a particular thread but 'preparePayload' and the destructor
|
|
|
|
* is called from the main thread.
|
|
|
|
*/
|
2013-09-25 19:28:34 +04:00
|
|
|
class ProfilerMarkerPayload
|
|
|
|
{
|
2013-07-11 08:27:04 +04:00
|
|
|
public:
|
2017-01-06 17:21:01 +03:00
|
|
|
explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr);
|
2013-09-25 19:28:34 +04:00
|
|
|
ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
2017-01-06 17:21:01 +03:00
|
|
|
UniqueProfilerBacktrace aStack = nullptr);
|
2013-07-11 08:27:04 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2013-09-25 19:28:34 +04:00
|
|
|
virtual ~ProfilerMarkerPayload();
|
2013-07-11 08:27:04 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) = 0;
|
2013-07-11 08:27:04 +04:00
|
|
|
|
2014-05-24 20:14:14 +04:00
|
|
|
mozilla::TimeStamp GetStartTime() const { return mStartTime; }
|
|
|
|
|
2013-07-11 08:27:04 +04:00
|
|
|
protected:
|
2013-09-25 19:28:34 +04:00
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2017-02-27 05:52:58 +03:00
|
|
|
void streamCommonProps(const char* aMarkerType,
|
|
|
|
SpliceableJSONWriter& aWriter,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks);
|
2013-09-25 19:28:34 +04:00
|
|
|
|
2017-01-06 17:21:01 +03:00
|
|
|
void SetStack(UniqueProfilerBacktrace aStack) { mStack = mozilla::Move(aStack); }
|
2014-04-22 22:13:00 +04:00
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
private:
|
|
|
|
mozilla::TimeStamp mStartTime;
|
|
|
|
mozilla::TimeStamp mEndTime;
|
2017-01-06 17:21:01 +03:00
|
|
|
UniqueProfilerBacktrace mStack;
|
2013-07-11 08:27:04 +04:00
|
|
|
};
|
|
|
|
|
2013-09-27 20:08:45 +04:00
|
|
|
class ProfilerMarkerTracing : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
2017-03-29 05:56:14 +03:00
|
|
|
ProfilerMarkerTracing(const char* aCategory, TracingKind aKind);
|
|
|
|
ProfilerMarkerTracing(const char* aCategory, TracingKind aKind,
|
2017-01-06 17:21:01 +03:00
|
|
|
UniqueProfilerBacktrace aCause);
|
2013-09-27 20:08:45 +04:00
|
|
|
|
|
|
|
const char *GetCategory() const { return mCategory; }
|
2017-03-29 05:56:14 +03:00
|
|
|
TracingKind GetKind() const { return mKind; }
|
2013-09-27 20:08:45 +04:00
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2013-09-27 20:08:45 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char *mCategory;
|
2017-03-29 05:56:14 +03:00
|
|
|
TracingKind mKind;
|
2013-09-27 20:08:45 +04:00
|
|
|
};
|
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
class ProfilerMarkerImagePayload : public ProfilerMarkerPayload
|
|
|
|
{
|
2013-07-11 08:27:04 +04:00
|
|
|
public:
|
2014-09-02 17:44:54 +04:00
|
|
|
explicit ProfilerMarkerImagePayload(gfxASurface *aImg);
|
2013-07-11 08:27:04 +04:00
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2013-07-11 08:27:04 +04:00
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxASurface> mImg;
|
2013-07-11 08:27:04 +04:00
|
|
|
};
|
|
|
|
|
2013-09-25 19:28:34 +04:00
|
|
|
class IOMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
2014-02-13 22:32:38 +04:00
|
|
|
IOMarkerPayload(const char* aSource, const char* aFilename, const mozilla::TimeStamp& aStartTime,
|
2013-09-25 19:28:34 +04:00
|
|
|
const mozilla::TimeStamp& aEndTime,
|
2017-01-06 17:21:01 +03:00
|
|
|
UniqueProfilerBacktrace aStack);
|
2014-02-13 22:32:38 +04:00
|
|
|
~IOMarkerPayload();
|
2013-09-25 19:28:34 +04:00
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2013-09-25 19:28:34 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char* mSource;
|
2014-02-13 22:32:38 +04:00
|
|
|
char* mFilename;
|
2013-09-25 19:28:34 +04:00
|
|
|
};
|
|
|
|
|
2016-12-23 14:44:35 +03:00
|
|
|
class DOMEventMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime);
|
|
|
|
~DOMEventMarkerPayload();
|
|
|
|
|
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2016-12-23 14:44:35 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsString mType;
|
|
|
|
uint16_t mPhase;
|
|
|
|
};
|
|
|
|
|
2017-04-24 18:15:11 +03:00
|
|
|
class UserTimingMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UserTimingMarkerPayload(const nsAString& aName,
|
|
|
|
const mozilla::TimeStamp& aStartTime);
|
|
|
|
UserTimingMarkerPayload(const nsAString& aName,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime);
|
|
|
|
~UserTimingMarkerPayload();
|
|
|
|
|
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
UniqueStacks& aUniqueStacks) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Either "mark" or "measure".
|
|
|
|
const char* mEntryType;
|
|
|
|
nsString mName;
|
|
|
|
};
|
|
|
|
|
2014-09-05 23:39:59 +04:00
|
|
|
/**
|
|
|
|
* Contains the translation applied to a 2d layer so we can
|
|
|
|
* track the layer position at each frame.
|
|
|
|
*/
|
|
|
|
class LayerTranslationPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LayerTranslationPayload(mozilla::layers::Layer* aLayer,
|
|
|
|
mozilla::gfx::Point aPoint);
|
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2014-09-05 23:39:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::layers::Layer* mLayer;
|
|
|
|
mozilla::gfx::Point mPoint;
|
|
|
|
};
|
|
|
|
|
2015-06-18 08:05:42 +03:00
|
|
|
#include "Units.h" // For ScreenIntPoint
|
|
|
|
|
2014-09-05 23:39:59 +04:00
|
|
|
/**
|
|
|
|
* Tracks when touch events are processed by gecko, not when
|
|
|
|
* the touch actually occured in gonk/android.
|
|
|
|
*/
|
|
|
|
class TouchDataPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
2014-09-11 06:06:53 +04:00
|
|
|
explicit TouchDataPayload(const mozilla::ScreenIntPoint& aPoint);
|
2014-09-05 23:39:59 +04:00
|
|
|
virtual ~TouchDataPayload() {}
|
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2014-09-05 23:39:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::ScreenIntPoint mPoint;
|
|
|
|
};
|
|
|
|
|
2014-10-02 00:01:59 +04:00
|
|
|
/**
|
|
|
|
* Tracks when a vsync occurs according to the HardwareComposer.
|
|
|
|
*/
|
|
|
|
class VsyncPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit VsyncPayload(mozilla::TimeStamp aVsyncTimestamp);
|
|
|
|
virtual ~VsyncPayload() {}
|
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2014-10-02 00:01:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::TimeStamp mVsyncTimestamp;
|
|
|
|
};
|
|
|
|
|
2014-05-24 20:14:14 +04:00
|
|
|
class GPUMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GPUMarkerPayload(const mozilla::TimeStamp& aCpuTimeStart,
|
|
|
|
const mozilla::TimeStamp& aCpuTimeEnd,
|
|
|
|
uint64_t aGpuTimeStart,
|
|
|
|
uint64_t aGpuTimeEnd);
|
|
|
|
~GPUMarkerPayload() {}
|
|
|
|
|
2015-05-12 00:16:44 +03:00
|
|
|
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
2017-02-27 05:52:58 +03:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
2015-05-12 00:16:44 +03:00
|
|
|
UniqueStacks& aUniqueStacks) override;
|
2014-05-24 20:14:14 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::TimeStamp mCpuTimeStart;
|
|
|
|
mozilla::TimeStamp mCpuTimeEnd;
|
|
|
|
uint64_t mGpuTimeStart;
|
|
|
|
uint64_t mGpuTimeEnd;
|
|
|
|
};
|
|
|
|
|
2017-05-03 02:13:49 +03:00
|
|
|
class GCSliceMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GCSliceMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
JS::UniqueChars&& aTimingJSON)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
|
|
|
|
mTimingJSON(mozilla::Move(aTimingJSON))
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~GCSliceMarkerPayload() {}
|
|
|
|
|
|
|
|
void StreamPayload(SpliceableJSONWriter& aWriter,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
UniqueStacks& aUniqueStacks) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
JS::UniqueChars mTimingJSON;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GCMajorMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GCMajorMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
JS::UniqueChars&& aTimingJSON)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
|
|
|
|
mTimingJSON(mozilla::Move(aTimingJSON))
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~GCMajorMarkerPayload() {}
|
|
|
|
|
|
|
|
void StreamPayload(SpliceableJSONWriter& aWriter,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
UniqueStacks& aUniqueStacks) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
JS::UniqueChars mTimingJSON;
|
|
|
|
};
|
|
|
|
|
2017-04-25 23:24:34 +03:00
|
|
|
class GCMinorMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GCMinorMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
JS::UniqueChars&& aTimingData)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
|
|
|
|
mTimingData(mozilla::Move(aTimingData))
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~GCMinorMarkerPayload() {};
|
|
|
|
|
|
|
|
void StreamPayload(SpliceableJSONWriter& aWriter,
|
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
UniqueStacks& aUniqueStacks) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
JS::UniqueChars mTimingData;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-07-11 08:27:04 +04:00
|
|
|
#endif // PROFILER_MARKERS_H
|