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

Unified Diff: runtime/vm/tags.cc

Issue 205713004: Add isolate tag-profile and better handling of errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months 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
Index: runtime/vm/tags.cc
diff --git a/runtime/vm/tags.cc b/runtime/vm/tags.cc
index 84b40f4f24ecfae6bf57aeb2dd06f101c736bf28..f05aa22cc77cf3b478de034d91fd3d78e946f146 100644
--- a/runtime/vm/tags.cc
+++ b/runtime/vm/tags.cc
@@ -5,14 +5,15 @@
#include "vm/tags.h"
#include "vm/isolate.h"
+#include "vm/json_stream.h"
namespace dart {
-const char* VMTag::TagName(uword id) {
- ASSERT(id != kInvalidTagId);
- ASSERT(id < kNumVMTags);
- const TagEntry& entry = entries_[id];
- ASSERT(entry.id == id);
+const char* VMTag::TagName(uword tag) {
+ ASSERT(tag != kInvalidTagId);
+ ASSERT(tag < kNumVMTags);
+ const TagEntry& entry = entries_[tag];
+ ASSERT(entry.id == tag);
return entry.name;
}
@@ -41,4 +42,40 @@ VMTagScope::~VMTagScope() {
}
+VMTagCounters::VMTagCounters() {
+ for (intptr_t i = 0; i < VMTag::kNumVMTags; i++) {
+ counters_[i] = 0;
+ }
+}
+
+
+void VMTagCounters::Increment(uword tag) {
+ ASSERT(tag != VMTag::kInvalidTagId);
+ ASSERT(tag < VMTag::kNumVMTags);
+ counters_[tag]++;
+}
+
+
+int64_t VMTagCounters::count(uword tag) {
+ ASSERT(tag != VMTag::kInvalidTagId);
+ ASSERT(tag < VMTag::kNumVMTags);
+ return counters_[tag];
+}
+
+
+void VMTagCounters::PrintToJSONObject(JSONObject* obj) {
+ {
+ JSONArray arr(obj, "names");
+ for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) {
+ arr.AddValue(VMTag::TagName(i));
+ }
+ }
+ {
+ JSONArray arr(obj, "counters");
+ for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) {
+ arr.AddValue64(counters_[i]);
+ }
+ }
turnidge 2014/03/24 20:22:13 So you split the message into two parallel arrays?
Cutch 2014/03/25 14:39:06 I would prefer to keep them as separate arrays. Ma
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698