Commit 94476cb8 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Also time other API functions calling into javascript.

And prevent crash when starting chromium without --single-process.

BUG=

Review URL: https://chromiumcodereview.appspot.com/11411144

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13051 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3c251ec9
...@@ -1682,7 +1682,7 @@ Local<Value> Script::Run() { ...@@ -1682,7 +1682,7 @@ Local<Value> Script::Run() {
LOG_API(isolate, "Script::Run"); LOG_API(isolate, "Script::Run");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope( i::Logger::TimerEventScope timer_scope(
isolate->logger(), i::Logger::TimerEventScope::v8_execute); isolate, i::Logger::TimerEventScope::v8_execute);
i::Object* raw_result = NULL; i::Object* raw_result = NULL;
{ {
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
...@@ -3651,6 +3651,8 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, ...@@ -3651,6 +3651,8 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv,
return Local<v8::Value>()); return Local<v8::Value>());
LOG_API(isolate, "Object::CallAsFunction"); LOG_API(isolate, "Object::CallAsFunction");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope(
isolate, i::Logger::TimerEventScope::v8_execute);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> obj = Utils::OpenHandle(this); i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
...@@ -3682,6 +3684,8 @@ Local<v8::Value> Object::CallAsConstructor(int argc, ...@@ -3682,6 +3684,8 @@ Local<v8::Value> Object::CallAsConstructor(int argc,
return Local<v8::Object>()); return Local<v8::Object>());
LOG_API(isolate, "Object::CallAsConstructor"); LOG_API(isolate, "Object::CallAsConstructor");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope(
isolate, i::Logger::TimerEventScope::v8_execute);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> obj = Utils::OpenHandle(this); i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
...@@ -3724,6 +3728,8 @@ Local<v8::Object> Function::NewInstance(int argc, ...@@ -3724,6 +3728,8 @@ Local<v8::Object> Function::NewInstance(int argc,
return Local<v8::Object>()); return Local<v8::Object>());
LOG_API(isolate, "Function::NewInstance"); LOG_API(isolate, "Function::NewInstance");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope(
isolate, i::Logger::TimerEventScope::v8_execute);
HandleScope scope; HandleScope scope;
i::Handle<i::JSFunction> function = Utils::OpenHandle(this); i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
...@@ -3742,6 +3748,8 @@ Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, ...@@ -3742,6 +3748,8 @@ Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc,
ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
LOG_API(isolate, "Function::Call"); LOG_API(isolate, "Function::Call");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope(
isolate, i::Logger::TimerEventScope::v8_execute);
i::Object* raw_result = NULL; i::Object* raw_result = NULL;
{ {
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
......
...@@ -396,10 +396,9 @@ static bool GenerateCode(CompilationInfo* info) { ...@@ -396,10 +396,9 @@ static bool GenerateCode(CompilationInfo* info) {
bool is_optimizing = V8::UseCrankshaft() && bool is_optimizing = V8::UseCrankshaft() &&
!info->IsCompilingForDebugging() && !info->IsCompilingForDebugging() &&
info->IsOptimizing(); info->IsOptimizing();
Logger* logger = info->isolate()->logger();
if (is_optimizing) { if (is_optimizing) {
Logger::TimerEventScope timer( Logger::TimerEventScope timer(
logger, Logger::TimerEventScope::v8_recompile_synchronous); info->isolate(), Logger::TimerEventScope::v8_recompile_synchronous);
return MakeCrankshaftCode(info); return MakeCrankshaftCode(info);
} else { } else {
if (info->IsOptimizing()) { if (info->IsOptimizing()) {
...@@ -408,7 +407,7 @@ static bool GenerateCode(CompilationInfo* info) { ...@@ -408,7 +407,7 @@ static bool GenerateCode(CompilationInfo* info) {
info->DisableOptimization(); info->DisableOptimization();
} }
Logger::TimerEventScope timer( Logger::TimerEventScope timer(
logger, Logger::TimerEventScope::v8_compile_full_code); info->isolate(), Logger::TimerEventScope::v8_compile_full_code);
return FullCodeGenerator::MakeCode(info); return FullCodeGenerator::MakeCode(info);
} }
} }
...@@ -860,7 +859,7 @@ void Compiler::RecompileParallel(Handle<JSFunction> closure) { ...@@ -860,7 +859,7 @@ void Compiler::RecompileParallel(Handle<JSFunction> closure) {
// Here we prepare compile data for the parallel recompilation thread, but // Here we prepare compile data for the parallel recompilation thread, but
// this still happens synchronously and interrupts execution. // this still happens synchronously and interrupts execution.
Logger::TimerEventScope timer( Logger::TimerEventScope timer(
isolate->logger(), Logger::TimerEventScope::v8_recompile_synchronous); isolate, Logger::TimerEventScope::v8_recompile_synchronous);
if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
if (FLAG_trace_parallel_recompilation) { if (FLAG_trace_parallel_recompilation) {
...@@ -921,7 +920,7 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { ...@@ -921,7 +920,7 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
Isolate* isolate = info->isolate(); Isolate* isolate = info->isolate();
VMState state(isolate, PARALLEL_COMPILER); VMState state(isolate, PARALLEL_COMPILER);
Logger::TimerEventScope timer( Logger::TimerEventScope timer(
isolate->logger(), Logger::TimerEventScope::v8_recompile_synchronous); isolate, Logger::TimerEventScope::v8_recompile_synchronous);
// If crankshaft succeeded, install the optimized code else install // If crankshaft succeeded, install the optimized code else install
// the unoptimized code. // the unoptimized code.
OptimizingCompiler::Status status = optimizing_compiler->last_status(); OptimizingCompiler::Status status = optimizing_compiler->last_status();
......
...@@ -92,9 +92,8 @@ void HistogramTimer::Stop() { ...@@ -92,9 +92,8 @@ void HistogramTimer::Stop() {
histogram_.AddSample(milliseconds); histogram_.AddSample(milliseconds);
} }
if (FLAG_log_timer_events) { if (FLAG_log_timer_events) {
stop_time_ = OS::Ticks(); LOG(Isolate::Current(),
Isolate::Current()->logger()->TimerEvent( TimerEvent(histogram_.name_, start_time_, OS::Ticks()));
histogram_.name_, start_time_, stop_time_);
} }
} }
......
...@@ -67,6 +67,7 @@ void Log::Initialize() { ...@@ -67,6 +67,7 @@ void Log::Initialize() {
FLAG_log_suspect = true; FLAG_log_suspect = true;
FLAG_log_handles = true; FLAG_log_handles = true;
FLAG_log_regexp = true; FLAG_log_regexp = true;
FLAG_log_timer_events = true;
} }
// --prof implies --log-code. // --prof implies --log-code.
......
...@@ -706,6 +706,7 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path, ...@@ -706,6 +706,7 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path,
void Logger::TimerEvent(const char* name, int64_t start, int64_t end) { void Logger::TimerEvent(const char* name, int64_t start, int64_t end) {
if (!log_->IsEnabled()) return;
ASSERT(FLAG_log_timer_events); ASSERT(FLAG_log_timer_events);
LogMessageBuilder msg(this); LogMessageBuilder msg(this);
int since_epoch = static_cast<int>(start - epoch_); int since_epoch = static_cast<int>(start - epoch_);
...@@ -715,6 +716,11 @@ void Logger::TimerEvent(const char* name, int64_t start, int64_t end) { ...@@ -715,6 +716,11 @@ void Logger::TimerEvent(const char* name, int64_t start, int64_t end) {
} }
void Logger::TimerEventScope::LogTimerEvent() {
LOG(isolate_, TimerEvent(name_, start_, OS::Ticks()));
}
const char* Logger::TimerEventScope::v8_recompile_synchronous = const char* Logger::TimerEventScope::v8_recompile_synchronous =
"V8.RecompileSynchronous"; "V8.RecompileSynchronous";
const char* Logger::TimerEventScope::v8_recompile_parallel = const char* Logger::TimerEventScope::v8_recompile_parallel =
......
...@@ -76,6 +76,7 @@ class Profiler; ...@@ -76,6 +76,7 @@ class Profiler;
class Semaphore; class Semaphore;
class SlidingStateWindow; class SlidingStateWindow;
class Ticker; class Ticker;
class Isolate;
#undef LOG #undef LOG
#define LOG(isolate, Call) \ #define LOG(isolate, Call) \
...@@ -278,24 +279,24 @@ class Logger { ...@@ -278,24 +279,24 @@ class Logger {
class TimerEventScope { class TimerEventScope {
public: public:
TimerEventScope(Logger* logger, const char* name) TimerEventScope(Isolate* isolate, const char* name)
: logger_(logger), name_(name), start_(0) { : isolate_(isolate), name_(name), start_(0) {
if (FLAG_log_timer_events) start_ = OS::Ticks(); if (FLAG_log_timer_events) start_ = OS::Ticks();
} }
~TimerEventScope() { ~TimerEventScope() {
if (FLAG_log_timer_events) { if (FLAG_log_timer_events) LogTimerEvent();
logger_->TimerEvent(name_, start_, OS::Ticks());
}
} }
void LogTimerEvent();
static const char* v8_recompile_synchronous; static const char* v8_recompile_synchronous;
static const char* v8_recompile_parallel; static const char* v8_recompile_parallel;
static const char* v8_compile_full_code; static const char* v8_compile_full_code;
static const char* v8_execute; static const char* v8_execute;
private: private:
Logger* logger_; Isolate* isolate_;
const char* name_; const char* name_;
int64_t start_; int64_t start_;
}; };
......
...@@ -49,7 +49,7 @@ void OptimizingCompilerThread::Run() { ...@@ -49,7 +49,7 @@ void OptimizingCompilerThread::Run() {
while (true) { while (true) {
input_queue_semaphore_->Wait(); input_queue_semaphore_->Wait();
Logger::TimerEventScope timer( Logger::TimerEventScope timer(
isolate_->logger(), Logger::TimerEventScope::v8_recompile_parallel); isolate_, Logger::TimerEventScope::v8_recompile_parallel);
if (Acquire_Load(&stop_thread_)) { if (Acquire_Load(&stop_thread_)) {
stop_semaphore_->Signal(); stop_semaphore_->Signal();
if (FLAG_trace_parallel_recompilation) { if (FLAG_trace_parallel_recompilation) {
......
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