| Index: src/counters.cc
|
| diff --git a/src/counters.cc b/src/counters.cc
|
| index d1a1a44c9f9c65cfa7f7dd93f2b5c24c4d3b3c52..276492f4cd8d7c7d46edbda7d24861bab39cb0cb 100644
|
| --- a/src/counters.cc
|
| +++ b/src/counters.cc
|
| @@ -20,11 +20,54 @@ StatsTable::StatsTable()
|
| create_histogram_function_(NULL),
|
| add_histogram_sample_function_(NULL) {}
|
|
|
| +void StatsTable::SetCounterFunction(CounterLookupCallback f, Isolate* isolate) {
|
| + lookup_function_ = f;
|
| + if (!isolate->InitializeCounters()) isolate->counters()->ResetCounters();
|
| +}
|
|
|
| int* StatsCounter::FindLocationInStatsTable() const {
|
| return isolate_->stats_table()->FindLocation(name_);
|
| }
|
|
|
| +StatsCounterThreadSafe::StatsCounterThreadSafe(Isolate* isolate,
|
| + const char* name)
|
| + : StatsCounter(isolate, name) {
|
| + lookup_done_ = true;
|
| + GetPtr();
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Set(int Value) {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + StatsCounter::Set(ptr_, Value);
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Increment() {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + StatsCounter::Increment(ptr_);
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Increment(int value) {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + StatsCounter::Increment(ptr_, value);
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Decrement() {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + StatsCounter::Decrement(ptr_);
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Decrement(int value) {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + StatsCounter::Decrement(ptr_, value);
|
| +}
|
| +
|
| +void StatsCounterThreadSafe::Reset() { GetPtr(); }
|
| +
|
| +int* StatsCounterThreadSafe::GetPtr() {
|
| + base::LockGuard<base::Mutex> Guard(&mutex_);
|
| + ptr_ = FindLocationInStatsTable();
|
| + return ptr_;
|
| +}
|
|
|
| void Histogram::AddSample(int sample) {
|
| if (Enabled()) {
|
| @@ -60,8 +103,14 @@ void HistogramTimer::Stop() {
|
| Logger::CallEventLogger(isolate(), name(), Logger::END, true);
|
| }
|
|
|
| -
|
| -Counters::Counters(Isolate* isolate) {
|
| +Counters::Counters(Isolate* isolate)
|
| + :
|
| +// clang format off
|
| +#define SC(name, caption) name##_(isolate, "c:" #caption),
|
| + STATS_COUNTER_TS_LIST(SC)
|
| +#undef SC
|
| + // clang format on
|
| + runtime_call_stats_() {
|
| static const struct {
|
| Histogram Counters::*member;
|
| const char* caption;
|
| @@ -200,13 +249,16 @@ Counters::Counters(Isolate* isolate) {
|
| }
|
| }
|
|
|
| -
|
| void Counters::ResetCounters() {
|
| #define SC(name, caption) name##_.Reset();
|
| STATS_COUNTER_LIST_1(SC)
|
| STATS_COUNTER_LIST_2(SC)
|
| #undef SC
|
|
|
| +#define SC(name, caption) name##_.Reset();
|
| + STATS_COUNTER_TS_LIST(SC)
|
| +#undef SC
|
| +
|
| #define SC(name) \
|
| count_of_##name##_.Reset(); \
|
| size_of_##name##_.Reset();
|
|
|