OLD | NEW |
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/native_entry.h" | 9 #include "vm/native_entry.h" |
10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| 11 #include "vm/object.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 const char* VMTag::TagName(uword tag) { | 15 const char* VMTag::TagName(uword tag) { |
15 if (IsNativeEntryTag(tag)) { | 16 if (IsNativeEntryTag(tag)) { |
16 const uint8_t* native_reverse_lookup = NativeEntry::ResolveSymbol(tag); | 17 const uint8_t* native_reverse_lookup = NativeEntry::ResolveSymbol(tag); |
17 if (native_reverse_lookup != NULL) { | 18 if (native_reverse_lookup != NULL) { |
18 return reinterpret_cast<const char*>(native_reverse_lookup); | 19 return reinterpret_cast<const char*>(native_reverse_lookup); |
19 } | 20 } |
20 return "Unknown native entry"; | 21 return "Unknown native entry"; |
21 } else if (IsRuntimeEntryTag(tag)) { | 22 } else if (IsRuntimeEntryTag(tag)) { |
22 const char* runtime_entry_name = RuntimeEntryTagName(tag); | 23 const char* runtime_entry_name = RuntimeEntryTagName(tag); |
23 ASSERT(runtime_entry_name != NULL); | 24 ASSERT(runtime_entry_name != NULL); |
24 return runtime_entry_name; | 25 return runtime_entry_name; |
25 } | 26 } |
26 ASSERT(tag != kInvalidTagId); | 27 ASSERT(tag != kInvalidTagId); |
27 ASSERT(tag < kNumVMTags); | 28 ASSERT(tag < kNumVMTags); |
28 const TagEntry& entry = entries_[tag]; | 29 const TagEntry& entry = entries_[tag]; |
29 ASSERT(entry.id == tag); | 30 ASSERT(entry.id == tag); |
30 return entry.name; | 31 return entry.name; |
31 } | 32 } |
32 | 33 |
33 | 34 |
34 bool VMTag::IsNativeEntryTag(uword tag) { | 35 bool VMTag::IsNativeEntryTag(uword tag) { |
| 36 if (tag == 0) { |
| 37 return false; |
| 38 } |
35 ASSERT(tag != kInvalidTagId); | 39 ASSERT(tag != kInvalidTagId); |
36 ASSERT(tag != kNumVMTags); | 40 ASSERT(tag != kNumVMTags); |
37 return (tag > kNumVMTags) && !IsRuntimeEntryTag(tag); | 41 return (tag > kNumVMTags) && !IsRuntimeEntryTag(tag); |
38 } | 42 } |
39 | 43 |
40 static RuntimeEntry* runtime_entry_list = NULL; | 44 static RuntimeEntry* runtime_entry_list = NULL; |
41 | 45 |
42 bool VMTag::IsRuntimeEntryTag(uword id) { | 46 bool VMTag::IsRuntimeEntryTag(uword id) { |
43 const RuntimeEntry* current = runtime_entry_list; | 47 const RuntimeEntry* current = runtime_entry_list; |
44 while (current != NULL) { | 48 while (current != NULL) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 135 } |
132 } | 136 } |
133 { | 137 { |
134 JSONArray arr(obj, "counters"); | 138 JSONArray arr(obj, "counters"); |
135 for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) { | 139 for (intptr_t i = 1; i < VMTag::kNumVMTags; i++) { |
136 arr.AddValue64(counters_[i]); | 140 arr.AddValue64(counters_[i]); |
137 } | 141 } |
138 } | 142 } |
139 } | 143 } |
140 | 144 |
| 145 |
| 146 const char* UserTags::TagName(uword tag_id) { |
| 147 ASSERT(tag_id >= kUserTagIdOffset); |
| 148 ASSERT(tag_id < kUserTagIdOffset + kMaxUserTags); |
| 149 Isolate* isolate = Isolate::Current(); |
| 150 const UserTag& tag = |
| 151 UserTag::Handle(isolate, UserTag::FindTagById(tag_id)); |
| 152 ASSERT(!tag.IsNull()); |
| 153 const String& label = String::Handle(isolate, tag.label()); |
| 154 return label.ToCString(); |
| 155 } |
| 156 |
| 157 |
141 } // namespace dart | 158 } // namespace dart |
OLD | NEW |