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

Unified Diff: runtime/vm/tags.cc

Issue 230863005: Initial UserTag and dart:profiler library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 f05aa22cc77cf3b478de034d91fd3d78e946f146..b1695b82fb0ee550c65cf85fdd79bf04154f0cfa 100644
--- a/runtime/vm/tags.cc
+++ b/runtime/vm/tags.cc
@@ -6,6 +6,8 @@
#include "vm/isolate.h"
#include "vm/json_stream.h"
+#include "vm/object.h"
+#include "vm/object_store.h"
namespace dart {
@@ -78,4 +80,34 @@ void VMTagCounters::PrintToJSONObject(JSONObject* obj) {
}
}
+
+const char* UserTagHelper::TagName(uword tag_address) {
+ Isolate* isolate = Isolate::Current();
+ const Instance& tag = Instance::Handle(
+ isolate,
+ reinterpret_cast<RawInstance*>(tag_address));
+ if (tag.IsNull()) {
+ return "Default User Tag";
+ }
+ const Library& profiler_lib = Library::Handle(
+ isolate,
+ isolate->object_store()->profiler_library());
+ ASSERT(!profiler_lib.IsNull());
+ const String& tag_class_name = String::Handle(isolate, String::New("Tag"));
+ ASSERT(!tag_class_name.IsNull());
+ const Class& tag_class = Class::Handle(
+ profiler_lib.LookupClass(tag_class_name));
+ ASSERT(!tag_class.IsNull());
+ const String& label_field_name = String::Handle(String::New("label"));
+ ASSERT(!label_field_name.IsNull());
+ const Field& label_field =
+ Field::Handle(tag_class.LookupField(label_field_name));
+ ASSERT(!label_field.IsNull());
+ const Object& field = Object::Handle(tag.GetField(label_field));
+ ASSERT(!field.IsNull());
+ const String& label = String::Cast(field);
+ return label.ToCString();
+}
+
+
} // namespace dart
« runtime/vm/object.cc ('K') | « runtime/vm/tags.h ('k') | runtime/vm/vm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698