Title: [187137] trunk
Revision
187137
Author
benja...@webkit.org
Date
2015-07-21 16:45:00 -0700 (Tue, 21 Jul 2015)

Log Message

[Content Extensions] Use a jump table when consecutive transitions have different targets
https://bugs.webkit.org/show_bug.cgi?id=147099

Reviewed by Alex Christensen.

Source/WebCore:

When handling consecutive single transitions, merge them into
a jump table instead of creating many individual CheckValue.

>From local testing on x86_64, it reduces the bytecode size by about 5%
and improve the runtime by about 10%.

* contentextensions/DFABytecode.h:
(WebCore::ContentExtensions::instructionSizeWithArguments):
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::DFABytecodeCompiler::extractJumpTable):
(WebCore::ContentExtensions::DFABytecodeCompiler::transitions):
(WebCore::ContentExtensions::DFABytecodeCompiler::checkForJumpTableMaxBytecodeSize):
(WebCore::ContentExtensions::DFABytecodeCompiler::compileJumpTable):
(WebCore::ContentExtensions::DFABytecodeCompiler::nodeTransitionsMaxBytecodeSize):
(WebCore::ContentExtensions::DFABytecodeCompiler::compileNodeTransitions):
(WebCore::ContentExtensions::DFABytecodeCompiler::ranges): Deleted.
* contentextensions/DFABytecodeCompiler.h:
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpetJumpTable):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
* contentextensions/DFABytecodeInterpreter.h:

Source/WebKit2:

* UIProcess/API/APIUserContentExtensionStore.h:

LayoutTests:

Add some primitive testing to make sure the code is covered.

* http/tests/contentextensions/test-jump-table-bytecode-generation-expected.txt: Added.
* http/tests/contentextensions/test-jump-table-bytecode-generation.html: Added.
* http/tests/contentextensions/test-jump-table-bytecode-generation.html.json: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187136 => 187137)


--- trunk/LayoutTests/ChangeLog	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/LayoutTests/ChangeLog	2015-07-21 23:45:00 UTC (rev 187137)
@@ -1,3 +1,16 @@
+2015-07-21  Benjamin Poulain  <benja...@webkit.org>
+
+        [Content Extensions] Use a jump table when consecutive transitions have different targets
+        https://bugs.webkit.org/show_bug.cgi?id=147099
+
+        Reviewed by Alex Christensen.
+
+        Add some primitive testing to make sure the code is covered.
+
+        * http/tests/contentextensions/test-jump-table-bytecode-generation-expected.txt: Added.
+        * http/tests/contentextensions/test-jump-table-bytecode-generation.html: Added.
+        * http/tests/contentextensions/test-jump-table-bytecode-generation.html.json: Added.
+
 2015-07-21  Benjamin Poulain  <bpoul...@apple.com>
 
         StyleSheetContents::wrapperInsertRule() can create rules that overflow RuleData's selector index

Added: trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation-expected.txt (0 => 187137)


--- trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation-expected.txt	2015-07-21 23:45:00 UTC (rev 187137)
@@ -0,0 +1 @@
+This text should be visible.

Added: trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html (0 => 187137)


--- trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html	2015-07-21 23:45:00 UTC (rev 187137)
@@ -0,0 +1,11 @@
+<head>
+<meta charset="UTF-8"></meta>
+<script>
+    testRunner.dumpAsText();
+</script>
+</head>
+<body>
+<p>This text should be visible.</p>
+<p class="foo">This text should not be visible.</p>
+<p class="bar">This text should not be visible.</p>
+</body>

Added: trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html.json (0 => 187137)


--- trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html.json	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/test-jump-table-bytecode-generation.html.json	2015-07-21 23:45:00 UTC (rev 187137)
@@ -0,0 +1,60 @@
+[
+    {
+        "action": {
+            "type": "css-display-none",
+            "selector": ".foo"
+        },
+        "trigger": {
+            "url-filter": "cod"
+        }
+    },
+    {
+        "action": {
+            "type": "block"
+        },
+        "trigger": {
+            "url-filter": "dpc"
+        }
+    },
+    {
+        "action": {
+            "type": "block-cookies"
+        },
+        "trigger": {
+            "url-filter": "eme"
+        }
+    },
+    {
+        "action": {
+            "type": "css-display-none",
+            "selector": ".bar"
+        },
+        "trigger": {
+            "url-filter": "eco"
+        }
+    },
+    {
+        "action": {
+            "type": "block"
+        },
+        "trigger": {
+            "url-filter": "cco"
+        }
+    },
+    {
+        "action": {
+            "type": "ignore-previous-rules"
+        },
+        "trigger": {
+            "url-filter": "cpd"
+        }
+    },
+    {
+        "action": {
+            "type": "block"
+        },
+        "trigger": {
+            "url-filter": "doc"
+        }
+    }
+]

Modified: trunk/Source/WebCore/ChangeLog (187136 => 187137)


--- trunk/Source/WebCore/ChangeLog	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/ChangeLog	2015-07-21 23:45:00 UTC (rev 187137)
@@ -1,3 +1,32 @@
+2015-07-21  Benjamin Poulain  <benja...@webkit.org>
+
+        [Content Extensions] Use a jump table when consecutive transitions have different targets
+        https://bugs.webkit.org/show_bug.cgi?id=147099
+
+        Reviewed by Alex Christensen.
+
+        When handling consecutive single transitions, merge them into
+        a jump table instead of creating many individual CheckValue.
+
+        From local testing on x86_64, it reduces the bytecode size by about 5%
+        and improve the runtime by about 10%.
+
+        * contentextensions/DFABytecode.h:
+        (WebCore::ContentExtensions::instructionSizeWithArguments):
+        * contentextensions/DFABytecodeCompiler.cpp:
+        (WebCore::ContentExtensions::DFABytecodeCompiler::extractJumpTable):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::transitions):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::checkForJumpTableMaxBytecodeSize):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::compileJumpTable):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::nodeTransitionsMaxBytecodeSize):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::compileNodeTransitions):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::ranges): Deleted.
+        * contentextensions/DFABytecodeCompiler.h:
+        * contentextensions/DFABytecodeInterpreter.cpp:
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpetJumpTable):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+        * contentextensions/DFABytecodeInterpreter.h:
+
 2015-07-21  Simon Fraser  <simon.fra...@apple.com>
 
         Add a logging channel for Layout, remove the LiveConnect channel

Modified: trunk/Source/WebCore/contentextensions/DFABytecode.h (187136 => 187137)


--- trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-07-21 23:45:00 UTC (rev 187137)
@@ -45,30 +45,38 @@
     CheckValueCaseInsensitive = 0x0,
     CheckValueCaseSensitive = 0x1,
 
+    // Jump table if the input value is within a certain range.
+    // The lower value (1 byte).
+    // The higher value (1 byte).
+    // The distance to jump if the value is in the range
+    // for every character in the range (1-4 bytes, signed).
+    JumpTableCaseInsensitive = 0x2,
+    JumpTableCaseSensitive = 0x3,
+
     // Jump to an offset if the input value is within a certain range.
     // The lower value (1 byte).
     // The higher value (1 byte).
     // The distance to jump if the value is in the range (1-4 bytes, signed).
-    CheckValueRangeCaseInsensitive = 0x2,
-    CheckValueRangeCaseSensitive = 0x3,
+    CheckValueRangeCaseInsensitive = 0x4,
+    CheckValueRangeCaseSensitive = 0x5,
 
     // AppendAction has one argument:
     // The action to append (4 bytes).
-    AppendAction = 0x4,
-    AppendActionWithIfDomain = 0x5,
+    AppendAction = 0x6,
+    AppendActionWithIfDomain = 0x7,
     
     // TestFlagsAndAppendAction has two arguments:
     // The flags to check before appending (2 bytes).
     // The action to append (4 bytes).
-    TestFlagsAndAppendAction = 0x6,
-    TestFlagsAndAppendActionWithIfDomain = 0x7,
+    TestFlagsAndAppendAction = 0x8,
+    TestFlagsAndAppendActionWithIfDomain = 0x9,
 
     // Terminate has no arguments.
