зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1499507 - Add ProfilingStackFrame flags for to choose the string template that is used to combine the label with the dynamic string. r=njn
These flags will be used by WebIDL APIs in an upcoming patch. Depends on D9199 Differential Revision: https://phabricator.services.mozilla.com/D9203 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9bed7de565
Коммит
30477de777
|
@ -152,7 +152,7 @@ class ProfilingStackFrame
|
|||
mozilla::Atomic<int32_t, mozilla::ReleaseAcquire,
|
||||
mozilla::recordreplay::Behavior::DontPreserve> pcOffsetIfJS_;
|
||||
|
||||
// Bits 0...3 hold the Flags. Bits 4...31 hold the category.
|
||||
// Bits 0...6 hold the Flags. Bits 7...31 hold the category.
|
||||
mozilla::Atomic<uint32_t, mozilla::ReleaseAcquire,
|
||||
mozilla::recordreplay::Behavior::DontPreserve> flagsAndCategory_;
|
||||
|
||||
|
@ -173,8 +173,8 @@ class ProfilingStackFrame
|
|||
return *this;
|
||||
}
|
||||
|
||||
// 4 bits for the flags.
|
||||
// That leaves 32 - 4 = 28 bits for the category.
|
||||
// 7 bits for the flags.
|
||||
// That leaves 32 - 7 = 25 bits for the category.
|
||||
enum class Flags : uint32_t {
|
||||
// The first three flags describe the kind of the frame and are
|
||||
// mutually exclusive. (We still give them individual bits for
|
||||
|
@ -198,7 +198,16 @@ class ProfilingStackFrame
|
|||
// JS_OSR frames are ignored.
|
||||
JS_OSR = 1 << 3,
|
||||
|
||||
FLAGS_BITCOUNT = 4,
|
||||
// The next three are mutually exclusive.
|
||||
// By default, for profiling stack frames that have both a label and a
|
||||
// dynamic string, the two strings are combined into one string of the
|
||||
// form "<label> <dynamicString>" during JSON serialization. The
|
||||
// following flags can be used to change this preset.
|
||||
STRING_TEMPLATE_METHOD = 1 << 4, // "<label>.<dynamicString>"
|
||||
STRING_TEMPLATE_GETTER = 1 << 5, // "get <label>.<dynamicString>"
|
||||
STRING_TEMPLATE_SETTER = 1 << 6, // "set <label>.<dynamicString>"
|
||||
|
||||
FLAGS_BITCOUNT = 7,
|
||||
FLAGS_MASK = (1 << FLAGS_BITCOUNT) - 1
|
||||
};
|
||||
|
||||
|
@ -292,6 +301,10 @@ class ProfilingStackFrame
|
|||
MOZ_ASSERT(isJsFrame());
|
||||
}
|
||||
|
||||
uint32_t flags() const {
|
||||
return uint32_t(flagsAndCategory_) & uint32_t(Flags::FLAGS_MASK);
|
||||
}
|
||||
|
||||
Category category() const {
|
||||
return Category(flagsAndCategory_ >> uint32_t(Flags::FLAGS_BITCOUNT));
|
||||
}
|
||||
|
|
|
@ -68,11 +68,12 @@ ProfileBuffer::AddStoredMarker(ProfilerMarker *aStoredMarker)
|
|||
|
||||
void
|
||||
ProfileBuffer::CollectCodeLocation(
|
||||
const char* aLabel, const char* aStr,
|
||||
const char* aLabel, const char* aStr, uint32_t aFrameFlags,
|
||||
const Maybe<uint32_t>& aLineNumber, const Maybe<uint32_t>& aColumnNumber,
|
||||
const Maybe<js::ProfilingStackFrame::Category>& aCategory)
|
||||
{
|
||||
AddEntry(ProfileBufferEntry::Label(aLabel));
|
||||
AddEntry(ProfileBufferEntry::FrameFlags(uint64_t(aFrameFlags)));
|
||||
|
||||
if (aStr) {
|
||||
// Store the string using one or more DynamicStringFragment entries.
|
||||
|
@ -154,7 +155,8 @@ ProfileBufferCollector::CollectJitReturnAddr(void* aAddr)
|
|||
void
|
||||
ProfileBufferCollector::CollectWasmFrame(const char* aLabel)
|
||||
{
|
||||
mBuf.CollectCodeLocation("", aLabel, Nothing(), Nothing(), Nothing());
|
||||
mBuf.CollectCodeLocation("", aLabel, 0,
|
||||
Nothing(), Nothing(), Nothing());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -209,6 +211,6 @@ ProfileBufferCollector::CollectProfilingStackFrame(const js::ProfilingStackFrame
|
|||
}
|
||||
}
|
||||
|
||||
mBuf.CollectCodeLocation(label, dynamicString, line, column,
|
||||
Some(aFrame.category()));
|
||||
mBuf.CollectCodeLocation(label, dynamicString, aFrame.flags(),
|
||||
line, column, Some(aFrame.category()));
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
uint64_t AddThreadIdEntry(int aThreadId);
|
||||
|
||||
void CollectCodeLocation(
|
||||
const char* aLabel, const char* aStr,
|
||||
const char* aLabel, const char* aStr, uint32_t aFrameFlags,
|
||||
const mozilla::Maybe<uint32_t>& aLineNumber,
|
||||
const mozilla::Maybe<uint32_t>& aColumnNumber,
|
||||
const mozilla::Maybe<js::ProfilingStackFrame::Category>& aCategory);
|
||||
|
|
|
@ -823,7 +823,7 @@ private:
|
|||
// ThreadId
|
||||
// Time
|
||||
// ( NativeLeafAddr
|
||||
// | Label DynamicStringFragment* LineNumber? Category?
|
||||
// | Label FrameFlags? DynamicStringFragment* LineNumber? Category?
|
||||
// | JitReturnAddr
|
||||
// )+
|
||||
// Marker*
|
||||
|
@ -866,12 +866,14 @@ private:
|
|||
// - ProfilingStack frames with a dynamic string:
|
||||
//
|
||||
// Label("nsObserverService::NotifyObservers")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_LABEL_FRAME))
|
||||
// DynamicStringFragment("domwindo")
|
||||
// DynamicStringFragment("wopened")
|
||||
// LineNumber(291)
|
||||
// Category(ProfilingStackFrame::Category::OTHER)
|
||||
//
|
||||
// Label("")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_JS_FRAME))
|
||||
// DynamicStringFragment("closeWin")
|
||||
// DynamicStringFragment("dow (chr")
|
||||
// DynamicStringFragment("ome://gl")
|
||||
|
@ -884,6 +886,7 @@ private:
|
|||
// Category(ProfilingStackFrame::Category::JS)
|
||||
//
|
||||
// Label("")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_JS_FRAME))
|
||||
// DynamicStringFragment("bound (s")
|
||||
// DynamicStringFragment("elf-host")
|
||||
// DynamicStringFragment("ed:914)")
|
||||
|
@ -893,6 +896,7 @@ private:
|
|||
// - A profiling stack frame with a dynamic string, but with privacy enabled:
|
||||
//
|
||||
// Label("nsObserverService::NotifyObservers")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_LABEL_FRAME))
|
||||
// DynamicStringFragment("(private")
|
||||
// DynamicStringFragment(")")
|
||||
// LineNumber(291)
|
||||
|
@ -901,6 +905,7 @@ private:
|
|||
// - A profiling stack frame with an overly long dynamic string:
|
||||
//
|
||||
// Label("")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_LABEL_FRAME))
|
||||
// DynamicStringFragment("(too lon")
|
||||
// DynamicStringFragment("g)")
|
||||
// LineNumber(100)
|
||||
|
@ -909,6 +914,7 @@ private:
|
|||
// - A wasm JIT frame:
|
||||
//
|
||||
// Label("")
|
||||
// FrameFlags(uint64_t(0))
|
||||
// DynamicStringFragment("wasm-fun")
|
||||
// DynamicStringFragment("ction[87")
|
||||
// DynamicStringFragment("36] (blo")
|
||||
|
@ -925,6 +931,7 @@ private:
|
|||
// - A JS frame in a synchronous sample:
|
||||
//
|
||||
// Label("")
|
||||
// FrameFlags(uint64_t(ProfilingStackFrame::Flags::IS_LABEL_FRAME))
|
||||
// DynamicStringFragment("u (https")
|
||||
// DynamicStringFragment("://perf-")
|
||||
// DynamicStringFragment("html.io/")
|
||||
|
@ -1025,9 +1032,15 @@ ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
|
|||
numFrames++;
|
||||
|
||||
const char* label = e.Get().u.mString;
|
||||
|
||||
e.Next();
|
||||
|
||||
using FrameFlags = js::ProfilingStackFrame::Flags;
|
||||
uint32_t frameFlags = 0;
|
||||
if (e.Has() && e.Get().IsFrameFlags()) {
|
||||
frameFlags = uint32_t(e.Get().u.mUint64);
|
||||
e.Next();
|
||||
}
|
||||
|
||||
// Copy potential dynamic string fragments into dynStrBuf, so that
|
||||
// dynStrBuf will then contain the entire dynamic string.
|
||||
size_t i = 0;
|
||||
|
@ -1051,7 +1064,17 @@ ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
|
|||
|
||||
nsCString frameLabel;
|
||||
if (label[0] != '\0' && hasDynamicString) {
|
||||
frameLabel.AppendPrintf("%s %s", label, dynStrBuf.get());
|
||||
if (frameFlags & uint32_t(FrameFlags::STRING_TEMPLATE_METHOD)) {
|
||||
frameLabel.AppendPrintf("%s.%s", label, dynStrBuf.get());
|
||||
} else if (frameFlags & uint32_t(FrameFlags::STRING_TEMPLATE_GETTER)) {
|
||||
frameLabel.AppendPrintf("get %s.%s", label, dynStrBuf.get());
|
||||
} else if (frameFlags & uint32_t(FrameFlags::STRING_TEMPLATE_SETTER)) {
|
||||
frameLabel.AppendPrintf("set %s.%s", label, dynStrBuf.get());
|
||||
} else {
|
||||
frameLabel.AppendPrintf("%s %s", label, dynStrBuf.get());
|
||||
}
|
||||
} else if (hasDynamicString) {
|
||||
frameLabel.Append(dynStrBuf.get());
|
||||
} else {
|
||||
frameLabel.Append(label);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class ProfilerMarker;
|
|||
macro(CollectionStart, double) \
|
||||
macro(CollectionEnd, double) \
|
||||
macro(Label, const char*) \
|
||||
macro(FrameFlags, uint64_t) \
|
||||
macro(DynamicStringFragment, char*) /* char[kNumChars], really */ \
|
||||
macro(JitReturnAddr, void*) \
|
||||
macro(LineNumber, int) \
|
||||
|
|
|
@ -1840,8 +1840,9 @@ CollectJavaThreadProfileData()
|
|||
parentFrameWasIdleFrame = false;
|
||||
}
|
||||
|
||||
buffer->CollectCodeLocation("", frameNameString.get(), Nothing(),
|
||||
Nothing(), category);
|
||||
buffer->CollectCodeLocation("", frameNameString.get(),
|
||||
js::ProfilingStackFrame::StringTemplate::DEFAULT,
|
||||
Nothing(), Nothing(), category);
|
||||
}
|
||||
sampleId++;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче