/home/travis/build/MoarVM/MoarVM/src/profiler/log.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Per-thread profiling data. */ |
2 | | struct MVMProfileThreadData { |
3 | | /* The root of the call graph. */ |
4 | | MVMProfileCallNode *call_graph; |
5 | | |
6 | | /* The current call graph node we're in. */ |
7 | | MVMProfileCallNode *current_call; |
8 | | |
9 | | /* The time we started profiling. */ |
10 | | MVMuint64 start_time; |
11 | | |
12 | | /* The time we finished profiling, if we got there already. */ |
13 | | MVMuint64 end_time; |
14 | | |
15 | | /* Garbage collection time measurements. */ |
16 | | MVMProfileGC *gcs; |
17 | | MVMuint32 num_gcs; |
18 | | MVMuint32 alloc_gcs; |
19 | | |
20 | | /* Amount of time spent in spesh. */ |
21 | | MVMuint64 spesh_time; |
22 | | |
23 | | /* Current spesh work start time, if any. */ |
24 | | MVMuint64 cur_spesh_start_time; |
25 | | |
26 | | /* Current GC start time, if any. */ |
27 | | MVMuint64 cur_gc_start_time; |
28 | | |
29 | | /* We have to make sure to not count the newest allocation infinitely |
30 | | * often if there's a conditionally-allocating operation (like getlex) |
31 | | * that gets called multiple times with no actual allocations in between */ |
32 | | MVMObject *last_counted_allocation; |
33 | | }; |
34 | | |
35 | | /* Information collected about a GC run. */ |
36 | | struct MVMProfileGC { |
37 | | /* How long the collection took. */ |
38 | | MVMuint64 time; |
39 | | |
40 | | /* Was it a full collection? */ |
41 | | MVMuint32 full; |
42 | | |
43 | | /* Nursery statistics. */ |
44 | | MVMuint32 cleared_bytes; |
45 | | MVMuint32 retained_bytes; |
46 | | MVMuint32 promoted_bytes; |
47 | | |
48 | | /* Inter-generation links count */ |
49 | | MVMuint32 num_gen2roots; |
50 | | }; |
51 | | |
52 | | /* Call graph node, which is kept per thread. */ |
53 | | struct MVMProfileCallNode { |
54 | | /* The frame this data is for. |
55 | | * If this CallNode is for a native call, this is NULL. */ |
56 | | MVMStaticFrame *sf; |
57 | | |
58 | | /* If the static frame is NULL, we're collecting data on a native call */ |
59 | | char *native_target_name; |
60 | | |
61 | | /* The timestamp when we entered the node. */ |
62 | | MVMuint64 cur_entry_time; |
63 | | |
64 | | /* Time we should skip since cur_entry_time because execution was |
65 | | * suspended due to GC or spesh. */ |
66 | | MVMuint64 cur_skip_time; |
67 | | |
68 | | /* The node in the profiling call graph that we came from. */ |
69 | | MVMProfileCallNode *pred; |
70 | | |
71 | | /* Successor nodes so far. */ |
72 | | MVMProfileCallNode **succ; |
73 | | |
74 | | /* Number of successors we have, and have allocated space for. */ |
75 | | MVMuint32 num_succ; |
76 | | MVMuint32 alloc_succ; |
77 | | |
78 | | /* Allocations of different types, and the number of allocation |
79 | | * counts we have so far. */ |
80 | | MVMProfileAllocationCount *alloc; |
81 | | MVMuint32 num_alloc; |
82 | | MVMuint32 alloc_alloc; |
83 | | |
84 | | /* The total inclusive time so far spent in this node. */ |
85 | | MVMuint64 total_time; |
86 | | |
87 | | /* The total number of times this node was entered. */ |
88 | | MVMuint64 total_entries; |
89 | | |
90 | | /* Entries that were to specialized bytecode. */ |
91 | | MVMuint64 specialized_entries; |
92 | | |
93 | | /* Entries that were inlined. */ |
94 | | MVMuint64 inlined_entries; |
95 | | |
96 | | /* Entries that were to JITted code. */ |
97 | | MVMuint64 jit_entries; |
98 | | |
99 | | /* Number of times OSR took place. */ |
100 | | MVMuint64 osr_count; |
101 | | |
102 | | /* Number of times deopt_one happened. */ |
103 | | MVMuint64 deopt_one_count; |
104 | | |
105 | | /* Number of times deopt_all happened. */ |
106 | | MVMuint64 deopt_all_count; |
107 | | |
108 | | /* Entry mode, persisted for the sake of continuations. */ |
109 | | MVMuint64 entry_mode; |
110 | | }; |
111 | | |
112 | | /* Allocation counts for a call node. */ |
113 | | struct MVMProfileAllocationCount { |
114 | | /* The type we're counting allocations of. */ |
115 | | MVMObject *type; |
116 | | |
117 | | /* The number of allocations we've counted. */ |
118 | | /* a) in regularly interpreted code */ |
119 | | MVMuint64 allocations_interp; |
120 | | |
121 | | /* b) in spesh'd code */ |
122 | | MVMuint64 allocations_spesh; |
123 | | |
124 | | /* c) in jitted code */ |
125 | | MVMuint64 allocations_jit; |
126 | | }; |
127 | | |
128 | | /* When a continuation is taken, we attach one of these to it. It carries the |
129 | | * data needed to restore profiler state if the continuation is invoked. */ |
130 | | struct MVMProfileContinuationData { |
131 | | /* List of static frames we should restore, in reverse order. */ |
132 | | MVMStaticFrame **sfs; |
133 | | |
134 | | /* Entry modes to restore also. */ |
135 | | MVMuint64 *modes; |
136 | | |
137 | | /* Number of static frames in the list. */ |
138 | | MVMuint64 num_sfs; |
139 | | }; |
140 | | |
141 | | /* Ways we might enter a frame. */ |
142 | 0 | #define MVM_PROFILE_ENTER_NORMAL 0 |
143 | 0 | #define MVM_PROFILE_ENTER_SPESH 1 |
144 | 0 | #define MVM_PROFILE_ENTER_SPESH_INLINE 2 |
145 | 0 | #define MVM_PROFILE_ENTER_JIT 3 |
146 | 0 | #define MVM_PROFILE_ENTER_JIT_INLINE 4 |
147 | | |
148 | | /* Logging functions. */ |
149 | | void MVM_profile_log_enter(MVMThreadContext *tc, MVMStaticFrame *sf, MVMuint64 mode); |
150 | | void MVM_profile_log_enter_native(MVMThreadContext *tc, MVMObject *nativecallsite); |
151 | | void MVM_profile_log_exit(MVMThreadContext *tc); |
152 | | void MVM_profile_log_unwind(MVMThreadContext *tc); |
153 | | MVMProfileContinuationData * MVM_profile_log_continuation_control(MVMThreadContext *tc, const MVMFrame *root_frame); |
154 | | void MVM_profile_log_continuation_invoke(MVMThreadContext *tc, const MVMProfileContinuationData *cd); |
155 | | void MVM_profile_log_allocated(MVMThreadContext *tc, MVMObject *obj); |
156 | | void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full); |
157 | | void MVM_profiler_log_gc_end(MVMThreadContext *tc); |
158 | | void MVM_profiler_log_spesh_start(MVMThreadContext *tc); |
159 | | void MVM_profiler_log_spesh_end(MVMThreadContext *tc); |
160 | | void MVM_profiler_log_osr(MVMThreadContext *tc, MVMuint64 jitted); |
161 | | void MVM_profiler_log_deopt_one(MVMThreadContext *tc); |
162 | | void MVM_profiler_log_deopt_all(MVMThreadContext *tc); |