From 0ed433ce30808533e3c1b763853555da9807b8f7 Mon Sep 17 00:00:00 2001 From: dcarney Date: Fri, 21 Nov 2014 01:53:04 -0800 Subject: [PATCH] dump compiler stats from d8 on direct exit from js BUG= Review URL: https://codereview.chromium.org/753483002 Cr-Commit-Position: refs/heads/master@{#25453} --- src/d8.cc | 7 ++++--- src/d8.h | 2 +- src/isolate.cc | 19 ++++++++++++++----- src/isolate.h | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/d8.cc b/src/d8.cc index fd80fcd..1c3ff8c 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -617,7 +617,7 @@ void Shell::Load(const v8::FunctionCallbackInfo& args) { void Shell::Quit(const v8::FunctionCallbackInfo& args) { int exit_code = args[0]->Int32Value(); - OnExit(); + OnExit(args.GetIsolate()); exit(exit_code); } @@ -1054,10 +1054,11 @@ inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { #endif // !V8_SHARED -void Shell::OnExit() { +void Shell::OnExit(v8::Isolate* isolate) { LineEditor* line_editor = LineEditor::Get(); if (line_editor) line_editor->Close(); #ifndef V8_SHARED + reinterpret_cast(isolate)->DumpAndResetCompilationStats(); if (i::FLAG_dump_counters) { int number_of_counters = 0; for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { @@ -1746,7 +1747,7 @@ int Shell::Main(int argc, char* argv[]) { RunShell(isolate); } } - OnExit(); + OnExit(isolate); #ifndef V8_SHARED // Dump basic block profiling data. if (i::BasicBlockProfiler* profiler = diff --git a/src/d8.h b/src/d8.h index 44ee09a..caa5a0a 100644 --- a/src/d8.h +++ b/src/d8.h @@ -263,7 +263,7 @@ class Shell : public i::AllStatic { static int RunMain(Isolate* isolate, int argc, char* argv[]); static int Main(int argc, char* argv[]); static void Exit(int exit_code); - static void OnExit(); + static void OnExit(Isolate* isolate); #ifndef V8_SHARED static Handle GetCompletions(Isolate* isolate, diff --git a/src/isolate.cc b/src/isolate.cc index f5f83d6..d7bfad6 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1743,11 +1743,7 @@ void Isolate::Deinit() { heap_.mark_compact_collector()->EnsureSweepingCompleted(); } - if (turbo_statistics() != NULL) { - OFStream os(stdout); - os << *turbo_statistics() << std::endl; - } - if (FLAG_hydrogen_stats) GetHStatistics()->Print(); + DumpAndResetCompilationStats(); if (FLAG_print_deopt_stress) { PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); @@ -2249,6 +2245,19 @@ void Isolate::UnlinkDeferredHandles(DeferredHandles* deferred) { } +void Isolate::DumpAndResetCompilationStats() { + if (turbo_statistics() != nullptr) { + OFStream os(stdout); + os << *turbo_statistics() << std::endl; + } + if (hstatistics() != nullptr) hstatistics()->Print(); + delete turbo_statistics_; + turbo_statistics_ = nullptr; + delete hstatistics_; + hstatistics_ = nullptr; +} + + HStatistics* Isolate::GetHStatistics() { if (hstatistics() == NULL) set_hstatistics(new HStatistics()); return hstatistics(); diff --git a/src/isolate.h b/src/isolate.h index 3cc46a0..b44cbb5 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -1064,6 +1064,8 @@ class Isolate { HTracer* GetHTracer(); CodeTracer* GetCodeTracer(); + void DumpAndResetCompilationStats(); + FunctionEntryHook function_entry_hook() { return function_entry_hook_; } void set_function_entry_hook(FunctionEntryHook function_entry_hook) { function_entry_hook_ = function_entry_hook; -- 2.7.4