Add kdebug_trace signposts for a few WebCore operations
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jan 2016 20:57:37 +0000 (20:57 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jan 2016 20:57:37 +0000 (20:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153136
rdar://problem/24208487

Reviewed by Sam Weinig.
Source/WebCore:

Add trace points for style recalc, layout, view painting and layer painting.

* dom/Document.cpp:
(WebCore::Document::recalcStyle):
* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::paintContents):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::platformCALayerPaintContents):

Source/WTF:

New header with the reserved WebKit component code, trace point codes, and
a stack-based helper that traces scope entry and exit.

The available range of trace point codes is arbitrarily segmented into WTF, JSC,
WebCore, WebKit and WebKit2.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/SystemTracing.h: Added.
(WTF::TraceScope::TraceScope):
(WTF::TraceScope::~TraceScope):

Tools:

Plist used by kdebug_trace() viewing tools.

* Tracing/SystemTracePoints.plist: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195142 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/WTF.vcxproj/WTF.vcxproj
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/SystemTracing.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Tools/ChangeLog
Tools/Tracing/SystemTracePoints.plist [new file with mode: 0644]

index b8237bb..a4d7afb 100644 (file)
@@ -1,3 +1,23 @@
+2016-01-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Add kdebug_trace signposts for a few WebCore operations
+        https://bugs.webkit.org/show_bug.cgi?id=153136
+        rdar://problem/24208487
+
+        Reviewed by Sam Weinig.
+        
+        New header with the reserved WebKit component code, trace point codes, and
+        a stack-based helper that traces scope entry and exit.
+        
+        The available range of trace point codes is arbitrarily segmented into WTF, JSC,
+        WebCore, WebKit and WebKit2.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/SystemTracing.h: Added.
+        (WTF::TraceScope::TraceScope):
+        (WTF::TraceScope::~TraceScope):
+
 2016-01-15  Andreas Kling  <akling@apple.com>
 
         Fragmentation-free allocator for timeless and/or coupled allocations.
index 8f63466..d0d6ad1 100644 (file)
     <ClInclude Include="..\wtf\Stopwatch.h" />
     <ClInclude Include="..\wtf\StringExtras.h" />
     <ClInclude Include="..\wtf\StringPrintStream.h" />
+    <ClInclude Include="..\wtf\SystemTracing.h" />
     <ClInclude Include="..\wtf\TemporaryChange.h" />
     <ClInclude Include="..\wtf\text\ASCIIFastPath.h" />
     <ClInclude Include="..\wtf\text\AtomicString.h" />
index 13314b3..4fc0097 100644 (file)
@@ -41,6 +41,7 @@
                0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335E165DBA73005AD387 /* PrintStream.h */; };
                0FB14E19180FA218009B6B4D /* Bag.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB14E18180FA218009B6B4D /* Bag.h */; };
                0FB14E1B1810E1DC009B6B4D /* BagToHashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB14E1A1810E1DA009B6B4D /* BagToHashMap.h */; };
+               0FB317C41C488001007E395A /* SystemTracing.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB317C31C488001007E395A /* SystemTracing.h */; };
                0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4488216FE9FE100844BE9 /* ProcessID.h */; };
                0FC4EDE61696149600F65041 /* CommaPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4EDE51696149600F65041 /* CommaPrinter.h */; };
                0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
                0F9D335E165DBA73005AD387 /* PrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintStream.h; sourceTree = "<group>"; };
                0FB14E18180FA218009B6B4D /* Bag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bag.h; sourceTree = "<group>"; };
                0FB14E1A1810E1DA009B6B4D /* BagToHashMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BagToHashMap.h; sourceTree = "<group>"; };
+               0FB317C31C488001007E395A /* SystemTracing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemTracing.h; sourceTree = "<group>"; };
                0FC4488216FE9FE100844BE9 /* ProcessID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessID.h; sourceTree = "<group>"; };
                0FC4EDE51696149600F65041 /* CommaPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommaPrinter.h; sourceTree = "<group>"; };
                0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = "<group>"; };
                                A748745117A0BDAE00FA04CB /* StringHashDumpContext.h */,
                                0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */,
                                0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */,
