Title: [181935] trunk
Revision
181935
Author
[email protected]
Date
2015-03-25 00:40:01 -0700 (Wed, 25 Mar 2015)

Log Message

Unreviewed, rolling out r181932.
https://bugs.webkit.org/show_bug.cgi?id=143041

The test fails most of the time on bots (Requested by ap on
#webkit).

Reverted changeset:

"[Content Extensions] Add multi-DFA compiling and
interpreting."
https://bugs.webkit.org/show_bug.cgi?id=143010
http://trac.webkit.org/changeset/181932

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (181934 => 181935)


--- trunk/Source/WebCore/ChangeLog	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Source/WebCore/ChangeLog	2015-03-25 07:40:01 UTC (rev 181935)
@@ -1,3 +1,18 @@
+2015-03-25  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r181932.
+        https://bugs.webkit.org/show_bug.cgi?id=143041
+
+        The test fails most of the time on bots (Requested by ap on
+        #webkit).
+
+        Reverted changeset:
+
+        "[Content Extensions] Add multi-DFA compiling and
+        interpreting."
+        https://bugs.webkit.org/show_bug.cgi?id=143010
+        http://trac.webkit.org/changeset/181932
+
 2015-03-24  Dean Jackson  <[email protected]>
 
         Source/WebCore/rendering/RenderThemeMac.mm:2181:118: error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (181934 => 181935)


--- trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp	2015-03-25 07:40:01 UTC (rev 181935)
@@ -111,23 +111,16 @@
     Vector<unsigned> actionLocations = serializeActions(parsedRuleList, actions);
     Vector<uint64_t> universalActionLocations;
 
-    Vector<NFA> nfas;
-    nfas.append(NFA());
+    NFA nfa;
+    URLFilterParser urlFilterParser(nfa);
     bool nonUniversalActionSeen = false;
     for (unsigned ruleIndex = 0; ruleIndex < parsedRuleList.size(); ++ruleIndex) {
-
-        // FIXME: Tune this better and adjust ContentExtensionTest.MultiDFA accordingly.
-        if (nfas[nfas.size() - 1].graphSize() > 500)
-            nfas.append(NFA());
-
-        NFA& lastNFA = nfas[nfas.size() - 1];
-        URLFilterParser urlFilterParser(lastNFA);
         const ContentExtensionRule& contentExtensionRule = parsedRuleList[ruleIndex];
         const Trigger& trigger = contentExtensionRule.trigger();
         ASSERT(trigger.urlFilter.length());
 
         // High bits are used for flags. This should match how they are used in DFABytecodeCompiler::compileNode.
-        uint64_t actionLocationAndFlags = (static_cast<uint64_t>(trigger.flags) << 32) | static_cast<uint64_t>(actionLocations[ruleIndex]);
+        uint64_t actionLocationAndFlags =(static_cast<uint64_t>(trigger.flags) << 32) | static_cast<uint64_t>(actionLocations[ruleIndex]);
         URLFilterParser::ParseStatus status = urlFilterParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocationAndFlags);
 
         if (status == URLFilterParser::MatchesEverything) {
@@ -156,17 +149,9 @@
     double dfaBuildTimeStart = monotonicallyIncreasingTime();
 #endif
 
-    Vector<DFABytecode> bytecode;
-    for (size_t i = 0; i < nfas.size(); ++i) {
-        DFA dfa = NFAToDFA::convert(nfas[i]);
-        if (!i) {
-            // Put all the universal actions on the first DFA.
-            for (uint64_t actionLocation : universalActionLocations)
-                dfa.nodeAt(dfa.root()).actions.append(actionLocation);
-        }
-        DFABytecodeCompiler compiler(dfa, bytecode);
-        compiler.compile();
-    }
+    DFA dfa = NFAToDFA::convert(nfa);
+    for (uint64_t actionLocation : universalActionLocations)
+        dfa.nodeAt(dfa.root()).actions.append(actionLocation);
 
 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
     double dfaBuildTimeEnd = monotonicallyIncreasingTime();
@@ -179,6 +164,10 @@
     dfa.debugPrintDot();
 #endif
 
+    Vector<DFABytecode> bytecode;
+    DFABytecodeCompiler compiler(dfa, bytecode);
+    compiler.compile();
+
     return { WTF::move(bytecode), WTF::move(actions) };
 }
 

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (181934 => 181935)


--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2015-03-25 07:40:01 UTC (rev 181935)
@@ -80,7 +80,6 @@
         const SerializedActionByte* actions = compiledExtension.actions();
         const unsigned actionsLength = compiledExtension.actionsLength();
         
-        bool sawIgnorePreviousRules = false;
         if (!triggeredActions.isEmpty()) {
             Vector<unsigned> actionLocations;
             actionLocations.reserveInitialCapacity(triggeredActions.size());
@@ -88,6 +87,8 @@
                 actionLocations.append(static_cast<unsigned>(actionLocation));
             std::sort(actionLocations.begin(), actionLocations.end());
 
+            bool sawIgnorePreviousRules = false;
+
             // Add actions in reverse order to properly deal with IgnorePreviousRules.
             for (unsigned i = actionLocations.size(); i; i--) {
                 Action action = "" actionsLength, actionLocations[i - 1]);
@@ -97,9 +98,10 @@
                 }
                 finalActions.append(action);
             }
+
+            if (!sawIgnorePreviousRules)
+                finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->identifier()));
         }
