Bug 772630 - Deay JS profiling until we have a JSRuntime. r=ehsan,acrichton

This commit is contained in:
Benoit Girard 2012-07-10 22:05:38 -04:00
parent 67b19a9db9
commit e25a726e82
2 changed files with 19 additions and 6 deletions

View File

@ -891,8 +891,9 @@ void mozilla_sampler_init()
return;
}
const char* features = "js";
mozilla_sampler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
PROFILE_DEFAULT_FEATURES, PROFILE_DEFAULT_FEATURE_COUNT);
&features, 1);
}
void mozilla_sampler_deinit()

View File

@ -234,6 +234,7 @@ public:
: mStackPointer(0)
, mMarkerPointer(0)
, mQueueClearMarker(false)
, mStartJSSampling(false)
{ }
void addMarker(const char *aMarker)
@ -304,16 +305,25 @@ public:
void sampleRuntime(JSRuntime *runtime) {
mRuntime = runtime;
if (mStartJSSampling)
installJSSampling();
}
void installJSSampling() {
JS_STATIC_ASSERT(sizeof(mStack[0]) == sizeof(js::ProfileEntry));
js::SetRuntimeProfilingStack(mRuntime,
(js::ProfileEntry*) mStack,
(uint32_t*) &mStackPointer,
mozilla::ArrayLength(mStack));
if (mRuntime) {
js::SetRuntimeProfilingStack(mRuntime,
(js::ProfileEntry*) mStack,
(uint32_t*) &mStackPointer,
mozilla::ArrayLength(mStack));
mStartJSSampling = false;
} else {
mStartJSSampling = true;
}
}
void uninstallJSSampling() {
js::SetRuntimeProfilingStack(mRuntime, NULL, NULL, 0);
mStartJSSampling = false;
if (mRuntime)
js::SetRuntimeProfilingStack(mRuntime, NULL, NULL, 0);
}
// Keep a list of active checkpoints
@ -327,6 +337,8 @@ public:
volatile mozilla::sig_safe_t mQueueClearMarker;
// The runtime which is being sampled
JSRuntime *mRuntime;
// Start JS Profiling when possible
bool mStartJSSampling;
};
inline ProfileStack* mozilla_profile_stack(void)