]> gitweb.factorcode.org Git - factor.git/blob - vm/sampling_profiler.hpp
vm: charge samples collected in prolog to parent
[factor.git] / vm / sampling_profiler.hpp
1 namespace factor
2 {
3
4 struct profiling_sample_count
5 {
6         // Number of samples taken before the safepoint that recorded the sample
7         fixnum sample_count;
8         // Number of samples taken during GC
9         fixnum gc_sample_count;
10         // Number of samples taken during unoptimized compiler
11         fixnum jit_sample_count;
12         // Number of samples taken during foreign code execution
13         fixnum foreign_sample_count;
14         // Number of samples taken during code execution in non-Factor threads
15         fixnum foreign_thread_sample_count;
16
17         profiling_sample_count() :
18                 sample_count(0),
19                 gc_sample_count(0),
20                 jit_sample_count(0),
21                 foreign_sample_count(0),
22                 foreign_thread_sample_count(0) {}
23
24         profiling_sample_count(fixnum sample_count,
25                 fixnum gc_sample_count,
26                 fixnum jit_sample_count,
27                 fixnum foreign_sample_count,
28                 fixnum foreign_thread_sample_count) :
29                 sample_count(sample_count),
30                 gc_sample_count(gc_sample_count),
31                 jit_sample_count(jit_sample_count),
32                 foreign_sample_count(foreign_sample_count),
33                 foreign_thread_sample_count(foreign_thread_sample_count) {}
34
35         bool empty() const
36         {
37                 return sample_count
38                         + gc_sample_count
39                         + jit_sample_count
40                         + foreign_sample_count
41                         + foreign_thread_sample_count == 0;
42         }
43
44         profiling_sample_count record_counts() volatile;
45         void clear() volatile;
46 };
47
48 struct profiling_sample
49 {
50         // Sample counts
51         profiling_sample_count counts;
52         // Active thread during sample
53         cell thread;
54         /* The callstack at safepoint time. Indexes to the beginning and ending
55         code_block entries in the vm sample_callstacks array. */
56         cell callstack_begin, callstack_end;
57
58         profiling_sample(factor_vm *vm,
59                 bool prolog_p,
60                 profiling_sample_count const &counts,
61                 cell thread);
62 };
63
64 }