Reviewers: Jakob,
Message:
PTAL.
Sorry for the other one that I closed. Please ignore it.
Description:
Also time other API functions calling into javascript.
And prevent crash when starting chromium without --single-process.
BUG=
Please review this at https://codereview.chromium.org/11411144/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/api.cc
M src/compiler.cc
M src/log-utils.cc
M src/log.h
M src/log.cc
M src/optimizing-compiler-thread.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
ca38dd90cabddecbff1975dc6ff68c823d53e422..5351b96f0d087ba120f27277c9b1bc8ac95804ea
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1682,7 +1682,7 @@ Local<Value> Script::Run() {
LOG_API(isolate, "Script::Run");
ENTER_V8(isolate);
i::Logger::TimerEventScope timer_scope(
- isolate->logger(), i::Logger::TimerEventScope::v8_execute);
+ isolate, i::Logger::TimerEventScope::v8_execute);
i::Object* raw_result = NULL;
{
i::HandleScope scope(isolate);
@@ -3651,6 +3651,8 @@ Local<v8::Value>
Object::CallAsFunction(v8::Handle<v8::Object> recv,
return Local<v8::Value>());
LOG_API(isolate, "Object::CallAsFunction");
ENTER_V8(isolate);
+ i::Logger::TimerEventScope timer_scope(
+ isolate, i::Logger::TimerEventScope::v8_execute);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
@@ -3682,6 +3684,8 @@ Local<v8::Value> Object::CallAsConstructor(int argc,
return Local<v8::Object>());
LOG_API(isolate, "Object::CallAsConstructor");
ENTER_V8(isolate);
+ i::Logger::TimerEventScope timer_scope(
+ isolate, i::Logger::TimerEventScope::v8_execute);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
@@ -3724,6 +3728,8 @@ Local<v8::Object> Function::NewInstance(int argc,
return Local<v8::Object>());
LOG_API(isolate, "Function::NewInstance");
ENTER_V8(isolate);
+ i::Logger::TimerEventScope timer_scope(
+ isolate, i::Logger::TimerEventScope::v8_execute);
HandleScope scope;
i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
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,
ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
LOG_API(isolate, "Function::Call");
ENTER_V8(isolate);
+ i::Logger::TimerEventScope timer_scope(
+ isolate, i::Logger::TimerEventScope::v8_execute);
i::Object* raw_result = NULL;
{
i::HandleScope scope(isolate);
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
0c6e1a9cc115755a71e0a883fe074d701ea5cc8b..3dfc4e3ddb70577ed5181b06e9b9ca5345a4a4b4
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -396,10 +396,9 @@ static bool GenerateCode(CompilationInfo* info) {
bool is_optimizing = V8::UseCrankshaft() &&
!info->IsCompilingForDebugging() &&
info->IsOptimizing();
- Logger* logger = info->isolate()->logger();
if (is_optimizing) {
Logger::TimerEventScope timer(
- logger, Logger::TimerEventScope::v8_recompile_synchronous);
+ info->isolate(),
Logger::TimerEventScope::v8_recompile_synchronous);
return MakeCrankshaftCode(info);
} else {
if (info->IsOptimizing()) {
@@ -408,7 +407,7 @@ static bool GenerateCode(CompilationInfo* info) {
info->DisableOptimization();
}
Logger::TimerEventScope timer(
- logger, Logger::TimerEventScope::v8_compile_full_code);
+ info->isolate(), Logger::TimerEventScope::v8_compile_full_code);
return FullCodeGenerator::MakeCode(info);
}
}
@@ -860,7 +859,7 @@ void Compiler::RecompileParallel(Handle<JSFunction>
closure) {
// Here we prepare compile data for the parallel recompilation thread,
but
// this still happens synchronously and interrupts execution.
Logger::TimerEventScope timer(
- isolate->logger(),
Logger::TimerEventScope::v8_recompile_synchronous);
+ isolate, Logger::TimerEventScope::v8_recompile_synchronous);
if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
if (FLAG_trace_parallel_recompilation) {
@@ -921,7 +920,7 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler*
optimizing_compiler) {
Isolate* isolate = info->isolate();
VMState state(isolate, PARALLEL_COMPILER);
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
// the unoptimized code.
OptimizingCompiler::Status status = optimizing_compiler->last_status();
Index: src/log-utils.cc
diff --git a/src/log-utils.cc b/src/log-utils.cc
index
7ae96dbde48f738645a2c508dd181a939051c2d8..246f6851359ebc8ece402d60fad6157fd089df9b
100644
--- a/src/log-utils.cc
+++ b/src/log-utils.cc
@@ -67,6 +67,7 @@ void Log::Initialize() {
FLAG_log_suspect = true;
FLAG_log_handles = true;
FLAG_log_regexp = true;
+ FLAG_log_timer_events = true;
}
// --prof implies --log-code.
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index
92b80542abdf9996bfe1c01849e93ae2a65fbef2..748db5c62ca9a394f2580bdca20df2f07fafd7b6
100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -706,6 +706,7 @@ void Logger::SharedLibraryEvent(const wchar_t*
library_path,
void Logger::TimerEvent(const char* name, int64_t start, int64_t end) {
+ if (!log_->IsEnabled()) return;
ASSERT(FLAG_log_timer_events);
LogMessageBuilder msg(this);
int since_epoch = static_cast<int>(start - epoch_);
@@ -715,6 +716,16 @@ void Logger::TimerEvent(const char* name, int64_t
start, int64_t end) {
}
+Logger::TimerEventScope::~TimerEventScope() {
+ if (FLAG_log_timer_events) {
+ Logger* logger = isolate_->logger();
+ if (logger->is_logging()) {
+ logger->TimerEvent(name_, start_, OS::Ticks());
+ }
+ }
+}
+
+
const char* Logger::TimerEventScope::v8_recompile_synchronous =
"V8.RecompileSynchronous";
const char* Logger::TimerEventScope::v8_recompile_parallel =
Index: src/log.h
diff --git a/src/log.h b/src/log.h
index
a1ebd79ccae6ca843fbf18cf69cba9cf999c2796..93a6f73a27d050a13f68262f384c315f064d0044
100644
--- a/src/log.h
+++ b/src/log.h
@@ -76,6 +76,7 @@ class Profiler;
class Semaphore;
class SlidingStateWindow;
class Ticker;
+class Isolate;
#undef LOG
#define LOG(isolate, Call) \
@@ -278,16 +279,12 @@ class Logger {
class TimerEventScope {
public:
- TimerEventScope(Logger* logger, const char* name)
- : logger_(logger), name_(name), start_(0) {
+ TimerEventScope(Isolate* isolate, const char* name)
+ : isolate_(isolate), name_(name), start_(0) {
if (FLAG_log_timer_events) start_ = OS::Ticks();
}
- ~TimerEventScope() {
- if (FLAG_log_timer_events) {
- logger_->TimerEvent(name_, start_, OS::Ticks());
- }
- }
+ ~TimerEventScope();
static const char* v8_recompile_synchronous;
static const char* v8_recompile_parallel;
@@ -295,7 +292,7 @@ class Logger {
static const char* v8_execute;
private:
- Logger* logger_;
+ Isolate* isolate_;
const char* name_;
int64_t start_;
};
Index: src/optimizing-compiler-thread.cc
diff --git a/src/optimizing-compiler-thread.cc
b/src/optimizing-compiler-thread.cc
index
d93f6714dc4c7ce8adaadc6835b5078021e6de8e..dc5a2f76587e136f811f223ff059ce1b8911abea
100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -49,7 +49,7 @@ void OptimizingCompilerThread::Run() {
while (true) {
input_queue_semaphore_->Wait();
Logger::TimerEventScope timer(
- isolate_->logger(),
Logger::TimerEventScope::v8_recompile_parallel);
+ isolate_, Logger::TimerEventScope::v8_recompile_parallel);
if (Acquire_Load(&stop_thread_)) {
stop_semaphore_->Signal();
if (FLAG_trace_parallel_recompilation) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev