<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191849] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191849">191849</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2015-10-31 19:29:47 -0700 (Sat, 31 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add a debug overlay with information about web process resource usage.
<https://webkit.org/b/150599>
Reviewed by Darin Adler.
Source/JavaScriptCore:
Have Heap track the exact number of bytes allocated in CopiedBlock, MarkedBlock and
WeakBlock objects, keeping them in a single location that can be sampled by the
resource usage overlay thread.
The bulk of these changes is threading a Heap& through from sites where blocks are
allocated or freed.
* heap/CopiedBlock.cpp:
(JSC::CopiedBlock::createNoZeroFill):
(JSC::CopiedBlock::destroy):
(JSC::CopiedBlock::create):
* heap/CopiedBlock.h:
* heap/CopiedSpace.cpp:
(JSC::CopiedSpace::~CopiedSpace):
(JSC::CopiedSpace::tryAllocateOversize):
(JSC::CopiedSpace::tryReallocateOversize):
* heap/CopiedSpaceInlines.h:
(JSC::CopiedSpace::recycleEvacuatedBlock):
(JSC::CopiedSpace::recycleBorrowedBlock):
(JSC::CopiedSpace::allocateBlockForCopyingPhase):
(JSC::CopiedSpace::allocateBlock):
(JSC::CopiedSpace::startedCopying):
* heap/Heap.cpp:
(JSC::Heap::~Heap):
(JSC::Heap::sweepNextLogicallyEmptyWeakBlock):
* heap/Heap.h:
(JSC::Heap::blockBytesAllocated):
* heap/HeapInlines.h:
(JSC::Heap::didAllocateBlock):
(JSC::Heap::didFreeBlock):
* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::allocateBlock):
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::create):
(JSC::MarkedBlock::destroy):
* heap/MarkedBlock.h:
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::freeBlock):
* heap/WeakBlock.cpp:
(JSC::WeakBlock::create):
(JSC::WeakBlock::destroy):
* heap/WeakBlock.h:
* heap/WeakSet.cpp:
(JSC::WeakSet::~WeakSet):
(JSC::WeakSet::addAllocator):
(JSC::WeakSet::removeAllocator):
Source/WebCore:
A new kind of PageOverlay is added behind the ENABLE(RESOURCE_USAGE_OVERLAY) flag.
It's owned by Page, but not instantiated unless the Settings::resourceUsageOverlayVisible flag is set.
All ResourceUsageOverlay objects share a single sampler thread. The thread currently runs every 500ms
and samples CPU usage, dirty memory regions, and GC heap size/capacity.
Most things in here are currently quite Mac-specific, but I will be iterating on this towards a more
cross-platform friendly solution.
There are two small changes to PageOverlay in order to support dragging the resource usage overlay:
- A "should ignore mouse events outside bounds" state flag. This is on by default
but turned off during a drag.
- PageOverlay::bounds() will now return the override frame verbatim if one is set,
instead of returning it relocated to 0,0.
Note that this is intended as a tool for WebKit engine developers to better understand memory usage.
It's not a goal to expose this information to end users.
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
(WebCore::Page::setResourceUsageOverlayVisible):
* page/Page.h:
* page/PageOverlay.cpp:
(WebCore::PageOverlay::bounds):
(WebCore::PageOverlay::mouseEvent):
* page/PageOverlay.h:
* page/ResourceUsageOverlay.cpp: Added.
(WebCore::ResourceUsageOverlay::ResourceUsageOverlay):
(WebCore::ResourceUsageOverlay::~ResourceUsageOverlay):
(WebCore::ResourceUsageOverlay::mouseEvent):
* page/ResourceUsageOverlay.h: Added.
* page/Settings.cpp:
(WebCore::Settings::setResourceUsageOverlayVisible):
* page/Settings.h:
(WebCore::Settings::resourceUsageOverlayVisible):
* page/cocoa/ResourceUsageOverlayCocoa.mm: Added.
(-[WebOverlayLayer initWithResourceUsageOverlay:]):
(-[WebOverlayLayer drawInContext:]):
(WebCore::RingBuffer::RingBuffer):
(WebCore::RingBuffer::append):
(WebCore::RingBuffer::last):
(WebCore::RingBuffer::forEach):
(WebCore::RingBuffer::incrementIndex):
(WebCore::RingBuffer::decrementIndex):
(WebCore::sharedData):
(WebCore::ResourceUsageOverlay::platformInitialize):
(WebCore::ResourceUsageOverlay::platformDestroy):
(WebCore::drawCpuHistory):
(WebCore::drawGCHistory):
(WebCore::drawSlice):
(WebCore::drawPlate):
(WebCore::drawMemoryPie):
(WebCore::formatByteNumber):
(WebCore::showText):
(WebCore::ResourceUsageOverlay::draw):
(WebCore::dirtyPagesPerVMTag):
(WebCore::cpuUsage):
(WebCore::runSamplerThread):
* platform/spi/cocoa/MachVMSPI.h:
Source/WebKit2:
Add WK2 preferences SPI for showing/hiding the resource usage overlay.
* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetResourceUsageOverlayVisible):
(WKPreferencesGetResourceUsageOverlayVisible):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _resourceUsageOverlayVisible]):
(-[WKPreferences _setResourceUsageOverlayVisible:]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Source/WTF:
Add ENABLE(RESOURCE_USAGE_OVERLAY) flag, enabled on Mac by default.
* wtf/Platform.h:
Tools:
Add a menu item to the MiniBrowser so we can toggle the resource usage overlay on/off.
* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController toggleShowResourceUsageOverlay:]):
(-[SettingsController resourceUsageOverlayVisible]):
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController didChangeSettings]):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapCopiedBlockcpp">trunk/Source/JavaScriptCore/heap/CopiedBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapCopiedBlockh">trunk/Source/JavaScriptCore/heap/CopiedBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapCopiedSpacecpp">trunk/Source/JavaScriptCore/heap/CopiedSpace.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapCopiedSpaceInlinesh">trunk/Source/JavaScriptCore/heap/CopiedSpaceInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapcpp">trunk/Source/JavaScriptCore/heap/Heap.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeaph">trunk/Source/JavaScriptCore/heap/Heap.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapInlinesh">trunk/Source/JavaScriptCore/heap/HeapInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMarkedAllocatorcpp">trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMarkedBlockcpp">trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMarkedBlockh">trunk/Source/JavaScriptCore/heap/MarkedBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMarkedSpacecpp">trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapWeakBlockcpp">trunk/Source/JavaScriptCore/heap/WeakBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapWeakBlockh">trunk/Source/JavaScriptCore/heap/WeakBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapWeakSetcpp">trunk/Source/JavaScriptCore/heap/WeakSet.cpp</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlaycpp">trunk/Source/WebCore/page/PageOverlay.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlayh">trunk/Source/WebCore/page/PageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspicocoaMachVMSPIh">trunk/Source/WebCore/platform/spi/cocoa/MachVMSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesDefinitionsh">trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPreferencescpp">trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPreferencesRefPrivateh">trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKPreferencesmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKPreferencesPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacSettingsControllerh">trunk/Tools/MiniBrowser/mac/SettingsController.h</a></li>
<li><a href="#trunkToolsMiniBrowsermacSettingsControllerm">trunk/Tools/MiniBrowser/mac/SettingsController.m</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlaycpp">trunk/Source/WebCore/page/ResourceUsageOverlay.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlayh">trunk/Source/WebCore/page/ResourceUsageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm">trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2015-10-31 Andreas Kling <akling@apple.com>
+
+ Add a debug overlay with information about web process resource usage.
+ <https://webkit.org/b/150599>
+
+ Reviewed by Darin Adler.
+
+ Have Heap track the exact number of bytes allocated in CopiedBlock, MarkedBlock and
+ WeakBlock objects, keeping them in a single location that can be sampled by the
+ resource usage overlay thread.
+
+ The bulk of these changes is threading a Heap& through from sites where blocks are
+ allocated or freed.
+
+ * heap/CopiedBlock.cpp:
+ (JSC::CopiedBlock::createNoZeroFill):
+ (JSC::CopiedBlock::destroy):
+ (JSC::CopiedBlock::create):
+ * heap/CopiedBlock.h:
+ * heap/CopiedSpace.cpp:
+ (JSC::CopiedSpace::~CopiedSpace):
+ (JSC::CopiedSpace::tryAllocateOversize):
+ (JSC::CopiedSpace::tryReallocateOversize):
+ * heap/CopiedSpaceInlines.h:
+ (JSC::CopiedSpace::recycleEvacuatedBlock):
+ (JSC::CopiedSpace::recycleBorrowedBlock):
+ (JSC::CopiedSpace::allocateBlockForCopyingPhase):
+ (JSC::CopiedSpace::allocateBlock):
+ (JSC::CopiedSpace::startedCopying):
+ * heap/Heap.cpp:
+ (JSC::Heap::~Heap):
+ (JSC::Heap::sweepNextLogicallyEmptyWeakBlock):
+ * heap/Heap.h:
+ (JSC::Heap::blockBytesAllocated):
+ * heap/HeapInlines.h:
+ (JSC::Heap::didAllocateBlock):
+ (JSC::Heap::didFreeBlock):
+ * heap/MarkedAllocator.cpp:
+ (JSC::MarkedAllocator::allocateBlock):
+ * heap/MarkedBlock.cpp:
+ (JSC::MarkedBlock::create):
+ (JSC::MarkedBlock::destroy):
+ * heap/MarkedBlock.h:
+ * heap/MarkedSpace.cpp:
+ (JSC::MarkedSpace::freeBlock):
+ * heap/WeakBlock.cpp:
+ (JSC::WeakBlock::create):
+ (JSC::WeakBlock::destroy):
+ * heap/WeakBlock.h:
+ * heap/WeakSet.cpp:
+ (JSC::WeakSet::~WeakSet):
+ (JSC::WeakSet::addAllocator):
+ (JSC::WeakSet::removeAllocator):
+
</ins><span class="cx"> 2015-10-30 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> Air should eliminate dead code
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapCopiedBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/CopiedBlock.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/CopiedBlock.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/CopiedBlock.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -33,30 +33,34 @@
</span><span class="cx"> static const bool computeBalance = false;
</span><span class="cx"> static size_t balance;
</span><span class="cx">
</span><del>-CopiedBlock* CopiedBlock::createNoZeroFill(size_t capacity)
</del><ins>+CopiedBlock* CopiedBlock::createNoZeroFill(Heap& heap, size_t capacity)
</ins><span class="cx"> {
</span><span class="cx"> if (computeBalance) {
</span><span class="cx"> balance++;
</span><span class="cx"> if (!(balance % 10))
</span><span class="cx"> dataLog("CopiedBlock Balance: ", balance, "\n");
</span><span class="cx"> }
</span><del>- return new(NotNull, fastAlignedMalloc(CopiedBlock::blockSize, capacity)) CopiedBlock(capacity);
</del><ins>+ CopiedBlock* block = new (NotNull, fastAlignedMalloc(CopiedBlock::blockSize, capacity)) CopiedBlock(capacity);
+ heap.didAllocateBlock(capacity);
+ return block;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CopiedBlock::destroy(CopiedBlock* copiedBlock)
</del><ins>+void CopiedBlock::destroy(Heap& heap, CopiedBlock* copiedBlock)
</ins><span class="cx"> {
</span><span class="cx"> if (computeBalance) {
</span><span class="cx"> balance--;
</span><span class="cx"> if (!(balance % 10))
</span><span class="cx"> dataLog("CopiedBlock Balance: ", balance, "\n");
</span><span class="cx"> }
</span><ins>+ size_t capacity = copiedBlock->capacity();
</ins><span class="cx"> copiedBlock->~CopiedBlock();
</span><span class="cx"> fastAlignedFree(copiedBlock);
</span><ins>+ heap.didFreeBlock(capacity);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-CopiedBlock* CopiedBlock::create(size_t capacity)
</del><ins>+CopiedBlock* CopiedBlock::create(Heap& heap, size_t capacity)
</ins><span class="cx"> {
</span><del>- CopiedBlock* newBlock = createNoZeroFill(capacity);
</del><ins>+ CopiedBlock* newBlock = createNoZeroFill(heap, capacity);
</ins><span class="cx"> newBlock->zeroFillWilderness();
</span><span class="cx"> return newBlock;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapCopiedBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/CopiedBlock.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/CopiedBlock.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/CopiedBlock.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -41,9 +41,9 @@
</span><span class="cx"> friend class CopiedSpace;
</span><span class="cx"> friend class CopiedAllocator;
</span><span class="cx"> public:
</span><del>- static CopiedBlock* create(size_t = blockSize);
- static CopiedBlock* createNoZeroFill(size_t = blockSize);
- static void destroy(CopiedBlock*);
</del><ins>+ static CopiedBlock* create(Heap&, size_t = blockSize);
+ static CopiedBlock* createNoZeroFill(Heap&, size_t = blockSize);
+ static void destroy(Heap&, CopiedBlock*);
</ins><span class="cx">
</span><span class="cx"> void pin();
</span><span class="cx"> bool isPinned();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapCopiedSpacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/CopiedSpace.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/CopiedSpace.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/CopiedSpace.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -44,22 +44,22 @@
</span><span class="cx"> CopiedSpace::~CopiedSpace()
</span><span class="cx"> {
</span><span class="cx"> while (!m_oldGen.toSpace->isEmpty())
</span><del>- CopiedBlock::destroy(m_oldGen.toSpace->removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_oldGen.toSpace->removeHead());
</ins><span class="cx">
</span><span class="cx"> while (!m_oldGen.fromSpace->isEmpty())
</span><del>- CopiedBlock::destroy(m_oldGen.fromSpace->removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_oldGen.fromSpace->removeHead());
</ins><span class="cx">
</span><span class="cx"> while (!m_oldGen.oversizeBlocks.isEmpty())
</span><del>- CopiedBlock::destroy(m_oldGen.oversizeBlocks.removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_oldGen.oversizeBlocks.removeHead());
</ins><span class="cx">
</span><span class="cx"> while (!m_newGen.toSpace->isEmpty())
</span><del>- CopiedBlock::destroy(m_newGen.toSpace->removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_newGen.toSpace->removeHead());
</ins><span class="cx">
</span><span class="cx"> while (!m_newGen.fromSpace->isEmpty())
</span><del>- CopiedBlock::destroy(m_newGen.fromSpace->removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_newGen.fromSpace->removeHead());
</ins><span class="cx">
</span><span class="cx"> while (!m_newGen.oversizeBlocks.isEmpty())
</span><del>- CopiedBlock::destroy(m_newGen.oversizeBlocks.removeHead());
</del><ins>+ CopiedBlock::destroy(*heap(), m_newGen.oversizeBlocks.removeHead());
</ins><span class="cx">
</span><span class="cx"> ASSERT(m_oldGen.toSpace->isEmpty());
</span><span class="cx"> ASSERT(m_oldGen.fromSpace->isEmpty());
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isOversize(bytes));
</span><span class="cx">
</span><del>- CopiedBlock* block = CopiedBlock::create(WTF::roundUpToMultipleOf<sizeof(double)>(sizeof(CopiedBlock) + bytes));
</del><ins>+ CopiedBlock* block = CopiedBlock::create(*m_heap, WTF::roundUpToMultipleOf<sizeof(double)>(sizeof(CopiedBlock) + bytes));
</ins><span class="cx"> m_newGen.oversizeBlocks.push(block);
</span><span class="cx"> m_newGen.blockFilter.add(reinterpret_cast<Bits>(block));
</span><span class="cx"> m_blockSet.add(block);
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx"> } else
</span><span class="cx"> m_newGen.oversizeBlocks.remove(oldBlock);
</span><span class="cx"> m_blockSet.remove(oldBlock);
</span><del>- CopiedBlock::destroy(oldBlock);
</del><ins>+ CopiedBlock::destroy(*heap(), oldBlock);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> *ptr = newPtr;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapCopiedSpaceInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/CopiedSpaceInlines.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/CopiedSpaceInlines.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/CopiedSpaceInlines.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -104,12 +104,12 @@
</span><span class="cx"> else
</span><span class="cx"> m_oldGen.fromSpace->remove(block);
</span><span class="cx"> }
</span><del>- CopiedBlock::destroy(block);
</del><ins>+ CopiedBlock::destroy(*heap(), block);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline void CopiedSpace::recycleBorrowedBlock(CopiedBlock* block)
</span><span class="cx"> {
</span><del>- CopiedBlock::destroy(block);
</del><ins>+ CopiedBlock::destroy(*heap(), block);
</ins><span class="cx">
</span><span class="cx"> {
</span><span class="cx"> LockHolder locker(m_loanedBlocksLock);
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> inline CopiedBlock* CopiedSpace::allocateBlockForCopyingPhase()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_inCopyingPhase);
</span><del>- CopiedBlock* block = CopiedBlock::createNoZeroFill();
</del><ins>+ CopiedBlock* block = CopiedBlock::createNoZeroFill(*m_heap);
</ins><span class="cx">
</span><span class="cx"> {
</span><span class="cx"> LockHolder locker(m_loanedBlocksLock);
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">
</span><span class="cx"> m_allocator.resetCurrentBlock();
</span><span class="cx">
</span><del>- CopiedBlock* block = CopiedBlock::create();
</del><ins>+ CopiedBlock* block = CopiedBlock::create(*m_heap);
</ins><span class="cx">
</span><span class="cx"> m_newGen.toSpace->push(block);
</span><span class="cx"> m_newGen.blockFilter.add(reinterpret_cast<Bits>(block));
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx"> } else {
</span><span class="cx"> oversizeBlocks->remove(block);
</span><span class="cx"> m_blockSet.remove(block);
</span><del>- CopiedBlock::destroy(block);
</del><ins>+ CopiedBlock::destroy(*heap(), block);
</ins><span class="cx"> }
</span><span class="cx"> block = next;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/Heap.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx"> Heap::~Heap()
</span><span class="cx"> {
</span><span class="cx"> for (WeakBlock* block : m_logicallyEmptyWeakBlocks)
</span><del>- WeakBlock::destroy(block);
</del><ins>+ WeakBlock::destroy(*this, block);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool Heap::isPagedOut(double deadline)
</span><span class="lines">@@ -1572,7 +1572,7 @@
</span><span class="cx"> if (block->isEmpty()) {
</span><span class="cx"> std::swap(m_logicallyEmptyWeakBlocks[m_indexOfNextLogicallyEmptyWeakBlockToSweep], m_logicallyEmptyWeakBlocks.last());
</span><span class="cx"> m_logicallyEmptyWeakBlocks.removeLast();
</span><del>- WeakBlock::destroy(block);
</del><ins>+ WeakBlock::destroy(*this, block);
</ins><span class="cx"> } else
</span><span class="cx"> m_indexOfNextLogicallyEmptyWeakBlockToSweep++;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/Heap.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx"> JS_EXPORT_PRIVATE void protect(JSValue);
</span><span class="cx"> JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
</span><span class="cx">
</span><del>- size_t extraMemorySize(); // Non-GC memory referenced by GC objects.
</del><ins>+ JS_EXPORT_PRIVATE size_t extraMemorySize(); // Non-GC memory referenced by GC objects.
</ins><span class="cx"> JS_EXPORT_PRIVATE size_t size();
</span><span class="cx"> JS_EXPORT_PRIVATE size_t capacity();
</span><span class="cx"> JS_EXPORT_PRIVATE size_t objectCount();
</span><span class="lines">@@ -236,6 +236,13 @@
</span><span class="cx">
</span><span class="cx"> void addLogicallyEmptyWeakBlock(WeakBlock*);
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ size_t blockBytesAllocated() const { return m_blockBytesAllocated; }
+#endif
+
+ void didAllocateBlock(size_t capacity);
+ void didFreeBlock(size_t capacity);
+
</ins><span class="cx"> private:
</span><span class="cx"> friend class CodeBlock;
</span><span class="cx"> friend class CopiedBlock;
</span><span class="lines">@@ -439,6 +446,10 @@
</span><span class="cx"> ListableHandler<UnconditionalFinalizer>::List m_unconditionalFinalizers;
</span><span class="cx">
</span><span class="cx"> ParallelHelperClient m_helperClient;
</span><ins>+
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ size_t m_blockBytesAllocated { 0 };
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/HeapInlines.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/HeapInlines.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/HeapInlines.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -307,7 +307,25 @@
</span><span class="cx"> {
</span><span class="cx"> m_weakGCMaps.remove(weakGCMap);
</span><span class="cx"> }
</span><del>-
</del><ins>+
+inline void Heap::didAllocateBlock(size_t capacity)
+{
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ m_blockBytesAllocated += capacity;
+#else
+ UNUSED_PARAM(capacity);
+#endif
+}
+
+inline void Heap::didFreeBlock(size_t capacity)
+{
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ m_blockBytesAllocated -= capacity;
+#else
+ UNUSED_PARAM(capacity);
+#endif
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // HeapInlines_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMarkedAllocatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -181,7 +181,7 @@
</span><span class="cx">
</span><span class="cx"> size_t cellSize = m_cellSize ? m_cellSize : WTF::roundUpToMultipleOf<MarkedBlock::atomSize>(bytes);
</span><span class="cx">
</span><del>- return MarkedBlock::create(this, blockSize, cellSize, m_needsDestruction);
</del><ins>+ return MarkedBlock::create(*m_heap, this, blockSize, cellSize, m_needsDestruction);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MarkedAllocator::addBlock(MarkedBlock* block)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMarkedBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -35,25 +35,29 @@
</span><span class="cx"> static const bool computeBalance = false;
</span><span class="cx"> static size_t balance;
</span><span class="cx">
</span><del>-MarkedBlock* MarkedBlock::create(MarkedAllocator* allocator, size_t capacity, size_t cellSize, bool needsDestruction)
</del><ins>+MarkedBlock* MarkedBlock::create(Heap& heap, MarkedAllocator* allocator, size_t capacity, size_t cellSize, bool needsDestruction)
</ins><span class="cx"> {
</span><span class="cx"> if (computeBalance) {
</span><span class="cx"> balance++;
</span><span class="cx"> if (!(balance % 10))
</span><span class="cx"> dataLog("MarkedBlock Balance: ", balance, "\n");
</span><span class="cx"> }
</span><del>- return new (NotNull, fastAlignedMalloc(blockSize, capacity)) MarkedBlock(allocator, capacity, cellSize, needsDestruction);
</del><ins>+ MarkedBlock* block = new (NotNull, fastAlignedMalloc(blockSize, capacity)) MarkedBlock(allocator, capacity, cellSize, needsDestruction);
+ heap.didAllocateBlock(capacity);
+ return block;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void MarkedBlock::destroy(MarkedBlock* block)
</del><ins>+void MarkedBlock::destroy(Heap& heap, MarkedBlock* block)
</ins><span class="cx"> {
</span><span class="cx"> if (computeBalance) {
</span><span class="cx"> balance--;
</span><span class="cx"> if (!(balance % 10))
</span><span class="cx"> dataLog("MarkedBlock Balance: ", balance, "\n");
</span><span class="cx"> }
</span><ins>+ size_t capacity = block->capacity();
</ins><span class="cx"> block->~MarkedBlock();
</span><span class="cx"> fastAlignedFree(block);
</span><ins>+ heap.didFreeBlock(capacity);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> MarkedBlock::MarkedBlock(MarkedAllocator* allocator, size_t capacity, size_t cellSize, bool needsDestruction)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMarkedBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MarkedBlock.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MarkedBlock.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/MarkedBlock.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -106,8 +106,8 @@
</span><span class="cx"> ReturnType m_count;
</span><span class="cx"> };
</span><span class="cx">
</span><del>- static MarkedBlock* create(MarkedAllocator*, size_t capacity, size_t cellSize, bool needsDestruction);
- static void destroy(MarkedBlock*);
</del><ins>+ static MarkedBlock* create(Heap&, MarkedAllocator*, size_t capacity, size_t cellSize, bool needsDestruction);
+ static void destroy(Heap&, MarkedBlock*);
</ins><span class="cx">
</span><span class="cx"> static bool isAtomAligned(const void*);
</span><span class="cx"> static MarkedBlock* blockFor(const void*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMarkedSpacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx"> block->allocator()->removeBlock(block);
</span><span class="cx"> m_capacity -= block->capacity();
</span><span class="cx"> m_blocks.remove(block);
</span><del>- MarkedBlock::destroy(block);
</del><ins>+ MarkedBlock::destroy(*m_heap, block);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MarkedSpace::freeOrShrinkBlock(MarkedBlock* block)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapWeakBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/WeakBlock.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/WeakBlock.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/WeakBlock.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -34,15 +34,17 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><del>-WeakBlock* WeakBlock::create(MarkedBlock& markedBlock)
</del><ins>+WeakBlock* WeakBlock::create(Heap& heap, MarkedBlock& markedBlock)
</ins><span class="cx"> {
</span><ins>+ heap.didAllocateBlock(WeakBlock::blockSize);
</ins><span class="cx"> return new (NotNull, fastMalloc(blockSize)) WeakBlock(markedBlock);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WeakBlock::destroy(WeakBlock* block)
</del><ins>+void WeakBlock::destroy(Heap& heap, WeakBlock* block)
</ins><span class="cx"> {
</span><span class="cx"> block->~WeakBlock();
</span><span class="cx"> fastFree(block);
</span><ins>+ heap.didFreeBlock(WeakBlock::blockSize);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WeakBlock::WeakBlock(MarkedBlock& markedBlock)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapWeakBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/WeakBlock.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/WeakBlock.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/WeakBlock.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><ins>+class Heap;
</ins><span class="cx"> class HeapRootVisitor;
</span><span class="cx"> class MarkedBlock;
</span><span class="cx">
</span><span class="lines">@@ -52,8 +53,8 @@
</span><span class="cx"> FreeCell* freeList { nullptr };
</span><span class="cx"> };
</span><span class="cx">
</span><del>- static WeakBlock* create(MarkedBlock&);
- static void destroy(WeakBlock*);
</del><ins>+ static WeakBlock* create(Heap&, MarkedBlock&);
+ static void destroy(Heap&, WeakBlock*);
</ins><span class="cx">
</span><span class="cx"> static WeakImpl* asWeakImpl(FreeCell*);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapWeakSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/WeakSet.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/WeakSet.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/JavaScriptCore/heap/WeakSet.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -34,10 +34,11 @@
</span><span class="cx">
</span><span class="cx"> WeakSet::~WeakSet()
</span><span class="cx"> {
</span><ins>+ Heap& heap = *this->heap();
</ins><span class="cx"> WeakBlock* next = 0;
</span><span class="cx"> for (WeakBlock* block = m_blocks.head(); block; block = next) {
</span><span class="cx"> next = block->next();
</span><del>- WeakBlock::destroy(block);
</del><ins>+ WeakBlock::destroy(heap, block);
</ins><span class="cx"> }
</span><span class="cx"> m_blocks.clear();
</span><span class="cx"> }
</span><span class="lines">@@ -85,7 +86,7 @@
</span><span class="cx">
</span><span class="cx"> WeakBlock::FreeCell* WeakSet::addAllocator()
</span><span class="cx"> {
</span><del>- WeakBlock* block = WeakBlock::create(m_markedBlock);
</del><ins>+ WeakBlock* block = WeakBlock::create(*heap(), m_markedBlock);
</ins><span class="cx"> heap()->didAllocate(WeakBlock::blockSize);
</span><span class="cx"> m_blocks.append(block);
</span><span class="cx"> WeakBlock::SweepResult sweepResult = block->takeSweepResult();
</span><span class="lines">@@ -96,7 +97,7 @@
</span><span class="cx"> void WeakSet::removeAllocator(WeakBlock* block)
</span><span class="cx"> {
</span><span class="cx"> m_blocks.remove(block);
</span><del>- WeakBlock::destroy(block);
</del><ins>+ WeakBlock::destroy(*heap(), block);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WTF/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-10-31 Andreas Kling <akling@apple.com>
+
+ Add a debug overlay with information about web process resource usage.
+ <https://webkit.org/b/150599>
+
+ Reviewed by Darin Adler.
+
+ Add ENABLE(RESOURCE_USAGE_OVERLAY) flag, enabled on Mac by default.
+
+ * wtf/Platform.h:
+
</ins><span class="cx"> 2015-10-30 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Regression(r191673): Crash in RunLoopTimer::schedule()
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WTF/wtf/Platform.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1081,6 +1081,10 @@
</span><span class="cx"> #define USE_IOSURFACE 1
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+#define ENABLE_RESOURCE_USAGE_OVERLAY 1
+#endif
+
</ins><span class="cx"> #if PLATFORM(GTK) || PLATFORM(EFL)
</span><span class="cx"> #undef ENABLE_OPENTYPE_VERTICAL
</span><span class="cx"> #define ENABLE_OPENTYPE_VERTICAL 1
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -2045,6 +2045,7 @@
</span><span class="cx"> page/PerformanceUserTiming.cpp
</span><span class="cx"> page/PointerLockController.cpp
</span><span class="cx"> page/PrintContext.cpp
</span><ins>+ page/ResourceUsageOverlay.cpp
</ins><span class="cx"> page/Screen.cpp
</span><span class="cx"> page/SecurityOrigin.cpp
</span><span class="cx"> page/SecurityOriginData.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2015-10-31 Andreas Kling <akling@apple.com>
+
+ Add a debug overlay with information about web process resource usage.
+ <https://webkit.org/b/150599>
+
+ Reviewed by Darin Adler.
+
+ A new kind of PageOverlay is added behind the ENABLE(RESOURCE_USAGE_OVERLAY) flag.
+ It's owned by Page, but not instantiated unless the Settings::resourceUsageOverlayVisible flag is set.
+
+ All ResourceUsageOverlay objects share a single sampler thread. The thread currently runs every 500ms
+ and samples CPU usage, dirty memory regions, and GC heap size/capacity.
+
+ Most things in here are currently quite Mac-specific, but I will be iterating on this towards a more
+ cross-platform friendly solution.
+
+ There are two small changes to PageOverlay in order to support dragging the resource usage overlay:
+
+ - A "should ignore mouse events outside bounds" state flag. This is on by default
+ but turned off during a drag.
+ - PageOverlay::bounds() will now return the override frame verbatim if one is set,
+ instead of returning it relocated to 0,0.
+
+ Note that this is intended as a tool for WebKit engine developers to better understand memory usage.
+ It's not a goal to expose this information to end users.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/Page.cpp:
+ (WebCore::Page::setResourceUsageOverlayVisible):
+ * page/Page.h:
+ * page/PageOverlay.cpp:
+ (WebCore::PageOverlay::bounds):
+ (WebCore::PageOverlay::mouseEvent):
+ * page/PageOverlay.h:
+ * page/ResourceUsageOverlay.cpp: Added.
+ (WebCore::ResourceUsageOverlay::ResourceUsageOverlay):
+ (WebCore::ResourceUsageOverlay::~ResourceUsageOverlay):
+ (WebCore::ResourceUsageOverlay::mouseEvent):
+ * page/ResourceUsageOverlay.h: Added.
+ * page/Settings.cpp:
+ (WebCore::Settings::setResourceUsageOverlayVisible):
+ * page/Settings.h:
+ (WebCore::Settings::resourceUsageOverlayVisible):
+ * page/cocoa/ResourceUsageOverlayCocoa.mm: Added.
+ (-[WebOverlayLayer initWithResourceUsageOverlay:]):
+ (-[WebOverlayLayer drawInContext:]):
+ (WebCore::RingBuffer::RingBuffer):
+ (WebCore::RingBuffer::append):
+ (WebCore::RingBuffer::last):
+ (WebCore::RingBuffer::forEach):
+ (WebCore::RingBuffer::incrementIndex):
+ (WebCore::RingBuffer::decrementIndex):
+ (WebCore::sharedData):
+ (WebCore::ResourceUsageOverlay::platformInitialize):
+ (WebCore::ResourceUsageOverlay::platformDestroy):
+ (WebCore::drawCpuHistory):
+ (WebCore::drawGCHistory):
+ (WebCore::drawSlice):
+ (WebCore::drawPlate):
+ (WebCore::drawMemoryPie):
+ (WebCore::formatByteNumber):
+ (WebCore::showText):
+ (WebCore::ResourceUsageOverlay::draw):
+ (WebCore::dirtyPagesPerVMTag):
+ (WebCore::cpuUsage):
+ (WebCore::runSamplerThread):
+ * platform/spi/cocoa/MachVMSPI.h:
+
</ins><span class="cx"> 2015-10-31 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html is flaky.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/PlatformMac.cmake        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -269,6 +269,7 @@
</span><span class="cx"> page/PageDebuggable.cpp
</span><span class="cx">
</span><span class="cx"> page/cocoa/UserAgent.mm
</span><ins>+ page/cocoa/ResourceUsageOverlayCocoa.mm
</ins><span class="cx">
</span><span class="cx"> page/mac/ChromeMac.mm
</span><span class="cx"> page/mac/DragControllerMac.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -4625,9 +4625,12 @@
</span><span class="cx">                 AD726FEF16DA11F5003A4E6D /* JSCSSRuleCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 AD9FF6E11908391D003B61E0 /* IOSurfacePoolCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */; };
</span><span class="cx">                 ADB6B29818FB90240081963E /* MemoryPressureHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */; };
</span><ins>+                ADBAD6EE1BCDD95500381325 /* ResourceUsageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */; };
+                ADBAD6EF1BCDD95700381325 /* ResourceUsageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */; };
</ins><span class="cx">                 ADDA94C219687AA500453029 /* JSDocumentCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDA94BF19686F8000453029 /* JSDocumentCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 ADDF1AD71257CD9A0003A759 /* RenderSVGPath.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */; };
</span><span class="cx">                 ADEC78F818EE5308001315C2 /* JSElementCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = ADEC78F718EE5308001315C2 /* JSElementCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                ADFE2B551BD5F61200DAB457 /* ResourceUsageOverlayCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */; };
</ins><span class="cx">                 B10B6980140C174000BC1C26 /* WebVTTToken.h in Headers */ = {isa = PBXBuildFile; fileRef = B10B697D140C174000BC1C26 /* WebVTTToken.h */; };
</span><span class="cx">                 B10B6981140C174000BC1C26 /* WebVTTTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */; };
</span><span class="cx">                 B10B6982140C174000BC1C26 /* WebVTTTokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = B10B697F140C174000BC1C26 /* WebVTTTokenizer.h */; };
</span><span class="lines">@@ -12206,12 +12209,15 @@
</span><span class="cx">                 AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStyleSheetCustom.h; sourceTree = "<group>"; };
</span><span class="cx">                 AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSurfacePoolCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">                 ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerCocoa.mm; sourceTree = "<group>"; };
</span><ins>+                ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageOverlay.cpp; sourceTree = "<group>"; };
+                ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageOverlay.h; sourceTree = "<group>"; };
</ins><span class="cx">                 ADDA94BF19686F8000453029 /* JSDocumentCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDocumentCustom.h; sourceTree = "<group>"; };
</span><span class="cx">                 ADDF1AD41257CD9A0003A759 /* RenderSVGPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGPath.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGPath.h; sourceTree = "<group>"; };
</span><span class="cx">                 ADE11F4A18D8311B0078983B /* ElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementDescendantIterator.h; sourceTree = "<group>"; };
</span><span class="cx">                 ADE16736181050C300463A2E /* RenderPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPtr.h; sourceTree = "<group>"; };
</span><span class="cx">                 ADEC78F718EE5308001315C2 /* JSElementCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSElementCustom.h; sourceTree = "<group>"; };
</span><ins>+                ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceUsageOverlayCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 B10B697D140C174000BC1C26 /* WebVTTToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTToken.h; sourceTree = "<group>"; };
</span><span class="cx">                 B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTTokenizer.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 B10B697F140C174000BC1C26 /* WebVTTTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTTokenizer.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -14968,7 +14974,6 @@
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="cx"> /* End PBXFrameworksBuildPhase section */
</span><del>-
</del><span class="cx"> /* Begin PBXGroup section */
</span><span class="cx">                 00B9318013BA867F0035A948 /* parser */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="lines">@@ -17076,6 +17081,7 @@
</span><span class="cx">                 5D5975B5196362BE00D00878 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
</ins><span class="cx">                                 26255F0118878E110006E1FD /* UserAgent.h */,
</span><span class="cx">                                 5D5975B61963637B00D00878 /* UserAgent.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -17504,6 +17510,8 @@
</span><span class="cx">                 65BF02180974806300C43196 /* page */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
+                                ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */,
</ins><span class="cx">                                 316FE1060E6E1D8400BF6088 /* animation */,
</span><span class="cx">                                 5D5975B5196362BE00D00878 /* cocoa */,
</span><span class="cx">                                 18A6CD6F0D8F2025001DC3CE /* ios */,
</span><span class="lines">@@ -27740,6 +27748,7 @@
</span><span class="cx">                                 854FE7370A2297BE0058D7AD /* Traversal.h in Headers */,
</span><span class="cx">                                 37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */,
</span><span class="cx">                                 14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */,
</span><ins>+                                ADBAD6EF1BCDD95700381325 /* ResourceUsageOverlay.h in Headers */,
</ins><span class="cx">                                 A77E1FF014AACB6E005B7CB6 /* TreeScopeAdopter.h in Headers */,
</span><span class="cx">                                 854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */,
</span><span class="cx">                                 2D232C001A326F02006BF2DB /* TUCallSPI.h in Headers */,
</span><span class="lines">@@ -29515,6 +29524,7 @@
</span><span class="cx">                                 BC46C2060C0DDCA10020CFC3 /* JSCSSStyleRule.cpp in Sources */,
</span><span class="cx">                                 BCC5BE000C0E93110011C2DB /* JSCSSStyleSheet.cpp in Sources */,
</span><span class="cx">                                 FD67773A195CB14A0072E0D3 /* JSCSSSupportsRule.cpp in Sources */,
</span><ins>+                                ADFE2B551BD5F61200DAB457 /* ResourceUsageOverlayCocoa.mm in Sources */,
</ins><span class="cx">                                 14CF78A409F58CBF00EB3665 /* JSCSSValue.cpp in Sources */,
</span><span class="cx">                                 BC20FB7F0C0E8E6C00D1447F /* JSCSSValueCustom.cpp in Sources */,
</span><span class="cx">                                 A8D05FAB0A23B30F005E7203 /* JSCSSValueList.cpp in Sources */,
</span><span class="lines">@@ -30388,6 +30398,7 @@
</span><span class="cx">                                 A5A2AF0B1829734300DE1729 /* PageDebuggable.cpp in Sources */,
</span><span class="cx">                                 F34742DC134362F000531BC2 /* PageDebuggerAgent.cpp in Sources */,
</span><span class="cx">                                 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */,
</span><ins>+                                ADBAD6EE1BCDD95500381325 /* ResourceUsageOverlay.cpp in Sources */,
</ins><span class="cx">                                 7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */,
</span><span class="cx">                                 2D5C9CFF19C7B52E00B3C5C1 /* PageOverlay.cpp in Sources */,
</span><span class="cx">                                 2D5C9D0119C7B52E00B3C5C1 /* PageOverlayController.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/Page.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> #include "RenderTheme.h"
</span><span class="cx"> #include "RenderView.h"
</span><span class="cx"> #include "RenderWidget.h"
</span><ins>+#include "ResourceUsageOverlay.h"
</ins><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="cx"> #include "SchemeRegistry.h"
</span><span class="cx"> #include "ScriptController.h"
</span><span class="lines">@@ -1782,4 +1783,17 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+void Page::setResourceUsageOverlayVisible(bool visible)
+{
+ if (!visible) {
+ m_resourceUsageOverlay = nullptr;
+ return;
+ }
+
+ if (!m_resourceUsageOverlay)
+ m_resourceUsageOverlay = std::make_unique<ResourceUsageOverlay>(*this);
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/Page.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -109,6 +109,7 @@
</span><span class="cx"> class RenderObject;
</span><span class="cx"> class RenderTheme;
</span><span class="cx"> class ReplayController;
</span><ins>+class ResourceUsageOverlay;
</ins><span class="cx"> class VisibleSelection;
</span><span class="cx"> class ScrollableArea;
</span><span class="cx"> class ScrollingCoordinator;
</span><span class="lines">@@ -333,6 +334,10 @@
</span><span class="cx"> void dnsPrefetchingStateChanged();
</span><span class="cx"> void storageBlockingStateChanged();
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ void setResourceUsageOverlayVisible(bool);
+#endif
+
</ins><span class="cx"> void setDebugger(JSC::Debugger*);
</span><span class="cx"> JSC::Debugger* debugger() const { return m_debugger; }
</span><span class="cx">
</span><span class="lines">@@ -631,6 +636,10 @@
</span><span class="cx">
</span><span class="cx"> HashSet<ViewStateChangeObserver*> m_viewStateChangeObservers;
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ std::unique_ptr<ResourceUsageOverlay> m_resourceUsageOverlay;
+#endif
+
</ins><span class="cx"> SessionID m_sessionID;
</span><span class="cx">
</span><span class="cx"> bool m_isClosing;
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlay.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlay.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/PageOverlay.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> IntRect PageOverlay::bounds() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_overrideFrame.isEmpty())
</span><del>- return IntRect(IntPoint(), m_overrideFrame.size());
</del><ins>+ return m_overrideFrame;
</ins><span class="cx">
</span><span class="cx"> FrameView* frameView = m_page->mainFrame().view();
</span><span class="cx">
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx"> mousePositionInOverlayCoordinates = m_page->mainFrame().view()->windowToContents(mousePositionInOverlayCoordinates);
</span><span class="cx">
</span><span class="cx"> // Ignore events outside the bounds.
</span><del>- if (!bounds().contains(mousePositionInOverlayCoordinates))
</del><ins>+ if (m_shouldIgnoreMouseEventsOutsideBounds && !bounds().contains(mousePositionInOverlayCoordinates))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> return m_client.mouseEvent(*this, mouseEvent);
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlay.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlay.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/PageOverlay.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -110,6 +110,8 @@
</span><span class="cx"> RGBA32 backgroundColor() const { return m_backgroundColor; }
</span><span class="cx"> void setBackgroundColor(RGBA32);
</span><span class="cx">
</span><ins>+ void setShouldIgnoreMouseEventsOutsideBounds(bool flag) { m_shouldIgnoreMouseEventsOutsideBounds = flag; }
+
</ins><span class="cx"> // FIXME: PageOverlay should own its layer, instead of PageOverlayController.
</span><span class="cx"> WEBCORE_EXPORT GraphicsLayer& layer();
</span><span class="cx">
</span><span class="lines">@@ -140,6 +142,8 @@
</span><span class="cx">
</span><span class="cx"> RGBA32 m_backgroundColor;
</span><span class="cx"> PageOverlayID m_pageOverlayID;
</span><ins>+
+ bool m_shouldIgnoreMouseEventsOutsideBounds { true };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlaycpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageOverlay.cpp (0 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.cpp         (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -0,0 +1,107 @@
</span><ins>+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+
+#include "ResourceUsageOverlay.h"
+
+#include "FrameView.h"
+#include "PageOverlayController.h"
+#include "PlatformMouseEvent.h"
+
+namespace WebCore {
+
+ResourceUsageOverlay::ResourceUsageOverlay(Page& page)
+ : m_page(page)
+ , m_overlay(PageOverlay::create(*this, PageOverlay::OverlayType::View))
+{
+ m_overlay->setFrame(IntRect(80, 80, 500, 120));
+ m_overlay->setShouldIgnoreMouseEventsOutsideBounds(false);
+
+ m_page.mainFrame().pageOverlayController().installPageOverlay(m_overlay.get(), PageOverlay::FadeMode::DoNotFade);
+
+ platformInitialize();
+}
+
+ResourceUsageOverlay::~ResourceUsageOverlay()
+{
+ platformDestroy();
+}
+
+bool ResourceUsageOverlay::mouseEvent(PageOverlay&, const PlatformMouseEvent& event)
+{
+ if (event.button() != LeftButton)
+ return false;
+
+ switch (event.type()) {
+ case PlatformEvent::MousePressed: {
+ m_overlay->setShouldIgnoreMouseEventsOutsideBounds(false);
+ m_dragging = true;
+ IntPoint location = m_overlay->frame().location();
+ m_dragPoint = event.position() + IntPoint(-location.x(), -location.y());
+ return true;
+ }
+ case PlatformEvent::MouseReleased:
+ if (m_dragging) {
+ m_overlay->setShouldIgnoreMouseEventsOutsideBounds(true);
+ m_dragging = false;
+ return true;
+ }
+ break;
+ case PlatformEvent::MouseMoved:
+ if (m_dragging) {
+ IntRect newFrame = m_overlay->frame();
+
+ // Move the new frame relative to the point where the drag was initiated.
+ newFrame.setLocation(event.position());
+ newFrame.moveBy(IntPoint(-m_dragPoint.x(), -m_dragPoint.y()));
+
+ // Force the frame to stay inside the viewport entirely.
+ if (newFrame.x() < 0)
+ newFrame.setX(0);
+ if (newFrame.y() < m_page.topContentInset())
+ newFrame.setY(m_page.topContentInset());
+ FrameView& frameView = *m_page.mainFrame().view();
+ if (newFrame.maxX() > frameView.width())
+ newFrame.setX(frameView.width() - newFrame.width());
+ if (newFrame.maxY() > frameView.height())
+ newFrame.setY(frameView.height() - newFrame.height());
+
+ m_overlay->setFrame(newFrame);
+ m_overlay->setNeedsDisplay();
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlayh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/ResourceUsageOverlay.h (0 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.h         (rev 0)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 ResourceUsageOverlay_h
+#define ResourceUsageOverlay_h
+
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "MainFrame.h"
+#include "PageOverlay.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(COCOA)
+#include "PlatformCALayer.h"
+#endif
+
+namespace WebCore {
+
+class FloatRect;
+class IntPoint;
+class IntRect;
+
+class ResourceUsageOverlay final : public PageOverlay::Client {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(ResourceUsageOverlay);
+public:
+ explicit ResourceUsageOverlay(Page&);
+ ~ResourceUsageOverlay();
+
+ PageOverlay& overlay() { return *m_overlay; }
+
+ void draw(GraphicsContext&);
+
+private:
+ void pageOverlayDestroyed(PageOverlay&) override { }
+ void willMoveToPage(PageOverlay&, Page*) override { }
+ void didMoveToPage(PageOverlay&, Page*) override { }
+ void drawRect(PageOverlay&, GraphicsContext&, const IntRect&) override { }
+ bool mouseEvent(PageOverlay&, const PlatformMouseEvent&) override;
+ void didScrollFrame(PageOverlay&, Frame&) override { }
+
+ void platformInitialize();
+ void platformDestroy();
+
+ Page& m_page;
+ RefPtr<PageOverlay> m_overlay;
+ bool m_dragging { false };
+ IntPoint m_dragPoint;
+
+#if PLATFORM(COCOA)
+ ThreadIdentifier m_threadID { 0 };
+ RetainPtr<CALayer> m_layer;
+#endif
+};
+
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/Settings.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -531,6 +531,18 @@
</span><span class="cx"> m_showTiledScrollingIndicator = enabled;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+void Settings::setResourceUsageOverlayVisible(bool visible)
+{
+ if (m_resourceUsageOverlayVisible == visible)
+ return;
+
+ m_resourceUsageOverlayVisible = visible;
+ if (m_page)
+ m_page->setResourceUsageOverlayVisible(visible);
+}
+#endif
+
</ins><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx"> void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/page/Settings.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -189,6 +189,11 @@
</span><span class="cx"> WEBCORE_EXPORT void setShowTiledScrollingIndicator(bool);
</span><span class="cx"> bool showTiledScrollingIndicator() const { return m_showTiledScrollingIndicator; }
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ bool resourceUsageOverlayVisible() const { return m_resourceUsageOverlayVisible; }
+ WEBCORE_EXPORT void setResourceUsageOverlayVisible(bool);
+#endif
+
</ins><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx"> static void setShouldUseHighResolutionTimers(bool);
</span><span class="cx"> static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; }
</span><span class="lines">@@ -333,6 +338,10 @@
</span><span class="cx">
</span><span class="cx"> bool m_forcePendingWebGLPolicy : 1;
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ bool m_resourceUsageOverlayVisible { false };
+#endif
+
</ins><span class="cx"> #if USE(AVFOUNDATION)
</span><span class="cx"> WEBCORE_EXPORT static bool gAVFoundationEnabled;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorepagecocoaResourceUsageOverlayCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (0 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm         (rev 0)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -0,0 +1,474 @@
</span><ins>+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+#include "ResourceUsageOverlay.h"
+
+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+
+#include "GraphicsContext.h"
+#include "JSDOMWindow.h"
+#include "MachVMSPI.h"
+#include "PlatformCALayer.h"
+#include <QuartzCore/CALayer.h>
+#include <QuartzCore/CATransaction.h>
+#include <array>
+#include <mach/mach.h>
+#include <mach/vm_statistics.h>
+#include <runtime/JSLock.h>
+#include <thread>
+#include <wtf/MathExtras.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+@interface WebOverlayLayer : CALayer {
+ ResourceUsageOverlay* m_overlay;
+}
+@end
+
+@implementation WebOverlayLayer
+
+- (WebOverlayLayer *)initWithResourceUsageOverlay:(ResourceUsageOverlay *)overlay
+{
+ self = [super init];
+ if (!self)
+ return nil;
+ m_overlay = overlay;
+ return self;
+}
+
+- (void)drawInContext:(CGContextRef)context
+{
+ GraphicsContext gc(context);
+ m_overlay->draw(gc);
+}
+
+@end
+
+namespace WebCore {
+
+static const RGBA32 colorForJITCode = 0xFFFF60FF;
+static const RGBA32 colorForImages = 0xFFFFFF00;
+static const RGBA32 colorForLayers = 0xFF00FFFF;
+static const RGBA32 colorForGCHeap = 0xFFA0A0FF;
+static const RGBA32 colorForLibcMalloc = 0xFF00FF00;
+static const RGBA32 colorForFastMalloc = 0xFFFF6060;
+static const RGBA32 colorForOther = 0xFFC0FF00;
+static const RGBA32 colorForLabels = 0xFFE0E0E0;
+
+template<typename T, size_t size = 50>
+class RingBuffer {
+public:
+ RingBuffer()
+ {
+ m_data.fill(0);
+ }
+
+ void append(T v)
+ {
+ m_data[m_current] = WTF::move(v);
+ incrementIndex(m_current);
+ }
+
+ T last() const
+ {
+ unsigned index = m_current;
+ decrementIndex(index);
+ return m_data[index];
+ }
+
+ void forEach(std::function<void(T)> func) const
+ {
+ unsigned i = m_current;
+ for (unsigned visited = 0; visited < size; ++visited) {
+ func(m_data[i]);
+ incrementIndex(i);
+ }
+ }
+
+private:
+ static void incrementIndex(unsigned& index)
+ {
+ if (++index == size)
+ index = 0;
+ }
+
+ static void decrementIndex(unsigned& index)
+ {
+ if (index)
+ --index;
+ else
+ index = size - 1;
+ }
+
+ std::array<T, size> m_data;
+ unsigned m_current { 0 };
+};
+
+struct ResourceUsageData {
+ Lock lock;
+ RingBuffer<float> cpuHistory;
+ RingBuffer<size_t> gcHeapSizeHistory;
+ RingBuffer<size_t> gcHeapCapacityHistory;
+ size_t layers { 0 };
+ size_t images { 0 };
+ size_t jitCode { 0 };
+ size_t libcMalloc { 0 };
+ size_t bmalloc { 0 };
+ size_t sumDirty { 0 };
+
+ HashSet<CALayer *> overlayLayers;
+ JSC::VM* vm { nullptr };
+};
+
+static ResourceUsageData& sharedData()
+{
+ static NeverDestroyed<ResourceUsageData> data;
+ return data;
+}
+
+void runSamplerThread(void*);
+
+void ResourceUsageOverlay::platformInitialize()
+{
+ auto& data = sharedData();
+ LockHolder locker(data.lock);
+
+ // FIXME: The sampler thread will never stop once started.
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [&] {
+ data.vm = &JSDOMWindow::commonVM();
+ createThread(runSamplerThread, nullptr, "ResourceUsageOverlay Sampler");
+ });
+
+ m_layer = adoptNS([[WebOverlayLayer alloc] initWithResourceUsageOverlay:this]);
+
+ [overlay().layer().platformLayer() addSublayer:m_layer.get()];
+
+ [m_layer.get() setContentsScale:2.0];
+ [m_layer.get() setBackgroundColor:adoptCF(CGColorCreateGenericRGB(0, 0, 0, 0.8)).get()];
+ [m_layer.get() setFrame:CGRectMake(0, 0, 500, 120)];
+
+ data.overlayLayers.add(m_layer.get());
+}
+
+void ResourceUsageOverlay::platformDestroy()
+{
+ auto& data = sharedData();
+ LockHolder locker(data.lock);
+ data.overlayLayers.remove(m_layer.get());
+}
+
+static void drawCpuHistory(GraphicsContext& gc, float x1, float y1, float y2, RingBuffer<float>& history)
+{
+ Ref<Gradient> gradient = Gradient::create(FloatPoint(0, y1), FloatPoint(0, y2));
+ gradient->addColorStop(0.0, Color(0, 255, 0));
+ gradient->addColorStop(0.5, Color(255, 255, 0));
+ gradient->addColorStop(1.0, Color(255, 0, 0));
+ gc.setStrokeGradient(WTF::move(gradient));
+ gc.setStrokeThickness(1);
+
+ int i = 0;
+
+ history.forEach([&](float c) {
+ float cpu = c / 100;
+ float yScale = y2 - y1;
+
+ Path path;
+ path.moveTo(FloatPoint(x1 + i, y1));
+ path.addLineTo(FloatPoint(x1 + i, y1 + (yScale * cpu)));
+ gc.strokePath(path);
+ i++;
+ });
+}
+
+static void drawGCHistory(GraphicsContext& gc, float x1, float y1, float y2, RingBuffer<size_t>& sizeHistory, RingBuffer<size_t>& capacityHistory)
+{
+ size_t peak = 0;
+ capacityHistory.forEach([&](size_t m) {
+ if (m > peak)
+ peak = m;
+ });
+
+ gc.setStrokeThickness(1);
+
+ Ref<Gradient> capacityGradient = Gradient::create(FloatPoint(0, y1), FloatPoint(0, y2));
+ capacityGradient->addColorStop(0.0, Color(0xCC, 0x00, 0x33));
+ capacityGradient->addColorStop(0.5, Color(0xFF, 0x00, 0x33));
+ capacityGradient->addColorStop(1.0, Color(0xFF, 0x00, 0x00));
+ gc.setStrokeGradient(WTF::move(capacityGradient));
+
+ size_t i = 0;
+
+ capacityHistory.forEach([&](size_t m) {
+ float mem = (float)m / (float)peak;
+ float yScale = y2 - y1;
+
+ Path path;
+ path.moveTo(FloatPoint(x1 + i, y1));
+ path.addLineTo(FloatPoint(x1 + i, y1 + (yScale * mem)));
+ gc.strokePath(path);
+ i++;
+ });
+
+ Ref<Gradient> sizeGradient = Gradient::create(FloatPoint(0, y1), FloatPoint(0, y2));
+ sizeGradient->addColorStop(0.0, Color(0x29, 0x56, 0x8F));
+ sizeGradient->addColorStop(0.5, Color(0x47, 0x71, 0xA5));
+ sizeGradient->addColorStop(1.0, Color(0x96, 0xB1, 0xD2));
+ gc.setStrokeGradient(WTF::move(sizeGradient));
+
+ i = 0;
+
+ sizeHistory.forEach([&](size_t m) {
+ float mem = (float)m / (float)peak;
+ float yScale = y2 - y1;
+
+ Path path;
+ path.moveTo(FloatPoint(x1 + i, y1));
+ path.addLineTo(FloatPoint(x1 + i, y1 + (yScale * mem)));
+ gc.strokePath(path);
+ i++;
+ });
+}
+
+static const float fullCircleInRadians = piFloat * 2;
+
+static void drawSlice(GraphicsContext& context, FloatPoint center, float& angle, size_t sliceSize, size_t totalSize, Color color)
+{
+ Path path;
+ path.moveTo(center);
+ float part = (float)sliceSize / (float)totalSize;
+ path.addArc(center, 30, angle, angle + part * fullCircleInRadians, false);
+ context.setFillColor(color, ColorSpaceDeviceRGB);
+ context.fillPath(path);
+ angle += part * fullCircleInRadians;
+}
+
+static void drawPlate(GraphicsContext& context, FloatPoint center, float& angle, Color color)
+{
+ Path path;
+ path.moveTo(center);
+ path.addArc(center, 30, angle, fullCircleInRadians, false);
+ context.setFillColor(color, ColorSpaceDeviceRGB);
+ context.fillPath(path);
+}
+
+static void drawMemoryPie(GraphicsContext& context, float x, float y, ResourceUsageData& data)
+{
+ GraphicsContextStateSaver saver(context);
+
+ context.setShouldAntialias(true);
+
+ FloatPoint center(x - 15, y + 60);
+
+ size_t bmallocWithDeductions = data.bmalloc - data.gcHeapCapacityHistory.last();
+
+ float angle = 0;
+ drawSlice(context, center, angle, bmallocWithDeductions, data.sumDirty, colorForFastMalloc);
+ drawSlice(context, center, angle, data.libcMalloc, data.sumDirty, colorForLibcMalloc);
+ drawSlice(context, center, angle, data.gcHeapCapacityHistory.last(), data.sumDirty, colorForGCHeap);
+ drawSlice(context, center, angle, data.layers, data.sumDirty, colorForLayers);
+ drawSlice(context, center, angle, data.images, data.sumDirty, colorForImages);
+ drawSlice(context, center, angle, data.jitCode, data.sumDirty, colorForJITCode);
+ drawPlate(context, center, angle, colorForOther);
+}
+
+static String formatByteNumber(size_t number)
+{
+ if (number >= 1024 * 1048576)
+ return String::format("%.3f GB", static_cast<double>(number) / 1024 * 1048576);
+ if (number >= 1048576)
+ return String::format("%.2f MB", static_cast<double>(number) / 1048576);
+ if (number >= 1024)
+ return String::format("%.1f kB", static_cast<double>(number) / 1024);
+ return String::format("%lu", number);
+}
+
+// FIXME: All of this should be done without using CGContext directly, so the code can be cross-platform.
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
+static void showText(GraphicsContext& gc, float x, float y, Color color, const String& text)
+{
+ gc.setFillColor(color, ColorSpaceDeviceRGB);
+ CString cstr = text.ascii();
+ CGContextShowTextAtPoint(gc.platformContext(), x, y, cstr.data(), cstr.length());
+}
+
+void ResourceUsageOverlay::draw(GraphicsContext& context)
+{
+ auto& data = sharedData();
+ LockHolder locker(data.lock);
+
+ size_t gcHeapSize = data.gcHeapSizeHistory.last();
+ size_t gcHeapCapacity = data.gcHeapCapacityHistory.last();
+
+ context.setShouldAntialias(false);
+ context.setShouldSmoothFonts(false);
+
+ context.clearRect(m_overlay->bounds());
+ CGContextRef ctx = context.platformContext();
+ CGRect viewBounds = m_overlay->bounds();
+
+ context.translate(0, viewBounds.size.height);
+ context.scale(FloatSize(1, -1));
+
+ {
+ GraphicsContextStateSaver saver(context);
+
+ CGContextSetLineWidth(ctx, 2.0);
+ CGContextSelectFont(ctx, "Menlo", 11.0, kCGEncodingMacRoman);
+ CGContextSetCharacterSpacing(ctx, 1.7);
+ CGContextSetTextDrawingMode(ctx, kCGTextFill);
+
+ size_t bmallocWithDeductions = data.bmalloc - gcHeapCapacity;
+ size_t footprintWithDeductions = data.sumDirty - data.bmalloc - data.layers - data.images - data.libcMalloc - data.jitCode;
+
+ showText(context, 10, 10, colorForOther, " Other: " + formatByteNumber(footprintWithDeductions));
+ showText(context, 10, 20, colorForGCHeap, " GC heap: " + formatByteNumber(gcHeapSize) + " (" + formatByteNumber(gcHeapCapacity) + ")");
+ showText(context, 10, 30, colorForJITCode, " JS JIT: " + formatByteNumber(data.jitCode));
+ showText(context, 10, 40, colorForLayers, " Layers: " + formatByteNumber(data.layers));
+ showText(context, 10, 50, colorForImages, " Images: " + formatByteNumber(data.images));
+ showText(context, 10, 60, colorForLibcMalloc, "libc malloc: " + formatByteNumber(data.libcMalloc));
+ showText(context, 10, 70, colorForFastMalloc, " bmalloc: " + formatByteNumber(bmallocWithDeductions));
+
+ showText(context, 10, 90, colorForLabels, " Footprint: " + formatByteNumber(data.sumDirty));
+ showText(context, 10, 100, colorForLabels, String::format(" CPU: %g", data.cpuHistory.last()));
+ }
+
+ drawCpuHistory(context, m_overlay->frame().width() - 50, 0, viewBounds.size.height, data.cpuHistory);
+ drawGCHistory(context, m_overlay->frame().width() - 100, 0, viewBounds.size.height, data.gcHeapSizeHistory, data.gcHeapCapacityHistory);
+ drawMemoryPie(context, m_overlay->frame().width() - 150, 0, data);
+}
+
+#pragma clang diagnostic pop
+
+static std::array<size_t, 256> dirtyPagesPerVMTag()
+{
+ std::array<size_t, 256> dirty;
+ dirty.fill(0);
+ task_t task = mach_task_self();
+ mach_vm_size_t size;
+ uint32_t depth = 0;
+ struct vm_region_submap_info_64 info = { };
+ mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
+ for (mach_vm_address_t addr = 0; ; addr += size) {
+ kern_return_t kr = mach_vm_region_recurse(task, &addr, &size, &depth, (vm_region_info_t)&info, &count);
+ if (kr != KERN_SUCCESS)
+ break;
+ dirty[info.user_tag] += info.pages_dirtied;
+ }
+ return dirty;
+}
+
+static float cpuUsage()
+{
+ thread_array_t threadList;
+ mach_msg_type_number_t threadCount;
+ kern_return_t kr = task_threads(mach_task_self(), &threadList, &threadCount);
+ if (kr != KERN_SUCCESS)
+ return -1;
+
+ float usage = 0;
+
+ for (mach_msg_type_number_t i = 0; i < threadCount; ++i) {
+ thread_info_data_t threadInfo;
+ thread_basic_info_t threadBasicInfo;
+
+ mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
+ kr = thread_info(threadList[i], THREAD_BASIC_INFO, static_cast<thread_info_t>(threadInfo), &threadInfoCount);
+ if (kr != KERN_SUCCESS)
+ return -1;
+
+ threadBasicInfo = reinterpret_cast<thread_basic_info_t>(threadInfo);
+
+ if (!(threadBasicInfo->flags & TH_FLAGS_IDLE))
+ usage += threadBasicInfo->cpu_usage / static_cast<float>(TH_USAGE_SCALE) * 100.0;
+ }
+
+ kr = vm_deallocate(mach_task_self(), (vm_offset_t)threadList, threadCount * sizeof(thread_t));
+ ASSERT(kr == KERN_SUCCESS);
+
+ return usage;
+}
+
+NO_RETURN void runSamplerThread(void*)
+{
+ static size_t vmPageSize = getpagesize();
+ auto& data = sharedData();
+ while (1) {
+ float cpu = cpuUsage();
+ auto dirtyPages = dirtyPagesPerVMTag();
+ Vector<CALayer *, 8> layers;
+
+ {
+ LockHolder locker(data.lock);
+ data.cpuHistory.append(cpu);
+ data.layers = (dirtyPages[VM_MEMORY_IOKIT] + dirtyPages[VM_MEMORY_LAYERKIT]) * vmPageSize;
+ data.images = (dirtyPages[VM_MEMORY_IMAGEIO] + dirtyPages[VM_MEMORY_CGIMAGE]) * vmPageSize;
+ data.jitCode = dirtyPages[VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR] * vmPageSize;
+ data.libcMalloc = vmPageSize *
+ (dirtyPages[VM_MEMORY_MALLOC]
+ + dirtyPages[VM_MEMORY_MALLOC_HUGE]
+ + dirtyPages[VM_MEMORY_MALLOC_LARGE]
+ + dirtyPages[VM_MEMORY_MALLOC_SMALL]
+ + dirtyPages[VM_MEMORY_MALLOC_TINY]
+ + dirtyPages[VM_MEMORY_MALLOC_NANO]);
+ data.bmalloc = vmPageSize * dirtyPages[VM_MEMORY_TCMALLOC];
+
+ data.sumDirty = 0;
+ for (auto dirty : dirtyPages)
+ data.sumDirty += dirty;
+ data.sumDirty *= vmPageSize;
+
+ copyToVector(data.overlayLayers, layers);
+
+ data.gcHeapCapacityHistory.append(data.vm->heap.blockBytesAllocated());
+ }
+
+ [CATransaction begin];
+ for (CALayer *layer : layers)
+ [layer setNeedsDisplay];
+ [CATransaction commit];
+
+ // FIXME: Find a way to get the size of the current GC heap size safely from the sampler thread.
+ callOnMainThread([] {
+ auto& data = sharedData();
+ JSC::JSLockHolder lock(data.vm);
+ size_t gcHeapSize = data.vm->heap.size() - data.vm->heap.extraMemorySize();
+
+ LockHolder locker(data.lock);
+ data.gcHeapSizeHistory.append(gcHeapSize);
+ });
+
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ }
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformspicocoaMachVMSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cocoa/MachVMSPI.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cocoa/MachVMSPI.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebCore/platform/spi/cocoa/MachVMSPI.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -41,5 +41,6 @@
</span><span class="cx"> EXTERN_C kern_return_t mach_vm_protect(vm_map_t targetTask, mach_vm_address_t, mach_vm_size_t, boolean_t setMaximum, vm_prot_t newProtection);
</span><span class="cx"> EXTERN_C kern_return_t mach_vm_region(vm_map_t targetTask, mach_vm_address_t*, mach_vm_size_t*, vm_region_flavor_t, vm_region_info_t,
</span><span class="cx"> mach_msg_type_number_t* infoCount, mach_port_t* objectName);
</span><ins>+EXTERN_C kern_return_t mach_vm_region_recurse(vm_map_t targetTask, mach_vm_address_t*, mach_vm_size_t*, uint32_t* depth, vm_region_recurse_info_t, mach_msg_type_number_t* infoCount);
</ins><span class="cx">
</span><span class="cx"> #endif // MachVMSPI_h
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-10-31 Andreas Kling <akling@apple.com>
+
+ Add a debug overlay with information about web process resource usage.
+ <https://webkit.org/b/150599>
+
+ Reviewed by Darin Adler.
+
+ Add WK2 preferences SPI for showing/hiding the resource usage overlay.
+
+ * Shared/WebPreferencesDefinitions.h:
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetResourceUsageOverlayVisible):
+ (WKPreferencesGetResourceUsageOverlayVisible):
+ * UIProcess/API/C/WKPreferencesRefPrivate.h:
+ * UIProcess/API/Cocoa/WKPreferences.mm:
+ (-[WKPreferences _resourceUsageOverlayVisible]):
+ (-[WKPreferences _setResourceUsageOverlayVisible:]):
+ * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+
</ins><span class="cx"> 2015-10-31 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Share more code between NETWORK_SESSION and non-NETWORK_SESSION NetworkResourceLoaders
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesDefinitionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -243,6 +243,7 @@
</span><span class="cx"> macro(LogsPageMessagesToSystemConsoleEnabled, logsPageMessagesToSystemConsoleEnabled, Bool, bool, false) \
</span><span class="cx"> macro(IgnoreViewportScalingConstraints, ignoreViewportScalingConstraints, Bool, bool, true) \
</span><span class="cx"> macro(ForceAlwaysUserScalable, forceAlwaysUserScalable, Bool, bool, false) \
</span><ins>+ macro(ResourceUsageOverlayVisible, resourceUsageOverlayVisible, Bool, bool, false) \
</ins><span class="cx"> \
</span><span class="cx">
</span><span class="cx"> #define FOR_EACH_WEBKIT_DEBUG_UINT32_PREFERENCE(macro) \
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1406,3 +1406,14 @@
</span><span class="cx"> {
</span><span class="cx"> return toImpl(preferencesRef)->allowsAirPlayForMediaPlayback();
</span><span class="cx"> }
</span><ins>+
+void WKPreferencesSetResourceUsageOverlayVisible(WKPreferencesRef preferencesRef, bool javaEnabled)
+{
+ toImpl(preferencesRef)->setResourceUsageOverlayVisible(javaEnabled);
+}
+
+bool WKPreferencesGetResourceUsageOverlayVisible(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->resourceUsageOverlayVisible();
+}
+
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPreferencesRefPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -383,6 +383,10 @@
</span><span class="cx"> WK_EXPORT void WKPreferencesSetHTTPEquivEnabled(WKPreferencesRef preferences, bool enabled);
</span><span class="cx"> WK_EXPORT bool WKPreferencesGetHTTPEquivEnabled(WKPreferencesRef preferences);
</span><span class="cx">
</span><ins>+// Defaults to false.
+WK_EXPORT void WKPreferencesSetResourceUsageOverlayVisible(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetResourceUsageOverlayVisible(WKPreferencesRef);
+
</ins><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKPreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -217,6 +217,16 @@
</span><span class="cx"> _preferences->setTiledScrollingIndicatorVisible(tiledScrollingIndicatorVisible);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (BOOL)_resourceUsageOverlayVisible
+{
+ return _preferences->resourceUsageOverlayVisible();
+}
+
+- (void)_setResourceUsageOverlayVisible:(BOOL)resourceUsageOverlayVisible
+{
+ _preferences->setResourceUsageOverlayVisible(resourceUsageOverlayVisible);
+}
+
</ins><span class="cx"> - (_WKDebugOverlayRegions)_visibleDebugOverlayRegions
</span><span class="cx"> {
</span><span class="cx"> return _preferences->visibleDebugOverlayRegions();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKPreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> @property (nonatomic, setter=_setCompositingBordersVisible:) BOOL _compositingBordersVisible;
</span><span class="cx"> @property (nonatomic, setter=_setCompositingRepaintCountersVisible:) BOOL _compositingRepaintCountersVisible;
</span><span class="cx"> @property (nonatomic, setter=_setTiledScrollingIndicatorVisible:) BOOL _tiledScrollingIndicatorVisible;
</span><ins>+@property (nonatomic, setter=_setResourceUsageOverlayVisible:) BOOL _resourceUsageOverlayVisible WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</ins><span class="cx"> @property (nonatomic, setter=_setVisibleDebugOverlayRegions:) _WKDebugOverlayRegions _visibleDebugOverlayRegions WK_AVAILABLE(10_11, 9_0);
</span><span class="cx"> @property (nonatomic, setter=_setSimpleLineLayoutDebugBordersEnabled:) BOOL _simpleLineLayoutDebugBordersEnabled WK_AVAILABLE(10_11, 9_0);
</span><span class="cx"> @property (nonatomic, setter=_setAcceleratedDrawingEnabled:) BOOL _acceleratedDrawingEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -2824,6 +2824,10 @@
</span><span class="cx"> settings.setAllowsAirPlayForMediaPlayback(store.getBoolValueForKey(WebPreferencesKey::allowsAirPlayForMediaPlaybackKey()));
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(RESOURCE_USAGE_OVERLAY)
+ settings.setResourceUsageOverlayVisible(store.getBoolValueForKey(WebPreferencesKey::resourceUsageOverlayVisibleKey()));
+#endif
+
</ins><span class="cx"> settings.setSuppressesIncrementalRendering(store.getBoolValueForKey(WebPreferencesKey::suppressesIncrementalRenderingKey()));
</span><span class="cx"> settings.setIncrementalRenderingSuppressionTimeoutInSeconds(store.getDoubleValueForKey(WebPreferencesKey::incrementalRenderingSuppressionTimeoutKey()));
</span><span class="cx"> settings.setBackspaceKeyNavigationEnabled(store.getBoolValueForKey(WebPreferencesKey::backspaceKeyNavigationEnabledKey()));
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Tools/ChangeLog        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-10-31 Andreas Kling <akling@apple.com>
+
+ Add a debug overlay with information about web process resource usage.
+ <https://webkit.org/b/150599>
+
+ Reviewed by Darin Adler.
+
+ Add a menu item to the MiniBrowser so we can toggle the resource usage overlay on/off.
+
+ * MiniBrowser/mac/SettingsController.h:
+ * MiniBrowser/mac/SettingsController.m:
+ (-[SettingsController _populateMenu]):
+ (-[SettingsController validateMenuItem:]):
+ (-[SettingsController toggleShowResourceUsageOverlay:]):
+ (-[SettingsController resourceUsageOverlayVisible]):
+ * MiniBrowser/mac/WK2BrowserWindowController.m:
+ (-[WK2BrowserWindowController didChangeSettings]):
+
</ins><span class="cx"> 2015-10-31 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><span class="cx"> Teach the CompileWebKit step to look for additional arguments.
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacSettingsControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/SettingsController.h (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/SettingsController.h        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Tools/MiniBrowser/mac/SettingsController.h        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> @property (nonatomic, readonly) BOOL simpleLineLayoutDebugBordersEnabled;
</span><span class="cx"> @property (nonatomic, readonly) BOOL incrementalRenderingSuppressed;
</span><span class="cx"> @property (nonatomic, readonly) BOOL tiledScrollingIndicatorVisible;
</span><ins>+@property (nonatomic, readonly) BOOL resourceUsageOverlayVisible;
</ins><span class="cx"> @property (nonatomic, readonly) BOOL nonFastScrollableRegionOverlayVisible;
</span><span class="cx"> @property (nonatomic, readonly) BOOL wheelEventHandlerRegionOverlayVisible;
</span><span class="cx"> @property (nonatomic, readonly) BOOL useUISideCompositing;
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacSettingsControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/SettingsController.m (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/SettingsController.m        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Tools/MiniBrowser/mac/SettingsController.m        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> static NSString * const LayerBordersVisiblePreferenceKey = @"LayerBordersVisible";
</span><span class="cx"> static NSString * const SimpleLineLayoutDebugBordersEnabledPreferenceKey = @"SimpleLineLayoutDebugBordersEnabled";
</span><span class="cx"> static NSString * const TiledScrollingIndicatorVisiblePreferenceKey = @"TiledScrollingIndicatorVisible";
</span><ins>+static NSString * const ResourceUsageOverlayVisiblePreferenceKey = @"ResourceUsageOverlayVisible";
</ins><span class="cx"> static NSString * const IncrementalRenderingSuppressedPreferenceKey = @"IncrementalRenderingSuppressed";
</span><span class="cx"> static NSString * const AcceleratedDrawingEnabledPreferenceKey = @"AcceleratedDrawingEnabled";
</span><span class="cx">
</span><span class="lines">@@ -115,6 +116,7 @@
</span><span class="cx"> [self _addItemWithTitle:@"Show Tiled Scrolling Indicator" action:@selector(toggleShowTiledScrollingIndicator:) indented:YES];
</span><span class="cx"> [self _addItemWithTitle:@"Use UI-Side Compositing" action:@selector(toggleUseUISideCompositing:) indented:YES];
</span><span class="cx"> [self _addItemWithTitle:@"Disable Per-Window Web Processes" action:@selector(togglePerWindowWebProcessesDisabled:) indented:YES];
</span><ins>+ [self _addItemWithTitle:@"Show Resource Usage Overlay" action:@selector(toggleShowResourceUsageOverlay:) indented:YES];
</ins><span class="cx">
</span><span class="cx"> NSMenuItem *debugOverlaysSubmenuItem = [[NSMenuItem alloc] initWithTitle:@"Debug Overlays" action:nil keyEquivalent:@""];
</span><span class="cx"> NSMenu *debugOverlaysMenu = [[NSMenu alloc] initWithTitle:@"Debug Overlays"];
</span><span class="lines">@@ -158,6 +160,8 @@
</span><span class="cx"> [menuItem setState:[self acceleratedDrawingEnabled] ? NSOnState : NSOffState];
</span><span class="cx"> else if (action == @selector(toggleShowTiledScrollingIndicator:))
</span><span class="cx"> [menuItem setState:[self tiledScrollingIndicatorVisible] ? NSOnState : NSOffState];
</span><ins>+ else if (action == @selector(toggleShowResourceUsageOverlay:))
+ [menuItem setState:[self resourceUsageOverlayVisible] ? NSOnState : NSOffState];
</ins><span class="cx"> else if (action == @selector(toggleUseUISideCompositing:))
</span><span class="cx"> [menuItem setState:[self useUISideCompositing] ? NSOnState : NSOffState];
</span><span class="cx"> else if (action == @selector(togglePerWindowWebProcessesDisabled:))
</span><span class="lines">@@ -283,11 +287,21 @@
</span><span class="cx"> [self _toggleBooleanDefault:TiledScrollingIndicatorVisiblePreferenceKey];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)toggleShowResourceUsageOverlay:(id)sender
+{
+ [self _toggleBooleanDefault:ResourceUsageOverlayVisiblePreferenceKey];
+}
+
</ins><span class="cx"> - (BOOL)tiledScrollingIndicatorVisible
</span><span class="cx"> {
</span><span class="cx"> return [[NSUserDefaults standardUserDefaults] boolForKey:TiledScrollingIndicatorVisiblePreferenceKey];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (BOOL)resourceUsageOverlayVisible
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:ResourceUsageOverlayVisiblePreferenceKey];
+}
+
</ins><span class="cx"> - (void)toggleEnableSubPixelCSSOMMetrics:(id)sender
</span><span class="cx"> {
</span><span class="cx"> [self _toggleBooleanDefault:EnableSubPixelCSSOMMetricsPreferenceKey];
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (191848 => 191849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2015-11-01 00:14:49 UTC (rev 191848)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2015-11-01 02:29:47 UTC (rev 191849)
</span><span class="lines">@@ -342,6 +342,7 @@
</span><span class="cx"> preferences._compositingRepaintCountersVisible = settings.layerBordersVisible;
</span><span class="cx"> preferences._simpleLineLayoutDebugBordersEnabled = settings.simpleLineLayoutDebugBordersEnabled;
</span><span class="cx"> preferences._acceleratedDrawingEnabled = settings.acceleratedDrawingEnabled;
</span><ins>+ preferences._resourceUsageOverlayVisible = settings.resourceUsageOverlayVisible;
</ins><span class="cx">
</span><span class="cx"> BOOL useTransparentWindows = settings.useTransparentWindows;
</span><span class="cx"> if (useTransparentWindows != _webView._drawsTransparentBackground) {
</span></span></pre>
</div>
</div>
</body>
</html>