| 1 | /* |
| 2 | * Copyright (C) 2016 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #if USE(APPLE_INTERNAL_SDK) |
| 29 | #include <System/sys/kdebug.h> |
| 30 | #define HAVE_KDEBUG_H 1 |
| 31 | #endif |
| 32 | |
| 33 | // No namespaces because this file has to be includable from C and Objective-C. |
| 34 | |
| 35 | // Reserved component code. Do not change this. |
| 36 | #define WEBKIT_COMPONENT 47 |
| 37 | |
| 38 | // Trace point codes can be up to 14 bits (0-16383). |
| 39 | // When adding or changing these codes, update Tools/Tracing/SystemTracePoints.plist to match. |
| 40 | enum TracePointCode { |
| 41 | WTFRange = 0, |
| 42 | |
| 43 | JavaScriptRange = 2500, |
| 44 | VMEntryScopeStart, |
| 45 | VMEntryScopeEnd, |
| 46 | WebAssemblyCompileStart, |
| 47 | WebAssemblyCompileEnd, |
| 48 | WebAssemblyExecuteStart, |
| 49 | WebAssemblyExecuteEnd, |
| 50 | DumpJITMemoryStart, |
| 51 | DumpJITMemoryStop, |
| 52 | |
| 53 | WebCoreRange = 5000, |
| 54 | MainResourceLoadDidStartProvisional, |
| 55 | MainResourceLoadDidEnd, |
| 56 | SubresourceLoadWillStart, |
| 57 | SubresourceLoadDidEnd, |
| 58 | FetchCookiesStart, |
| 59 | FetchCookiesEnd, |
| 60 | StyleRecalcStart, |
| 61 | StyleRecalcEnd, |
| 62 | RenderTreeBuildStart, |
| 63 | RenderTreeBuildEnd, |
| 64 | LayoutStart, |
| 65 | LayoutEnd, |
| 66 | PaintLayerStart, |
| 67 | PaintLayerEnd, |
| 68 | AsyncImageDecodeStart, |
| 69 | AsyncImageDecodeEnd, |
| 70 | RAFCallbackStart, |
| 71 | RAFCallbackEnd, |
| 72 | MemoryPressureHandlerStart, |
| 73 | MemoryPressureHandlerEnd, |
| 74 | UpdateTouchRegionsStart, |
| 75 | UpdateTouchRegionsEnd, |
| 76 | DisplayListRecordStart, |
| 77 | DisplayListRecordEnd, |
| 78 | DisplayRefreshDispatchingToMainThread, |
| 79 | ComputeEventRegionsStart, |
| 80 | ComputeEventRegionsEnd, |
| 81 | |
| 82 | ScheduleRenderingUpdate, |
| 83 | TriggerRenderingUpdate, |
| 84 | RenderingUpdateStart, |
| 85 | RenderingUpdateEnd, |
| 86 | |
| 87 | WebKitRange = 10000, |
| 88 | WebHTMLViewPaintStart, |
| 89 | WebHTMLViewPaintEnd, |
| 90 | |
| 91 | WebKit2Range = 12000, |
| 92 | BackingStoreFlushStart, |
| 93 | BackingStoreFlushEnd, |
| 94 | BuildTransactionStart, |
| 95 | BuildTransactionEnd, |
| 96 | SyncMessageStart, |
| 97 | SyncMessageEnd, |
| 98 | SyncTouchEventStart, |
| 99 | SyncTouchEventEnd, |
| 100 | InitializeWebProcessStart, |
| 101 | InitializeWebProcessEnd, |
| 102 | |
| 103 | UIProcessRange = 14000, |
| 104 | CommitLayerTreeStart, |
| 105 | CommitLayerTreeEnd, |
| 106 | ProcessLaunchStart, |
| 107 | ProcessLaunchEnd, |
| 108 | InitializeSandboxStart, |
| 109 | InitializeSandboxEnd, |
| 110 | }; |
| 111 | |
| 112 | #ifdef __cplusplus |
| 113 | |
| 114 | namespace WTF { |
| 115 | |
| 116 | inline void tracePoint(TracePointCode code, uint64_t data1 = 0, uint64_t data2 = 0, uint64_t data3 = 0, uint64_t data4 = 0) |
| 117 | { |
| 118 | #if HAVE(KDEBUG_H) |
| 119 | kdebug_trace(ARIADNEDBG_CODE(WEBKIT_COMPONENT, code), data1, data2, data3, data4); |
| 120 | #else |
| 121 | UNUSED_PARAM(code); |
| 122 | UNUSED_PARAM(data1); |
| 123 | UNUSED_PARAM(data2); |
| 124 | UNUSED_PARAM(data3); |
| 125 | UNUSED_PARAM(data4); |
| 126 | #endif |
| 127 | } |
| 128 | |
| 129 | class TraceScope { |
| 130 | public: |
| 131 | |
| 132 | TraceScope(TracePointCode entryCode, TracePointCode exitCode, uint64_t data1 = 0, uint64_t data2 = 0, uint64_t data3 = 0, uint64_t data4 = 0) |
| 133 | : m_exitCode(exitCode) |
| 134 | { |
| 135 | tracePoint(entryCode, data1, data2, data3, data4); |
| 136 | } |
| 137 | |
| 138 | ~TraceScope() |
| 139 | { |
| 140 | tracePoint(m_exitCode); |
| 141 | } |
| 142 | |
| 143 | private: |
| 144 | TracePointCode m_exitCode; |
| 145 | }; |
| 146 | |
| 147 | } // namespace WTF |
| 148 | |
| 149 | using WTF::TraceScope; |
| 150 | using WTF::tracePoint; |
| 151 | |
| 152 | #endif // __cplusplus |
| 153 | |