Bug 974980 - Always push a js:RunScript frame in pseudostack; r=BenWa

This commit is contained in:
Jim Chen 2014-02-24 12:27:58 -05:00
parent a6e6fc47d1
commit dca2479fd2
4 changed files with 15 additions and 5 deletions

View File

@ -78,6 +78,10 @@ class ProfileEntry
// a pc into a script's code. To signify a nullptr pc, use a -1 index. This
// is checked against in pc() and setPC() to set/get the right pc.
static const int32_t NullPCIndex = -1;
// This bit is added to the stack address to indicate that copying the
// frame label is not necessary when taking a sample of the pseudostack.
static const uintptr_t NoCopyBit = 1;
};
JS_FRIEND_API(void)

View File

@ -212,7 +212,7 @@ SPSProfiler::push(const char *string, void *sp, JSScript *script, jsbytecode *pc
volatile uint32_t *size = size_;
uint32_t current = *size;
JS_ASSERT(enabled());
JS_ASSERT(installed());
if (current < max_) {
stack[current].setLabel(string);
stack[current].setStackAddress(sp);
@ -291,12 +291,12 @@ SPSEntryMarker::SPSEntryMarker(JSRuntime *rt
: profiler(&rt->spsProfiler)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (!profiler->enabled()) {
if (!profiler->installed()) {
profiler = nullptr;
return;
}
size_before = *profiler->size_;
profiler->push("js::RunScript", this, nullptr, nullptr);
profiler->pushNoCopy("js::RunScript", this, nullptr, nullptr);
}
SPSEntryMarker::~SPSEntryMarker()

View File

@ -128,6 +128,12 @@ class SPSProfiler
const char *allocProfileString(JSScript *script, JSFunction *function);
void push(const char *string, void *sp, JSScript *script, jsbytecode *pc);
void pushNoCopy(const char *string, void *sp,
JSScript *script, jsbytecode *pc) {
push(string, reinterpret_cast<void*>(
reinterpret_cast<uintptr_t>(sp) | ProfileEntry::NoCopyBit),
script, pc);
}
void pop();
public:

View File

@ -93,10 +93,10 @@ public:
// Last bit 1 = Don't copy, Last bit 0 = Copy.
if (copy) {
setStackAddress(reinterpret_cast<void*>(
reinterpret_cast<uintptr_t>(sparg) & ~0x1));
reinterpret_cast<uintptr_t>(sparg) & ~NoCopyBit));
} else {
setStackAddress(reinterpret_cast<void*>(
reinterpret_cast<uintptr_t>(sparg) | 0x1));
reinterpret_cast<uintptr_t>(sparg) | NoCopyBit));
}
}
};