-        if (!sawIgnorePreviousRules)
-            finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->identifier()));
     }
     return finalActions;
 }

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (181934 => 181935)


--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-03-25 07:40:01 UTC (rev 181935)
@@ -167,9 +167,7 @@
 
 void DFABytecodeCompiler::compile()
 {
-    // DFA header.
-    unsigned startLocation = m_bytecode.size();
-    append<unsigned>(m_bytecode, 0);
+    ASSERT(!m_bytecode.size());
     m_nodeStartOffsets.resize(m_dfa.size());
     
     // Make sure the root is always at the beginning of the bytecode.
@@ -182,9 +180,6 @@
     // Link.
     for (const auto& linkRecord : m_linkRecords)
         set32Bits(m_bytecode, linkRecord.first, m_nodeStartOffsets[linkRecord.second]);
-    
-    // Set size header.
-    set32Bits(m_bytecode, startLocation, m_bytecode.size() - startLocation);
 }
     
 } // namespace ContentExtensions

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (181934 => 181935)


--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-03-25 07:40:01 UTC (rev 181935)
@@ -43,15 +43,13 @@
     
 DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsFromDFARoot()
 {
-    DFABytecodeInterpreter::Actions universalActionLocations;
-
-    // Skip first DFA header. All universal actions are in the first DFA root.
-    unsigned programCounter = sizeof(unsigned);
+    unsigned programCounter = 0;
+    DFABytecodeInterpreter::Actions globalActionLocations;
     while (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]) == DFABytecodeInstruction::AppendAction) {
-        universalActionLocations.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))));
+        globalActionLocations.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))));
         programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
     }
-    return universalActionLocations;
+    return globalActionLocations;
 }
     
 DFABytecodeInterpreter::Actions DFABytecodeInterpreter::interpret(const CString& urlCString, uint16_t flags)
@@ -59,92 +57,78 @@
     const char* url = ""
     ASSERT(url);
     
+    unsigned programCounter = 0;
+    unsigned urlIndex = 0;
+    bool urlIndexIsAfterEndOfString = false;
     Actions actions;
     
-    unsigned programCounter = 0;
-    while (programCounter < m_bytecodeLength) {
+    while (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]) == DFABytecodeInstruction::AppendAction)
+        programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
 
