Compile fix when using content extensions debugging code.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 May 2015 05:01:17 +0000 (05:01 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 May 2015 05:01:17 +0000 (05:01 +0000)
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionsDebugging.h:
* contentextensions/DFA.cpp:
(WebCore::ContentExtensions::printTransitions):
(WebCore::ContentExtensions::DFA::debugPrintDot):
* contentextensions/DFANode.h:
* contentextensions/NFA.cpp:
(WebCore::ContentExtensions::NFA::memoryUsed):
(WebCore::ContentExtensions::NFA::debugPrintDot):

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

Source/WebCore/ChangeLog
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionsDebugging.h
Source/WebCore/contentextensions/DFA.cpp
Source/WebCore/contentextensions/DFANode.h
Source/WebCore/contentextensions/NFA.cpp

index 12607e9..6994e79 100644 (file)
@@ -1,3 +1,18 @@
+2015-04-30  Alex Christensen  <achristensen@webkit.org>
+
+        Compile fix when using content extensions debugging code.
+
+        * contentextensions/ContentExtensionCompiler.cpp:
+        (WebCore::ContentExtensions::compileRuleList):
+        * contentextensions/ContentExtensionsDebugging.h:
+        * contentextensions/DFA.cpp:
+        (WebCore::ContentExtensions::printTransitions):
+        (WebCore::ContentExtensions::DFA::debugPrintDot):
+        * contentextensions/DFANode.h:
+        * contentextensions/NFA.cpp:
+        (WebCore::ContentExtensions::NFA::memoryUsed):
+        (WebCore::ContentExtensions::NFA::debugPrintDot):
+
 2015-04-30  Dan Bernstein  <mitz@apple.com>
 
         Fixed the build for <rdar://problem/20758514>
index 060cef8..d3fc57b 100644 (file)
@@ -214,7 +214,7 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, const
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
         double dfaBuildTimeEnd = monotonicallyIncreasingTime();
-        dataLogF("    Time spent building the DFA %zu: %f\n", i, (dfaBuildTimeEnd - dfaBuildTimeStart));
+        dataLogF("    Time spent building the DFA: %f\n", (dfaBuildTimeEnd - dfaBuildTimeStart));
 #endif
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
@@ -223,11 +223,11 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, const
         dfa.minimize();
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
         double dfaMinimizationTimeEnd = monotonicallyIncreasingTime();
-        dataLogF("    Time spent miniminizing the DFA %zu: %f\n", i, (dfaMinimizationTimeEnd - dfaMinimizationTimeStart));
+        dataLogF("    Time spent miniminizing the DFA: %f\n", (dfaMinimizationTimeEnd - dfaMinimizationTimeStart));
 #endif
 
 #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
-        WTFLogAlways("DFA %zu", i);
+        WTFLogAlways("DFA");
         dfa.debugPrintDot();
 #endif
         ASSERT_WITH_MESSAGE(!dfa.nodes[dfa.root].hasActions(), "All actions on the DFA root should come from regular expressions that match everything.");
@@ -266,7 +266,6 @@ std::error_code compileRuleList(ContentExtensionCompilationClient& client, const
     double totalNFAToByteCodeBuildTimeEnd = monotonicallyIncreasingTime();
     dataLogF("    Time spent building and compiling the DFAs: %f\n", (totalNFAToByteCodeBuildTimeEnd - totalNFAToByteCodeBuildTimeStart));
     dataLogF("    Bytecode size %zu\n", bytecode.size());
-    dataLogF("    DFA count %zu\n", nfas.size());
 #endif
 
     LOG_LARGE_STRUCTURES(bytecode, bytecode.capacity() * sizeof(uint8_t));
index 5e338aa..f5ecb88 100644 (file)
@@ -36,7 +36,7 @@
 #define CONTENT_EXTENSIONS_PAGE_SIZE 16384
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
-#define LOG_LARGE_STRUCTURES(name, size) if (size > 1000000) { WTFLogAlways("NAME: %s SIZE %d", #name, (int)(size)); };
+#define LOG_LARGE_STRUCTURES(name, size) if (size > 1000000) { dataLogF("NAME: %s SIZE %d", #name, (int)(size)); };
 #else
 #define LOG_LARGE_STRUCTURES(name, size)
 #endif
index 0aacb5b..2670449 100644 (file)
@@ -137,22 +137,22 @@ static void printRange(bool firstRange, char rangeStart, char rangeEnd)
         dataLogF("\\\\%d-\\\\%d", rangeStart, rangeEnd);
 }
 
-static void printTransitions(const Vector<DFANode>& graph, unsigned sourceNodeId)
+static void printTransitions(const DFA& dfa, unsigned sourceNodeId)
 {
-    const DFANode& sourceNode = graph[sourceNodeId];
-    const DFANodeTransitions& transitions = sourceNode.transitions;
+    const DFANode& sourceNode = dfa.nodes[sourceNodeId];
+    auto transitions = sourceNode.transitions(dfa);
 
-    if (transitions.isEmpty() && !sourceNode.hasFallbackTransition)
+    if (transitions.isEmpty() && !sourceNode.hasFallbackTransition())
         return;
 
     HashMap<unsigned, Vector<uint16_t>, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> transitionsPerTarget;
 
     // First, we build the list of transitions coming to each target node.
     for (const auto& transition : transitions) {
-        unsigned target = transition.value;
+        unsigned target = transition.second;
         transitionsPerTarget.add(target, Vector<uint16_t>());
 
-        transitionsPerTarget.find(target)->value.append(transition.key);
+        transitionsPerTarget.find(target)->value.append(transition.first);
     }
 
     // Then we go over each one an display the ranges one by one.
@@ -180,8 +180,8 @@ static void printTransitions(const Vector<DFANode>& graph, unsigned sourceNodeId
         dataLogF("\"];\n");
     }
 
-    if (sourceNode.hasFallbackTransition)
-        dataLogF("        %d -> %d [label=\"[fallback]\"];\n", sourceNodeId, sourceNode.fallbackTransition);
+    if (sourceNode.hasFallbackTransition())
+        dataLogF("        %d -> %d [label=\"[fallback]\"];\n", sourceNodeId, sourceNode.fallbackTransitionDestination(dfa));
 }
 
 void DFA::debugPrintDot() const
@@ -190,12 +190,12 @@ void DFA::debugPrintDot() const
     dataLogF("    rankdir=LR;\n");
     dataLogF("    node [shape=circle];\n");
     dataLogF("    {\n");
-    for (unsigned i = 0; i < m_nodes.size(); ++i) {
-        if (m_nodes[i].isKilled)
+    for (unsigned i = 0; i < nodes.size(); ++i) {
+        if (nodes[i].isKilled())
             continue;
 
         dataLogF("         %d [label=<Node %d", i, i);
-        const Vector<uint64_t>& actions = m_nodes[i].actions;
+        const Vector<uint64_t>& actions = nodes[i].actions(*this);
         if (!actions.isEmpty()) {
             dataLogF("<BR/>Actions: ");
             for (unsigned actionIndex = 0; actionIndex < actions.size(); ++actionIndex) {
@@ -205,7 +205,7 @@ void DFA::debugPrintDot() const
             }
         }
 
-        Vector<unsigned> correspondingNFANodes = m_nodes[i].correspondingNFANodes;
+        Vector<unsigned> correspondingNFANodes = nodes[i].correspondingNFANodes;
         ASSERT(!correspondingNFANodes.isEmpty());
         dataLogF("<BR/>NFA Nodes: ");
         for (unsigned correspondingDFANodeIndex = 0; correspondingDFANodeIndex < correspondingNFANodes.size(); ++correspondingDFANodeIndex) {
@@ -224,8 +224,8 @@ void DFA::debugPrintDot() const
     dataLogF("    }\n");
 
     dataLogF("    {\n");
-    for (unsigned i = 0; i < m_nodes.size(); ++i)
-        printTransitions(m_nodes, i);
+    for (unsigned i = 0; i < nodes.size(); ++i)
+        printTransitions(*this, i);
 
     dataLogF("    }\n");
     dataLogF("}\n");
index bd1f1f9..6bd64e1 100644 (file)
@@ -102,7 +102,11 @@ private:
 
 // FIXME: Pack this down to 12.
 // It's probably already 12 on ARMv7.
+#if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
+COMPILE_ASSERT(sizeof(DFANode) <= 16 + sizeof(Vector<unsigned>), Keep the DFANodes small);
+#else
 COMPILE_ASSERT(sizeof(DFANode) <= 16, Keep the DFANodes small);
+#endif
 
 }
 
index 7cb6a66..4bfc837 100644 (file)
@@ -49,7 +49,7 @@ unsigned NFA::createNode()
 
 size_t NFA::memoryUsed() const
 {
-    size_t size = 0;
+    size_t size = sizeof(NFA);
     for (const NFANode& node : m_nodes) {
         for (const auto& transition : node.transitions)
             size += transition.value.capacity() * sizeof(unsigned);
@@ -188,7 +188,7 @@ void NFA::debugPrintDot() const
     for (unsigned i = 0; i < m_nodes.size(); ++i) {
         dataLogF("         %d [label=<Node %d", i, i);
 
-        const Vector<uint64_t>& finalRules = m_nodes[i].finalRuleIds;
+        const ActionList& finalRules = m_nodes[i].finalRuleIds;
         if (!finalRules.isEmpty()) {
             dataLogF("<BR/>(Final: ");
             for (unsigned ruleIndex = 0; ruleIndex < finalRules.size(); ++ruleIndex) {