+                               0FB317C31C488001007E395A /* SystemTracing.h */,
                                A8A4731A151A825B004123FF /* TemporaryChange.h */,
                                A8A4732F151A825B004123FF /* ThreadFunctionInvocation.h */,
                                A8A47330151A825B004123FF /* ThreadIdentifierDataPthreads.cpp */,
                                A8A473DC151A825B004123FF /* InlineASM.h in Headers */,
                                A70DA0841799F04D00529A9B /* Insertion.h in Headers */,
                                26147B0A15DDCCDC00DDB907 /* IntegerToStringConversion.h in Headers */,
+                               0FB317C41C488001007E395A /* SystemTracing.h in Headers */,
                                7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */,
                                7CDD7FFA186D2A54007433CD /* IteratorRange.h in Headers */,
                                93AC91A818942FC400244939 /* LChar.h in Headers */,
index 955d77b..d868c52 100644 (file)
@@ -99,6 +99,7 @@ set(WTF_HEADERS
     Stopwatch.h
     StringExtras.h
     StringPrintStream.h
+    SystemTracing.h
     ThreadIdentifierDataPthreads.h
     ThreadSafeRefCounted.h
     ThreadSpecific.h
diff --git a/Source/WTF/wtf/SystemTracing.h b/Source/WTF/wtf/SystemTracing.h
new file mode 100644 (file)
index 0000000..5531d67
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef SystemTracing_h
+#define SystemTracing_h
+
+#if defined(__has_include) && __has_include(<System/sys/kdebug.h>)
+#include <System/sys/kdebug.h>
+#define HAVE_KDEBUG_H 1
+#endif
+
+// No namespaces because this file has to be includable from C and Objective-C.
+
+// Reserved component code. Do not change this.
+#define WEBKIT_COMPONENT 47
+
+// Trace point codes can be up to 14 bits (0-16383).
+// When adding or changing these codes, update Tools/Tracing/SystemTracePoints.plist to match.
+enum TracePointCode {
+    WTFRange = 0,
+
+    JavaScriptRange = 2500,
+
+    WebCoreRange = 5000,
+    StyleRecalcStart,
+    StyleRecalcEnd,
+    LayoutStart,
+    LayoutEnd,
+    PaintViewStart,
+    PaintViewEnd,
+    PaintLayerStart,
+    PaintLayerEnd,
+
+    WebKitRange = 10000,
+    WebKit2Range = 12000,
+};
+
+#ifdef __cplusplus
+
+namespace WTF {
+
+class TraceScope {
+public:
+
+#if HAVE(KDEBUG_H)
+    TraceScope(TracePointCode entryCode, TracePointCode exitCode)
+        : m_exitCode(exitCode)
+    {
+        kdebug_trace(ARIADNEDBG_CODE(WEBKIT_COMPONENT, entryCode), 0, 0, 0, 0);
+    }
+#else
+    TraceScope(TracePointCode, TracePointCode)
+    {
+    }
+#endif
+    
+    ~TraceScope()
+    {
+#if HAVE(KDEBUG_H)
+        kdebug_trace(ARIADNEDBG_CODE(WEBKIT_COMPONENT, m_exitCode), 0, 0, 0, 0);
+#endif
+    }
+
+private:
+#if HAVE(KDEBUG_H)
+    TracePointCode m_exitCode;
+#endif
+};
+
+} // namespace WTF
+
+using WTF::TraceScope;
+
+#endif // __cplusplus
+
+#endif // SystemTracing_h
+
index 84a8094..86de3b0 100644 (file)
@@ -1,3 +1,21 @@
+2016-01-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Add kdebug_trace signposts for a few WebCore operations
+        https://bugs.webkit.org/show_bug.cgi?id=153136
+        rdar://problem/24208487
+
+        Reviewed by Sam Weinig.
+
+        Add trace points for style recalc, layout, view painting and layer painting.
+
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::paintContents):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::platformCALayerPaintContents):
+
 2016-01-15  Andreas Kling  <akling@apple.com>
 
         Use BumpArena for style sheet object tree.
index 50dd968..126c411 100644 (file)
 #include <inspector/ScriptCallStack.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/SystemTracing.h>
 #include <wtf/TemporaryChange.h>
 #include <wtf/text/StringBuffer.h>
 #include <yarr/RegularExpression.h>
@@ -1823,6 +1824,8 @@ void Document::recalcStyle(Style::Change change)
     if (m_inStyleRecalc)
         return; // Guard against re-entrancy. -dwh
 