-    Terminate = 0x8,
+    Terminate = 0xA,
 
     // Jump has one argument:
     // The distance to jump (1-4 bytes, signed).
-    Jump = 0x9,
+    Jump = 0xB,
 };
 
 // The last four bits contain the instruction type.
@@ -104,6 +112,8 @@
     switch (instruction) {
     case DFABytecodeInstruction::CheckValueCaseSensitive:
     case DFABytecodeInstruction::CheckValueCaseInsensitive:
+    case DFABytecodeInstruction::JumpTableCaseInsensitive:
+    case DFABytecodeInstruction::JumpTableCaseSensitive:
     case DFABytecodeInstruction::CheckValueRangeCaseSensitive:
     case DFABytecodeInstruction::CheckValueRangeCaseInsensitive:
     case DFABytecodeInstruction::Jump:

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (187136 => 187137)


--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-07-21 23:45:00 UTC (rev 187137)
@@ -198,27 +198,56 @@
     return size;
 }
 
-Vector<DFABytecodeCompiler::Range> DFABytecodeCompiler::ranges(const DFANode& node)
+DFABytecodeCompiler::JumpTable DFABytecodeCompiler::extractJumpTable(Vector<DFABytecodeCompiler::Range>& ranges, unsigned firstRange, unsigned lastRange)
 {
+    ASSERT(lastRange > firstRange);
+    ASSERT(lastRange < ranges.size());
+
+    JumpTable jumpTable;
+    jumpTable.min = ranges[firstRange].min;
+    jumpTable.max = ranges[lastRange].max;
+    jumpTable.caseSensitive = ranges[lastRange].caseSensitive;
+
+    unsigned size = lastRange - firstRange + 1;
+    jumpTable.destinations.reserveInitialCapacity(size);
+    for (unsigned i = firstRange; i <= lastRange; ++i) {
+        const Range& range = ranges[i];
+
+        ASSERT(range.caseSensitive == jumpTable.caseSensitive);
+        ASSERT(range.min == range.max);
+        ASSERT(range.min >= jumpTable.min);
+        ASSERT(range.min <= jumpTable.max);
+
+        jumpTable.destinations.append(range.destination);
+    }
+
+    ranges.remove(firstRange, size);
+
+    return jumpTable;
+}
+
+DFABytecodeCompiler::Transitions DFABytecodeCompiler::transitions(const DFANode& node)
+{
+    Transitions transitions;
+
     uint32_t destinations[128];
     memset(destinations, 0xff, sizeof(destinations));
     const uint32_t noDestination = std::numeric_limits<uint32_t>::max();
 
-    bool canUseFallbackTransition = node.canUseFallbackTransition(m_dfa);
-    uint32_t fallbackTransitionTarget = std::numeric_limits<uint32_t>::max();
-    if (canUseFallbackTransition)
-        fallbackTransitionTarget = node.bestFallbackTarget(m_dfa);
+    transitions.useFallbackTransition = node.canUseFallbackTransition(m_dfa);
+    if (transitions.useFallbackTransition)
+        transitions.fallbackTransitionTarget = node.bestFallbackTarget(m_dfa);
 
     for (const auto& transition : node.transitions(m_dfa)) {
         uint32_t targetNodeIndex = transition.target();
-        if (canUseFallbackTransition && fallbackTransitionTarget == targetNodeIndex)
+        if (transitions.useFallbackTransition && transitions.fallbackTransitionTarget == targetNodeIndex)
             continue;
 
         for (uint16_t i = transition.range().first; i <= transition.range().last; ++i)
             destinations[i] = targetNodeIndex;
     }
 
-    Vector<Range> ranges;
+    Vector<Range>& ranges = transitions.ranges;
     uint8_t rangeMin;
     bool hasRangeMin = false;
     for (uint8_t i = 0; i < 128; i++) {
@@ -268,8 +297,44 @@
         ranges.append(Range(rangeMin, 127, destinations[rangeMin], true));
     }
 
-    return ranges;
+    Vector<JumpTable>& jumpTables = transitions.jumpTables;
+    unsigned rangePosition = 0;
+    unsigned baseRangePosition = std::numeric_limits<unsigned>::max();
+    Range* baseRange = nullptr;
+    while (rangePosition < ranges.size()) {
+        auto& range = ranges[rangePosition];
+        if (baseRange) {
+            if (range.min != range.max
+                || baseRange->caseSensitive != range.caseSensitive
+                || ranges[rangePosition - 1].max + 1 != range.min) {
+                if (rangePosition - baseRangePosition > 1) {
+                    jumpTables.append(extractJumpTable(ranges, baseRangePosition, rangePosition - 1));
+                    rangePosition = baseRangePosition;
+                }
+                baseRangePosition = std::numeric_limits<unsigned>::max();
+                baseRange = nullptr;
+            }
+        } else {
+            if (range.min == range.max) {
+                baseRangePosition = rangePosition;
+                baseRange = &range;
+            }
+        }
+        ++rangePosition;
+    }
+
+    if (baseRange && ranges.size() - baseRangePosition > 1)
+        jumpTables.append(extractJumpTable(ranges, baseRangePosition, ranges.size() - 1));
+
+    return transitions;
 }
