Index: src/counters.cc |
diff --git a/src/counters.cc b/src/counters.cc |
index 8a5908c9af3d1dc981235cb5481b1798d0c938c9..20d0ee45633781b5f49b45e86ab0872841746588 100644 |
--- a/src/counters.cc |
+++ b/src/counters.cc |
@@ -282,18 +282,15 @@ void RuntimeCallCounter::Dump(std::stringstream& out) { |
} |
// static |
-void RuntimeCallStats::Enter(Isolate* isolate, RuntimeCallTimer* timer, |
+void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, |
CounterId counter_id) { |
- RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
RuntimeCallCounter* counter = &(stats->*counter_id); |
timer->Start(counter, stats->current_timer_); |
stats->current_timer_ = timer; |
} |
// static |
-void RuntimeCallStats::Leave(Isolate* isolate, RuntimeCallTimer* timer) { |
- RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
- |
+void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { |
if (stats->current_timer_ == timer) { |
stats->current_timer_ = timer->Stop(); |
} else { |
@@ -307,9 +304,8 @@ void RuntimeCallStats::Leave(Isolate* isolate, RuntimeCallTimer* timer) { |
} |
// static |
-void RuntimeCallStats::CorrectCurrentCounterId(Isolate* isolate, |
+void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, |
CounterId counter_id) { |
- RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); |
DCHECK_NOT_NULL(stats->current_timer_); |
RuntimeCallCounter* counter = &(stats->*counter_id); |
stats->current_timer_->counter_ = counter; |
@@ -364,5 +360,45 @@ void RuntimeCallStats::Reset() { |
#undef RESET_COUNTER |
} |
+const char* RuntimeCallStats::Dump() { |
+ buffer_.str(std::string()); |
+ buffer_.clear(); |
+ buffer_ << "{"; |
+#define DUMP_COUNTER(name) \ |
+ if (this->name.count > 0) this->name.Dump(buffer_); |
+ 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(buffer_); |
+ FOR_EACH_INTRINSIC(DUMP_COUNTER) |
+#undef DUMP_COUNTER |
+ |
+#define DUMP_COUNTER(name) \ |
+ if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_); |
+ BUILTIN_LIST_C(DUMP_COUNTER) |
+#undef DUMP_COUNTER |
+ |
+#define DUMP_COUNTER(name) \ |
+ if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); |
+ FOR_EACH_API_COUNTER(DUMP_COUNTER) |
+#undef DUMP_COUNTER |
+ |
+#define DUMP_COUNTER(name) \ |
+ if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); |
+ FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) |
+#undef DUMP_COUNTER |
+ buffer_ << "\"END\":[]}"; |
+ const std::string& buffer_str = buffer_.str(); |
+ size_t length = buffer_str.size(); |
+ if (length > len_) { |
+ buffer_c_str_.reset(new char[length + 1]); |
+ len_ = length; |
+ } |
+ strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1); |
+ in_use_ = false; |
+ return buffer_c_str_.get(); |
+} |
+ |
} // namespace internal |
} // namespace v8 |