mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 15:43:10 -10:00
It's now a very thin wrapper around ThreadInfo, and so can be removed. The patch also has the bonus of setting mIsMainThread correctly for the ThreadInfos that used to be SyncProfiles (i.e. the ones created in profiler_get_backtrace()). As far as I can tell this has only one very minor effect, because that field is only used for those objects to determine how ThreadResponsiveness::Update() dispatches its runnables.
227 lines
6.7 KiB
C++
227 lines
6.7 KiB
C++
/* -*- 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/. */
|
|
|
|
#include "GeckoProfiler.h"
|
|
#include "ProfilerBacktrace.h"
|
|
#include "ProfilerMarkers.h"
|
|
#include "gfxASurface.h"
|
|
#include "Layers.h"
|
|
#include "mozilla/Sprintf.h"
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(UniqueProfilerBacktrace aStack)
|
|
: mStack(mozilla::Move(aStack))
|
|
{}
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
const mozilla::TimeStamp& aEndTime,
|
|
UniqueProfilerBacktrace aStack)
|
|
: mStartTime(aStartTime)
|
|
, mEndTime(aEndTime)
|
|
, mStack(mozilla::Move(aStack))
|
|
{}
|
|
|
|
ProfilerMarkerPayload::~ProfilerMarkerPayload()
|
|
{
|
|
}
|
|
|
|
void
|
|
ProfilerMarkerPayload::streamCommonProps(const char* aMarkerType,
|
|
SpliceableJSONWriter& aWriter,
|
|
UniqueStacks& aUniqueStacks)
|
|
{
|
|
MOZ_ASSERT(aMarkerType);
|
|
aWriter.StringProperty("type", aMarkerType);
|
|
if (!mStartTime.IsNull()) {
|
|
aWriter.DoubleProperty("startTime", profiler_time(mStartTime));
|
|
}
|
|
if (!mEndTime.IsNull()) {
|
|
aWriter.DoubleProperty("endTime", profiler_time(mEndTime));
|
|
}
|
|
if (mStack) {
|
|
aWriter.StartObjectProperty("stack");
|
|
{
|
|
mStack->StreamJSON(aWriter, aUniqueStacks);
|
|
}
|
|
aWriter.EndObject();
|
|
}
|
|
}
|
|
|
|
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData)
|
|
: mCategory(aCategory)
|
|
, mMetaData(aMetaData)
|
|
{
|
|
if (aMetaData == TRACING_EVENT_BACKTRACE) {
|
|
SetStack(profiler_get_backtrace());
|
|
}
|
|
}
|
|
|
|
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData,
|
|
UniqueProfilerBacktrace aCause)
|
|
: mCategory(aCategory)
|
|
, mMetaData(aMetaData)
|
|
{
|
|
if (aCause) {
|
|
SetStack(mozilla::Move(aCause));
|
|
}
|
|
}
|
|
|
|
void
|
|
ProfilerMarkerTracing::StreamPayload(SpliceableJSONWriter& aWriter,
|
|
UniqueStacks& aUniqueStacks)
|
|
{
|
|
streamCommonProps("tracing", aWriter, aUniqueStacks);
|
|
|
|
if (GetCategory()) {
|
|
aWriter.StringProperty("category", GetCategory());
|
|
}
|
|
if (GetMetaData() != TRACING_DEFAULT) {
|
|
if (GetMetaData() == TRACING_INTERVAL_START) {
|
|
aWriter.StringProperty("interval", "start");
|
|
} else if (GetMetaData() == TRACING_INTERVAL_END) {
|
|
aWriter.StringProperty("interval", "end");
|
|
}
|
|
}
|
|
}
|
|
|
|
GPUMarkerPayload::GPUMarkerPayload(
|
|
const mozilla::TimeStamp& aCpuTimeStart,
|
|
const mozilla::TimeStamp& aCpuTimeEnd,
|
|
uint64_t aGpuTimeStart,
|
|
uint64_t aGpuTimeEnd)
|
|
|
|
: ProfilerMarkerPayload(aCpuTimeStart, aCpuTimeEnd)
|
|
, mCpuTimeStart(aCpuTimeStart)
|
|
, mCpuTimeEnd(aCpuTimeEnd)
|
|
, mGpuTimeStart(aGpuTimeStart)
|
|
, mGpuTimeEnd(aGpuTimeEnd)
|
|
{ }
|
|
|
|
void
|
|
GPUMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
|
|
UniqueStacks& aUniqueStacks)
|
|
{
|
|
streamCommonProps("gpu_timer_query", aWriter, aUniqueStacks);
|
|
|
|
aWriter.DoubleProperty("cpustart", profiler_time(mCpuTimeStart));
|
|
aWriter.DoubleProperty("cpuend", profiler_time(mCpuTimeEnd));
|
|
aWriter.IntProperty("gpustart", (int)mGpuTimeStart);
|
|
aWriter.IntProperty("gpuend", (int)mGpuTimeEnd);
|
|
}
|
|
|
|
ProfilerMarkerImagePayload::ProfilerMarkerImagePayload(gfxASurface *aImg)
|
|
: mImg(aImg)
|
|
{ }
|
|
|
|
void
|
|
ProfilerMarkerImagePayload::StreamPayload(SpliceableJSONWriter& aWriter,
|
|
UniqueStacks& aUniqueStacks)
|
|
{
|
|
streamCommonProps("innerHTML", aWriter, aUniqueStacks);
|
|
// TODO: Finish me
|
|
//aWriter.NameValue("innerHTML", "<img src=''/>");
|
|
}
|
|
|
|
IOMarkerPayload::IOMarkerPayload(const char* aSource,
|
|
const char* aFilename,
|
|
const mozilla::TimeStamp& aStartTime,
|
|
const mozilla::TimeStamp& aEndTime,
|
|
UniqueProfilerBacktrace aStack)
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime,
|
|
mozilla::Move(aStack)),
|
|
mSource(aSource)
|
|
{
|
|
mFilename = aFilename ? strdup(aFilename) : nullptr;
|
|
MOZ_ASSERT(aSource);
|
|
}
|
|
|
|
IOMarkerPayload::~IOMarkerPayload(){
|
|
free(mFilename);
|
|
}
|
|
|
|
void
|
|
IOMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
|
|
{
|
|
streamCommonProps("io", aWriter, aUniqueStacks);
|
|
aWriter.StringProperty("source", mSource);
|
|
if (mFilename != nullptr) {
|
|
aWriter.StringProperty("filename", mFilename);
|
|
}
|
|
}
|
|
|
|
DOMEventMarkerPayload::DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
|
|
const mozilla::TimeStamp& aStartTime,
|
|
const mozilla::TimeStamp& aEndTime)
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr)
|
|
, mType(aType)
|
|
, mPhase(aPhase)
|
|
{
|
|
}
|
|
|
|
DOMEventMarkerPayload::~DOMEventMarkerPayload()
|
|
{
|
|
}
|
|
|
|
void
|
|
DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
|
|
{
|
|
streamCommonProps("DOMEvent", aWriter, aUniqueStacks);
|
|
aWriter.StringProperty("type", NS_ConvertUTF16toUTF8(mType).get());
|
|
aWriter.IntProperty("phase", mPhase);
|
|
}
|
|
|
|
void
|
|
ProfilerJSEventMarker(const char *event)
|
|
{
|
|
PROFILER_MARKER(event);
|
|
}
|
|
|
|
LayerTranslationPayload::LayerTranslationPayload(mozilla::layers::Layer* aLayer,
|
|
mozilla::gfx::Point aPoint)
|
|
: ProfilerMarkerPayload(mozilla::TimeStamp::Now(), mozilla::TimeStamp::Now(), nullptr)
|
|
, mLayer(aLayer)
|
|
, mPoint(aPoint)
|
|
{
|
|
}
|
|
|
|
void
|
|
LayerTranslationPayload::StreamPayload(SpliceableJSONWriter& aWriter,
|
|
UniqueStacks& aUniqueStacks)
|
|
{
|
|
const size_t bufferSize = 32;
|
|
char buffer[bufferSize];
|
|
SprintfLiteral(buffer, "%p", mLayer);
|
|
|
|
aWriter.StringProperty("layer", buffer);
|
|
aWriter.IntProperty("x", mPoint.x);
|
|
aWriter.IntProperty("y", mPoint.y);
|
|
aWriter.StringProperty("category", "LayerTranslation");
|
|
}
|
|
|
|
TouchDataPayload::TouchDataPayload(const mozilla::ScreenIntPoint& aPoint)
|
|
: ProfilerMarkerPayload(mozilla::TimeStamp::Now(), mozilla::TimeStamp::Now(), nullptr)
|
|
{
|
|
mPoint = aPoint;
|
|
}
|
|
|
|
void
|
|
TouchDataPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
|
|
{
|
|
aWriter.IntProperty("x", mPoint.x);
|
|
aWriter.IntProperty("y", mPoint.y);
|
|
}
|
|
|
|
VsyncPayload::VsyncPayload(mozilla::TimeStamp aVsyncTimestamp)
|
|
: ProfilerMarkerPayload(aVsyncTimestamp, aVsyncTimestamp, nullptr)
|
|
, mVsyncTimestamp(aVsyncTimestamp)
|
|
{
|
|
}
|
|
|
|
void
|
|
VsyncPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
|
|
{
|
|
aWriter.DoubleProperty("vsync", profiler_time(mVsyncTimestamp));
|
|
aWriter.StringProperty("category", "VsyncTimestamp");
|
|
}
|