-        // DFA header.
-        unsigned dfaStart = programCounter;
-        unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter);
-        programCounter += sizeof(unsigned);
+    // This should always terminate if interpreting correctly compiled bytecode.
+    while (true) {
+        ASSERT(programCounter <= m_bytecodeLength);
+        switch (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter])) {
 
-        // Skip the universal actions.
-        // FIXME: Replace AppendAction with AppendActions to make this just one jump and make sure there aren't universal actions with flags.
-        while (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]) == DFABytecodeInstruction::AppendAction)
-            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
-        
-        // Interpret the bytecode from this DFA.
-        // This should always terminate if interpreting correctly compiled bytecode.
-        unsigned urlIndex = 0;
-        bool urlIndexIsAfterEndOfString = false;
-        while (true) {
-            ASSERT(programCounter <= m_bytecodeLength);
-            switch (static_cast<DFABytecodeInstruction>(m_bytecode[programCounter])) {
+        case DFABytecodeInstruction::Terminate:
+            return actions;
 
-            case DFABytecodeInstruction::Terminate:
-                goto nextDFA;
-                    
-            case DFABytecodeInstruction::CheckValue:
-                if (urlIndexIsAfterEndOfString)
-                    goto nextDFA;
+        case DFABytecodeInstruction::CheckValue:
+            if (urlIndexIsAfterEndOfString)
+                return actions;
 
-                // Check to see if the next character in the url is the value stored with the bytecode.
-                if (url[urlIndex] == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))) {
-                    programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t));
-                    if (!url[urlIndex])
-                        urlIndexIsAfterEndOfString = true;
-                    urlIndex++; // This represents an edge in the DFA.
-                } else
-                    programCounter += instructionSizeWithArguments(DFABytecodeInstruction::CheckValue);
-                break;
-                    
-            case DFABytecodeInstruction::CheckValueRange: {
-                if (urlIndexIsAfterEndOfString)
-                    goto nextDFA;
-                
-                char character = url[urlIndex];
-                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));
-                    if (!character)
-                        urlIndexIsAfterEndOfString = true;
-                    urlIndex++; // This represents an edge in the DFA.
-                } else
-                    programCounter += instructionSizeWithArguments(DFABytecodeInstruction::CheckValueRange);
-                break;
-            }
+            // Check to see if the next character in the url is the value stored with the bytecode.
+            if (url[urlIndex] == getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))) {
+                programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint8_t));
+                if (!url[urlIndex])
+                    urlIndexIsAfterEndOfString = true;
+                urlIndex++; // This represents an edge in the DFA.
+            } else
+                programCounter += instructionSizeWithArguments(DFABytecodeInstruction::CheckValue);
+            break;
 
-            case DFABytecodeInstruction::Jump:
-                if (!url[urlIndex] || urlIndexIsAfterEndOfString)
-                    goto nextDFA;
-                
-                programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode));
+        case DFABytecodeInstruction::CheckValueRange: {
+            if (urlIndexIsAfterEndOfString)
+                return actions;
+
+            char character = url[urlIndex];
+            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));
+                if (!character)
+                    urlIndexIsAfterEndOfString = true;
                 urlIndex++; // This represents an edge in the DFA.
-                break;
-                    
-            case DFABytecodeInstruction::AppendAction:
-                actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))));
-                programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
-                break;
-                    
-            case 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))));
-                programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
-                break;
-                    
-            default:
-                RELEASE_ASSERT_NOT_REACHED(); // Invalid bytecode.
-            }
-            // We should always terminate before or at a null character at the end of a String.
-            ASSERT(urlIndex <= urlCString.length() || (urlIndexIsAfterEndOfString && urlIndex <= urlCString.length() + 1));
+            } else
+                programCounter += instructionSizeWithArguments(DFABytecodeInstruction::CheckValueRange);
+            break;
         }
-        nextDFA:
-        ASSERT(dfaBytecodeLength);
-        programCounter = dfaStart + dfaBytecodeLength;
+
+        case DFABytecodeInstruction::Jump:
+            if (!url[urlIndex] || urlIndexIsAfterEndOfString)
+                return actions;
+
+            programCounter = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode));
+            urlIndex++; // This represents an edge in the DFA.
+            break;
+
+        case DFABytecodeInstruction::AppendAction:
+            actions.add(static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode))));
+            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
+            break;
+
+        case 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))));
+            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
+            break;
+
+        default:
+            RELEASE_ASSERT_NOT_REACHED(); // Invalid bytecode.
+        }
+        // We should always terminate before or at a null character at the end of a String.
+        ASSERT(urlIndex <= urlCString.length() || (urlIndexIsAfterEndOfString && urlIndex <= urlCString.length() + 1));
     }
-    return actions;
+    RELEASE_ASSERT_NOT_REACHED();
 }
 
 } // namespace ContentExtensions

Modified: trunk/Tools/ChangeLog (181934 => 181935)


--- trunk/Tools/ChangeLog	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Tools/ChangeLog	2015-03-25 07:40:01 UTC (rev 181935)
@@ -1,3 +1,18 @@
+2015-03-25  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r181932.
+        https://bugs.webkit.org/show_bug.cgi?id=143041
+
+        The test fails most of the time on bots (Requested by ap on
+        #webkit).
+
+        Reverted changeset:
+
+        "[Content Extensions] Add multi-DFA compiling and
+        interpreting."
+        https://bugs.webkit.org/show_bug.cgi?id=143010
+        http://trac.webkit.org/changeset/181932
+
 2015-03-24  Alex Christensen  <[email protected]>
 
         [Content Extensions] Add multi-DFA compiling and interpreting.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (181934 => 181935)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2015-03-25 06:06:15 UTC (rev 181934)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2015-03-25 07:40:01 UTC (rev 181935)
@@ -36,7 +36,6 @@
 #include <wtf/MainThread.h>
 #include <wtf/RunLoop.h>
 #include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 namespace ContentExtensions {
@@ -99,22 +98,16 @@
     ContentExtensions::CompiledContentExtensionData m_data;
 };
 
