Commit 1083d1f8 authored by yurys@chromium.org's avatar yurys@chromium.org

Remove deprecated profiler API

This change removes --prof-lazy command line flag that was introduced for the old CPU profiler implementation in Chrome DevTools. DevTools now use profiler API defined in v8-profiler.h

This change also removes methods for pausing resuming --prof profiler. These methods were deprecated in v.3.20 (https://code.google.com/p/v8/source/browse/branches/3.20/include/v8.h#4629)

After this change the profiler will always start if --prof option is passed and can be stopped either in the tests or if write to log file fails.

BUG=None
R=bmeurer@chromium.org, loislo@chromium.org

Review URL: https://codereview.chromium.org/23478010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16417 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e76482f2
...@@ -4546,28 +4546,6 @@ class V8_EXPORT V8 { ...@@ -4546,28 +4546,6 @@ class V8_EXPORT V8 {
static intptr_t AdjustAmountOfExternalAllocatedMemory( static intptr_t AdjustAmountOfExternalAllocatedMemory(
intptr_t change_in_bytes); intptr_t change_in_bytes);
/**
* Suspends recording of tick samples in the profiler.
* When the V8 profiling mode is enabled (usually via command line
* switches) this function suspends recording of tick samples.
* Profiling ticks are discarded until ResumeProfiler() is called.
*
* See also the --prof and --prof_auto command line switches to
* enable V8 profiling.
*/
V8_DEPRECATED(static void PauseProfiler());
/**
* Resumes recording of tick samples in the profiler.
* See also PauseProfiler().
*/
V8_DEPRECATED(static void ResumeProfiler());
/**
* Return whether profiler is currently paused.
*/
V8_DEPRECATED(static bool IsProfilerPaused());
/** /**
* Retrieve the V8 thread id of the calling thread. * Retrieve the V8 thread id of the calling thread.
* *
......
...@@ -6735,24 +6735,6 @@ void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { ...@@ -6735,24 +6735,6 @@ void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
} }
void V8::PauseProfiler() {
i::Isolate* isolate = i::Isolate::Current();
isolate->logger()->PauseProfiler();
}
void V8::ResumeProfiler() {
i::Isolate* isolate = i::Isolate::Current();
isolate->logger()->ResumeProfiler();
}
bool V8::IsProfilerPaused() {
i::Isolate* isolate = i::Isolate::Current();
return isolate->logger()->IsProfilerPaused();
}
int V8::GetCurrentThreadId() { int V8::GetCurrentThreadId() {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
......
...@@ -430,8 +430,8 @@ void CpuProfiler::StartProcessorIfNotStarted() { ...@@ -430,8 +430,8 @@ void CpuProfiler::StartProcessorIfNotStarted() {
if (processor_ == NULL) { if (processor_ == NULL) {
Logger* logger = isolate_->logger(); Logger* logger = isolate_->logger();
// Disable logging when using the new implementation. // Disable logging when using the new implementation.
saved_logging_nesting_ = logger->logging_nesting_; saved_is_logging_ = logger->is_logging_;
logger->logging_nesting_ = 0; logger->is_logging_ = false;
generator_ = new ProfileGenerator(profiles_); generator_ = new ProfileGenerator(profiles_);
Sampler* sampler = logger->sampler(); Sampler* sampler = logger->sampler();
processor_ = new ProfilerEventsProcessor( processor_ = new ProfilerEventsProcessor(
...@@ -501,7 +501,7 @@ void CpuProfiler::StopProcessor() { ...@@ -501,7 +501,7 @@ void CpuProfiler::StopProcessor() {
sampler->Stop(); sampler->Stop();
need_to_stop_sampler_ = false; need_to_stop_sampler_ = false;
} }
logger->logging_nesting_ = saved_logging_nesting_; logger->is_logging_ = saved_is_logging_;
} }
......
...@@ -265,7 +265,7 @@ class CpuProfiler : public CodeEventListener { ...@@ -265,7 +265,7 @@ class CpuProfiler : public CodeEventListener {
unsigned next_profile_uid_; unsigned next_profile_uid_;
ProfileGenerator* generator_; ProfileGenerator* generator_;
ProfilerEventsProcessor* processor_; ProfilerEventsProcessor* processor_;
int saved_logging_nesting_; bool saved_is_logging_;
bool need_to_stop_sampler_; bool need_to_stop_sampler_;
bool is_profiling_; bool is_profiling_;
......
...@@ -775,9 +775,6 @@ DEFINE_bool(log_snapshot_positions, false, ...@@ -775,9 +775,6 @@ DEFINE_bool(log_snapshot_positions, false,
DEFINE_bool(log_suspect, false, "Log suspect operations.") DEFINE_bool(log_suspect, false, "Log suspect operations.")
DEFINE_bool(prof, false, DEFINE_bool(prof, false,
"Log statistical profiling information (implies --log-code).") "Log statistical profiling information (implies --log-code).")
DEFINE_bool(prof_lazy, false,
"Used with --prof, only does sampling and logging"
" when profiler is active.")
DEFINE_bool(prof_browser_mode, true, DEFINE_bool(prof_browser_mode, true,
"Used with --prof, turns on browser-compatible mode for profiling.") "Used with --prof, turns on browser-compatible mode for profiling.")
DEFINE_bool(log_regexp, false, "Log regular expression execution.") DEFINE_bool(log_regexp, false, "Log regular expression execution.")
......
...@@ -64,11 +64,6 @@ void Log::Initialize(const char* log_file_name) { ...@@ -64,11 +64,6 @@ void Log::Initialize(const char* log_file_name) {
// --prof implies --log-code. // --prof implies --log-code.
if (FLAG_prof) FLAG_log_code = true; if (FLAG_prof) FLAG_log_code = true;
// --prof_lazy controls --log-code.
if (FLAG_prof_lazy) {
FLAG_log_code = false;
}
// If we're logging anything, we need to open the log file. // If we're logging anything, we need to open the log file.
if (Log::InitLogAtStart()) { if (Log::InitLogAtStart()) {
if (strcmp(log_file_name, kLogToConsole) == 0) { if (strcmp(log_file_name, kLogToConsole) == 0) {
......
...@@ -563,7 +563,6 @@ class Profiler: public Thread { ...@@ -563,7 +563,6 @@ class Profiler: public Thread {
virtual void Run(); virtual void Run();
// Pause and Resume TickSample data collection. // Pause and Resume TickSample data collection.
bool paused() const { return paused_; }
void pause() { paused_ = true; } void pause() { paused_ = true; }
void resume() { paused_ = false; } void resume() { paused_ = false; }
...@@ -623,7 +622,7 @@ class Ticker: public Sampler { ...@@ -623,7 +622,7 @@ class Ticker: public Sampler {
ASSERT(profiler_ == NULL); ASSERT(profiler_ == NULL);
profiler_ = profiler; profiler_ = profiler;
IncreaseProfilingDepth(); IncreaseProfilingDepth();
if (!FLAG_prof_lazy && !IsActive()) Start(); if (!IsActive()) Start();
} }
void ClearProfiler() { void ClearProfiler() {
...@@ -710,8 +709,7 @@ Logger::Logger(Isolate* isolate) ...@@ -710,8 +709,7 @@ Logger::Logger(Isolate* isolate)
ticker_(NULL), ticker_(NULL),
profiler_(NULL), profiler_(NULL),
log_events_(NULL), log_events_(NULL),
logging_nesting_(0), is_logging_(false),
cpu_profiler_nesting_(0),
log_(new Log(this)), log_(new Log(this)),
ll_logger_(NULL), ll_logger_(NULL),
jit_logger_(NULL), jit_logger_(NULL),
...@@ -1521,43 +1519,11 @@ void Logger::TickEvent(TickSample* sample, bool overflow) { ...@@ -1521,43 +1519,11 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
} }
bool Logger::IsProfilerPaused() { void Logger::StopProfiler() {
return profiler_ == NULL || profiler_->paused();
}
void Logger::PauseProfiler() {
if (!log_->IsEnabled()) return; if (!log_->IsEnabled()) return;
if (profiler_ != NULL) { if (profiler_ != NULL) {
// It is OK to have negative nesting. profiler_->pause();
if (--cpu_profiler_nesting_ == 0) { is_logging_ = false;
profiler_->pause();
if (FLAG_prof_lazy) {
ticker_->Stop();
FLAG_log_code = false;
LOG(ISOLATE, UncheckedStringEvent("profiler", "pause"));
}
--logging_nesting_;
}
}
}
void Logger::ResumeProfiler() {
if (!log_->IsEnabled()) return;
if (profiler_ != NULL) {
if (cpu_profiler_nesting_++ == 0) {
++logging_nesting_;
if (FLAG_prof_lazy) {
profiler_->Engage();
LOG(ISOLATE, UncheckedStringEvent("profiler", "resume"));
FLAG_log_code = true;
LogCompiledFunctions();
LogAccessorCallbacks();
if (!ticker_->IsActive()) ticker_->Start();
}
profiler_->resume();
}
} }
} }
...@@ -1565,7 +1531,7 @@ void Logger::ResumeProfiler() { ...@@ -1565,7 +1531,7 @@ void Logger::ResumeProfiler() {
// This function can be called when Log's mutex is acquired, // This function can be called when Log's mutex is acquired,
// either from main or Profiler's thread. // either from main or Profiler's thread.
void Logger::LogFailure() { void Logger::LogFailure() {
PauseProfiler(); StopProfiler();
} }
...@@ -1865,11 +1831,6 @@ bool Logger::SetUp(Isolate* isolate) { ...@@ -1865,11 +1831,6 @@ bool Logger::SetUp(Isolate* isolate) {
FLAG_log_snapshot_positions = true; FLAG_log_snapshot_positions = true;
} }
// --prof_lazy controls --log-code.
if (FLAG_prof_lazy) {
FLAG_log_code = false;
}
SmartArrayPointer<const char> log_file_name = SmartArrayPointer<const char> log_file_name =
PrepareLogFileName(FLAG_logfile); PrepareLogFileName(FLAG_logfile);
log_->Initialize(*log_file_name); log_->Initialize(*log_file_name);
...@@ -1882,17 +1843,13 @@ bool Logger::SetUp(Isolate* isolate) { ...@@ -1882,17 +1843,13 @@ bool Logger::SetUp(Isolate* isolate) {
ticker_ = new Ticker(isolate, kSamplingIntervalMs); ticker_ = new Ticker(isolate, kSamplingIntervalMs);
if (Log::InitLogAtStart()) { if (Log::InitLogAtStart()) {
logging_nesting_ = 1; is_logging_ = true;
} }
if (FLAG_prof) { if (FLAG_prof) {
profiler_ = new Profiler(isolate); profiler_ = new Profiler(isolate);
if (FLAG_prof_lazy) { is_logging_ = true;
profiler_->pause(); profiler_->Engage();
} else {
logging_nesting_ = 1;
profiler_->Engage();
}
} }
if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start(); if (FLAG_log_internal_timer_events || FLAG_prof) timer_.Start();
......
...@@ -341,19 +341,16 @@ class Logger { ...@@ -341,19 +341,16 @@ class Logger {
void LogRuntime(Vector<const char> format, JSArray* args); void LogRuntime(Vector<const char> format, JSArray* args);
bool is_logging() { bool is_logging() {
return logging_nesting_ > 0; return is_logging_;
} }
bool is_logging_code_events() { bool is_logging_code_events() {
return is_logging() || jit_logger_ != NULL; return is_logging() || jit_logger_ != NULL;
} }
// Pause/Resume collection of profiling data. // Stop collection of profiling data.
// When data collection is paused, CPU Tick events are discarded until // When data collection is paused, CPU Tick events are discarded.
// data collection is Resumed. void StopProfiler();
void PauseProfiler();
void ResumeProfiler();
bool IsProfilerPaused();
void LogExistingFunction(Handle<SharedFunctionInfo> shared, void LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<Code> code); Handle<Code> code);
...@@ -435,13 +432,9 @@ class Logger { ...@@ -435,13 +432,9 @@ class Logger {
friend class TimeLog; friend class TimeLog;
friend class Profiler; friend class Profiler;
template <StateTag Tag> friend class VMState; template <StateTag Tag> friend class VMState;
friend class LoggerTestHelper; friend class LoggerTestHelper;
bool is_logging_;
int logging_nesting_;
int cpu_profiler_nesting_;
Log* log_; Log* log_;
LowLevelLogger* ll_logger_; LowLevelLogger* ll_logger_;
JitLogger* jit_logger_; JitLogger* jit_logger_;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// //
// Tests of logging functions from log.h // Tests of logging functions from log.h
#define V8_DISABLE_DEPRECATIONS 1
#ifdef __linux__ #ifdef __linux__
#include <pthread.h> #include <pthread.h>
#include <signal.h> #include <signal.h>
...@@ -44,7 +43,6 @@ ...@@ -44,7 +43,6 @@
#include "v8utils.h" #include "v8utils.h"
#include "cctest.h" #include "cctest.h"
#include "vm-state-inl.h" #include "vm-state-inl.h"
#undef V8_DISABLE_DEPRECATIONS
using v8::internal::Address; using v8::internal::Address;
using v8::internal::EmbeddedVector; using v8::internal::EmbeddedVector;
...@@ -56,13 +54,12 @@ namespace { ...@@ -56,13 +54,12 @@ namespace {
class ScopedLoggerInitializer { class ScopedLoggerInitializer {
public: public:
explicit ScopedLoggerInitializer(bool prof_lazy) ScopedLoggerInitializer()
: saved_log_(i::FLAG_log), : saved_log_(i::FLAG_log),
saved_prof_lazy_(i::FLAG_prof_lazy),
saved_prof_(i::FLAG_prof), saved_prof_(i::FLAG_prof),
temp_file_(NULL), temp_file_(NULL),
// Need to run this prior to creating the scope. // Need to run this prior to creating the scope.
trick_to_run_init_flags_(init_flags_(prof_lazy)), trick_to_run_init_flags_(init_flags_()),
scope_(v8::Isolate::GetCurrent()), scope_(v8::Isolate::GetCurrent()),
env_(v8::Context::New(v8::Isolate::GetCurrent())), env_(v8::Context::New(v8::Isolate::GetCurrent())),
logger_(i::Isolate::Current()->logger()) { logger_(i::Isolate::Current()->logger()) {
...@@ -73,7 +70,6 @@ class ScopedLoggerInitializer { ...@@ -73,7 +70,6 @@ class ScopedLoggerInitializer {
env_->Exit(); env_->Exit();
logger_->TearDown(); logger_->TearDown();
if (temp_file_ != NULL) fclose(temp_file_); if (temp_file_ != NULL) fclose(temp_file_);
i::FLAG_prof_lazy = saved_prof_lazy_;
i::FLAG_prof = saved_prof_; i::FLAG_prof = saved_prof_;
i::FLAG_log = saved_log_; i::FLAG_log = saved_log_;
} }
...@@ -91,16 +87,14 @@ class ScopedLoggerInitializer { ...@@ -91,16 +87,14 @@ class ScopedLoggerInitializer {
} }
private: private:
static bool init_flags_(bool prof_lazy) { static bool init_flags_() {
i::FLAG_log = true; i::FLAG_log = true;
i::FLAG_prof = true; i::FLAG_prof = true;
i::FLAG_prof_lazy = prof_lazy;
i::FLAG_logfile = i::Log::kLogToTemporaryFile; i::FLAG_logfile = i::Log::kLogToTemporaryFile;
return prof_lazy; return false;
} }
const bool saved_log_; const bool saved_log_;
const bool saved_prof_lazy_;
const bool saved_prof_; const bool saved_prof_;
FILE* temp_file_; FILE* temp_file_;
const bool trick_to_run_init_flags_; const bool trick_to_run_init_flags_;
...@@ -124,70 +118,6 @@ static const char* StrNStr(const char* s1, const char* s2, int n) { ...@@ -124,70 +118,6 @@ static const char* StrNStr(const char* s1, const char* s2, int n) {
} }
TEST(ProfLazyMode) {
ScopedLoggerInitializer initialize_logger(true);
Logger* logger = initialize_logger.logger();
if (!i::V8::UseCrankshaft()) return;
logger->StringEvent("test-start", "");
CompileRun("var a = (function(x) { return x + 1; })(10);");
logger->StringEvent("test-profiler-start", "");
v8::V8::ResumeProfiler();
CompileRun(
"var b = (function(x) { return x + 2; })(10);\n"
"var c = (function(x) { return x + 3; })(10);\n"
"var d = (function(x) { return x + 4; })(10);\n"
"var e = (function(x) { return x + 5; })(10);");
v8::V8::PauseProfiler();
logger->StringEvent("test-profiler-stop", "");
CompileRun("var f = (function(x) { return x + 6; })(10);");
// Check that profiling can be resumed again.
logger->StringEvent("test-profiler-start-2", "");
v8::V8::ResumeProfiler();
CompileRun(
"var g = (function(x) { return x + 7; })(10);\n"
"var h = (function(x) { return x + 8; })(10);\n"
"var i = (function(x) { return x + 9; })(10);\n"
"var j = (function(x) { return x + 10; })(10);");
v8::V8::PauseProfiler();
logger->StringEvent("test-profiler-stop-2", "");
logger->StringEvent("test-stop", "");
bool exists = false;
i::Vector<const char> log(
i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
CHECK(exists);
const char* test_start_position =
StrNStr(log.start(), "test-start,", log.length());
CHECK_NE(NULL, test_start_position);
const char* test_profiler_start_position =
StrNStr(log.start(), "test-profiler-start,", log.length());
CHECK_NE(NULL, test_profiler_start_position);
CHECK_GT(test_profiler_start_position, test_start_position);
const char* test_profiler_stop_position =
StrNStr(log.start(), "test-profiler-stop,", log.length());
CHECK_NE(NULL, test_profiler_stop_position);
CHECK_GT(test_profiler_stop_position, test_profiler_start_position);
const char* test_profiler_start_2_position =
StrNStr(log.start(), "test-profiler-start-2,", log.length());
CHECK_NE(NULL, test_profiler_start_2_position);
CHECK_GT(test_profiler_start_2_position, test_profiler_stop_position);
// Nothing must be logged until profiling is resumed.
CHECK_EQ(NULL, StrNStr(test_start_position,
"code-creation,",
static_cast<int>(test_profiler_start_position -
test_start_position)));
// Nothing must be logged while profiling is suspended.
CHECK_EQ(NULL, StrNStr(test_profiler_stop_position,
"code-creation,",
static_cast<int>(test_profiler_start_2_position -
test_profiler_stop_position)));
}
// BUG(913). Need to implement support for profiling multiple VM threads. // BUG(913). Need to implement support for profiling multiple VM threads.
#if 0 #if 0
...@@ -396,7 +326,7 @@ static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -396,7 +326,7 @@ static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(LogCallbacks) { TEST(LogCallbacks) {
ScopedLoggerInitializer initialize_logger(false); ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger(); Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate> obj =
...@@ -445,7 +375,7 @@ static void Prop2Getter(v8::Local<v8::String> property, ...@@ -445,7 +375,7 @@ static void Prop2Getter(v8::Local<v8::String> property,
TEST(LogAccessorCallbacks) { TEST(LogAccessorCallbacks) {
ScopedLoggerInitializer initialize_logger(false); ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger(); Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate> obj =
...@@ -486,18 +416,6 @@ TEST(LogAccessorCallbacks) { ...@@ -486,18 +416,6 @@ TEST(LogAccessorCallbacks) {
} }
TEST(IsLoggingPreserved) {
ScopedLoggerInitializer initialize_logger(false);
Logger* logger = initialize_logger.logger();
CHECK(logger->is_logging());
logger->ResumeProfiler();
CHECK(logger->is_logging());
logger->PauseProfiler();
CHECK(logger->is_logging());
}
typedef i::NativesCollection<i::TEST> TestSources; typedef i::NativesCollection<i::TEST> TestSources;
...@@ -514,7 +432,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { ...@@ -514,7 +432,7 @@ TEST(EquivalenceOfLoggingAndTraversal) {
CHECK(!i::V8::IsRunning()); CHECK(!i::V8::IsRunning());
// Start with profiling to capture all code events from the beginning. // Start with profiling to capture all code events from the beginning.
ScopedLoggerInitializer initialize_logger(false); ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger(); Logger* logger = initialize_logger.logger();
// Compile and run a function that creates other functions. // Compile and run a function that creates other functions.
...@@ -523,7 +441,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { ...@@ -523,7 +441,7 @@ TEST(EquivalenceOfLoggingAndTraversal) {
" obj.test =\n" " obj.test =\n"
" (function a(j) { return function b() { return j; } })(100);\n" " (function a(j) { return function b() { return j; } })(100);\n"
"})(this);"); "})(this);");
v8::V8::PauseProfiler(); logger->StopProfiler();
HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
logger->StringEvent("test-logging-done", ""); logger->StringEvent("test-logging-done", "");
......
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