OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #ifndef VM_TAGS_H_ | 5 #ifndef VM_TAGS_H_ |
6 #define VM_TAGS_H_ | 6 #define VM_TAGS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 class Isolate; | 12 class Isolate; |
13 class JSONObject; | 13 class JSONObject; |
14 | 14 |
15 #define VM_TAG_LIST(V) \ | 15 #define VM_TAG_LIST(V) \ |
16 V(Idle) \ | 16 V(Idle) \ |
17 V(VM) /* Catch all */ \ | 17 V(VM) /* Catch all */ \ |
18 V(Compile) \ | 18 V(Compile) \ |
19 V(Script) \ | 19 V(Script) \ |
20 V(GCNewSpace) \ | 20 V(GCNewSpace) \ |
21 V(GCOldSpace) \ | 21 V(GCOldSpace) \ |
22 V(RuntimeNative) \ | 22 V(RuntimeNative) \ |
23 | 23 |
24 | |
25 class VMTag : public AllStatic { | 24 class VMTag : public AllStatic { |
26 public: | 25 public: |
27 enum VMTagId { | 26 enum VMTagId { |
28 kInvalidTagId = 0, | 27 kInvalidTagId = 0, |
29 #define DEFINE_VM_TAG_ID(tag) \ | 28 #define DEFINE_VM_TAG_ID(tag) \ |
30 k##tag##TagId, | 29 k##tag##TagId, |
31 VM_TAG_LIST(DEFINE_VM_TAG_ID) | 30 VM_TAG_LIST(DEFINE_VM_TAG_ID) |
32 #undef DEFINE_VM_TAG_KIND | 31 #undef DEFINE_VM_TAG_KIND |
33 kNumVMTags, | 32 kNumVMTags, |
34 }; | 33 }; |
35 | 34 |
| 35 static bool IsVMTag(uword id) { |
| 36 return (id != kInvalidTagId) && (id < kNumVMTags); |
| 37 } |
36 static const char* TagName(uword id); | 38 static const char* TagName(uword id); |
37 | 39 |
38 private: | 40 private: |
39 struct TagEntry { | 41 struct TagEntry { |
40 const char* name; | 42 const char* name; |
41 uword id; | 43 uword id; |
42 }; | 44 }; |
43 static TagEntry entries_[]; | 45 static TagEntry entries_[]; |
44 }; | 46 }; |
45 | 47 |
(...skipping 17 matching lines...) Expand all Loading... |
63 void Increment(uword tag); | 65 void Increment(uword tag); |
64 | 66 |
65 int64_t count(uword tag); | 67 int64_t count(uword tag); |
66 | 68 |
67 void PrintToJSONObject(JSONObject* obj); | 69 void PrintToJSONObject(JSONObject* obj); |
68 | 70 |
69 private: | 71 private: |
70 int64_t counters_[VMTag::kNumVMTags]; | 72 int64_t counters_[VMTag::kNumVMTags]; |
71 }; | 73 }; |
72 | 74 |
| 75 |
| 76 class UserTagHelper : public AllStatic { |
| 77 public: |
| 78 // UserTag id space: [kUserTagIdOffset, kUserTagIdOffset + kMaxUserTags). |
| 79 static const intptr_t kMaxUserTags = 64; |
| 80 static const intptr_t kUserTagIdOffset = 0x4096; |
| 81 static const char* TagName(uword tag); |
| 82 }; |
| 83 |
| 84 |
73 } // namespace dart | 85 } // namespace dart |
74 | 86 |
75 #endif // VM_TAGS_H_ | 87 #endif // VM_TAGS_H_ |
OLD | NEW |