2013-07-10 21:27:04 -07: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/. */
|
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "ProfilerBacktrace.h"
|
2013-07-10 21:27:04 -07:00
|
|
|
#include "ProfilerMarkers.h"
|
|
|
|
#include "gfxASurface.h"
|
2013-09-25 08:28:34 -07:00
|
|
|
#include "SyncProfile.h"
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
|
|
|
|
: mStack(aStack)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack)
|
2013-09-27 09:08:45 -07:00
|
|
|
: mStartTime(aStartTime)
|
|
|
|
, mEndTime(aEndTime)
|
|
|
|
, mStack(aStack)
|
2013-09-25 08:28:34 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
ProfilerMarkerPayload::~ProfilerMarkerPayload()
|
|
|
|
{
|
|
|
|
profiler_free_backtrace(mStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Builder> void
|
|
|
|
ProfilerMarkerPayload::prepareCommonProps(const char* aMarkerType,
|
|
|
|
Builder& aBuilder,
|
|
|
|
typename Builder::ObjectHandle aObject)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aMarkerType);
|
|
|
|
aBuilder.DefineProperty(aObject, "type", aMarkerType);
|
|
|
|
if (!mStartTime.IsNull()) {
|
|
|
|
aBuilder.DefineProperty(aObject, "startTime", profiler_time(mStartTime));
|
|
|
|
}
|
|
|
|
if (!mEndTime.IsNull()) {
|
|
|
|
aBuilder.DefineProperty(aObject, "endTime", profiler_time(mEndTime));
|
|
|
|
}
|
|
|
|
if (mStack) {
|
|
|
|
typename Builder::RootedObject stack(aBuilder.context(),
|
|
|
|
aBuilder.CreateObject());
|
|
|
|
aBuilder.DefineProperty(aObject, "stack", stack);
|
|
|
|
mStack->BuildJSObject(aBuilder, stack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template void
|
|
|
|
ProfilerMarkerPayload::prepareCommonProps<JSCustomObjectBuilder>(
|
|
|
|
const char* aMarkerType,
|
|
|
|
JSCustomObjectBuilder& b,
|
|
|
|
JSCustomObjectBuilder::ObjectHandle aObject);
|
|
|
|
template void
|
|
|
|
ProfilerMarkerPayload::prepareCommonProps<JSObjectBuilder>(
|
|
|
|
const char* aMarkerType,
|
|
|
|
JSObjectBuilder& b,
|
|
|
|
JSObjectBuilder::ObjectHandle aObject);
|
2013-07-10 21:27:04 -07:00
|
|
|
|
2013-09-27 09:08:45 -07:00
|
|
|
ProfilerMarkerTracing::ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mMetaData(aMetaData)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename Builder>
|
|
|
|
typename Builder::Object
|
|
|
|
ProfilerMarkerTracing::preparePayloadImp(Builder& b)
|
|
|
|
{
|
|
|
|
typename Builder::RootedObject data(b.context(), b.CreateObject());
|
|
|
|
prepareCommonProps("tracing", b, data);
|
|
|
|
|
|
|
|
if (GetCategory()) {
|
|
|
|
b.DefineProperty(data, "category", GetCategory());
|
|
|
|
}
|
|
|
|
if (GetMetaData() != TRACING_DEFAULT) {
|
|
|
|
if (GetMetaData() == TRACING_INTERVAL_START) {
|
|
|
|
b.DefineProperty(data, "interval", "start");
|
|
|
|
} else if (GetMetaData() == TRACING_INTERVAL_END) {
|
|
|
|
b.DefineProperty(data, "interval", "end");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
template JSCustomObjectBuilder::Object
|
|
|
|
ProfilerMarkerTracing::preparePayloadImp<JSCustomObjectBuilder>(JSCustomObjectBuilder& b);
|
|
|
|
template JSObjectBuilder::Object
|
|
|
|
ProfilerMarkerTracing::preparePayloadImp<JSObjectBuilder>(JSObjectBuilder& b);
|
|
|
|
|
2013-07-10 21:27:04 -07:00
|
|
|
ProfilerMarkerImagePayload::ProfilerMarkerImagePayload(gfxASurface *aImg)
|
|
|
|
: mImg(aImg)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename Builder>
|
|
|
|
typename Builder::Object
|
|
|
|
ProfilerMarkerImagePayload::preparePayloadImp(Builder& b)
|
|
|
|
{
|
|
|
|
typename Builder::RootedObject data(b.context(), b.CreateObject());
|
2013-09-25 08:28:34 -07:00
|
|
|
prepareCommonProps("innerHTML", b, data);
|
2013-07-10 21:27:04 -07:00
|
|
|
// TODO: Finish me
|
|
|
|
//b.DefineProperty(data, "innerHTML", "<img src=''/>");
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
template JSCustomObjectBuilder::Object
|
|
|
|
ProfilerMarkerImagePayload::preparePayloadImp<JSCustomObjectBuilder>(JSCustomObjectBuilder& b);
|
|
|
|
template JSObjectBuilder::Object
|
|
|
|
ProfilerMarkerImagePayload::preparePayloadImp<JSObjectBuilder>(JSObjectBuilder& b);
|
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
IOMarkerPayload::IOMarkerPayload(const char* aSource,
|
2014-02-13 10:32:38 -08:00
|
|
|
const char* aFilename,
|
2013-09-25 08:28:34 -07:00
|
|
|
const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack)
|
|
|
|
: ProfilerMarkerPayload(aStartTime, aEndTime, aStack),
|
2014-02-20 05:43:55 -08:00
|
|
|
mSource(aSource)
|
2013-09-25 08:28:34 -07:00
|
|
|
{
|
2014-02-20 05:43:55 -08:00
|
|
|
mFilename = aFilename ? strdup(aFilename) : nullptr;
|
2013-09-25 08:28:34 -07:00
|
|
|
MOZ_ASSERT(aSource);
|
|
|
|
}
|
|
|
|
|
2014-02-13 10:32:38 -08:00
|
|
|
IOMarkerPayload::~IOMarkerPayload(){
|
|
|
|
free(mFilename);
|
|
|
|
}
|
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
template<typename Builder> typename Builder::Object
|
|
|
|
IOMarkerPayload::preparePayloadImp(Builder& b)
|
|
|
|
{
|
|
|
|
typename Builder::RootedObject data(b.context(), b.CreateObject());
|
|
|
|
prepareCommonProps("io", b, data);
|
|
|
|
b.DefineProperty(data, "source", mSource);
|
2014-02-13 10:32:38 -08:00
|
|
|
if (mFilename != nullptr) {
|
|
|
|
b.DefineProperty(data, "filename", mFilename);
|
|
|
|
}
|
2013-09-25 08:28:34 -07:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
template JSCustomObjectBuilder::Object
|
|
|
|
IOMarkerPayload::preparePayloadImp<JSCustomObjectBuilder>(JSCustomObjectBuilder& b);
|
|
|
|
template JSObjectBuilder::Object
|
|
|
|
IOMarkerPayload::preparePayloadImp<JSObjectBuilder>(JSObjectBuilder& b);
|
|
|
|
|
2014-03-03 11:36:08 -08:00
|
|
|
void
|
|
|
|
ProfilerJSEventMarker(const char *event)
|
|
|
|
{
|
|
|
|
PROFILER_MARKER(event);
|
|
|
|
}
|