+
+unsigned DFABytecodeCompiler::checkForJumpTableMaxBytecodeSize(const JumpTable& jumpTable)
+{
+    unsigned baselineSize = sizeof(DFABytecodeInstruction::CheckValueRangeCaseInsensitive) + 2 * sizeof(uint8_t);
+    unsigned targetsSize = (jumpTable.max - jumpTable.min + 1) * sizeof(uint32_t);
+    return baselineSize + targetsSize;
+}
     
 unsigned DFABytecodeCompiler::checkForRangeMaxBytecodeSize(const Range& range)
 {
@@ -278,6 +343,35 @@
     return sizeof(DFABytecodeInstruction::CheckValueRangeCaseInsensitive) + 2 * sizeof(uint8_t) + sizeof(uint32_t);
 }
 
+void DFABytecodeCompiler::compileJumpTable(uint32_t nodeIndex, const JumpTable& jumpTable)
+{
+    unsigned startSize = m_bytecode.size();
+    ASSERT_WITH_MESSAGE(jumpTable.max < 128, "The DFA engine only supports the ASCII alphabet.");
+    ASSERT(jumpTable.min <= jumpTable.max);
+
+    uint32_t instructionLocation = m_bytecode.size();
+    DFABytecodeJumpSize jumpSize = Int8;
+    for (uint32_t destinationNodeIndex : jumpTable.destinations) {
+        int32_t longestPossibleJumpDistance = longestPossibleJump(instructionLocation, nodeIndex, destinationNodeIndex);
+        DFABytecodeJumpSize localJumpSize = smallestPossibleJumpSize(longestPossibleJumpDistance);
+        jumpSize = std::max(jumpSize, localJumpSize);
+    }
+
+    DFABytecodeInstruction instruction = jumpTable.caseSensitive ? DFABytecodeInstruction::JumpTableCaseSensitive : DFABytecodeInstruction::JumpTableCaseInsensitive;
+    append<uint8_t>(m_bytecode, static_cast<uint8_t>(instruction) | jumpSize);
+    append<uint8_t>(m_bytecode, jumpTable.min);
+    append<uint8_t>(m_bytecode, jumpTable.max);
+
+    for (uint32_t destinationNodeIndex : jumpTable.destinations) {
+        int32_t longestPossibleJumpDistance = longestPossibleJump(instructionLocation, nodeIndex, destinationNodeIndex);
+        uint32_t jumpLocation = m_bytecode.size();
+        m_linkRecords.append(LinkRecord({jumpSize, longestPossibleJumpDistance, instructionLocation, jumpLocation, destinationNodeIndex}));
+        appendZeroes(m_bytecode, jumpSize);
+    }
+
+    ASSERT_UNUSED(startSize, m_bytecode.size() - startSize <= checkForJumpTableMaxBytecodeSize(jumpTable));
+}
+
 void DFABytecodeCompiler::compileCheckForRange(uint32_t nodeIndex, const Range& range)
 {
     unsigned startSize = m_bytecode.size();
@@ -295,9 +389,12 @@
 unsigned DFABytecodeCompiler::nodeTransitionsMaxBytecodeSize(const DFANode& node)
 {
     unsigned size = 0;
-    for (const auto& range : ranges(node))
+    Transitions nodeTransitions = transitions(node);
+    for (const auto& jumpTable : nodeTransitions.jumpTables)
+        size += checkForJumpTableMaxBytecodeSize(jumpTable);
+    for (const auto& range : nodeTransitions.ranges)
         size += checkForRangeMaxBytecodeSize(range);
-    if (node.canUseFallbackTransition(m_dfa))
+    if (nodeTransitions.useFallbackTransition)
         size += sizeof(DFABytecodeInstruction::Jump) + sizeof(uint32_t);
     else
         size += instructionSizeWithArguments(DFABytecodeInstruction::Terminate);
@@ -308,11 +405,14 @@
 {
     const DFANode& node = m_dfa.nodes[nodeIndex];
     unsigned startSize = m_bytecode.size();
-    
-    for (const auto& range : ranges(node))
+
+    Transitions nodeTransitions = transitions(node);
+    for (const auto& jumpTable : nodeTransitions.jumpTables)
+        compileJumpTable(nodeIndex, jumpTable);
+    for (const auto& range : nodeTransitions.ranges)
         compileCheckForRange(nodeIndex, range);
-    if (node.canUseFallbackTransition(m_dfa))
-        emitJump(nodeIndex, node.bestFallbackTarget(m_dfa));
+    if (nodeTransitions.useFallbackTransition)
+        emitJump(nodeIndex, nodeTransitions.fallbackTransitionTarget);
     else
         emitTerminate();
 

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h (187136 => 187137)


--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h	2015-07-21 23:45:00 UTC (rev 187137)
@@ -62,13 +62,34 @@
         uint32_t destination;
         bool caseSensitive;
     };
-    Vector<Range> ranges(const DFANode&);
+    struct JumpTable {
+        ~JumpTable()
+        {
+            ASSERT(min + destinations.size() == max + 1);
+            ASSERT(min == max || destinations.size() > 1);
+        }
+
+        uint8_t min { 0 };
+        uint8_t max { 0 };
+        bool caseSensitive { true };
+        Vector<uint32_t> destinations;
+    };
+    struct Transitions {
+        Vector<JumpTable> jumpTables;
+        Vector<Range> ranges;
+        bool useFallbackTransition { false };
+        uint32_t fallbackTransitionTarget { std::numeric_limits<uint32_t>::max() };
+    };
+    JumpTable extractJumpTable(Vector<Range>&, unsigned first, unsigned last);
+    Transitions transitions(const DFANode&);
     
     unsigned compiledNodeMaxBytecodeSize(uint32_t index);
     void compileNode(uint32_t index, bool root);
     unsigned nodeTransitionsMaxBytecodeSize(const DFANode&);
     void compileNodeTransitions(uint32_t nodeIndex);
+    unsigned checkForJumpTableMaxBytecodeSize(const JumpTable&);
     unsigned checkForRangeMaxBytecodeSize(const Range&);
+    void compileJumpTable(uint32_t nodeIndex, const JumpTable&);
     void compileCheckForRange(uint32_t nodeIndex, const Range&);
     int32_t longestPossibleJump(uint32_t jumpLocation, uint32_t sourceNodeIndex, uint32_t destinationNodeIndex);
 

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (187136 => 187137)


--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-07-21 23:45:00 UTC (rev 187137)
@@ -126,6 +126,25 @@
     ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain));
 }
 
