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 class Isolate; | |
11 | |
12 namespace dart { | 10 namespace dart { |
13 | 11 |
| 12 class Isolate; |
| 13 class JSONObject; |
| 14 |
14 #define VM_TAG_LIST(V) \ | 15 #define VM_TAG_LIST(V) \ |
| 16 V(Idle) \ |
15 V(VM) /* Catch all */ \ | 17 V(VM) /* Catch all */ \ |
16 V(Compile) \ | 18 V(Compile) \ |
17 V(Script) \ | 19 V(Script) \ |
18 V(GCNewSpace) \ | 20 V(GCNewSpace) \ |
19 V(GCOldSpace) \ | 21 V(GCOldSpace) \ |
20 V(RuntimeNative) \ | 22 V(RuntimeNative) \ |
21 V(Idle) \ | |
22 | 23 |
23 | 24 |
24 class VMTag : public AllStatic { | 25 class VMTag : public AllStatic { |
25 public: | 26 public: |
26 enum VMTagId { | 27 enum VMTagId { |
27 kInvalidTagId = 0, | 28 kInvalidTagId = 0, |
28 #define DEFINE_VM_TAG_ID(tag) \ | 29 #define DEFINE_VM_TAG_ID(tag) \ |
29 k##tag##TagId, | 30 k##tag##TagId, |
30 VM_TAG_LIST(DEFINE_VM_TAG_ID) | 31 VM_TAG_LIST(DEFINE_VM_TAG_ID) |
31 #undef DEFINE_VM_TAG_KIND | 32 #undef DEFINE_VM_TAG_KIND |
32 kNumVMTags, | 33 kNumVMTags, |
33 }; | 34 }; |
34 | 35 |
35 static const char* TagName(uword id); | 36 static const char* TagName(uword id); |
36 | 37 |
37 private: | 38 private: |
38 struct TagEntry { | 39 struct TagEntry { |
39 const char* name; | 40 const char* name; |
40 uword id; | 41 uword id; |
41 }; | 42 }; |
42 static TagEntry entries_[]; | 43 static TagEntry entries_[]; |
43 }; | 44 }; |
44 | 45 |
| 46 |
45 class VMTagScope : StackResource { | 47 class VMTagScope : StackResource { |
46 public: | 48 public: |
47 VMTagScope(Isolate* isolate, uword tag); | 49 VMTagScope(Isolate* isolate, uword tag); |
48 ~VMTagScope(); | 50 ~VMTagScope(); |
49 private: | 51 private: |
50 uword previous_tag_; | 52 uword previous_tag_; |
51 | 53 |
52 DISALLOW_ALLOCATION(); | 54 DISALLOW_ALLOCATION(); |
53 DISALLOW_IMPLICIT_CONSTRUCTORS(VMTagScope); | 55 DISALLOW_IMPLICIT_CONSTRUCTORS(VMTagScope); |
54 }; | 56 }; |
55 | 57 |
| 58 |
| 59 class VMTagCounters { |
| 60 public: |
| 61 VMTagCounters(); |
| 62 |
| 63 void Increment(uword tag); |
| 64 |
| 65 int64_t count(uword tag); |
| 66 |
| 67 void PrintToJSONObject(JSONObject* obj); |
| 68 |
| 69 private: |
| 70 int64_t counters_[VMTag::kNumVMTags]; |
| 71 }; |
| 72 |
56 } // namespace dart | 73 } // namespace dart |
57 | 74 |
58 #endif // VM_TAGS_H_ | 75 #endif // VM_TAGS_H_ |
OLD | NEW |