Bug 1204584 - Ensure that entries created by AutoSPSEntry propogate their category information; r=djvj

This commit renames ProfileEntry::set{Js,Cpp}Frame methods to
ProfileEntry::init{Js,Cpp}Frame to highlight the fact that they are intended to
initialize the entry, and that setting other flags should happen after one of
these calls.
This commit is contained in:
Nick Fitzgerald 2015-09-19 11:19:07 +02:00
parent 0905e5d6f3
commit d89a90562f
3 changed files with 14 additions and 17 deletions

View File

@ -52,7 +52,8 @@ class ProfileEntry
enum Flags {
// Indicate whether a profile entry represents a CPP frame. If not set,
// a JS frame is assumed by default. You're not allowed to publicly
// change the frame type. Instead, call `setJsFrame` or `setCppFrame`.
// change the frame type. Instead, initialize the ProfileEntry as either
// a JS or CPP frame with `initJsFrame` or `initCppFrame` respectively.
IS_CPP_ENTRY = 0x01,
// Indicate that copying the frame label is not necessary when taking a
@ -106,12 +107,12 @@ class ProfileEntry
void setLabel(const char* aString) volatile { string = aString; }
const char* label() const volatile { return string; }
void setJsFrame(JSScript* aScript, jsbytecode* aPc) volatile {
void initJsFrame(JSScript* aScript, jsbytecode* aPc) volatile {
flags_ = 0;
spOrScript = aScript;
setPC(aPc);
}
void setCppFrame(void* aSp, uint32_t aLine) volatile {
void initCppFrame(void* aSp, uint32_t aLine) volatile {
flags_ = IS_CPP_ENTRY;
spOrScript = aSp;
lineOrPc = static_cast<int32_t>(aLine);
@ -137,6 +138,8 @@ class ProfileEntry
return flags_ & CATEGORY_MASK;
}
void setCategory(Category c) volatile {
MOZ_ASSERT(c >= Category::FIRST);
MOZ_ASSERT(c <= Category::LAST);
flags_ &= ~CATEGORY_MASK;
setFlag(static_cast<uint32_t>(c));
}

View File

@ -253,7 +253,7 @@ SPSProfiler::beginPseudoJS(const char* string, void* sp)
MOZ_ASSERT(installed());
if (current < max_) {
stack[current].setLabel(string);
stack[current].setCppFrame(sp, 0);
stack[current].initCppFrame(sp, 0);
stack[current].setFlag(ProfileEntry::BEGIN_PSEUDO_JS);
}
*size = current + 1;
@ -274,18 +274,19 @@ SPSProfiler::push(const char* string, void* sp, JSScript* script, jsbytecode* pc
MOZ_ASSERT(installed());
if (current < max_) {
volatile ProfileEntry& entry = stack[current];
entry.setLabel(string);
entry.setCategory(category);
if (sp != nullptr) {
entry.setCppFrame(sp, 0);
entry.initCppFrame(sp, 0);
MOZ_ASSERT(entry.flags() == js::ProfileEntry::IS_CPP_ENTRY);
}
else {
entry.setJsFrame(script, pc);
entry.initJsFrame(script, pc);
MOZ_ASSERT(entry.flags() == 0);
}
entry.setLabel(string);
entry.setCategory(category);
// Track if mLabel needs a copy.
if (copy)
entry.setFlag(js::ProfileEntry::FRAME_LABEL_COPY);

View File

@ -276,16 +276,10 @@ public:
// Make sure we increment the pointer after the name has
// been written such that mStack is always consistent.
entry.initCppFrame(aStackAddress, line);
entry.setLabel(aName);
entry.setCppFrame(aStackAddress, line);
MOZ_ASSERT(entry.flags() == js::ProfileEntry::IS_CPP_ENTRY);
uint32_t uint_category = static_cast<uint32_t>(aCategory);
MOZ_ASSERT(
uint_category >= static_cast<uint32_t>(js::ProfileEntry::Category::FIRST) &&
uint_category <= static_cast<uint32_t>(js::ProfileEntry::Category::LAST));
entry.setFlag(uint_category);
entry.setCategory(aCategory);
// Track if mLabel needs a copy.
if (aCopy)
@ -466,4 +460,3 @@ public:
};
#endif