+template<bool caseSensitive>
+inline void DFABytecodeInterpreter::interpetJumpTable(const char* url, uint32_t& urlIndex, uint32_t& programCounter, bool& urlIndexIsAfterEndOfString)
+{
+    DFABytecodeJumpSize jumpSize = getJumpSize(m_bytecode, m_bytecodeLength, programCounter);
+
+    char character = caseSensitive ? url[urlIndex] : toASCIILower(url[urlIndex]);
+    uint8_t firstCharacter = getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecodeInstruction));
+    uint8_t lastCharacter = getBits<uint8_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecodeInstruction) + sizeof(uint8_t));
+    if (character >= firstCharacter && character <= lastCharacter) {
+        uint32_t startOffset = programCounter + sizeof(DFABytecodeInstruction) + 2 * sizeof(uint8_t);
+        uint32_t jumpLocation = startOffset + (character - firstCharacter) * jumpSizeInBytes(jumpSize);
+        programCounter += getJumpDistance(m_bytecode, m_bytecodeLength, jumpLocation, jumpSize);
+        if (!character)
+            urlIndexIsAfterEndOfString = true;
+        urlIndex++; // This represents an edge in the DFA.
+    } else
+        programCounter += sizeof(DFABytecodeInstruction) + 2 * sizeof(uint8_t) + jumpSizeInBytes(jumpSize) * (lastCharacter - firstCharacter + 1);
+}
+
 DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsMatchingEverything()
 {
     Actions actions;
@@ -245,6 +264,19 @@
                     programCounter += sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + jumpSizeInBytes(jumpSize);
                 break;
             }
