When specifying a new create histogram callback, reset all histograms so they recreat...
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 1 Aug 2012 12:51:24 +0000 (12:51 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 1 Aug 2012 12:51:24 +0000 (12:51 +0000)
We only do this for histograms, and not for counters, as counters might be used directly from generated code

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10828113
Patch from Jochen Eisinger <jochen@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12248 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
src/counters.h
src/v8-counters.cc
src/v8-counters.h

index d439472..77bb982 100644 (file)
@@ -5223,6 +5223,8 @@ void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
   i::Isolate* isolate = EnterIsolateIfNeeded();
   if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return;
   isolate->stats_table()->SetCreateHistogramFunction(callback);
+  isolate->InitializeLoggingAndCounters();
+  isolate->counters()->ResetHistograms();
 }
 
 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
index 2338376..577280f 100644 (file)
@@ -219,6 +219,11 @@ struct Histogram {
     return GetHistogram() != NULL;
   }
 
+  // Reset the cached internal pointer.
+  void Reset() {
+    lookup_done_ = false;
+  }
+
  protected:
   // Returns the handle to the histogram.
   void* GetHistogram() {
@@ -251,6 +256,10 @@ struct HistogramTimer {
   bool Running() {
     return histogram_.Enabled() && (start_time_ != 0) && (stop_time_ == 0);
   }
+
+  void Reset() {
+    histogram_.Reset();
+  }
 };
 
 // Helper class for scoping a HistogramTimer.
index b5a40b5..36b45e2 100644 (file)
@@ -93,4 +93,14 @@ Counters::Counters() {
   }
 }
 
+void Counters::ResetHistograms() {
+#define HT(name, caption) name##_.Reset();
+    HISTOGRAM_TIMER_LIST(HT)
+#undef HT
+
+#define HP(name, caption) name##_.Reset();
+    HISTOGRAM_PERCENTAGE_LIST(HP)
+#undef HP
+}
+
 } }  // namespace v8::internal
index e230613..4a5755c 100644 (file)
@@ -363,6 +363,8 @@ class Counters {
     return &state_counters_[state];
   }
 
+  void ResetHistograms();
+
  private:
 #define HT(name, caption) \
   HistogramTimer name##_;