<!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>[180769] 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/180769">180769</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2015-02-27 11:20:27 -0800 (Fri, 27 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Compile DFA to bytecode.
https://bugs.webkit.org/show_bug.cgi?id=142031

Reviewed by Benjamin Poulain.

* WebCore.xcodeproj/project.pbxproj:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList):
(WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL):
* contentextensions/ContentExtensionsBackend.h:
* contentextensions/DFA.cpp:
(WebCore::ContentExtensions::DFA::nextState): Deleted.
(WebCore::ContentExtensions::DFA::actions): Deleted.
* contentextensions/DFA.h:
(WebCore::ContentExtensions::DFA::size):
(WebCore::ContentExtensions::DFA::nodeAt):
* contentextensions/DFABytecode.h: Added.
(WebCore::ContentExtensions::instructionSizeWithArguments):
* contentextensions/DFABytecodeCompiler.cpp: Added.
(WebCore::ContentExtensions::append):
(WebCore::ContentExtensions::set32Bits):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitJump):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValue):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitTerminate):
(WebCore::ContentExtensions::DFABytecodeCompiler::reserveBufferCapacity):
(WebCore::ContentExtensions::DFABytecodeCompiler::compileNode):
(WebCore::ContentExtensions::DFABytecodeCompiler::compile):
* contentextensions/DFABytecodeCompiler.h: Added.
(WebCore::ContentExtensions::DFABytecodeCompiler::DFABytecodeCompiler):
* contentextensions/DFABytecodeInterpreter.cpp: Added.
(WebCore::ContentExtensions::getBits):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
* contentextensions/DFABytecodeInterpreter.h: Added.
(WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFAcpp">trunk/Source/WebCore/contentextensions/DFA.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFAh">trunk/Source/WebCore/contentextensions/DFA.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeh">trunk/Source/WebCore/contentextensions/DFABytecode.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp">trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeCompilerh">trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.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 (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/ChangeLog        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2015-02-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Compile DFA to bytecode.
+        https://bugs.webkit.org/show_bug.cgi?id=142031
+
+        Reviewed by Benjamin Poulain.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList):
+        (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL):
+        * contentextensions/ContentExtensionsBackend.h:
+        * contentextensions/DFA.cpp:
+        (WebCore::ContentExtensions::DFA::nextState): Deleted.
+        (WebCore::ContentExtensions::DFA::actions): Deleted.
+        * contentextensions/DFA.h:
+        (WebCore::ContentExtensions::DFA::size):
+        (WebCore::ContentExtensions::DFA::nodeAt):
+        * contentextensions/DFABytecode.h: Added.
+        (WebCore::ContentExtensions::instructionSizeWithArguments):
+        * contentextensions/DFABytecodeCompiler.cpp: Added.
+        (WebCore::ContentExtensions::append):
+        (WebCore::ContentExtensions::set32Bits):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::emitJump):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValue):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::emitTerminate):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::reserveBufferCapacity):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::compileNode):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::compile):
+        * contentextensions/DFABytecodeCompiler.h: Added.
+        (WebCore::ContentExtensions::DFABytecodeCompiler::DFABytecodeCompiler):
+        * contentextensions/DFABytecodeInterpreter.cpp: Added.
+        (WebCore::ContentExtensions::getBits):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+        * contentextensions/DFABytecodeInterpreter.h: Added.
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter):
+
</ins><span class="cx"> 2015-02-27  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use after free in WebCore::RenderNamedFlowFragment::restoreRegionObjectsOriginalStyle
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -2142,6 +2142,11 @@
</span><span class="cx">                 5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
</span><span class="cx">                 5C4304B5191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304B3191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp */; };
</span><span class="cx">                 5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; };
</span><ins>+                5C9A7A751AA0F6EA00958ACF /* DFABytecodeCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C39305E1AA0F6A90029C816 /* DFABytecodeCompiler.cpp */; };
+                5C9A7A761AA0F6ED00958ACF /* DFABytecodeInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C3930601AA0F6A90029C816 /* DFABytecodeInterpreter.cpp */; };
+                5CD9F5661AA0F73C00DA45FF /* DFABytecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305D1AA0F6A90029C816 /* DFABytecode.h */; };
+                5CD9F5671AA0F74200DA45FF /* DFABytecodeCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */; };
+                5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */; };
</ins><span class="cx">                 5CFC4350192409E300A0D3B5 /* PointerLockController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CFC434E192406A900A0D3B5 /* PointerLockController.cpp */; };
</span><span class="cx">                 5D21A80213ECE5DF00BB7064 /* WebVTTParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D21A80013ECE5DF00BB7064 /* WebVTTParser.cpp */; };
</span><span class="cx">                 5D21A80313ECE5DF00BB7064 /* WebVTTParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D21A80113ECE5DF00BB7064 /* WebVTTParser.h */; };
</span><span class="lines">@@ -9286,6 +9291,11 @@
</span><span class="cx">                 5B30695A18B3D3450099D5E8 /* WebGLDrawBuffers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLDrawBuffers.cpp; path = canvas/WebGLDrawBuffers.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5B30695B18B3D3450099D5E8 /* WebGLDrawBuffers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLDrawBuffers.h; path = canvas/WebGLDrawBuffers.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5B30695C18B3D3450099D5E8 /* WebGLDrawBuffers.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLDrawBuffers.idl; path = canvas/WebGLDrawBuffers.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                5C39305D1AA0F6A90029C816 /* DFABytecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFABytecode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C39305E1AA0F6A90029C816 /* DFABytecodeCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFABytecodeCompiler.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFABytecodeCompiler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C3930601AA0F6A90029C816 /* DFABytecodeInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFABytecodeInterpreter.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFABytecodeInterpreter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5C4304AD191AC908000E2BC0 /* EXTShaderTextureLOD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EXTShaderTextureLOD.cpp; path = canvas/EXTShaderTextureLOD.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EXTShaderTextureLOD.h; path = canvas/EXTShaderTextureLOD.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C4304AF191AC908000E2BC0 /* EXTShaderTextureLOD.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = EXTShaderTextureLOD.idl; path = canvas/EXTShaderTextureLOD.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -15395,6 +15405,11 @@
</span><span class="cx">                                 26F0C8961A2E724B002794F8 /* ContentExtensionsManager.h */,
</span><span class="cx">                                 267725F61A5B3AD9003C24DD /* DFA.cpp */,
</span><span class="cx">                                 267725F71A5B3AD9003C24DD /* DFA.h */,
</span><ins>+                                5C39305D1AA0F6A90029C816 /* DFABytecode.h */,
+                                5C39305E1AA0F6A90029C816 /* DFABytecodeCompiler.cpp */,
+                                5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */,
+                                5C3930601AA0F6A90029C816 /* DFABytecodeInterpreter.cpp */,
+                                5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */,
</ins><span class="cx">                                 267725F91A5B3AD9003C24DD /* DFANode.h */,
</span><span class="cx">                                 269397251A4A5FBD00E8349D /* NFA.cpp */,
</span><span class="cx">                                 269397231A4A5B6400E8349D /* NFA.h */,
</span><span class="lines">@@ -24068,6 +24083,7 @@
</span><span class="cx">                                 85ECBEEB0AA7626900544F0B /* DOMHTMLAreaElement.h in Headers */,
</span><span class="cx">                                 85E7119C0AC5D5350053270F /* DOMHTMLAreaElementInternal.h in Headers */,
</span><span class="cx">                                 859A9C470AA5E3BD00B694B2 /* DOMHTMLBaseElement.h in Headers */,
</span><ins>+                                5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */,
</ins><span class="cx">                                 85E7119D0AC5D5350053270F /* DOMHTMLBaseElementInternal.h in Headers */,
</span><span class="cx">                                 85ECBEED0AA7626900544F0B /* DOMHTMLBaseFontElement.h in Headers */,
</span><span class="cx">                                 85E7119E0AC5D5350053270F /* DOMHTMLBaseFontElementInternal.h in Headers */,
</span><span class="lines">@@ -24547,6 +24563,7 @@
</span><span class="cx">                                 9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */,
</span><span class="cx">                                 BC3BC29C0E91AB0F00835588 /* HostWindow.h in Headers */,
</span><span class="cx">                                 FD31609912B026F700C1A359 /* HRTFDatabase.h in Headers */,
</span><ins>+                                5CD9F5671AA0F74200DA45FF /* DFABytecodeCompiler.h in Headers */,
</ins><span class="cx">                                 FD31609B12B026F700C1A359 /* HRTFDatabaseLoader.h in Headers */,
</span><span class="cx">                                 FD31609D12B026F700C1A359 /* HRTFElevation.h in Headers */,
</span><span class="cx">                                 FD31609F12B026F700C1A359 /* HRTFKernel.h in Headers */,
</span><span class="lines">@@ -24662,6 +24679,7 @@
</span><span class="cx">                                 A871DC280A15205700B12A68 /* HTMLTitleElement.h in Headers */,
</span><span class="cx">                                 977B3878122883E900B81FF8 /* HTMLTokenizer.h in Headers */,
</span><span class="cx">                                 0707568C142262D600414161 /* HTMLTrackElement.h in Headers */,
</span><ins>+                                5CD9F5661AA0F73C00DA45FF /* DFABytecode.h in Headers */,
</ins><span class="cx">                                 977B37261228721700B81FF8 /* HTMLTreeBuilder.h in Headers */,
</span><span class="cx">                                 A8EA79F20A1916DF00A8EF5F /* HTMLUListElement.h in Headers */,
</span><span class="cx">                                 AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */,
</span><span class="lines">@@ -28182,6 +28200,7 @@
</span><span class="cx">                                 B275357B0B053814002CE64F /* ImageMac.mm in Sources */,
</span><span class="cx">                                 2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */,
</span><span class="cx">                                 B51A2F4117D7D5DE0072517A /* ImageQualityController.cpp in Sources */,
</span><ins>+                                5C9A7A761AA0F6ED00958ACF /* DFABytecodeInterpreter.cpp in Sources */,
</ins><span class="cx">                                 0F3C725E1974874B00AEDD0C /* ImageSource.cpp in Sources */,
</span><span class="cx">                                 B275355F0B053814002CE64F /* ImageSourceCG.cpp in Sources */,
</span><span class="cx">                                 4B3480930EEF50D400AC1B41 /* ImageSourceCGMac.mm in Sources */,
</span><span class="lines">@@ -28713,6 +28732,7 @@
</span><span class="cx">                                 B2FA3D3A0AB75A6F000E5AC4 /* JSSVGAnimatedBoolean.cpp in Sources */,
</span><span class="cx">                                 B2FA3D3C0AB75A6F000E5AC4 /* JSSVGAnimatedEnumeration.cpp in Sources */,
</span><span class="cx">                                 B2FA3D3E0AB75A6F000E5AC4 /* JSSVGAnimatedInteger.cpp in Sources */,
</span><ins>+                                5C9A7A751AA0F6EA00958ACF /* DFABytecodeCompiler.cpp in Sources */,
</ins><span class="cx">                                 B2FA3D400AB75A6F000E5AC4 /* JSSVGAnimatedLength.cpp in Sources */,
</span><span class="cx">                                 B2FA3D420AB75A6F000E5AC4 /* JSSVGAnimatedLengthList.cpp in Sources */,
</span><span class="cx">                                 B2FA3D440AB75A6F000E5AC4 /* JSSVGAnimatedNumber.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ContentExtensionsDebugging.h&quot;
</span><ins>+#include &quot;DFABytecodeCompiler.h&quot;
+#include &quot;DFABytecodeInterpreter.h&quot;
</ins><span class="cx"> #include &quot;NFA.h&quot;
</span><span class="cx"> #include &quot;NFAToDFA.h&quot;
</span><span class="cx"> #include &quot;URL.h&quot;
</span><span class="lines">@@ -85,7 +87,7 @@
</span><span class="cx">     double dfaBuildTimeStart = monotonicallyIncreasingTime();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    CompiledContentExtension compiledContentExtension = { NFAToDFA::convert(nfa), ruleList };
</del><ins>+    const DFA dfa = NFAToDFA::convert(nfa);
</ins><span class="cx"> 
</span><span class="cx"> #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
</span><span class="cx">     double dfaBuildTimeEnd = monotonicallyIncreasingTime();
</span><span class="lines">@@ -95,9 +97,13 @@
</span><span class="cx">     // FIXME: never add a DFA that only matches the empty set.
</span><span class="cx"> 
</span><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span><del>-    compiledContentExtension.dfa.debugPrintDot();
</del><ins>+    dfa.debugPrintDot();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    Vector&lt;DFABytecode&gt; bytecode;
+    DFABytecodeCompiler compiler(dfa, bytecode);
+    compiler.compile();
+    CompiledContentExtension compiledContentExtension = { bytecode, ruleList };
</ins><span class="cx">     m_ruleLists.set(identifier, compiledContentExtension);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -115,24 +121,13 @@
</span><span class="cx"> {
</span><span class="cx">     const String&amp; urlString = url.string();
</span><span class="cx">     ASSERT_WITH_MESSAGE(urlString.containsOnlyASCII(), &quot;A decoded URL should only contain ASCII characters. The matching algorithm assumes the input is ASCII.&quot;);
</span><ins>+    const CString&amp; urlCString = urlString.utf8();
</ins><span class="cx"> 
</span><span class="cx">     for (auto&amp; ruleListSlot : m_ruleLists) {
</span><del>-        CompiledContentExtension&amp; compiledContentExtension = ruleListSlot.value;
-        unsigned state = compiledContentExtension.dfa.root();
-
-        HashSet&lt;uint64_t, DefaultHash&lt;uint64_t&gt;::Hash, WTF::UnsignedWithZeroKeyHashTraits&lt;uint64_t&gt;&gt; triggeredActions;
-
-        for (unsigned i = 0; i &lt; urlString.length(); ++i) {
-            char character = static_cast&lt;char&gt;(urlString[i]);
-            bool ok;
-            state = compiledContentExtension.dfa.nextState(state, character, ok);
-            if (!ok)
-                break;
-
-            const Vector&lt;uint64_t&gt;&amp; actions = compiledContentExtension.dfa.actions(state);
-            if (!actions.isEmpty())
-                triggeredActions.add(actions.begin(), actions.end());
-        }
</del><ins>+        const CompiledContentExtension&amp; compiledContentExtension = ruleListSlot.value;
+        DFABytecodeInterpreter interpreter(compiledContentExtension.bytecode);
+        DFABytecodeInterpreter::Actions triggeredActions = interpreter.interpret(urlCString);
+        // FIXME: We should eventually do something with each action rather than just returning a bool.
</ins><span class="cx">         if (!triggeredActions.isEmpty()) {
</span><span class="cx">             Vector&lt;uint64_t&gt; sortedActions;
</span><span class="cx">             copyToVector(triggeredActions, sortedActions);
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ContentExtensionRule.h&quot;
</span><span class="cx"> #include &quot;DFA.h&quot;
</span><ins>+#include &quot;DFABytecode.h&quot;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -60,7 +61,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     struct CompiledContentExtension {
</span><del>-        DFA dfa;
</del><ins>+        Vector&lt;DFABytecode&gt; bytecode;
</ins><span class="cx">         Vector&lt;ContentExtensionRule&gt; ruleList;
</span><span class="cx">     };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFA.cpp (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFA.cpp        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/contentextensions/DFA.cpp        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -59,31 +59,6 @@
</span><span class="cx">     return *this;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned DFA::nextState(unsigned currentState, char character, bool&amp; ok) const
-{
-    ASSERT(currentState &lt; m_nodes.size());
-
-    const DFANode&amp; node = m_nodes[currentState];
-    auto nextNode = node.transitions.find(character);
-    if (nextNode != node.transitions.end()) {
-        ok = true;
-        return nextNode-&gt;value;
-    }
-    if (node.hasFallbackTransition) {
-        ok = true;
-        return node.fallbackTransition;
-    }
-    ok = false;
-    return 0;
-
-}
-
-const Vector&lt;uint64_t&gt;&amp; DFA::actions(unsigned currentState) const
-{
-    ASSERT(currentState &lt; m_nodes.size());
-    return m_nodes[currentState].actions;
-}
-
</del><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span><span class="cx"> static void printRange(bool firstRange, char rangeStart, char rangeEnd)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFA.h (180768 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFA.h        2015-02-27 18:50:20 UTC (rev 180768)
+++ trunk/Source/WebCore/contentextensions/DFA.h        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -46,10 +46,8 @@
</span><span class="cx">     DFA&amp; operator=(const DFA&amp;);
</span><span class="cx"> 
</span><span class="cx">     unsigned root() const { return m_root; }
</span><del>-    // If there is a transition to a valid state on &quot;character&quot;, return that state and set ok to true.
-    // Otherwise, the return value is undefined and ok is false.
-    unsigned nextState(unsigned currentState, char character, bool&amp; ok) const;
-    const Vector&lt;uint64_t&gt;&amp; actions(unsigned currentState) const;
</del><ins>+    unsigned size() const { return m_nodes.size(); }
+    const DFANode&amp; nodeAt(unsigned i) const { return m_nodes[i]; }
</ins><span class="cx"> 
</span><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span><span class="cx">     void debugPrintDot() const;
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/DFABytecode.h (0 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecode.h                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFABytecode_h
+#define DFABytecode_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+namespace WebCore {
+    
+namespace ContentExtensions {
+
+typedef uint8_t DFABytecode;
+
+enum class DFABytecodeInstruction : uint8_t {
+
+    // CheckValue has two arguments:
+    // The value to check (1 byte),
+    // The index to jump to if the values are equal (4 bytes).
+    CheckValue,
+
+    // AppendAction has one argument:
+    // The action to append (4 bytes).
+    AppendAction,
+
+    // Terminate has no arguments.
+    Terminate,
+
+    // Jump has one argument:
+    // The index to jump to unconditionally (4 bytes).
+    Jump,
+};
+
+static inline size_t instructionSizeWithArguments(DFABytecodeInstruction instruction)
+{
+    switch (instruction) {
+    case DFABytecodeInstruction::CheckValue:
+        return sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + sizeof(unsigned);
+    case DFABytecodeInstruction::AppendAction:
+        return sizeof(DFABytecodeInstruction) + sizeof(unsigned);
+    case DFABytecodeInstruction::Terminate:
+        return sizeof(DFABytecodeInstruction);
+    case DFABytecodeInstruction::Jump:
+        return sizeof(DFABytecodeInstruction) + sizeof(unsigned);
+    }
+}
+    
+} // namespace ContentExtensions
+    
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+
+#endif // DFABytecode_h
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (0 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;DFABytecodeCompiler.h&quot;
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include &quot;ContentExtensionRule.h&quot;
+#include &quot;DFA.h&quot;
+
+namespace WebCore {
+    
+namespace ContentExtensions {
+
+template &lt;typename IntType&gt;
+inline void append(Vector&lt;DFABytecode&gt;&amp; bytecode, IntType value)
+{
+    bytecode.resize(bytecode.size() + sizeof(IntType));
+    *reinterpret_cast&lt;IntType*&gt;(&amp;bytecode[bytecode.size() - sizeof(IntType)]) = value;
+}
+
+inline void set32Bits(Vector&lt;DFABytecode&gt;&amp; bytecode, unsigned index, unsigned value)
+{
+    *reinterpret_cast&lt;unsigned*&gt;(&amp;bytecode[index]) = value;
+}
+
+void DFABytecodeCompiler::emitAppendAction(unsigned action)
+{
+    append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::AppendAction);
+    append&lt;unsigned&gt;(m_bytecode, action);
+}
+
+void DFABytecodeCompiler::emitJump(unsigned destinationNodeIndex)
+{
+    append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::Jump);
+    m_linkRecords.append(std::make_pair(m_bytecode.size(), destinationNodeIndex));
+    append&lt;unsigned&gt;(m_bytecode, 0); // This value will be set when linking.
+}
+
+void DFABytecodeCompiler::emitCheckValue(uint8_t value, unsigned destinationNodeIndex)
+{
+    append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::CheckValue);
+    append&lt;uint8_t&gt;(m_bytecode, value);
+    m_linkRecords.append(std::make_pair(m_bytecode.size(), destinationNodeIndex));
+    append&lt;unsigned&gt;(m_bytecode, 0); // This value will be set when linking.
+}
+
+void DFABytecodeCompiler::emitTerminate()
+{
+    append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::Terminate);
+}
+
+void DFABytecodeCompiler::compileNode(unsigned index)
+{
+    const DFANode&amp; node = m_dfa.nodeAt(index);
+
+    // Record starting index for linking.
+    m_nodeStartOffsets[index] = m_bytecode.size();
+
+    for (uint64_t action : node.actions)
+        emitAppendAction(static_cast&lt;unsigned&gt;(action));
+    
+    for (const auto&amp; transition : node.transitions)
+        emitCheckValue(transition.key, transition.value);
+    
+    if (node.hasFallbackTransition)
+        emitJump(node.fallbackTransition);
+    else
+        emitTerminate();
+}
+    
+void DFABytecodeCompiler::compile()
+{
+    ASSERT(!m_bytecode.size());
+    m_nodeStartOffsets.resize(m_dfa.size());
+    
+    // Make sure the root is always at the beginning of the bytecode.
+    compileNode(m_dfa.root());
+    for (unsigned i = 0; i &lt; m_dfa.size(); i++) {
+        if (i != m_dfa.root())
+            compileNode(i);
+    }
+
+    // Link.
+    for (const auto&amp; linkRecord : m_linkRecords)
+        set32Bits(m_bytecode, linkRecord.first, m_nodeStartOffsets[linkRecord.second]);
+}
+    
+} // namespace ContentExtensions
+
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeCompilerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h (0 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -0,0 +1,75 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFABytecodeCompiler_h
+#define DFABytecodeCompiler_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include &quot;DFABytecode.h&quot;
+#include &quot;DFANode.h&quot;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+
+namespace ContentExtensions {
+
+class DFA;
+
+class DFABytecodeCompiler {
+public:
+    DFABytecodeCompiler(const DFA&amp; dfa, Vector&lt;DFABytecode&gt;&amp; bytecode)
+        : m_bytecode(bytecode)
+        , m_dfa(dfa)
+    {
+    }
+    
+    void compile();
+
+private:
+    void compileNode(unsigned);
+
+    void emitAppendAction(unsigned);
+    void emitJump(unsigned destinationNodeIndex);
+    void emitCheckValue(uint8_t value, unsigned destinationNodeIndex);
+    void emitTerminate();
+
+    Vector&lt;DFABytecode&gt;&amp; m_bytecode;
+    const DFA&amp; m_dfa;
+    
+    Vector&lt;unsigned&gt; m_nodeStartOffsets;
+    
+    // The first value is the index in the bytecode buffer where the jump is to be written.
+    // The second value is the index of the node to jump to.
+    Vector&lt;std::pair&lt;unsigned, unsigned&gt;&gt; m_linkRecords;
+};
+
+} // namespace ContentExtensions
+
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+
+#endif // DFABytecodeCompiler_h
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (0 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;DFABytecodeInterpreter.h&quot;
+
+#include &lt;wtf/text/CString.h&gt;
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+namespace WebCore {
+    
+namespace ContentExtensions {
+
+template &lt;typename IntType&gt;
+static inline IntType getBits(const Vector&lt;DFABytecode&gt;&amp; bytecode, unsigned index)
+{
+    return *reinterpret_cast&lt;const IntType*&gt;(&amp;bytecode[index]);
+}
+
+DFABytecodeInterpreter::Actions DFABytecodeInterpreter::interpret(const CString&amp; urlCString)
+{
+    const char* url = urlCString.data();
+    ASSERT(url);
+    
+    unsigned programCounter = 0;
+    unsigned urlIndex = 0;
+    Actions actions;
+    
+    // This should always terminate if interpreting correctly compiled bytecode.
+    while (true) {
+        switch (static_cast&lt;DFABytecodeInstruction&gt;(bytecode[programCounter])) {
+
+        case DFABytecodeInstruction::Terminate:
+            return actions;
+
+        case DFABytecodeInstruction::CheckValue:
+            // Check to see if the next character in the url is the value stored with the bytecode.
+            if (!url[urlIndex])
+                return actions; // Reached null character at end.
+            if (url[urlIndex] == getBits&lt;uint8_t&gt;(bytecode, programCounter + sizeof(DFABytecode))) {
+                programCounter = getBits&lt;unsigned&gt;(bytecode, programCounter + sizeof(DFABytecode) + sizeof(uint8_t));
+                urlIndex++; // This represents an edge in the DFA.
+            } else
+                programCounter += instructionSizeWithArguments(DFABytecodeInstruction::CheckValue);
+            break;
+
+        case DFABytecodeInstruction::Jump:
+            programCounter = getBits&lt;unsigned&gt;(bytecode, programCounter + sizeof(DFABytecode));
+            urlIndex++; // This represents an edge in the DFA.
+            break;
+
+        case DFABytecodeInstruction::AppendAction:
+            actions.add(static_cast&lt;uint64_t&gt;(getBits&lt;unsigned&gt;(bytecode, programCounter + sizeof(DFABytecode))));
+            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
+            break;
+
+        default:
+            RELEASE_ASSERT_NOT_REACHED(); // Invalid bytecode.
+        }
+        ASSERT(urlIndex &lt;= urlCString.length()); // We should always terminate at a null character at the end of a String.
+    }
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+} // namespace ContentExtensions
+    
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h (0 => 180769)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-02-27 19:20:27 UTC (rev 180769)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DFABytecodeInterpreter_h
+#define DFABytecodeInterpreter_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include &quot;ContentExtensionRule.h&quot;
+#include &quot;DFABytecode.h&quot;
+#include &lt;wtf/HashSet.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+    
+namespace ContentExtensions {
+
+class DFABytecodeInterpreter {
+public:
+    DFABytecodeInterpreter(const Vector&lt;DFABytecode&gt;&amp; bytecode)
+        : bytecode(bytecode)
+    {
+    }
+    
+    typedef HashSet&lt;uint64_t, DefaultHash&lt;uint64_t&gt;::Hash, WTF::UnsignedWithZeroKeyHashTraits&lt;uint64_t&gt;&gt; Actions;
+    
+    Actions interpret(const CString&amp;);
+
+private:
+    const Vector&lt;DFABytecode&gt;&amp; bytecode;
+};
+
+} // namespace ContentExtensions
+    
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+
+#endif // DFABytecodeInterpreter_h
</ins></span></pre>
</div>
</div>

</body>
</html>