+    TraceScope tracingScope(StyleRecalcStart, StyleRecalcEnd);
+
     RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
     AnimationUpdateBlock animationUpdateBlock(&m_frame->animation());
 
index 722d057..59815b6 100644 (file)
@@ -93,6 +93,7 @@
 
 #include <wtf/CurrentTime.h>
 #include <wtf/Ref.h>
+#include <wtf/SystemTracing.h>
 #include <wtf/TemporaryChange.h>
 
 #if USE(COORDINATED_GRAPHICS)
@@ -1236,6 +1237,8 @@ void FrameView::layout(bool allowSubtree)
         if (!root || !root->needsLayout())
             return;
     }
+    
+    TraceScope tracingScope(LayoutStart, LayoutEnd);
 
 #if PLATFORM(IOS)
     if (updateFixedPositionLayoutRect())
@@ -4014,7 +4017,9 @@ void FrameView::paintContents(GraphicsContext& context, const IntRect& dirtyRect
 
     if (m_layoutPhase == InViewSizeAdjust)
         return;
-    
+
+    TraceScope tracingScope(PaintViewStart, PaintViewEnd);
+
     ASSERT(m_layoutPhase == InPostLayerPositionsUpdatedAfterLayout || m_layoutPhase == OutsideLayout);
     
     RenderView* renderView = this->renderView();
index 049f224..4d28544 100644 (file)
@@ -47,6 +47,7 @@
 #include <limits.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
+#include <wtf/SystemTracing.h>
 #include <wtf/TemporaryChange.h>
 #include <wtf/text/WTFString.h>
 
@@ -1446,6 +1447,8 @@ void GraphicsLayerCA::platformCALayerPaintContents(PlatformCALayer*, GraphicsCon
         replayer.replay(clip);
         return;
     }
+
+    TraceScope tracingScope(PaintLayerStart, PaintLayerEnd);
     paintGraphicsLayerContents(context, clip);
 }
 
index 6da789f..ce01dfe 100644 (file)
@@ -1,3 +1,15 @@
+2016-01-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Add kdebug_trace signposts for a few WebCore operations
+        https://bugs.webkit.org/show_bug.cgi?id=153136
+        rdar://problem/24208487
+
+        Reviewed by Sam Weinig.
+        
+        Plist used by kdebug_trace() viewing tools.
+
+        * Tracing/SystemTracePoints.plist: Added.
+
 2016-01-14  Konstantin Tokarev  <annulen@yandex.ru>
 
         [webkitdirs] Replaced grep invocation with perl code
diff --git a/Tools/Tracing/SystemTracePoints.plist b/Tools/Tracing/SystemTracePoints.plist
new file mode 100644 (file)
index 0000000..0cfee38
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <array>
+     <dict>
+         <key>Name</key>
+         <string>WebKit</string>
+         <key>Children</key>
+         <array>
+             <dict>
+                 <key>Name</key>
+                 <string>Document::recalcStyle()</string>
+                 <key>Type</key>
+                 <string>Interval</string>
+                 <key>Component</key>
+                 <string>47</string>
+                 <key>CodeBegin</key>
+                 <string>5001</string>
+                 <key>CodeEnd</key>
+                 <string>5002</string>
+             </dict>
+             <dict>
+                 <key>Name</key>
+                 <string>FrameView::layout()</string>
+                 <key>Type</key>
+                 <string>Interval</string>
+                 <key>Component</key>
+                 <string>47</string>
+                 <key>CodeBegin</key>
+                 <string>5003</string>
+                 <key>CodeEnd</key>
+                 <string>5004</string>
+             </dict>
+             <dict>
+                 <key>Name</key>
+                 <string>FrameView::paintContents()</string>
+                 <key>Type</key>
+                 <string>Interval</string>
+                 <key>Component</key>
+                 <string>47</string>
+                 <key>CodeBegin</key>
+                 <string>5005</string>
+                 <key>CodeEnd</key>
+                 <string>5006</string>
+             </dict>
+             <dict>
+                 <key>Name</key>
+                 <string>GraphicsLayerCA::paintLayerContents()</string>
+                 <key>Type</key>
+                 <string>Interval</string>
+                 <key>Component</key>
+                 <string>47</string>
+                 <key>CodeBegin</key>
+                 <string>5007</string>
+                 <key>CodeEnd</key>
+                 <string>5008</string>
+             </dict>
+         </array>
+     </dict>
+ </array>
+ </plist>
\ No newline at end of file