-void static testRequest(ContentExtensions::ContentExtensionsBackend contentExtensionsBackend, const ResourceLoadInfo& resourceLoadInfo, Vector<ContentExtensions::ActionType> expectedActions, bool ignorePreviousRules = false)
+void static testRequest(ContentExtensions::ContentExtensionsBackend contentExtensionsBackend, const ResourceLoadInfo& resourceLoadInfo, Vector<ContentExtensions::ActionType> expectedActions)
 {
     auto actions = contentExtensionsBackend.actionsForResourceLoad(resourceLoadInfo);
-
-    unsigned expectedSize = actions.size();
-    if (actions.size() && !ignorePreviousRules)
-        expectedSize--; // The last action is applying the compiled stylesheet.
-    
-    EXPECT_EQ(expectedActions.size(), expectedSize);
-    if (expectedActions.size() != expectedSize)
+    // The last action is applying the compiled stylesheet.
+    EXPECT_EQ(expectedActions.size(), actions.size() ? actions.size() - 1 : 0);
+    if (expectedActions.size() != (actions.size() ? actions.size() - 1 : 0))
         return;
 
     for (unsigned i = 0; i < expectedActions.size(); ++i)
         EXPECT_EQ(expectedActions[i], actions[i].type());
-    if (!ignorePreviousRules)
-        EXPECT_EQ(actions[actions.size() - 1].type(), ContentExtensions::ActionType::CSSDisplayNoneStyleSheet);
 }
 
 ResourceLoadInfo mainDocumentRequest(const char* url, ResourceType resourceType = ResourceType::Document)
@@ -517,47 +510,6 @@
     testRequest(backend, mainDocumentRequest("http://block_only_images.org", ResourceType::Document), { });
 }
 
-TEST_F(ContentExtensionTest, MultiDFA)
-{
-    // Make an NFA with about 2000 nodes.
-    StringBuilder ruleList;
-    ruleList.append('[');
-    for (char c1 = 'A'; c1 <= 'Z'; ++c1) {
-        for (char c2 = 'A'; c2 <= 'Z'; ++c2) {
-            for (char c3 = 'A'; c3 <= 'C'; ++c3) {
-                if (c1 != 'A' || c2 != 'A' || c3 != 'A')
-                    ruleList.append(',');
-                ruleList.append("{\"action\":{\"type\":\"");
-                
-                // Put an ignore-previous-rules near the middle.
-                if (c1 == 'L' && c2 == 'L' && c3 == 'A')
-                    ruleList.append("ignore-previous-rules");
-                else
-                    ruleList.append("block");
-                
-                ruleList.append("\"},\"trigger\":{\"url-filter\":\".*");
-                ruleList.append(c1);
-                ruleList.append(c2);
-                ruleList.append(c3);
-                ruleList.append("\", \"url-filter-is-case-sensitive\":true}}");
-            }
-        }
-    }
-    ruleList.append(']');
-    
-    auto extensionData = ContentExtensions::compileRuleList(ruleList.toString());
-    auto extension = InMemoryCompiledContentExtension::create(WTF::move(extensionData));
-        
-    ContentExtensions::ContentExtensionsBackend backend;
-    backend.addContentExtension("ResourceTypeFilter", extension);
-
-    testRequest(backend, mainDocumentRequest("http://webkit.org/AAA"), { ContentExtensions::ActionType::BlockLoad });
-    testRequest(backend, mainDocumentRequest("http://webkit.org/ZZC"), { ContentExtensions::ActionType::BlockLoad });
-    testRequest(backend, mainDocumentRequest("http://webkit.org/LLA/AAA"), { }, true);
-    testRequest(backend, mainDocumentRequest("http://webkit.org/LLA/MMC"), { ContentExtensions::ActionType::BlockLoad }, true);
-    testRequest(backend, mainDocumentRequest("http://webkit.org/"), { });
-}
-
 static void testPatternStatus(String pattern, ContentExtensions::URLFilterParser::ParseStatus status)
 {
     ContentExtensions::NFA nfa;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to