<!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>[164853] trunk/Source/WebCore</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/164853">164853</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-27 21:53:29 -0800 (Thu, 27 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>JSC ignores the extra memory cost of HTMLCollection after a major GC
https://bugs.webkit.org/show_bug.cgi?id=129450

Reviewed by Andreas Kling.

Report the extra memory cost of HTMLCollection to JSC.

Unfortunately, the existing mechanism to report the extra memory cost in toJS is insufficient for
HTMLCollection since collection caches are populated later when HTMLCollection is accessed. Also,
the extra memory cost reported by Heap::reportExtraMemoryCost will be thrown away after a major GC.

To work around this limitation, added a visitor.reportExtraMemoryUsage call inside visitChildren
for interfaces with a newly added ReportExtraMemoryCost IDL extension flag to report the extra cost.

Since we may need to generate visitChildren when this flag is set, we can't automatically detect
and generate calls using C++ template as done in <a href="http://trac.webkit.org/projects/webkit/changeset/148648">r148648</a>.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/webaudio/AudioBuffer.idl:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMBinding.h:
* bindings/scripts/CodeGeneratorJS.pm:
(InstanceNeedsVisitChildren):
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestException.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSattribute.cpp:
(WebCore::toJS):
* bindings/scripts/test/JS/JSreadonly.cpp:
(WebCore::toJS):
* dom/ChildNodeList.h:
* dom/CollectionIndexCache.cpp: Added.
(WebCore::reportExtraMemoryCostForCollectionIndexCache):
* dom/CollectionIndexCache.h:
(WebCore::CollectionIndexCache::memoryCost):
(WebCore::NodeType&gt;::CollectionIndexCache):
(WebCore::NodeType&gt;::nodeCount):
(WebCore::NodeType&gt;::computeNodeCountUpdatingListCache):
(WebCore::NodeType&gt;::nodeAt):
(WebCore::NodeType&gt;::invalidate):
* dom/DOMAllInOne.cpp:
* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::memoryCost):
* dom/LiveNodeList.h:
* dom/NodeList.h:
(WebCore::NodeList::memoryCost):
* dom/NodeList.idl:
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::updateNamedElementCache):
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
(WebCore::CollectionNamedElementCache::memoryCost):
(WebCore::CollectionNamedElementCache::find):
(WebCore::HTMLCollection::memoryCost):
* html/HTMLCollection.idl:
* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::updateNamedElementCache):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioBufferidl">trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributestxt">trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestActiveDOMObjectcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestCustomNamedGettercpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestEventConstructorcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestEventTargetcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestExceptioncpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestGenerateIsReachablecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestInterfacecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestMediaQueryListListenercpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestNamedConstructorcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestSerializedScriptValueInterfacecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSattributecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSreadonlycpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp</a></li>
<li><a href="#trunkSourceWebCoredomChildNodeListh">trunk/Source/WebCore/dom/ChildNodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomCollectionIndexCacheh">trunk/Source/WebCore/dom/CollectionIndexCache.h</a></li>
<li><a href="#trunkSourceWebCoredomDOMAllInOnecpp">trunk/Source/WebCore/dom/DOMAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLiveNodeListcpp">trunk/Source/WebCore/dom/LiveNodeList.cpp</a></li>
<li><a href="#trunkSourceWebCoredomLiveNodeListh">trunk/Source/WebCore/dom/LiveNodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomNodeListh">trunk/Source/WebCore/dom/NodeList.h</a></li>
<li><a href="#trunkSourceWebCoredomNodeListidl">trunk/Source/WebCore/dom/NodeList.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCollectioncpp">trunk/Source/WebCore/html/HTMLCollection.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCollectionh">trunk/Source/WebCore/html/HTMLCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCollectionidl">trunk/Source/WebCore/html/HTMLCollection.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlsCollectioncpp">trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomCollectionIndexCachecpp">trunk/Source/WebCore/dom/CollectionIndexCache.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -1125,6 +1125,7 @@
</span><span class="cx">     dom/ClientRectList.cpp
</span><span class="cx">     dom/Clipboard.cpp
</span><span class="cx">     dom/ClipboardEvent.cpp
</span><ins>+    dom/CollectionIndexCache.cpp
</ins><span class="cx">     dom/Comment.cpp
</span><span class="cx">     dom/CompositionEvent.cpp
</span><span class="cx">     dom/ContainerNode.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/ChangeLog        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -1,3 +1,91 @@
</span><ins>+2014-02-27  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        JSC ignores the extra memory cost of HTMLCollection after a major GC
+        https://bugs.webkit.org/show_bug.cgi?id=129450
+
+        Reviewed by Andreas Kling.
+
+        Report the extra memory cost of HTMLCollection to JSC.
+
+        Unfortunately, the existing mechanism to report the extra memory cost in toJS is insufficient for
+        HTMLCollection since collection caches are populated later when HTMLCollection is accessed. Also,
+        the extra memory cost reported by Heap::reportExtraMemoryCost will be thrown away after a major GC.
+
+        To work around this limitation, added a visitor.reportExtraMemoryUsage call inside visitChildren
+        for interfaces with a newly added ReportExtraMemoryCost IDL extension flag to report the extra cost.
+
+        Since we may need to generate visitChildren when this flag is set, we can't automatically detect
+        and generate calls using C++ template as done in r148648.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Modules/webaudio/AudioBuffer.idl:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMBinding.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (InstanceNeedsVisitChildren):
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestException.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSattribute.cpp:
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSreadonly.cpp:
+        (WebCore::toJS):
+        * dom/ChildNodeList.h:
+        * dom/CollectionIndexCache.cpp: Added.
+        (WebCore::reportExtraMemoryCostForCollectionIndexCache):
+        * dom/CollectionIndexCache.h:
+        (WebCore::CollectionIndexCache::memoryCost):
+        (WebCore::NodeType&gt;::CollectionIndexCache):
+        (WebCore::NodeType&gt;::nodeCount):
+        (WebCore::NodeType&gt;::computeNodeCountUpdatingListCache):
+        (WebCore::NodeType&gt;::nodeAt):
+        (WebCore::NodeType&gt;::invalidate):
+        * dom/DOMAllInOne.cpp:
+        * dom/LiveNodeList.cpp:
+        (WebCore::LiveNodeList::memoryCost):
+        * dom/LiveNodeList.h:
+        * dom/NodeList.h:
+        (WebCore::NodeList::memoryCost):
+        * dom/NodeList.idl:
+        * html/HTMLCollection.cpp:
+        (WebCore::HTMLCollection::updateNamedElementCache):
+        * html/HTMLCollection.h:
+        (WebCore::CollectionNamedElementCache::didPopulate):
+        (WebCore::CollectionNamedElementCache::memoryCost):
+        (WebCore::CollectionNamedElementCache::find):
+        (WebCore::HTMLCollection::memoryCost):
+        * html/HTMLCollection.idl:
+        * html/HTMLFormControlsCollection.cpp:
+        (WebCore::HTMLFormControlsCollection::updateNamedElementCache):
+
</ins><span class="cx"> 2014-02-27  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Compile attribute value matching
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -2757,13 +2757,14 @@
</span><span class="cx">         Source/WebCore/dom/ClipboardEvent.cpp \
</span><span class="cx">         Source/WebCore/dom/ClipboardEvent.h \
</span><span class="cx">         Source/WebCore/dom/Clipboard.h \
</span><ins>+        Source/WebCore/dom/CollectionIndexCache.cpp \
</ins><span class="cx">         Source/WebCore/dom/CollectionIndexCache.h \
</span><span class="cx">         Source/WebCore/dom/Comment.cpp \
</span><span class="cx">         Source/WebCore/dom/Comment.h \
</span><span class="cx">         Source/WebCore/dom/CompositionEvent.cpp \
</span><span class="cx">         Source/WebCore/dom/CompositionEvent.h \
</span><ins>+        Source/WebCore/dom/ContainerNodeAlgorithms.cpp \
</ins><span class="cx">         Source/WebCore/dom/ContainerNodeAlgorithms.h \
</span><del>-        Source/WebCore/dom/ContainerNodeAlgorithms.cpp \
</del><span class="cx">         Source/WebCore/dom/ContainerNode.cpp \
</span><span class="cx">         Source/WebCore/dom/ContainerNode.h \
</span><span class="cx">         Source/WebCore/dom/ContextDestructionObserver.cpp \
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioBufferidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBuffer.idl        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> [
</span><span class="cx">     Conditional=WEB_AUDIO,
</span><span class="cx">     ImplementationLacksVTable,
</span><ins>+    ReportExtraMemoryCost,
</ins><span class="cx"> ] interface AudioBuffer {
</span><span class="cx">     readonly attribute long length; // in sample-frames
</span><span class="cx">     readonly attribute float duration; // in seconds
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -12199,6 +12199,20 @@
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\dom\CollectionIndexCache.cpp&quot;&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='DebugSuffix|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\dom\Comment.cpp&quot;&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -3517,6 +3517,7 @@
</span><span class="cx">                 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; };
</span><span class="cx">                 9BD0BF9312A42BF50072FD43 /* ScopedEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */; };
</span><span class="cx">                 9BD0BF9412A42BF50072FD43 /* ScopedEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */; };
</span><ins>+                9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */; };
</ins><span class="cx">                 9BF9A8801648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */; };
</span><span class="cx">                 9BF9A8811648DD2F001C6B23 /* JSHTMLFormControlsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */; };
</span><span class="cx">                 9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9F0D6B2C121BFEBA006C0288 /* InspectorProfilerAgent.cpp */; };
</span><span class="lines">@@ -10477,6 +10478,7 @@
</span><span class="cx">                 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFormControlElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedEventQueue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedEventQueue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectionIndexCache.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9BF9A87F1648DD2F001C6B23 /* JSHTMLFormControlsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLFormControlsCollection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9F0D6B2C121BFEBA006C0288 /* InspectorProfilerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorProfilerAgent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -21880,6 +21882,7 @@
</span><span class="cx">                                 85031B2A0A44EFC700F992E0 /* ClipboardEvent.h */,
</span><span class="cx">                                 2D90660C0665D937006B6F1A /* ClipboardMac.mm */,
</span><span class="cx">                                 E425A49918292B840020CFCF /* CollectionIndexCache.h */,
</span><ins>+                                9BD8A95918BEFC7600987E9A /* CollectionIndexCache.cpp */,
</ins><span class="cx">                                 6550B697099DF0270090D781 /* Comment.cpp */,
</span><span class="cx">                                 6550B698099DF0270090D781 /* Comment.h */,
</span><span class="cx">                                 85089CC70A98C22600A275AA /* Comment.idl */,
</span><span class="lines">@@ -27057,6 +27060,7 @@
</span><span class="cx">                                 97DCE20110807C750057D394 /* HistoryController.cpp in Sources */,
</span><span class="cx">                                 51741D120B07259A00ED442C /* HistoryItem.cpp in Sources */,
</span><span class="cx">                                 5160F4980B0AA75F00C1D2AF /* HistoryItemMac.mm in Sources */,
</span><ins>+                                9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */,
</ins><span class="cx">                                 4969B0F213D0B33F00DF3521 /* HitTestingTransformState.cpp in Sources */,
</span><span class="cx">                                 2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */,
</span><span class="cx">                                 9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -642,19 +642,6 @@
</span><span class="cx">     static const bool value = sizeof(test&lt;T&gt;(0)) == sizeof(YesType);
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-template &lt;typename T, bool hasReportCostFunction = HasMemoryCostMemberFunction&lt;T&gt;::value &gt; struct ReportMemoryCost;
-template &lt;typename T&gt; struct ReportMemoryCost&lt;T, true&gt; {
-    static void reportMemoryCost(JSC::ExecState* exec, T* impl)
-    {
-        exec-&gt;heap()-&gt;reportExtraMemoryCost(impl-&gt;memoryCost());
-    }
-};
-template &lt;typename T&gt; struct ReportMemoryCost&lt;T, false&gt; {
-    static void reportMemoryCost(JSC::ExecState*, T*)
-    {
-    }
-};
-
</del><span class="cx"> enum SecurityReportingOption {
</span><span class="cx">     DoNotReportSecurityError,
</span><span class="cx">     ReportSecurityError,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -770,6 +770,15 @@
</span><span class="cx">         || $interface-&gt;extendedAttributes-&gt;{&quot;CustomIndexedSetter&quot;};
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub InstanceNeedsVisitChildren
+{
+    my $interface = shift;
+    return $interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;}
+    || $interface-&gt;extendedAttributes-&gt;{&quot;EventTarget&quot;}
+    || $interface-&gt;name eq &quot;EventTarget&quot;
+    || $interface-&gt;extendedAttributes-&gt;{&quot;ReportExtraMemoryCost&quot;};
+}
+
</ins><span class="cx"> sub GenerateHeader
</span><span class="cx"> {
</span><span class="cx">     my $object = shift;
</span><span class="lines">@@ -783,7 +792,7 @@
</span><span class="cx">     my $hasRealParent = $interface-&gt;parent;
</span><span class="cx">     my $hasParent = $hasLegacyParent || $hasRealParent;
</span><span class="cx">     my $parentClassName = GetParentClassName($interface);
</span><del>-    my $needsMarkChildren = $interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;} || $interface-&gt;extendedAttributes-&gt;{&quot;EventTarget&quot;} || $interface-&gt;name eq &quot;EventTarget&quot;;
</del><ins>+    my $needsVisitChildren = InstanceNeedsVisitChildren($interface);
</ins><span class="cx"> 
</span><span class="cx">     # - Add default header template and header protection
</span><span class="cx">     push(@headerContentHeader, GenerateHeaderContentHeader($interface));
</span><span class="lines">@@ -1005,14 +1014,14 @@
</span><span class="cx">                 push(@headerContent, &quot;#if ${conditionalString}\n&quot;) if $conditionalString;
</span><span class="cx">                 push(@headerContent, &quot;    JSC::WriteBarrier&lt;JSC::Unknown&gt; m_&quot; . $attribute-&gt;signature-&gt;name . &quot;;\n&quot;);
</span><span class="cx">                 $numCachedAttributes++;
</span><del>-                $needsMarkChildren = 1;
</del><ins>+                $needsVisitChildren = 1;
</ins><span class="cx">                 push(@headerContent, &quot;#endif\n&quot;) if $conditionalString;
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     # visit function
</span><del>-    if ($needsMarkChildren) {
</del><ins>+    if ($needsVisitChildren) {
</ins><span class="cx">         push(@headerContent, &quot;    static void visitChildren(JSCell*, JSC::SlotVisitor&amp;);\n\n&quot;);
</span><span class="cx">         $structureFlags{&quot;JSC::OverridesVisitChildren&quot;} = 1;
</span><span class="cx">     }
</span><span class="lines">@@ -1193,7 +1202,7 @@
</span><span class="cx">         push(@headerContent, &quot;    static bool getOwnPropertySlot(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&amp;);\n&quot;);
</span><span class="cx">         $structureFlags{&quot;JSC::OverridesGetOwnPropertySlot&quot;} = 1;
</span><span class="cx">     }
</span><del>-    if ($interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;} or $needsMarkChildren) {
</del><ins>+    if ($interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;} or $needsVisitChildren) {
</ins><span class="cx">         $structureFlags{&quot;JSC::OverridesVisitChildren&quot;} = 1;
</span><span class="cx">     }
</span><span class="cx">     push(@headerContent,
</span><span class="lines">@@ -1690,7 +1699,7 @@
</span><span class="cx">     my $parentClassName = GetParentClassName($interface);
</span><span class="cx">     my $visibleInterfaceName = $codeGenerator-&gt;GetVisibleInterfaceName($interface);
</span><span class="cx">     my $eventTarget = $interface-&gt;extendedAttributes-&gt;{&quot;EventTarget&quot;} || ($codeGenerator-&gt;InheritsInterface($interface, &quot;EventTarget&quot;) &amp;&amp; $interface-&gt;name ne &quot;EventTarget&quot;);
</span><del>-    my $needsMarkChildren = $interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;} || $interface-&gt;extendedAttributes-&gt;{&quot;EventTarget&quot;} || $interface-&gt;name eq &quot;EventTarget&quot;;
</del><ins>+    my $needsVisitChildren = InstanceNeedsVisitChildren($interface);
</ins><span class="cx"> 
</span><span class="cx">     my $namedGetterFunction = GetNamedGetterFunction($interface);
</span><span class="cx">     my $indexedGetterFunction = GetIndexedGetterFunction($interface);
</span><span class="lines">@@ -2162,7 +2171,7 @@
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if ($attribute-&gt;signature-&gt;extendedAttributes-&gt;{&quot;CachedAttribute&quot;}) {
</span><del>-                $needsMarkChildren = 1;
</del><ins>+                $needsVisitChildren = 1;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if ($interface-&gt;extendedAttributes-&gt;{&quot;CheckSecurity&quot;} &amp;&amp;
</span><span class="lines">@@ -2746,7 +2755,7 @@
</span><span class="cx"> 
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if ($needsMarkChildren &amp;&amp; !$interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;}) {
</del><ins>+    if ($needsVisitChildren &amp;&amp; !$interface-&gt;extendedAttributes-&gt;{&quot;JSCustomMarkFunction&quot;}) {
</ins><span class="cx">         push(@implContent, &quot;void ${className}::visitChildren(JSCell* cell, SlotVisitor&amp; visitor)\n&quot;);
</span><span class="cx">         push(@implContent, &quot;{\n&quot;);
</span><span class="cx">         push(@implContent, &quot;    ${className}* thisObject = jsCast&lt;${className}*&gt;(cell);\n&quot;);
</span><span class="lines">@@ -2757,6 +2766,9 @@
</span><span class="cx">         if ($interface-&gt;extendedAttributes-&gt;{&quot;EventTarget&quot;} || $interface-&gt;name eq &quot;EventTarget&quot;) {
</span><span class="cx">             push(@implContent, &quot;    thisObject-&gt;impl().visitJSEventListeners(visitor);\n&quot;);
</span><span class="cx">         }
</span><ins>+        if ($interface-&gt;extendedAttributes-&gt;{&quot;ReportExtraMemoryCost&quot;}) {
+            push(@implContent, &quot;    visitor.reportExtraMemoryUsage(cell, thisObject-&gt;impl().memoryCost());\n&quot;);
+        }
</ins><span class="cx">         if ($numCachedAttributes &gt; 0) {
</span><span class="cx">             foreach (@{$interface-&gt;attributes}) {
</span><span class="cx">                 my $attribute = $_;
</span><span class="lines">@@ -3019,8 +3031,8 @@
</span><span class="cx">     COMPILE_ASSERT(!__is_polymorphic($implType), ${implType}_is_polymorphic_but_idl_claims_not_to_be);
</span><span class="cx"> #endif
</span><span class="cx"> END
</span><del>-        push(@implContent, &lt;&lt;END);
-    ReportMemoryCost&lt;$implType&gt;::reportMemoryCost(exec, impl);
</del><ins>+        push(@implContent, &lt;&lt;END) if $interface-&gt;extendedAttributes-&gt;{&quot;ReportExtraMemoryCost&quot;};
+    exec-&gt;heap()-&gt;reportExtraMemoryCost(impl-&gt;memoryCost());
</ins><span class="cx"> END
</span><span class="cx"> 
</span><span class="cx">         if ($svgPropertyType) {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> Reflect=*
</span><span class="cx"> Replaceable
</span><span class="cx"> ReplaceableConstructor
</span><ins>+ReportExtraMemoryCost
</ins><span class="cx"> ReturnNewObject
</span><span class="cx"> SetterRaisesException
</span><span class="cx"> SkipVTableValidation
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestActiveDOMObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -253,7 +253,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestActiveDOMObject&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestActiveDOMObject&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestCustomNamedGettercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -224,7 +224,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestCustomNamedGetter&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestCustomNamedGetter&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestEventConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -267,7 +267,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestEventConstructor&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestEventConstructor&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestEventTargetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -333,7 +333,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestEventTarget&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestEventTarget&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestExceptioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -209,7 +209,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestException&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestException&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestGenerateIsReachablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -187,7 +187,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestGenerateIsReachable&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestGenerateIsReachable&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -845,7 +845,6 @@
</span><span class="cx">     // attribute to TestInterface.
</span><span class="cx">     COMPILE_ASSERT(!__is_polymorphic(TestInterface), TestInterface_is_polymorphic_but_idl_claims_not_to_be);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestInterface&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestInterface&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestMediaQueryListListenercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -200,7 +200,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestMediaQueryListListener&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestMediaQueryListListener&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestNamedConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -232,7 +232,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestNamedConstructor&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestNamedConstructor&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -4215,7 +4215,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestObj&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestObj&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -253,7 +253,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestOverloadedConstructors&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestOverloadedConstructors&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestSerializedScriptValueInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -337,7 +337,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestSerializedScriptValueInterface&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestSerializedScriptValueInterface&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -698,7 +698,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;TestTypedefs&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSTestTypedefs&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSattributecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -201,7 +201,6 @@
</span><span class="cx">     // by adding the SkipVTableValidation attribute to the interface IDL definition
</span><span class="cx">     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;attribute&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSattribute&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSreadonlycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -158,7 +158,6 @@
</span><span class="cx">     // attribute to readonly.
</span><span class="cx">     COMPILE_ASSERT(!__is_polymorphic(readonly), readonly_is_polymorphic_but_idl_claims_not_to_be);
</span><span class="cx"> #endif
</span><del>-    ReportMemoryCost&lt;readonly&gt;::reportMemoryCost(exec, impl);
</del><span class="cx">     return createNewWrapper&lt;JSreadonly&gt;(exec, globalObject, impl);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomChildNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ChildNodeList.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ChildNodeList.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/ChildNodeList.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">     virtual unsigned length() const override { return 0; }
</span><span class="cx">     virtual Node* item(unsigned) const override { return nullptr; }
</span><span class="cx">     virtual Node* namedItem(const AtomicString&amp;) const override { return nullptr; }
</span><ins>+    virtual size_t memoryCost() const override { return 0; }
</ins><span class="cx"> 
</span><span class="cx">     virtual bool isEmptyNodeList() const override { return true; }
</span><span class="cx"> 
</span><span class="lines">@@ -81,6 +82,7 @@
</span><span class="cx">     virtual unsigned length() const override;
</span><span class="cx">     virtual Node* item(unsigned index) const override;
</span><span class="cx">     virtual Node* namedItem(const AtomicString&amp;) const override;
</span><ins>+    virtual size_t memoryCost() const override { return m_indexCache.memoryCost(); }
</ins><span class="cx"> 
</span><span class="cx">     virtual bool isChildNodeList() const override { return true; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomCollectionIndexCachecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/CollectionIndexCache.cpp (0 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CollectionIndexCache.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/CollectionIndexCache.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 &quot;config.h&quot;
+#include &quot;CollectionIndexCache.h&quot;
+
+#include &quot;JSDOMWindowBase.h&quot;
+
+namespace WebCore {
+
+void reportExtraMemoryCostForCollectionIndexCache(size_t cost)
+{
+    JSC::VM* vm = JSDOMWindowBase::commonVM();
+    JSC::JSLockHolder lock(vm);
+    vm-&gt;heap.reportExtraMemoryCost(cost);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomCollectionIndexCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CollectionIndexCache.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CollectionIndexCache.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/CollectionIndexCache.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,8 +26,12 @@
</span><span class="cx"> #ifndef CollectionIndexCache_h
</span><span class="cx"> #define CollectionIndexCache_h
</span><span class="cx"> 
</span><ins>+#include &lt;wtf/Vector.h&gt;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+void reportExtraMemoryCostForCollectionIndexCache(size_t);
+
</ins><span class="cx"> template &lt;class Collection, class NodeType&gt;
</span><span class="cx"> class CollectionIndexCache {
</span><span class="cx"> public:
</span><span class="lines">@@ -37,15 +41,19 @@
</span><span class="cx">     NodeType* nodeAt(const Collection&amp;, unsigned index);
</span><span class="cx"> 
</span><span class="cx">     void invalidate();
</span><ins>+    size_t memoryCost() { return m_cachedList.capacity() * sizeof(NodeType*); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    unsigned computeNodeCountUpdatingListCache(const Collection&amp;);
</ins><span class="cx">     NodeType* nodeBeforeCached(const Collection&amp;, unsigned);
</span><span class="cx">     NodeType* nodeAfterCached(const Collection&amp;, unsigned);
</span><span class="cx"> 
</span><span class="cx">     NodeType* m_currentNode;
</span><span class="cx">     unsigned m_currentIndex;
</span><span class="cx">     unsigned m_nodeCount;
</span><del>-    bool m_nodeCountValid;
</del><ins>+    Vector&lt;NodeType*&gt; m_cachedList;
+    bool m_nodeCountValid : 1;
+    bool m_listValid : 1;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template &lt;class Collection, class NodeType&gt;
</span><span class="lines">@@ -54,6 +62,7 @@
</span><span class="cx">     , m_currentIndex(0)
</span><span class="cx">     , m_nodeCount(0)
</span><span class="cx">     , m_nodeCountValid(false)
</span><ins>+    , m_listValid(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -61,12 +70,7 @@
</span><span class="cx"> inline unsigned CollectionIndexCache&lt;Collection, NodeType&gt;::nodeCount(const Collection&amp; collection)
</span><span class="cx"> {
</span><span class="cx">     if (!m_nodeCountValid) {
</span><del>-        if (auto first = collection.collectionFirst()) {
-            unsigned count;
-            collection.collectionTraverseForward(*first, std::numeric_limits&lt;unsigned&gt;::max(), count);
-            m_nodeCount = count + 1;
-        } else
-            m_nodeCount = 0;
</del><ins>+        m_nodeCount = computeNodeCountUpdatingListCache(collection);
</ins><span class="cx">         m_nodeCountValid = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -74,6 +78,29 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;class Collection, class NodeType&gt;
</span><ins>+unsigned CollectionIndexCache&lt;Collection, NodeType&gt;::computeNodeCountUpdatingListCache(const Collection&amp; collection)
+{
+    NodeType* first = collection.collectionFirst();
+    if (!first)
+        return 0;
+
+    unsigned oldCapacity = m_cachedList.capacity();
+    NodeType* currentNode = first;
+    while (currentNode) {
+        m_cachedList.append(currentNode);
+        unsigned traversed;
+        currentNode = collection.collectionTraverseForward(*currentNode, 1, traversed);
+        ASSERT(traversed == (currentNode ? 1 : 0));
+    }
+    m_listValid = true;
+
+    if (unsigned capacityDifference = m_cachedList.capacity() - oldCapacity)
+        reportExtraMemoryCostForCollectionIndexCache(capacityDifference * sizeof(NodeType*));
+
+    return m_cachedList.size();
+}
+
+template &lt;class Collection, class NodeType&gt;
</ins><span class="cx"> inline NodeType* CollectionIndexCache&lt;Collection, NodeType&gt;::nodeBeforeCached(const Collection&amp; collection, unsigned index)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_currentNode);
</span><span class="lines">@@ -133,6 +160,9 @@
</span><span class="cx">     if (m_nodeCountValid &amp;&amp; index &gt;= m_nodeCount)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    if (m_listValid)
+        return m_cachedList[index];
+
</ins><span class="cx">     if (m_currentNode) {
</span><span class="cx">         if (index &gt; m_currentIndex)
</span><span class="cx">             return nodeAfterCached(collection, index);
</span><span class="lines">@@ -165,8 +195,11 @@
</span><span class="cx"> {
</span><span class="cx">     m_currentNode = nullptr;
</span><span class="cx">     m_nodeCountValid = false;
</span><ins>+    m_listValid = false;
+    m_cachedList.shrink(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoredomDOMAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMAllInOne.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;ClientRectList.cpp&quot;
</span><span class="cx"> #include &quot;Clipboard.cpp&quot;
</span><span class="cx"> #include &quot;ClipboardEvent.cpp&quot;
</span><ins>+#include &quot;CollectionIndexCache.cpp&quot;
</ins><span class="cx"> #include &quot;Comment.cpp&quot;
</span><span class="cx"> #include &quot;CompositionEvent.cpp&quot;
</span><span class="cx"> #include &quot;ContainerNode.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoredomLiveNodeListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LiveNodeList.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -143,6 +143,11 @@
</span><span class="cx">     return m_indexCache.nodeAt(*this, offset);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t LiveNodeList::memoryCost() const
+{
+    return m_indexCache.memoryCost();
+}
+
</ins><span class="cx"> void LiveNodeList::invalidateCache() const
</span><span class="cx"> {
</span><span class="cx">     m_indexCache.invalidate();
</span></span></pre></div>
<a id="trunkSourceWebCoredomLiveNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/LiveNodeList.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/LiveNodeList.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/LiveNodeList.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx">     // DOM API
</span><span class="cx">     virtual unsigned length() const override final;
</span><span class="cx">     virtual Node* item(unsigned offset) const override final;
</span><ins>+    virtual size_t memoryCost() const override;
</ins><span class="cx"> 
</span><span class="cx">     ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
</span><span class="cx">     ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast&lt;NodeListInvalidationType&gt;(m_invalidationType); }
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/NodeList.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NodeList.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/NodeList.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx">     virtual bool isLiveNodeList() const { return false; }
</span><span class="cx">     virtual bool isChildNodeList() const { return false; }
</span><span class="cx">     virtual bool isEmptyNodeList() const { return false; }
</span><ins>+    virtual size_t memoryCost() const { return 0; }
+
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeListidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/NodeList.idl (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/NodeList.idl        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/dom/NodeList.idl        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx">     CustomIsReachable,
</span><span class="cx">     JSCustomGetOwnPropertySlotAndDescriptor,
</span><span class="cx">     SkipVTableValidation,
</span><ins>+    ReportExtraMemoryCost,
</ins><span class="cx"> ] interface NodeList {
</span><span class="cx"> 
</span><span class="cx">     getter Node item(unsigned long index);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCollection.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -444,6 +444,10 @@
</span><span class="cx">         if (!nameAttrVal.isEmpty() &amp;&amp; idAttrVal != nameAttrVal &amp;&amp; (type() != DocAll || nameShouldBeVisibleInDocumentAll(toHTMLElement(*element))))
</span><span class="cx">             cache.appendNameCache(nameAttrVal, element);
</span><span class="cx">     }
</span><ins>+
+    m_indexCache.nodeCount(*this);
+
+    cache.didPopulate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLCollection::hasNamedItem(const AtomicString&amp; name) const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCollection.h (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCollection.h        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/html/HTMLCollection.h        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -40,17 +40,34 @@
</span><span class="cx"> 
</span><span class="cx"> class CollectionNamedElementCache {
</span><span class="cx"> public:
</span><ins>+#ifndef ASSERT_DISABLED
+    CollectionNamedElementCache : m_didPopulateCalled(false) { }
+#endif
+
</ins><span class="cx">     const Vector&lt;Element*&gt;* findElementsWithId(const AtomicString&amp; id) const { return find(m_idToElementsMap, id); }
</span><span class="cx">     const Vector&lt;Element*&gt;* findElementsWithName(const AtomicString&amp; name) const { return find(m_nameToElementsMap, name); }
</span><span class="cx"> 
</span><span class="cx">     void appendIdCache(const AtomicString&amp; id, Element* element) { return append(m_idToElementsMap, id, element); }
</span><span class="cx">     void appendNameCache(const AtomicString&amp; name, Element* element)  { return append(m_nameToElementsMap, name, element); }
</span><span class="cx"> 
</span><ins>+    void didPopulate()
+    {
+#ifndef ASSERT_DISABLED
+        m_didPopulateCalled = true;
+#endif
+        if (size_t cost = memoryCost())
+            reportExtraMemoryCostForCollectionIndexCache(cost);
+    }
+    size_t memoryCost() const { return (m_idToElementsMap.size() + m_nameToElementsMap.size()) * sizeof(Element*); }
+
</ins><span class="cx"> private:
</span><span class="cx">     typedef HashMap&lt;AtomicStringImpl*, Vector&lt;Element*&gt;&gt; StringToElementsMap;
</span><span class="cx"> 
</span><del>-    static const Vector&lt;Element*&gt;* find(const StringToElementsMap&amp; map, const AtomicString&amp; key)
</del><ins>+    const Vector&lt;Element*&gt;* find(const StringToElementsMap&amp; map, const AtomicString&amp; key) const
</ins><span class="cx">     {
</span><ins>+#ifndef ASSERT_DISABLED
+        ASSERT(m_didPopulateCalled);
+#endif
</ins><span class="cx">         auto it = map.find(key.impl());
</span><span class="cx">         return it != map.end() ? &amp;it-&gt;value : nullptr;
</span><span class="cx">     }
</span><span class="lines">@@ -62,6 +79,9 @@
</span><span class="cx"> 
</span><span class="cx">     StringToElementsMap m_idToElementsMap;
</span><span class="cx">     StringToElementsMap m_nameToElementsMap;
</span><ins>+#ifndef ASSERT_DISABLED
+    bool m_didPopulateCalled;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class HTMLCollection : public ScriptWrappable, public RefCounted&lt;HTMLCollection&gt; {
</span><span class="lines">@@ -78,6 +98,7 @@
</span><span class="cx">     // Non-DOM API
</span><span class="cx">     bool hasNamedItem(const AtomicString&amp; name) const;
</span><span class="cx">     void namedItems(const AtomicString&amp; name, Vector&lt;Ref&lt;Element&gt;&gt;&amp;) const;
</span><ins>+    size_t memoryCost() const { return m_indexCache.memoryCost() + (m_namedElementCache ? m_namedElementCache-&gt;memoryCost() : 0); }
</ins><span class="cx"> 
</span><span class="cx">     bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
</span><span class="cx">     NodeListInvalidationType invalidationType() const { return static_cast&lt;NodeListInvalidationType&gt;(m_invalidationType); }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCollectionidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCollection.idl (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCollection.idl        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/html/HTMLCollection.idl        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx">     CustomToJSObject,
</span><span class="cx">     GenerateIsReachable=ImplOwnerNodeRoot,
</span><span class="cx">     ObjCPolymorphic,
</span><ins>+    ReportExtraMemoryCost,
</ins><span class="cx"> ] interface HTMLCollection {
</span><span class="cx">     readonly attribute unsigned long length;
</span><span class="cx">     getter Node item([Default=Undefined] optional unsigned long index);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlsCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp (164852 => 164853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp        2014-02-28 05:52:33 UTC (rev 164852)
+++ trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp        2014-02-28 05:53:29 UTC (rev 164853)
</span><span class="lines">@@ -173,6 +173,8 @@
</span><span class="cx">                 cache.appendNameCache(nameAttrVal, &amp;element);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
+    cache.didPopulate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLFormControlsCollection::invalidateCache() const
</span></span></pre>
</div>
</div>

</body>
</html>