Make V8 compilable with profiling support turned off.

BUG=990

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6044 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mikhail.naganov@gmail.com 2010-12-16 12:14:56 +00:00
parent cdc7d3908e
commit e521db4afa
4 changed files with 25 additions and 2 deletions

View File

@ -709,6 +709,7 @@ void Logger::SetterCallbackEvent(String* name, Address entry_point) {
}
#ifdef ENABLE_LOGGING_AND_PROFILING
static const char* ComputeMarker(Code* code) {
switch (code->kind()) {
case Code::FUNCTION: return code->optimizable() ? "~" : "";
@ -716,6 +717,7 @@ static const char* ComputeMarker(Code* code) {
default: return "";
}
}
#endif
void Logger::CodeCreateEvent(LogEventsAndTags tag,
@ -1577,13 +1579,17 @@ bool Logger::Setup() {
void Logger::EnsureTickerStarted() {
#ifdef ENABLE_LOGGING_AND_PROFILING
ASSERT(ticker_ != NULL);
if (!ticker_->IsActive()) ticker_->Start();
#endif
}
void Logger::EnsureTickerStopped() {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (ticker_ != NULL && ticker_->IsActive()) ticker_->Stop();
#endif
}

View File

@ -350,6 +350,7 @@ void RuntimeProfiler::OptimizeSoon(JSFunction* function) {
}
#ifdef ENABLE_LOGGING_AND_PROFILING
static void UpdateStateRatio(SamplerState current_state) {
static const int kStateWindowSize = 128;
static SamplerState state_window[kStateWindowSize];
@ -366,15 +367,18 @@ static void UpdateStateRatio(SamplerState current_state) {
NoBarrier_Store(&js_ratio, state_counts[IN_JS_STATE] * 100 /
kStateWindowSize);
}
#endif
void RuntimeProfiler::NotifyTick() {
#ifdef ENABLE_LOGGING_AND_PROFILING
// Record state sample.
SamplerState state = Top::IsInJSState()
? IN_JS_STATE
: IN_NON_JS_STATE;
UpdateStateRatio(state);
StackGuard::RequestRuntimeProfilerTick();
#endif
}
@ -428,6 +432,7 @@ int RuntimeProfiler::SamplerWindowSize() {
bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
#ifdef ENABLE_LOGGING_AND_PROFILING
static const int kNonJSTicksThreshold = 100;
// We suspend the runtime profiler thread when not running
// JavaScript. If the CPU profiler is active we must not do this
@ -445,6 +450,7 @@ bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
}
}
}
#endif
return false;
}

View File

@ -40,7 +40,9 @@
namespace v8 {
namespace internal {
#ifdef ENABLE_LOGGING_AND_PROFILING
Semaphore* Top::runtime_profiler_semaphore_ = NULL;
#endif
ThreadLocalTop Top::thread_local_;
Mutex* Top::break_access_ = OS::CreateMutex();
@ -277,9 +279,11 @@ static bool initialized = false;
void Top::Initialize() {
CHECK(!initialized);
#ifdef ENABLE_LOGGING_AND_PROFILING
ASSERT(runtime_profiler_semaphore_ == NULL);
runtime_profiler_semaphore_ = OS::CreateSemaphore(0);
#endif
InitializeThreadLocal();
// Only preallocate on the first initialization.
@ -297,9 +301,11 @@ void Top::Initialize() {
void Top::TearDown() {
if (initialized) {
#ifdef ENABLE_LOGGING_AND_PROFILING
delete runtime_profiler_semaphore_;
runtime_profiler_semaphore_ = NULL;
#endif
// Remove the external reference to the preallocated stack memory.
if (preallocated_message_space != NULL) {
delete preallocated_message_space;

View File

@ -1181,6 +1181,8 @@ def BuildOptions():
result.add_option("--crankshaft",
help="Run with the --crankshaft flag",
default=False, action="store_true")
result.add_option("--noprof", help="Disable profiling support",
default=False)
return result
@ -1220,6 +1222,9 @@ def ProcessOptions(options):
options.special_command += " --crankshaft"
else:
options.special_command = "@--crankshaft"
if options.noprof:
options.scons_flags.append("prof=off")
options.scons_flags.append("profilingsupport=off")
return True