Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: src/counters.cc

Issue 2490643002: [counters] Implement off-isolate RuntimeCallStats for the Preparser (Closed)
Patch Set: addressing nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/counters.h ('k') | src/counters-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index 6e7c1cb90c740ca7ebc5ef45c63a5db267ecbabc..719fdedc54998dfd68ff6342082f2da4c2b10fdb 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -284,10 +284,16 @@ void RuntimeCallCounter::Dump(v8::tracing::TracedValue* value) {
value->EndArray();
}
+void RuntimeCallCounter::Add(RuntimeCallCounter* other) {
+ count += other->count;
+ time += other->time;
+}
+
// static
void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
CounterId counter_id) {
RuntimeCallCounter* counter = &(stats->*counter_id);
+ DCHECK(counter->name != NULL);
timer->Start(counter, stats->current_timer_.Value());
stats->current_timer_.SetValue(timer);
}
@@ -306,7 +312,18 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
}
}
-// static
+void RuntimeCallStats::Add(RuntimeCallStats* other) {
+ RuntimeCallCounter* current = &(this->First);
+ RuntimeCallCounter* other_counter = &(other->First);
+ while (current < &(this->Last)) {
+ current = reinterpret_cast<RuntimeCallCounter*>(
+ reinterpret_cast<intptr_t>(current) + sizeof(RuntimeCallCounter));
+ other_counter = reinterpret_cast<RuntimeCallCounter*>(
+ reinterpret_cast<intptr_t>(other_counter) + sizeof(RuntimeCallCounter));
+ current->Add(other_counter);
+ }
+}
+
void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats,
CounterId counter_id) {
RuntimeCallTimer* timer = stats->current_timer_.Value();
@@ -320,52 +337,24 @@ void RuntimeCallStats::Print(std::ostream& os) {
if (current_timer_.Value() != nullptr) {
current_timer_.Value()->Elapsed();
}
-
-#define PRINT_COUNTER(name) entries.Add(&this->name);
- FOR_EACH_MANUAL_COUNTER(PRINT_COUNTER)
-#undef PRINT_COUNTER
-
-#define PRINT_COUNTER(name, nargs, ressize) entries.Add(&this->Runtime_##name);
- FOR_EACH_INTRINSIC(PRINT_COUNTER)
-#undef PRINT_COUNTER
-
-#define PRINT_COUNTER(name) entries.Add(&this->Builtin_##name);
- BUILTIN_LIST_C(PRINT_COUNTER)
-#undef PRINT_COUNTER
-
-#define PRINT_COUNTER(name) entries.Add(&this->API_##name);
- FOR_EACH_API_COUNTER(PRINT_COUNTER)
-#undef PRINT_COUNTER
-
-#define PRINT_COUNTER(name) entries.Add(&this->Handler_##name);
- FOR_EACH_HANDLER_COUNTER(PRINT_COUNTER)
-#undef PRINT_COUNTER
-
+ RuntimeCallCounter* current = &(this->First);
+ while (current < &(this->Last)) {
+ current = reinterpret_cast<RuntimeCallCounter*>(
+ reinterpret_cast<intptr_t>(current) + sizeof(RuntimeCallCounter));
+ entries.Add(current);
+ }
entries.Print(os);
}
void RuntimeCallStats::Reset() {
if (V8_LIKELY(FLAG_runtime_stats == 0)) return;
-#define RESET_COUNTER(name) this->name.Reset();
- FOR_EACH_MANUAL_COUNTER(RESET_COUNTER)
-#undef RESET_COUNTER
-
-#define RESET_COUNTER(name, nargs, result_size) this->Runtime_##name.Reset();
- FOR_EACH_INTRINSIC(RESET_COUNTER)
-#undef RESET_COUNTER
-
-#define RESET_COUNTER(name) this->Builtin_##name.Reset();
- BUILTIN_LIST_C(RESET_COUNTER)
-#undef RESET_COUNTER
-
-#define RESET_COUNTER(name) this->API_##name.Reset();
- FOR_EACH_API_COUNTER(RESET_COUNTER)
-#undef RESET_COUNTER
-
-#define RESET_COUNTER(name) this->Handler_##name.Reset();
- FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
-#undef RESET_COUNTER
+ RuntimeCallCounter* current = &(this->First);
+ while (current < &(this->Last)) {
fmeawad 2016/11/10 15:51:00 Is there a performance impact from adding a check
Camillo Bruni 2016/11/14 09:38:56 I think this doesn't really matter speed-wise, we
+ current = reinterpret_cast<RuntimeCallCounter*>(
+ reinterpret_cast<intptr_t>(current) + sizeof(RuntimeCallCounter));
+ current->Reset();
+ }
in_use_ = true;
}
@@ -374,30 +363,12 @@ void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) {
if (current_timer_.Value() != nullptr) {
current_timer_.Value()->Elapsed();
}
-#define DUMP_COUNTER(name) \
- if (this->name.count > 0) this->name.Dump(value);
- FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
-#undef DUMP_COUNTER
-
-#define DUMP_COUNTER(name, nargs, result_size) \
- if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value);
- FOR_EACH_INTRINSIC(DUMP_COUNTER)
-#undef DUMP_COUNTER
-
-#define DUMP_COUNTER(name) \
- if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(value);
- BUILTIN_LIST_C(DUMP_COUNTER)
-#undef DUMP_COUNTER
-
-#define DUMP_COUNTER(name) \
- if (this->API_##name.count > 0) this->API_##name.Dump(value);
- FOR_EACH_API_COUNTER(DUMP_COUNTER)
-#undef DUMP_COUNTER
-
-#define DUMP_COUNTER(name) \
- if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value);
- FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
-#undef DUMP_COUNTER
+ RuntimeCallCounter* current = &(this->First);
+ while (current < &(this->Last)) {
+ current = reinterpret_cast<RuntimeCallCounter*>(
+ reinterpret_cast<intptr_t>(current) + sizeof(RuntimeCallCounter));
+ if (current->count > 0) current->Dump(value);
+ }
in_use_ = false;
}
« no previous file with comments | « src/counters.h ('k') | src/counters-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698