Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
tags.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_TAGS_H_
6#define RUNTIME_VM_TAGS_H_
7
9#include "vm/allocation.h"
10#include "vm/os_thread.h"
12
13namespace dart {
14
15class Isolate;
16class JSONObject;
17class RuntimeEntry;
18
19#define VM_TAG_LIST(V) \
20 V(Idle) /* isolate is idle and is_runnable() */ \
21 V(LoadWait) /* isolate is idle and !is_runnable() */ \
22 V(VM) /* Catch all */ \
23 V(CompileOptimized) \
24 V(CompileUnoptimized) \
25 V(ClassLoading) \
26 V(CompileParseRegExp) \
27 V(Dart) \
28 V(GCNewSpace) \
29 V(GCOldSpace) \
30 V(GCIdle) \
31 V(Embedder) \
32 V(Runtime) \
33 V(Native)
34
35class VMTag : public AllStatic {
36 public:
37 enum VMTagId {
39#define DEFINE_VM_TAG_ID(tag) k##tag##TagId,
41#undef DEFINE_VM_TAG_KIND
43 //
44 // All tags below |kNumVMTags| are special meta-data tags and do not
45 // indicate the state of the VM during a sample.
46 //
47 kRootTagId, // Special tag used as root of all profiles.
48 kTruncatedTagId, // Special tag used to indicate a truncated call stack.
49 // Code transition tags (used by unit tests).
57 };
58
59 static bool IsVMTag(uword id) {
60 return (id != kInvalidTagId) && (id < kNumVMTags);
61 }
62 static const char* TagName(uword id);
63 static bool IsNativeEntryTag(uword id);
64 static bool IsDartTag(uword id) { return id == kDartTagId; }
65 static bool IsExitFrameTag(uword id);
66 static bool IsRuntimeEntryTag(uword id);
67 static const char* RuntimeEntryTagName(uword id);
68
69 static void RegisterRuntimeEntry(RuntimeEntry* runtime_entry);
70
71 private:
72 struct TagEntry {
73 const char* name;
74 uword id;
75 };
76 static const TagEntry entries_[];
77};
78
80 public:
81 VMTagScope(Thread* thread, uword tag, bool conditional_set = true);
83
84 private:
85 uword previous_tag_;
86
87 DISALLOW_ALLOCATION();
89};
90
92 public:
94
95 void Increment(uword tag);
96
97 int64_t count(uword tag);
98
99#ifndef PRODUCT
100 void PrintToJSONObject(JSONObject* obj);
101#endif // !PRODUCT
102
103 private:
104 int64_t counters_[VMTag::kNumVMTags];
105};
106
107class UserTags : public AllStatic {
108 public:
109 // UserTag id space: [kUserTagIdOffset, kUserTagIdOffset + kMaxUserTags).
110 static constexpr intptr_t kMaxUserTags = 256;
111 static constexpr uword kUserTagIdOffset = 0x4096;
113 static const char* TagName(uword tag_id);
114 static bool IsUserTag(uword tag_id) {
115 return (tag_id >= kUserTagIdOffset) &&
116 (tag_id < kUserTagIdOffset + kMaxUserTags);
117 }
118 static void AddStreamableTagName(const char* tag);
119 static void RemoveStreamableTagName(const char* tag);
120 static bool IsTagNameStreamable(const char* tag);
121 static void Init();
122 static void Cleanup();
123
124 private:
125 static Mutex* subscribed_tags_lock_;
126 static MallocGrowableArray<const char*> subscribed_tags_;
127};
128
129} // namespace dart
130
131#endif // RUNTIME_VM_TAGS_H_
int count
static const char * TagName(uword tag_id)
Definition tags.cc:139
static constexpr intptr_t kMaxUserTags
Definition tags.h:110
static bool IsTagNameStreamable(const char *tag)
Definition tags.cc:177
static void RemoveStreamableTagName(const char *tag)
Definition tags.cc:163
static void Cleanup()
Definition tags.cc:191
static bool IsUserTag(uword tag_id)
Definition tags.h:114
static constexpr uword kUserTagIdOffset
Definition tags.h:111
static void AddStreamableTagName(const char *tag)
Definition tags.cc:152
static constexpr uword kDefaultUserTag
Definition tags.h:112
static void Init()
Definition tags.cc:187
void Increment(uword tag)
Definition tags.cc:104
void PrintToJSONObject(JSONObject *obj)
Definition tags.cc:123
static void RegisterRuntimeEntry(RuntimeEntry *runtime_entry)
static bool IsExitFrameTag(uword id)
Definition tags.cc:42
static bool IsVMTag(uword id)
Definition tags.h:59
static const char * RuntimeEntryTagName(uword id)
Definition tags.cc:51
static bool IsNativeEntryTag(uword id)
Definition tags.cc:38
@ kUnoptimizedCodeTagId
Definition tags.h:52
@ kNoneCodeTagId
Definition tags.h:50
@ kLastTagId
Definition tags.h:56
@ kInlineStartCodeTagId
Definition tags.h:54
@ kInvalidTagId
Definition tags.h:38
@ kNumVMTags
Definition tags.h:42
@ kNativeCodeTagId
Definition tags.h:53
@ kInlineEndCodeTagId
Definition tags.h:55
@ kTruncatedTagId
Definition tags.h:48
@ kRootTagId
Definition tags.h:47
@ kOptimizedCodeTagId
Definition tags.h:51
static bool IsRuntimeEntryTag(uword id)
Definition tags.cc:47
static const char * TagName(uword id)
Definition tags.cc:19
static bool IsDartTag(uword id)
Definition tags.h:64
uintptr_t uword
Definition globals.h:501
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition globals.h:593
#define VM_TAG_LIST(V)
Definition tags.h:19
#define DEFINE_VM_TAG_ID(tag)
Definition tags.h:39
const uintptr_t id