dump compiler stats from d8 on direct exit from js
authordcarney <dcarney@chromium.org>
Fri, 21 Nov 2014 09:53:04 +0000 (01:53 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 21 Nov 2014 09:53:12 +0000 (09:53 +0000)
BUG=

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

Cr-Commit-Position: refs/heads/master@{#25453}

src/d8.cc
src/d8.h
src/isolate.cc
src/isolate.h

index fd80fcdc036795f4dab92cac0be96955683781c3..1c3ff8c4056d3b53b76121d294af0d72f8c0cfcd 100644 (file)
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -617,7 +617,7 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& 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<i::Isolate*>(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 =
index 44ee09a3b1d5df6d91413eadb601df36ca1eddb5..caa5a0adba472ef5e8132ae9a7fdb5138dba34ef 100644 (file)
--- 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<Array> GetCompletions(Isolate* isolate,
index f5f83d6cfa96d2acf7f740ccf53d04c684d07a74..d7bfad6f16a18e58f08e0ae4a40e7bf1c1ddc23e 100644 (file)
@@ -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();
index 3cc46a02b060d19d33679ea319d1eccae561f803..b44cbb5c2724559fdc68703a533294bb78e123da 100644 (file)
@@ -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;