Debian Codegraph @

mozglue/baseprofiler/public/ProfileBufferEntryKinds.h

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef ProfileBufferEntryKinds_h
8 #define ProfileBufferEntryKinds_h
9
10 #include "mozilla/BaseProfilerUtils.h"
11
12 #include <cstdint>
13
14 namespace mozilla {
15
16 // This is equal to sizeof(double), which is the largest non-char variant in
17 // |u|.
18 static constexpr size_t ProfileBufferEntryNumChars = 8;
19
20 // NOTE! If you add entries, you need to verify if they need to be added to the
21 // switch statement in DuplicateLastSample!
22 // This will evaluate the MACRO with (KIND, TYPE, SIZE)
23 #define FOR_EACH_PROFILE_BUFFER_ENTRY_KIND(MACRO) \
24 MACRO(CategoryPair, int, sizeof(int)) \
25 MACRO(CollectionStart, double, sizeof(double)) \
26 MACRO(CollectionEnd, double, sizeof(double)) \
27 MACRO(Label, const char*, sizeof(const char*)) \
28 MACRO(FrameFlags, uint64_t, sizeof(uint64_t)) \
29 MACRO(DynamicStringFragment, char*, ProfileBufferEntryNumChars) \
30 MACRO(JitReturnAddr, void*, sizeof(void*)) \
31 MACRO(InnerWindowID, uint64_t, sizeof(uint64_t)) \
32 MACRO(LineNumber, int, sizeof(int)) \
33 MACRO(ColumnNumber, int, sizeof(int)) \
34 MACRO(NativeLeafAddr, void*, sizeof(void*)) \
35 MACRO(Pause, double, sizeof(double)) \
36 MACRO(Resume, double, sizeof(double)) \
37 MACRO(PauseSampling, double, sizeof(double)) \
38 MACRO(ResumeSampling, double, sizeof(double)) \
39 MACRO(Responsiveness, double, sizeof(double)) \
40 MACRO(ThreadId, ::mozilla::baseprofiler::BaseProfilerThreadId, \
41 sizeof(::mozilla::baseprofiler::BaseProfilerThreadId)) \
42 MACRO(Time, double, sizeof(double)) \
43 MACRO(TimeBeforeCompactStack, double, sizeof(double)) \
44 MACRO(TimeBeforeSameSample, double, sizeof(double)) \
45 MACRO(CounterId, void*, sizeof(void*)) \
46 MACRO(Number, uint64_t, sizeof(uint64_t)) \
47 MACRO(Count, int64_t, sizeof(int64_t)) \
48 MACRO(ProfilerOverheadTime, double, sizeof(double)) \
49 MACRO(ProfilerOverheadDuration, double, sizeof(double))
50
51 // The `Kind` is a single byte identifying the type of data that is actually
52 // stored in a `ProfileBufferEntry`, as per the list in
53 // `FOR_EACH_PROFILE_BUFFER_ENTRY_KIND`.
54 //
55 // This byte is also used to identify entries in ProfileChunkedBuffer blocks,
56 // for both "legacy" entries that do contain a `ProfileBufferEntry`, and for
57 // new types of entries that may carry more data of different types.
58 // TODO: Eventually each type of "legacy" entry should be replaced with newer,
59 // more efficient kinds of entries (e.g., stack frames could be stored in one
60 // bigger entry, instead of multiple `ProfileBufferEntry`s); then we could
61 // discard `ProfileBufferEntry` and move this enum to a more appropriate spot.
62 enum class ProfileBufferEntryKind : uint8_t {
63 INVALID = 0,
64 #define KIND(KIND, TYPE, SIZE) KIND,
65 FOR_EACH_PROFILE_BUFFER_ENTRY_KIND(KIND)
66 #undef KIND
67
68 // Any value under `LEGACY_LIMIT` represents a `ProfileBufferEntry`.
69 LEGACY_LIMIT,
70
71 // Any value starting here does *not* represent a `ProfileBufferEntry` and
72 // requires separate decoding and handling.
73
74 // Markers and their data.
75 Marker = LEGACY_LIMIT,
76
77 // Entry with "running times", such as CPU usage measurements.
78 // Optional between TimeBeforeX and X.
79 RunningTimes,
80
81 // Optional between TimeBeforeX and X.
82 UnresponsiveDurationMs,
83
84 // Collection of legacy stack entries, must follow a ThreadId and
85 // TimeBeforeCompactStack (which are not included in the CompactStack;
86 // TimeBeforeCompactStack is equivalent to Time, but indicates that a
87 // CompactStack follows shortly afterwards).
88 CompactStack,
89
90 // Indicates that this sample is identical to the previous one, must follow a
91 // ThreadId and TimeBeforeSameSample.
92 SameSample,
93
94 MODERN_LIMIT
95 };
96
97 enum class MarkerPayloadType : uint8_t {
98 Cpp,
99 Rust,
100 };
101
102 } // namespace mozilla
103
104 #endif // ProfileBufferEntryKinds_h