Changeset 187049 in webkit
- Timestamp:
- Jul 20, 2015 5:12:13 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r187044 r187049 1 2015-07-20 Alex Christensen <achristensen@webkit.org> 2 3 [Content Extensions] Cache actions with domains that match everything 4 https://bugs.webkit.org/show_bug.cgi?id=147050 5 6 Reviewed by Benjamin Poulain. 7 8 If you have lots of rules with triggers like {"url-filter":".*","if-domain":["*webkit.org"]} 9 we will spend a lot of time adding unnecessary actions to HashSets when you are not on webkit.org. 10 Caching all the rules and only adding them to a collection once when the domain changes saves a lot of URL interpreting time. 11 12 We already had an optimization for the css-display-none actions with triggers that matched everything using a special bytecode operation. 13 This removes the need for a special bytecode operation by caching the triggers that match everything with and without domains, 14 then from those cached actions we compile a stylesheet, and create cached actions for every new domain we visit. 15 16 All functionality is covered by existing API tests. 17 18 * contentextensions/CompiledContentExtension.cpp: 19 (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension): 20 (WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors): Deleted. 21 * contentextensions/CompiledContentExtension.h: 22 * contentextensions/ContentExtension.cpp: 23 (WebCore::ContentExtensions::ContentExtension::ContentExtension): 24 (WebCore::ContentExtensions::ContentExtension::findFirstIgnorePreviousRules): 25 (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet): 26 (WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet): 27 (WebCore::ContentExtensions::ContentExtension::populateDomainCacheIfNeeded): 28 (WebCore::ContentExtensions::ContentExtension::cachedDomainActions): 29 (WebCore::ContentExtensions::ContentExtension::universalActionsWithDomains): 30 * contentextensions/ContentExtension.h: 31 (WebCore::ContentExtensions::ContentExtension::compiledExtension): 32 (WebCore::ContentExtensions::ContentExtension::universalActionsWithoutDomains): 33 * contentextensions/ContentExtensionCompiler.cpp: 34 (WebCore::ContentExtensions::compileRuleList): 35 * contentextensions/ContentExtensionRule.cpp: 36 (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): 37 (WebCore::ContentExtensions::Action::deserialize): 38 (WebCore::ContentExtensions::Action::deserializeType): 39 (WebCore::ContentExtensions::Action::serializedLength): 40 * contentextensions/ContentExtensionRule.h: 41 (WebCore::ContentExtensions::Action::operator==): 42 (WebCore::ContentExtensions::Action::setExtensionIdentifier): 43 (WebCore::ContentExtensions::Action::extensionIdentifier): 44 * contentextensions/ContentExtensionsBackend.cpp: 45 (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad): 46 * contentextensions/DFABytecode.h: 47 (WebCore::ContentExtensions::instructionSizeWithArguments): 48 * contentextensions/DFABytecodeCompiler.cpp: 49 (WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction): 50 * contentextensions/DFABytecodeInterpreter.cpp: 51 (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction): 52 (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction): 53 (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsMatchingEverything): 54 (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): 55 (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot): Deleted. 56 * contentextensions/DFABytecodeInterpreter.h: 57 * loader/ResourceLoadInfo.h: 58 1 59 2015-07-20 Jeremy Jones <jeremyj@apple.com> 2 60 -
trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp
r186383 r187049 36 36 { 37 37 } 38 39 Vector<String> CompiledContentExtension::globalDisplayNoneSelectors()40 {41 DFABytecodeInterpreter interpreter(filtersWithoutDomainsBytecode(), filtersWithoutDomainsBytecodeLength());42 DFABytecodeInterpreter::Actions actionLocations = interpreter.actionsForDefaultStylesheetFromDFARoot();43 44 Vector<Action> globalActions;45 for (uint64_t actionLocation : actionLocations)46 globalActions.append(Action::deserialize(actions(), actionsLength(), static_cast<unsigned>(actionLocation)));47 48 Vector<String> selectors;49 for (Action& action : globalActions) {50 if (action.type() == ActionType::CSSDisplayNoneSelector)51 selectors.append(action.stringArgument());52 }53 54 return selectors;55 }56 38 57 39 } // namespace ContentExtensions -
trunk/Source/WebCore/contentextensions/CompiledContentExtension.h
r186383 r187049 49 49 virtual const SerializedActionByte* actions() const = 0; 50 50 virtual unsigned actionsLength() const = 0; 51 Vector<String> globalDisplayNoneSelectors();52 51 }; 53 52 -
trunk/Source/WebCore/contentextensions/ContentExtension.cpp
r186912 r187049 45 45 : m_identifier(identifier) 46 46 , m_compiledExtension(WTF::move(compiledExtension)) 47 , m_parsedGlobalDisplayNoneStyleSheet(false)48 47 { 48 DFABytecodeInterpreter withoutDomains(m_compiledExtension->filtersWithoutDomainsBytecode(), m_compiledExtension->filtersWithoutDomainsBytecodeLength()); 49 DFABytecodeInterpreter withDomains(m_compiledExtension->filtersWithDomainsBytecode(), m_compiledExtension->filtersWithDomainsBytecodeLength()); 50 for (uint64_t action : withoutDomains.actionsMatchingEverything()) { 51 ASSERT(static_cast<uint32_t>(action) == action); 52 m_universalActionsWithoutDomains.append(static_cast<uint32_t>(action)); 53 } 54 for (uint64_t action : withDomains.actionsMatchingEverything()) { 55 ASSERT((action & ~IfDomainFlag) == static_cast<uint32_t>(action)); 56 m_universalActionsWithDomains.append(action); 57 } 58 59 compileGlobalDisplayNoneStyleSheet(); 60 m_universalActionsWithoutDomains.shrinkToFit(); 61 m_universalActionsWithDomains.shrinkToFit(); 49 62 } 50 63 64 uint32_t ContentExtension::findFirstIgnorePreviousRules() const 65 { 66 auto* actions = m_compiledExtension->actions(); 67 uint32_t actionsLength = m_compiledExtension->actionsLength(); 68 uint32_t currentActionIndex = 0; 69 while (currentActionIndex < actionsLength) { 70 if (Action::deserializeType(actions, actionsLength, currentActionIndex) == ActionType::IgnorePreviousRules) 71 return currentActionIndex; 72 currentActionIndex += Action::serializedLength(actions, actionsLength, currentActionIndex); 73 } 74 return std::numeric_limits<uint32_t>::max(); 75 } 76 51 77 StyleSheetContents* ContentExtension::globalDisplayNoneStyleSheet() 52 78 { 53 if (m_parsedGlobalDisplayNoneStyleSheet)54 return m_globalDisplayNoneStyleSheet.get(); 79 return m_globalDisplayNoneStyleSheet.get(); 80 } 55 81 56 m_parsedGlobalDisplayNoneStyleSheet = true; 82 void ContentExtension::compileGlobalDisplayNoneStyleSheet() 83 { 84 uint32_t firstIgnorePreviousRules = findFirstIgnorePreviousRules(); 85 86 auto* actions = m_compiledExtension->actions(); 87 uint32_t actionsLength = m_compiledExtension->actionsLength(); 57 88 58 Vector<String> selectors = m_compiledExtension->globalDisplayNoneSelectors(); 59 if (selectors.isEmpty()) 60 return nullptr; 61 89 auto inGlobalDisplayNoneStyleSheet = [&](const uint32_t location) 90 { 91 return location < firstIgnorePreviousRules && Action::deserializeType(actions, actionsLength, location) == ActionType::CSSDisplayNoneSelector; 92 }; 93 62 94 StringBuilder css; 63 for (auto& selector : selectors) { 64 css.append(selector); 65 css.append("{"); 66 css.append(ContentExtensionsBackend::displayNoneCSSRule()); 67 css.append("}"); 95 for (uint32_t universalActionLocation : m_universalActionsWithoutDomains) { 96 if (inGlobalDisplayNoneStyleSheet(universalActionLocation)) { 97 if (!css.isEmpty()) 98 css.append(','); 99 Action action = Action::deserialize(actions, actionsLength, universalActionLocation); 100 ASSERT(action.type() == ActionType::CSSDisplayNoneSelector); 101 css.append(action.stringArgument()); 102 } 68 103 } 104 if (css.isEmpty()) 105 return; 106 css.append("{"); 107 css.append(ContentExtensionsBackend::displayNoneCSSRule()); 108 css.append("}"); 69 109 70 110 m_globalDisplayNoneStyleSheet = StyleSheetContents::create(); … … 73 113 m_globalDisplayNoneStyleSheet = nullptr; 74 114 75 return m_globalDisplayNoneStyleSheet.get(); 115 // These actions don't need to be applied individually any more. They will all be applied to every page as a precompiled style sheet. 116 m_universalActionsWithoutDomains.removeAllMatching(inGlobalDisplayNoneStyleSheet); 76 117 } 77 118 78 const DFABytecodeInterpreter::Actions& ContentExtension::cachedDomainActions(const String& domain)119 void ContentExtension::populateDomainCacheIfNeeded(const String& domain) 79 120 { 80 121 if (m_cachedDomain != domain) { … … 86 127 for (uint64_t action : domainActions) 87 128 m_cachedDomainActions.add(action); 129 130 m_cachedUniversalDomainActions.clear(); 131 for (uint64_t action : m_universalActionsWithDomains) { 132 ASSERT_WITH_MESSAGE((action & ~IfDomainFlag) == static_cast<uint32_t>(action), "Universal actions with domains should not have flags."); 133 if (!!(action & IfDomainFlag) == m_cachedDomainActions.contains(action)) 134 m_cachedUniversalDomainActions.append(static_cast<uint32_t>(action)); 135 } 136 m_cachedDomainActions.shrinkToFit(); 137 m_cachedUniversalDomainActions.shrinkToFit(); 88 138 m_cachedDomain = domain; 89 139 } 140 } 141 142 const DFABytecodeInterpreter::Actions& ContentExtension::cachedDomainActions(const String& domain) 143 { 144 populateDomainCacheIfNeeded(domain); 90 145 return m_cachedDomainActions; 146 } 147 148 const Vector<uint32_t>& ContentExtension::universalActionsWithDomains(const String& domain) 149 { 150 populateDomainCacheIfNeeded(domain); 151 return m_cachedUniversalDomainActions; 91 152 } 92 153 -
trunk/Source/WebCore/contentextensions/ContentExtension.h
r186912 r187049 50 50 StyleSheetContents* globalDisplayNoneStyleSheet(); 51 51 const DFABytecodeInterpreter::Actions& cachedDomainActions(const String& domain); 52 const Vector<uint32_t>& universalActionsWithoutDomains() { return m_universalActionsWithoutDomains; } 53 const Vector<uint32_t>& universalActionsWithDomains(const String& domain); 52 54 53 55 private: 54 56 ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&); 55 57 uint32_t findFirstIgnorePreviousRules() const; 58 56 59 String m_identifier; 57 60 Ref<CompiledContentExtension> m_compiledExtension; 61 58 62 RefPtr<StyleSheetContents> m_globalDisplayNoneStyleSheet; 59 bool m_parsedGlobalDisplayNoneStyleSheet;60 63 void compileGlobalDisplayNoneStyleSheet(); 64 61 65 String m_cachedDomain; 66 void populateDomainCacheIfNeeded(const String& domain); 62 67 DFABytecodeInterpreter::Actions m_cachedDomainActions; 68 Vector<uint32_t> m_cachedUniversalDomainActions; 69 70 Vector<uint32_t> m_universalActionsWithoutDomains; 71 Vector<uint64_t> m_universalActionsWithDomains; 63 72 }; 64 73 -
trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
r186957 r187049 252 252 URLFilterParser filtersWithDomainParser(filtersWithDomains); 253 253 254 bool ignorePreviousRulesSeen = false;255 254 for (unsigned ruleIndex = 0; ruleIndex < parsedRuleList.size(); ++ruleIndex) { 256 255 const ContentExtensionRule& contentExtensionRule = parsedRuleList[ruleIndex]; 257 256 const Trigger& trigger = contentExtensionRule.trigger(); 258 const Action& action = contentExtensionRule.action();259 257 ASSERT(trigger.urlFilter.length()); 260 258 … … 268 266 status = filtersWithoutDomainParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocationAndFlags); 269 267 if (status == URLFilterParser::MatchesEverything) { 270 if (!ignorePreviousRulesSeen271 && trigger.domainCondition == Trigger::DomainCondition::None272 && action.type() == ActionType::CSSDisplayNoneSelector273 && !trigger.flags)274 actionLocationAndFlags |= DisplayNoneStyleSheetFlag;275 268 universalActionsWithoutDomains.add(actionLocationAndFlags); 276 269 status = URLFilterParser::Ok; … … 301 294 } 302 295 ASSERT(status == URLFilterParser::Ok); 303 304 if (action.type() == ActionType::IgnorePreviousRules)305 ignorePreviousRulesSeen = true;306 296 } 307 297 LOG_LARGE_STRUCTURES(parsedRuleList, parsedRuleList.capacity() * sizeof(ContentExtensionRule)); // Doesn't include strings. -
trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp
r183195 r187049 40 40 } 41 41 42 Action Action::deserialize(const SerializedActionByte* actions, const u nsigned actionsLength, unsignedlocation)42 Action Action::deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location) 43 43 { 44 RELEASE_ASSERT(location < actionsLength); 44 45 switch (static_cast<ActionType>(actions[location])) { 45 46 case ActionType::BlockCookies: … … 50 51 return Action(ActionType::IgnorePreviousRules, location); 51 52 case ActionType::CSSDisplayNoneSelector: { 52 unsigned stringStartIndex = location + sizeof(ActionType) + sizeof(unsigned) + sizeof(bool); 53 uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool); 54 uint32_t stringStartIndex = location + headerLength; 53 55 RELEASE_ASSERT(actionsLength >= stringStartIndex); 54 u nsignedselectorLength = *reinterpret_cast<const unsigned*>(&actions[location + sizeof(ActionType)]);55 bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(u nsigned)];56 uint32_t selectorLength = *reinterpret_cast<const unsigned*>(&actions[location + sizeof(ActionType)]); 57 bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(uint32_t)]; 56 58 57 59 if (wideCharacters) { … … 64 66 case ActionType::CSSDisplayNoneStyleSheet: 65 67 case ActionType::InvalidAction: 68 default: 69 RELEASE_ASSERT_NOT_REACHED(); 70 } 71 } 72 73 ActionType Action::deserializeType(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location) 74 { 75 RELEASE_ASSERT(location < actionsLength); 76 ActionType type = static_cast<ActionType>(actions[location]); 77 switch (type) { 78 case ActionType::BlockCookies: 79 case ActionType::BlockLoad: 80 case ActionType::IgnorePreviousRules: 81 case ActionType::CSSDisplayNoneSelector: 82 return type; 83 case ActionType::CSSDisplayNoneStyleSheet: 84 case ActionType::InvalidAction: 85 default: 86 RELEASE_ASSERT_NOT_REACHED(); 87 } 88 } 89 90 uint32_t Action::serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location) 91 { 92 RELEASE_ASSERT(location < actionsLength); 93 switch (static_cast<ActionType>(actions[location])) { 94 case ActionType::BlockCookies: 95 case ActionType::BlockLoad: 96 case ActionType::IgnorePreviousRules: 97 return sizeof(ActionType); 98 case ActionType::CSSDisplayNoneSelector: { 99 uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool); 100 uint32_t stringStartIndex = location + headerLength; 101 RELEASE_ASSERT(actionsLength >= stringStartIndex); 102 uint32_t selectorLength = *reinterpret_cast<const unsigned*>(&actions[location + sizeof(ActionType)]); 103 bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(uint32_t)]; 104 105 if (wideCharacters) 106 return headerLength + selectorLength * sizeof(UChar); 107 return headerLength + selectorLength * sizeof(LChar); 108 } 109 case ActionType::CSSDisplayNoneStyleSheet: 110 case ActionType::InvalidAction: 111 default: 66 112 RELEASE_ASSERT_NOT_REACHED(); 67 113 } 68 114 } 69 115 70 } 116 } // namespace ContentExtensions 71 117 72 118 } // namespace WebCore -
trunk/Source/WebCore/contentextensions/ContentExtensionRule.h
r186957 r187049 158 158 } 159 159 160 static Action deserialize(const SerializedActionByte* actions, const unsigned actionsLength, uint32_t location); 160 static Action deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location); 161 static ActionType deserializeType(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location); 162 static uint32_t serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location); 161 163 162 164 void setExtensionIdentifier(const String& extensionIdentifier) { m_extensionIdentifier = extensionIdentifier; } -
trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
r186957 r187049 93 93 DFABytecodeInterpreter::Actions withoutDomainsActions = withoutDomainsInterpreter.interpret(urlCString, flags); 94 94 95 String domain = resourceLoadInfo.mainDocumentURL.host(); 95 96 DFABytecodeInterpreter withDomainsInterpreter(compiledExtension.filtersWithDomainsBytecode(), compiledExtension.filtersWithDomainsBytecodeLength()); 96 DFABytecodeInterpreter::Actions withDomainsActions = withDomainsInterpreter.interpretWithDomains(urlCString, flags, contentExtension->cachedDomainActions( resourceLoadInfo.mainDocumentURL.host()));97 DFABytecodeInterpreter::Actions withDomainsActions = withDomainsInterpreter.interpretWithDomains(urlCString, flags, contentExtension->cachedDomainActions(domain)); 97 98 98 99 const SerializedActionByte* actions = compiledExtension.actions(); … … 100 101 101 102 bool sawIgnorePreviousRules = false; 102 if (!withoutDomainsActions.isEmpty() || !withDomainsActions.isEmpty()) { 103 const Vector<uint32_t>& universalWithDomains = contentExtension->universalActionsWithDomains(domain); 104 const Vector<uint32_t>& universalWithoutDomains = contentExtension->universalActionsWithoutDomains(); 105 if (!withoutDomainsActions.isEmpty() || !withDomainsActions.isEmpty() || !universalWithDomains.isEmpty() || !universalWithoutDomains.isEmpty()) { 103 106 Vector<uint32_t> actionLocations; 104 actionLocations.reserveInitialCapacity(withoutDomainsActions.size() + withDomainsActions.size() );107 actionLocations.reserveInitialCapacity(withoutDomainsActions.size() + withDomainsActions.size() + universalWithoutDomains.size() + universalWithDomains.size()); 105 108 for (uint64_t actionLocation : withoutDomainsActions) 106 109 actionLocations.uncheckedAppend(static_cast<uint32_t>(actionLocation)); 107 110 for (uint64_t actionLocation : withDomainsActions) 108 111 actionLocations.uncheckedAppend(static_cast<uint32_t>(actionLocation)); 112 for (uint32_t actionLocation : universalWithoutDomains) 113 actionLocations.uncheckedAppend(actionLocation); 114 for (uint32_t actionLocation : universalWithDomains) 115 actionLocations.uncheckedAppend(actionLocation); 109 116 std::sort(actionLocations.begin(), actionLocations.end()); 110 117 … … 127 134 #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING 128 135 double addedTimeEnd = monotonicallyIncreasingTime(); 129 WTFLogAlways("Time added: %f microseconds %s", (addedTimeEnd - addedTimeStart) * 1.0e6, resourceLoadInfo.resourceURL.string().utf8().data());136 dataLogF("Time added: %f microseconds %s \n", (addedTimeEnd - addedTimeStart) * 1.0e6, resourceLoadInfo.resourceURL.string().utf8().data()); 130 137 #endif 131 138 return finalActions; -
trunk/Source/WebCore/contentextensions/DFABytecode.h
r186649 r187049 56 56 // The action to append (4 bytes). 57 57 AppendAction = 0x4, 58 AppendActionDefaultStylesheet = 0x5, 59 AppendActionWithIfDomain = 0x6, 58 AppendActionWithIfDomain = 0x5, 60 59 61 60 // TestFlagsAndAppendAction has two arguments: 62 61 // The flags to check before appending (2 bytes). 63 62 // The action to append (4 bytes). 64 TestFlagsAndAppendAction = 0x 7,65 TestFlagsAndAppendActionWithIfDomain = 0x 8,63 TestFlagsAndAppendAction = 0x6, 64 TestFlagsAndAppendActionWithIfDomain = 0x7, 66 65 67 66 // Terminate has no arguments. 68 Terminate = 0x 9,67 Terminate = 0x8, 69 68 70 69 // Jump has one argument: 71 70 // The distance to jump (1-4 bytes, signed). 72 Jump = 0x A,71 Jump = 0x9, 73 72 }; 74 73 … … 111 110 RELEASE_ASSERT_NOT_REACHED(); // Variable instruction size. 112 111 case DFABytecodeInstruction::AppendAction: 113 case DFABytecodeInstruction::AppendActionDefaultStylesheet:114 112 case DFABytecodeInstruction::AppendActionWithIfDomain: 115 113 return sizeof(DFABytecodeInstruction) + sizeof(uint32_t); -
trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp
r186649 r187049 82 82 // High bits are used to store flags. See compileRuleList. 83 83 if (action & ActionFlagMask) { 84 ASSERT(!(action & DisplayNoneStyleSheetFlag));85 84 if (action & IfDomainFlag) 86 85 append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain); … … 90 89 append<uint32_t>(m_bytecode, static_cast<uint32_t>(action)); 91 90 } else { 92 if (action & DisplayNoneStyleSheetFlag) { 93 RELEASE_ASSERT(!(action & IfDomainFlag)); 94 append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendActionDefaultStylesheet); 95 } else if (action & IfDomainFlag) 91 if (action & IfDomainFlag) 96 92 append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendActionWithIfDomain); 97 93 else -
trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
r186912 r187049 97 97 { 98 98 ASSERT(getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendAction 99 || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionWithIfDomain 100 || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionDefaultStylesheet); 99 || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionWithIfDomain); 101 100 uint64_t action = (ifDomain ? IfDomainFlag : 0) | static_cast<uint64_t>(getBits<uint32_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecodeInstruction))); 102 101 if (!m_domainActions || matchesDomain(action, *m_domainActions)) … … 105 104 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction); 106 105 ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionWithIfDomain)); 107 ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionDefaultStylesheet));108 106 } 109 107 … … 129 127 } 130 128 131 DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actions ForDefaultStylesheetFromDFARoot()129 DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsMatchingEverything() 132 130 { 133 131 Actions actions; … … 139 137 while (programCounter < dfaBytecodeLength) { 140 138 DFABytecodeInstruction instruction = getInstruction(m_bytecode, m_bytecodeLength, programCounter); 141 if (instruction == DFABytecodeInstruction::AppendAction DefaultStylesheet)139 if (instruction == DFABytecodeInstruction::AppendAction) 142 140 interpretAppendAction(programCounter, actions, false); 143 else if (instruction == DFABytecodeInstruction::AppendAction )144 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);141 else if (instruction == DFABytecodeInstruction::AppendActionWithIfDomain) 142 interpretAppendAction(programCounter, actions, true); 145 143 else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction) 146 144 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction); 147 else { 148 // actionsForDefaultStylesheetFromDFARoot should only be called on the DFA without domains, 149 // which should never have any actions with if-domain. 150 ASSERT(instruction != DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain); 151 ASSERT(instruction != DFABytecodeInstruction::AppendActionWithIfDomain); 145 else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain) 146 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain); 147 else 152 148 break; 153 }154 149 } 155 150 return actions; … … 180 175 programCounter += sizeof(uint32_t); 181 176 182 // Skip the default stylesheet actions on the DFA root. These are accessed via actionsForDefaultStylesheetFromDFARoot.177 // Skip the actions without flags on the DFA root. These are accessed via actionsMatchingEverything. 183 178 if (!dfaStart) { 184 179 while (programCounter < dfaBytecodeLength) { 185 180 DFABytecodeInstruction instruction = getInstruction(m_bytecode, m_bytecodeLength, programCounter); 186 if (instruction == DFABytecodeInstruction::AppendAction DefaultStylesheet)187 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction DefaultStylesheet);188 else if (instruction == DFABytecodeInstruction::AppendAction )189 interpretAppendAction(programCounter, actions, false);181 if (instruction == DFABytecodeInstruction::AppendAction) 182 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction); 183 else if (instruction == DFABytecodeInstruction::AppendActionWithIfDomain) 184 programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendActionWithIfDomain); 190 185 else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction) 191 186 interpretTestFlagsAndAppendAction(programCounter, flags, actions, false); 187 else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain) 188 interpretTestFlagsAndAppendAction(programCounter, flags, actions, true); 192 189 else 193 190 break; … … 197 194 } else { 198 195 ASSERT_WITH_MESSAGE(getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::AppendAction 199 && getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendAction, 196 && getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::AppendActionWithIfDomain 197 && getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendAction 198 && getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain, 200 199 "Triggers that match everything should only be in the first DFA."); 201 200 } -
trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h
r186912 r187049 52 52 Actions interpret(const CString&, uint16_t flags); 53 53 Actions interpretWithDomains(const CString&, uint16_t flags, const DFABytecodeInterpreter::Actions& domainActions); 54 Actions actions ForDefaultStylesheetFromDFARoot();54 Actions actionsMatchingEverything(); 55 55 56 56 private: -
trunk/Source/WebCore/loader/ResourceLoadInfo.h
r185621 r187049 63 63 const uint64_t ActionFlagMask = 0x0000FFFF00000000; 64 64 const uint64_t IfDomainFlag = 0x0001000000000000; 65 const uint64_t DisplayNoneStyleSheetFlag = 0x0002000000000000;66 65 67 66 ResourceType toResourceType(CachedResource::Type); -
trunk/Source/WebKit2/ChangeLog
r187047 r187049 1 2015-07-20 Alex Christensen <achristensen@webkit.org> 2 3 [Content Extensions] Cache actions with domains that match everything 4 https://bugs.webkit.org/show_bug.cgi?id=147050 5 6 Reviewed by Benjamin Poulain. 7 8 * UIProcess/API/APIUserContentExtensionStore.h: 9 1 10 2015-07-20 Gordon Sheridan <gordon_sheridan@apple.com> 2 11 -
trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h
r186649 r187049 52 52 // This should be incremented every time a functional change is made to the bytecode, file format, etc. 53 53 // to prevent crashing while loading old data. 54 const static uint32_t CurrentContentExtensionFileVersion = 5;54 const static uint32_t CurrentContentExtensionFileVersion = 6; 55 55 56 56 static UserContentExtensionStore& defaultStore();
Note: See TracChangeset
for help on using the changeset viewer.