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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/tags.h" 5 #include "vm/tags.h"
6 6
7 #include "vm/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/json_stream.h" 8 #include "vm/json_stream.h"
9 #include "vm/object.h"
10 #include "vm/object_store.h"
9 11
10 namespace dart { 12 namespace dart {
11 13
12 const char* VMTag::TagName(uword tag) { 14 const char* VMTag::TagName(uword tag) {
13 ASSERT(tag != kInvalidTagId); 15 ASSERT(tag != kInvalidTagId);
14 ASSERT(tag < kNumVMTags); 16 ASSERT(tag < kNumVMTags);
15 const TagEntry& entry = entries_[tag]; 17 const TagEntry& entry = entries_[tag];
16 ASSERT(entry.id == tag); 18 ASSERT(entry.id == tag);
17 return entry.name; 19 return entry.name;
18 } 20 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 73 }
72 } 74 }
73 { 75 {
74 JSONArray arr(obj, "counters"); 76 JSONArray arr(obj, "counters");
75 for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) { 77 for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) {
76 arr.AddValue64(counters_[i]); 78 arr.AddValue64(counters_[i]);
77 } 79 }
78 } 80 }
79 } 81 }
80 82
83
84 const char* UserTagHelper::TagName(uword tag_address) {
85 Isolate* isolate = Isolate::Current();
86 const Instance& tag = Instance::Handle(
Cutch 2014/04/09 20:28:54 This is dead code.
87 isolate,
88 reinterpret_cast<RawInstance*>(tag_address));
89 if (tag.IsNull()) {
90 return "Default User Tag";
91 }
92 const Library& profiler_lib = Library::Handle(
93 isolate,
94 isolate->object_store()->profiler_library());
95 ASSERT(!profiler_lib.IsNull());
96 const String& tag_class_name = String::Handle(isolate, String::New("Tag"));
97 ASSERT(!tag_class_name.IsNull());
98 const Class& tag_class = Class::Handle(
99 profiler_lib.LookupClass(tag_class_name));
100 ASSERT(!tag_class.IsNull());
101 const String& label_field_name = String::Handle(String::New("label"));
102 ASSERT(!label_field_name.IsNull());
103 const Field& label_field =
104 Field::Handle(tag_class.LookupField(label_field_name));
105 ASSERT(!label_field.IsNull());
106 const Object& field = Object::Handle(tag.GetField(label_field));
107 ASSERT(!field.IsNull());
108 const String& label = String::Cast(field);
109 return label.ToCString();
110 }
111
112
81 } // namespace dart 113 } // namespace dart
OLDNEW
« runtime/lib/profiler.dart ('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