<!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>[182335] 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/182335">182335</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2015-04-03 14:44:41 -0700 (Fri, 03 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Content Extensions] Add memory reporting.
https://bugs.webkit.org/show_bug.cgi?id=143386
Reviewed by Benjamin Poulain.
* contentextensions/CompiledContentExtension.cpp:
(WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors):
* contentextensions/CompiledContentExtension.h:
* contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
* contentextensions/ContentExtension.h:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
* contentextensions/ContentExtensionsDebugging.h:
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::getBits):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsFromDFARoot):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
* contentextensions/DFABytecodeInterpreter.h:
(WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
(WebCore::ContentExtensions::DFABytecodeInterpreter::~DFABytecodeInterpreter):
Keep track of which memory pages in the bytecode are being hit if CONTENT_EXTENSIONS_MEMORY_REPORTING is 1.
When CONTENT_EXTENSIONS_MEMORY_REPORTING is 0, this makes an empty vector in ContentExtension
and passes some pointers on the stack, many of which can be optimized out by the C++ compiler.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsCompiledContentExtensioncpp">trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsCompiledContentExtensionh">trunk/Source/WebCore/contentextensions/CompiledContentExtension.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensioncpp">trunk/Source/WebCore/contentextensions/ContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionh">trunk/Source/WebCore/contentextensions/ContentExtension.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsDebuggingh">trunk/Source/WebCore/contentextensions/ContentExtensionsDebugging.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp">trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh">trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/ChangeLog        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-04-03 Alex Christensen <achristensen@webkit.org>
+
+ [Content Extensions] Add memory reporting.
+ https://bugs.webkit.org/show_bug.cgi?id=143386
+
+ Reviewed by Benjamin Poulain.
+
+ * contentextensions/CompiledContentExtension.cpp:
+ (WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors):
+ * contentextensions/CompiledContentExtension.h:
+ * contentextensions/ContentExtension.cpp:
+ (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
+ * contentextensions/ContentExtension.h:
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
+ * contentextensions/ContentExtensionsDebugging.h:
+ * contentextensions/DFABytecodeInterpreter.cpp:
+ (WebCore::ContentExtensions::getBits):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsFromDFARoot):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+ * contentextensions/DFABytecodeInterpreter.h:
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::~DFABytecodeInterpreter):
+ Keep track of which memory pages in the bytecode are being hit if CONTENT_EXTENSIONS_MEMORY_REPORTING is 1.
+ When CONTENT_EXTENSIONS_MEMORY_REPORTING is 0, this makes an empty vector in ContentExtension
+ and passes some pointers on the stack, many of which can be optimized out by the C++ compiler.
+
</ins><span class="cx"> 2015-04-03 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> Expand test infrastructure to support scrolling tests
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsCompiledContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Vector<String> CompiledContentExtension::globalDisplayNoneSelectors()
</del><ins>+Vector<String> CompiledContentExtension::globalDisplayNoneSelectors(Vector<bool>& pagesUsed)
</ins><span class="cx"> {
</span><del>- DFABytecodeInterpreter interpreter(bytecode(), bytecodeLength());
</del><ins>+ DFABytecodeInterpreter interpreter(bytecode(), bytecodeLength(), pagesUsed);
</ins><span class="cx"> DFABytecodeInterpreter::Actions actionLocations = interpreter.actionsFromDFARoot();
</span><span class="cx">
</span><span class="cx"> Vector<Action> globalActions;
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsCompiledContentExtensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.h (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.h        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.h        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> virtual unsigned bytecodeLength() const = 0;
</span><span class="cx"> virtual const SerializedActionByte* actions() const = 0;
</span><span class="cx"> virtual unsigned actionsLength() const = 0;
</span><del>- Vector<String> globalDisplayNoneSelectors();
</del><ins>+ Vector<String> globalDisplayNoneSelectors(Vector<bool>& pagesUsed);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">
</span><span class="cx"> m_parsedGlobalDisplayNoneStyleSheet = true;
</span><span class="cx">
</span><del>- Vector<String> selectors = m_compiledExtension->globalDisplayNoneSelectors();
</del><ins>+ Vector<String> selectors = m_compiledExtension->globalDisplayNoneSelectors(m_pagesUsed);
</ins><span class="cx"> if (selectors.isEmpty())
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.h (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.h        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.h        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> const CompiledContentExtension& compiledExtension() const { return m_compiledExtension.get(); }
</span><span class="cx"> StyleSheetContents* globalDisplayNoneStyleSheet();
</span><span class="cx">
</span><ins>+ mutable Vector<bool> m_pagesUsed;
</ins><span class="cx"> private:
</span><span class="cx"> ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -79,8 +79,9 @@
</span><span class="cx"> Vector<Action> finalActions;
</span><span class="cx"> ResourceFlags flags = resourceLoadInfo.getResourceFlags();
</span><span class="cx"> for (auto& contentExtension : m_contentExtensions.values()) {
</span><ins>+ RELEASE_ASSERT(contentExtension);
</ins><span class="cx"> const CompiledContentExtension& compiledExtension = contentExtension->compiledExtension();
</span><del>- DFABytecodeInterpreter interpreter(compiledExtension.bytecode(), compiledExtension.bytecodeLength());
</del><ins>+ DFABytecodeInterpreter interpreter(compiledExtension.bytecode(), compiledExtension.bytecodeLength(), contentExtension->m_pagesUsed);
</ins><span class="cx"> DFABytecodeInterpreter::Actions triggeredActions = interpreter.interpret(urlCString, flags);
</span><span class="cx">
</span><span class="cx"> const SerializedActionByte* actions = compiledExtension.actions();
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsDebuggingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsDebugging.h (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsDebugging.h        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsDebugging.h        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -32,6 +32,9 @@
</span><span class="cx">
</span><span class="cx"> #define CONTENT_EXTENSIONS_PERFORMANCE_REPORTING 0
</span><span class="cx">
</span><ins>+#define CONTENT_EXTENSIONS_MEMORY_REPORTING 0
+#define CONTENT_EXTENSIONS_PAGE_SIZE 16384
+
</ins><span class="cx"> #endif // ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">
</span><span class="cx"> #endif // ContentExtensionsDebugging_h
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "DFABytecodeInterpreter.h"
</span><span class="cx">
</span><ins>+#include "ContentExtensionsDebugging.h"
</ins><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="lines">@@ -35,24 +36,32 @@
</span><span class="cx"> namespace ContentExtensions {
</span><span class="cx">
</span><span class="cx"> template <typename IntType>
</span><del>-static inline IntType getBits(const DFABytecode* bytecode, unsigned bytecodeLength, unsigned index)
</del><ins>+static inline IntType getBits(const DFABytecode* bytecode, unsigned bytecodeLength, unsigned index, Vector<bool>& pagesUsed)
</ins><span class="cx"> {
</span><ins>+#if CONTENT_EXTENSIONS_MEMORY_REPORTING
+ unsigned page = index / CONTENT_EXTENSIONS_PAGE_SIZE;
+ while (pagesUsed.size() < (bytecodeLength + CONTENT_EXTENSIONS_PAGE_SIZE - 1) / CONTENT_EXTENSIONS_PAGE_SIZE)
+ pagesUsed.append(false);
+ pagesUsed[page] = true;
+#else
+ UNUSED_PARAM(pagesUsed);
+#endif
</ins><span class="cx"> ASSERT_UNUSED(bytecodeLength, index + sizeof(IntType) <= bytecodeLength);
</span><span class="cx"> return *reinterpret_cast<const IntType*>(&bytecode[index]);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DFABytecodeInterpreter::interpretAppendAction(unsigned& programCounter, Actions& actions)
</span><span class="cx"> {
</span><del>- ASSERT(getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendAction);
- actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))));
</del><ins>+ ASSERT(getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::AppendAction);
+ actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)));
</ins><span class="cx"> programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DFABytecodeInterpreter::interpretTestFlagsAndAppendAction(unsigned& programCounter, uint16_t flags, Actions& actions)
</span><span class="cx"> {
</span><del>- ASSERT(getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::TestFlagsAndAppendAction);
- if (flags & getBits<uint16_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode)))
- actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint16_t))));
</del><ins>+ ASSERT(getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::TestFlagsAndAppendAction);
+ if (flags & getBits<uint16_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed))
+ actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint16_t), m_pagesUsed)));
</ins><span class="cx"> programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -61,7 +70,7 @@
</span><span class="cx"> Actions actions;
</span><span class="cx">
</span><span class="cx"> // DFA header.
</span><del>- unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, 0);
</del><ins>+ unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, 0, m_pagesUsed);
</ins><span class="cx"> unsigned programCounter = sizeof(unsigned);
</span><span class="cx">
</span><span class="cx"> while (programCounter < dfaBytecodeLength) {
</span><span class="lines">@@ -88,7 +97,7 @@
</span><span class="cx">
</span><span class="cx"> // DFA header.
</span><span class="cx"> unsigned dfaStart = programCounter;
</span><del>- unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter);
</del><ins>+ unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed);
</ins><span class="cx"> programCounter += sizeof(unsigned);
</span><span class="cx">
</span><span class="cx"> // Skip the actions on the DFA root. These are accessed via actionsFromDFARoot.
</span><span class="lines">@@ -127,8 +136,8 @@
</span><span class="cx">
</span><span class="cx"> // Check to see if the next character in the url is the value stored with the bytecode.
</span><span class="cx"> char character = url[urlIndex];
</span><del>- if (character == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))) {
- programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t));
</del><ins>+ if (character == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)) {
+ programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t), m_pagesUsed);
</ins><span class="cx"> if (!character)
</span><span class="cx"> urlIndexIsAfterEndOfString = true;
</span><span class="cx"> urlIndex++; // This represents an edge in the DFA.
</span><span class="lines">@@ -143,8 +152,8 @@
</span><span class="cx">
</span><span class="cx"> // Check to see if the next character in the url is the value stored with the bytecode.
</span><span class="cx"> char character = toASCIILower(url[urlIndex]);
</span><del>- if (character == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))) {
- programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t));
</del><ins>+ if (character == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)) {
+ programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t), m_pagesUsed);
</ins><span class="cx"> if (!character)
</span><span class="cx"> urlIndexIsAfterEndOfString = true;
</span><span class="cx"> urlIndex++; // This represents an edge in the DFA.
</span><span class="lines">@@ -158,9 +167,9 @@
</span><span class="cx"> goto nextDFA;
</span><span class="cx">
</span><span class="cx"> char character = url[urlIndex];
</span><del>- if (character >= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))
- && character <= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t))) {
- programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t) + sizeof(uint8_t));
</del><ins>+ if (character >= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)
+ && character <= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t), m_pagesUsed)) {
+ programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t) + sizeof(uint8_t), m_pagesUsed);
</ins><span class="cx"> if (!character)
</span><span class="cx"> urlIndexIsAfterEndOfString = true;
</span><span class="cx"> urlIndex++; // This represents an edge in the DFA.
</span><span class="lines">@@ -174,9 +183,9 @@
</span><span class="cx"> goto nextDFA;
</span><span class="cx">
</span><span class="cx"> char character = toASCIILower(url[urlIndex]);
</span><del>- if (character >= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))
- && character <= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t))) {
- programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t) + sizeof(uint8_t));
</del><ins>+ if (character >= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)
+ && character <= getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t), m_pagesUsed)) {
+ programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t) + sizeof(uint8_t), m_pagesUsed);
</ins><span class="cx"> if (!character)
</span><span class="cx"> urlIndexIsAfterEndOfString = true;
</span><span class="cx"> urlIndex++; // This represents an edge in the DFA.
</span><span class="lines">@@ -189,7 +198,7 @@
</span><span class="cx"> if (!url[urlIndex] || urlIndexIsAfterEndOfString)
</span><span class="cx"> goto nextDFA;
</span><span class="cx">
</span><del>- programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode));
</del><ins>+ programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed);
</ins><span class="cx"> urlIndex++; // This represents an edge in the DFA.
</span><span class="cx"> break;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h (182334 => 182335)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-04-03 21:32:59 UTC (rev 182334)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-04-03 21:44:41 UTC (rev 182335)
</span><span class="lines">@@ -29,7 +29,9 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">
</span><span class="cx"> #include "ContentExtensionRule.h"
</span><ins>+#include "ContentExtensionsDebugging.h"
</ins><span class="cx"> #include "DFABytecode.h"
</span><ins>+#include <wtf/DataLog.h>
</ins><span class="cx"> #include <wtf/HashSet.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="lines">@@ -39,11 +41,21 @@
</span><span class="cx">
</span><span class="cx"> class DFABytecodeInterpreter {
</span><span class="cx"> public:
</span><del>- DFABytecodeInterpreter(const DFABytecode* bytecode, unsigned bytecodeLength)
</del><ins>+ DFABytecodeInterpreter(const DFABytecode* bytecode, unsigned bytecodeLength, Vector<bool>& pagesUsed)
</ins><span class="cx"> : m_bytecode(bytecode)
</span><span class="cx"> , m_bytecodeLength(bytecodeLength)
</span><ins>+ , m_pagesUsed(pagesUsed)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><ins>+ ~DFABytecodeInterpreter()
+ {
+#if CONTENT_EXTENSIONS_MEMORY_REPORTING
+ size_t total = 0;
+ for (bool& b : m_pagesUsed)
+ total += b;
+ dataLogF("Pages used: %zu / %zu\n", total, m_pagesUsed.size());
+#endif
+ }
</ins><span class="cx">
</span><span class="cx"> typedef HashSet<uint64_t, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> Actions;
</span><span class="cx">
</span><span class="lines">@@ -55,6 +67,7 @@
</span><span class="cx"> void interpretTestFlagsAndAppendAction(unsigned& programCounter, uint16_t flags, Actions&);
</span><span class="cx"> const DFABytecode* m_bytecode;
</span><span class="cx"> const unsigned m_bytecodeLength;
</span><ins>+ Vector<bool>& m_pagesUsed;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre>
</div>
</div>
</body>
</html>