Commit 09dfc4b5 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Add global setup for runtime profiler.

Whether it's enabled or not must not change while we're running. Let's
not waste time recomputing it. This also makes the VM state tracking
code slightly more lightweight.

Review URL: http://codereview.chromium.org/6825054

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7593 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 34d50b3d
......@@ -114,6 +114,11 @@ Atomic32 RuntimeProfiler::state_ = 0;
Semaphore* RuntimeProfiler::semaphore_ = OS::CreateSemaphore(0);
#endif
#ifdef DEBUG
bool RuntimeProfiler::has_been_globally_setup_ = false;
#endif
bool RuntimeProfiler::enabled_ = false;
RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
: isolate_(isolate),
......@@ -134,8 +139,12 @@ RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
}
bool RuntimeProfiler::IsEnabled() {
return V8::UseCrankshaft() && FLAG_opt;
void RuntimeProfiler::GlobalSetup() {
ASSERT(!has_been_globally_setup_);
enabled_ = V8::UseCrankshaft() && FLAG_opt;
#ifdef DEBUG
has_been_globally_setup_ = true;
#endif
}
......@@ -363,6 +372,7 @@ void RuntimeProfiler::NotifyTick() {
void RuntimeProfiler::Setup() {
ASSERT(has_been_globally_setup_);
ClearSampleBuffer();
// If the ticker hasn't already started, make sure to do so to get
// the ticks for the runtime profiler.
......
......@@ -44,7 +44,12 @@ class RuntimeProfiler {
public:
explicit RuntimeProfiler(Isolate* isolate);
static bool IsEnabled();
static void GlobalSetup();
static inline bool IsEnabled() {
ASSERT(has_been_globally_setup_);
return enabled_;
}
void OptimizeNow();
void OptimizeSoon(JSFunction* function);
......@@ -143,6 +148,11 @@ class RuntimeProfiler {
// 0 or positive => the number of isolates running JavaScript code.
static Atomic32 state_;
static Semaphore* semaphore_;
#ifdef DEBUG
static bool has_been_globally_setup_;
#endif
static bool enabled_;
};
......
......@@ -204,6 +204,8 @@ void V8::InitializeOncePerProcess() {
use_crankshaft_ = false;
}
RuntimeProfiler::GlobalSetup();
// Peephole optimization might interfere with deoptimization.
FLAG_peephole_optimization = !use_crankshaft_;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment