When specifying a new create histogram callback, reset all histograms so they...

When specifying a new create histogram callback, reset all histograms so they recreate themselves on next use.

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
parent 5c6db6d0
......@@ -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) {
......
......@@ -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.
......
......@@ -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
......@@ -363,6 +363,8 @@ class Counters {
return &state_counters_[state];
}
void ResetHistograms();
private:
#define HT(name, caption) \
HistogramTimer name##_;
......
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