+
+            case DFABytecodeInstruction::JumpTableCaseInsensitive:
+                if (urlIndexIsAfterEndOfString)
+                    goto nextDFA;
+
+                interpetJumpTable<false>(url, urlIndex, programCounter, urlIndexIsAfterEndOfString);
+                break;
+            case DFABytecodeInstruction::JumpTableCaseSensitive:
+                if (urlIndexIsAfterEndOfString)
+                    goto nextDFA;
+
+                interpetJumpTable<true>(url, urlIndex, programCounter, urlIndexIsAfterEndOfString);
+                break;
                     
             case DFABytecodeInstruction::CheckValueRangeCaseSensitive: {
                 if (urlIndexIsAfterEndOfString)

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h (187136 => 187137)


--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h	2015-07-21 23:45:00 UTC (rev 187137)
@@ -56,6 +56,10 @@
 private:
     void interpretAppendAction(unsigned& programCounter, Actions&, bool ifDomain);
     void interpretTestFlagsAndAppendAction(unsigned& programCounter, uint16_t flags, Actions&, bool ifDomain);
+
+    template<bool caseSensitive>
+    void interpetJumpTable(const char* url, uint32_t& urlIndex, uint32_t& programCounter, bool& urlIndexIsAfterEndOfString);
+
     const DFABytecode* m_bytecode;
     const unsigned m_bytecodeLength;
     const DFABytecodeInterpreter::Actions* m_domainActions { nullptr };

Modified: trunk/Source/WebKit2/ChangeLog (187136 => 187137)


--- trunk/Source/WebKit2/ChangeLog	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-21 23:45:00 UTC (rev 187137)
@@ -1,3 +1,12 @@
+2015-07-21  Benjamin Poulain  <benja...@webkit.org>
+
+        [Content Extensions] Use a jump table when consecutive transitions have different targets
+        https://bugs.webkit.org/show_bug.cgi?id=147099
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APIUserContentExtensionStore.h:
+
 2015-07-21  Daniel Bates  <daba...@apple.com>
 
         Fix the build following <https://trac.webkit.org/changeset/187129>

Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h (187136 => 187137)


--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-07-21 23:33:37 UTC (rev 187136)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-07-21 23:45:00 UTC (rev 187137)
@@ -51,7 +51,7 @@
     
     // This should be incremented every time a functional change is made to the bytecode, file format, etc.
     // to prevent crashing while loading old data.
-    const static uint32_t CurrentContentExtensionFileVersion = 6;
+    const static uint32_t CurrentContentExtensionFileVersion = 7;
 
     static UserContentExtensionStore& defaultStore();
     static Ref<UserContentExtensionStore> storeWithPath(const WTF::String& storePath);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to