RESOLVED FIXED 126199
Use the Selector Code Generator for resolving style
https://bugs.webkit.org/show_bug.cgi?id=126199
Summary Use the Selector Code Generator for resolving style
Benjamin Poulain
Reported 2013-12-23 19:02:32 PST
Use the Selector Code Generator for resolving style
Attachments
Patch (4.38 KB, patch)
2013-12-23 19:03 PST, Benjamin Poulain
no flags
Patch (4.90 KB, patch)
2014-01-12 17:29 PST, Benjamin Poulain
no flags
Patch (4.74 KB, patch)
2014-01-12 22:04 PST, Benjamin Poulain
rniwa: review+
Benjamin Poulain
Comment 1 2013-12-23 19:03:03 PST
EFL EWS Bot
Comment 2 2013-12-23 19:07:19 PST
EFL EWS Bot
Comment 3 2013-12-23 20:48:18 PST
kov's GTK+ EWS bot
Comment 4 2013-12-23 22:47:09 PST
Antti Koivisto
Comment 5 2013-12-26 12:15:25 PST
Comment on attachment 219952 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=219952&action=review > Source/WebCore/css/ElementRuleCollector.cpp:301 > inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, PseudoId& dynamicPseudo) > { > const StyleResolver::State& state = m_state; > +#if ENABLE(CSS_SELECTOR_JIT) > + void* compiledSelectorChecker = ruleData.compiledSelectorCodeRef.code().executableAddress(); > + if (!compiledSelectorChecker && ruleData.compilationStatus == SelectorCompilationStatus::NotCompiled) { > + JSC::VM* vm = document().scriptExecutionContext()->vm(); > + ruleData.compilationStatus = SelectorCompiler::compileSelector(ruleData.selector(), vm, ruleData.compiledSelectorCodeRef); > + compiledSelectorChecker = ruleData.compiledSelectorCodeRef.code().executableAddress(); > + } This compiles too eagerly. If you look below in ruleData.hasFastCheckableSelector() branch you see there are number of cases we resolve without calling into SelectorCheckerFastPath at all. Those cases will use more memory and may get slower by activating the JIT. We should probably not compile selectors that are in this category. Does the infrastructure support compiling off the main thread? I think optimally we would kick off the compiling during RuleData construction and use the compiled versions when ready. > Source/WebCore/css/ElementRuleCollector.cpp:312 > + if (compiledSelectorChecker) { > + if (ruleData.compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) { > + if (m_pseudoStyleRequest.pseudoId != NOPSEUDO) > + return false; > + SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, ruleData.compilationStatus); > + return selectorChecker(state.element()); > + } > + ASSERT(ruleData.compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext); > + > + if (m_pseudoStyleRequest.pseudoId != NOPSEUDO) > + return false; NOPSEUDO tests can move before the compilationStatus check and combined. > Source/WebCore/css/RuleSet.h:84 > +#if ENABLE(CSS_SELECTOR_JIT) > + mutable SelectorCompilationStatus compilationStatus; > + mutable JSC::MacroAssemblerCodeRef compiledSelectorCodeRef; > +#endif // ENABLE(CSS_SELECTOR_JIT) These fields should be optimized for memory at some point (I think we can manage with 64bits or less for all this). We can have large numbers of selectors and so RuleDatas. We also shouldn't generate code for simplest selectors that are resolved by hash look-ups and don't need overhead of even having these fields.
Benjamin Poulain
Comment 6 2014-01-12 17:29:18 PST
EFL EWS Bot
Comment 7 2014-01-12 19:41:24 PST
kov's GTK+ EWS bot
Comment 8 2014-01-12 20:54:17 PST
EFL EWS Bot
Comment 9 2014-01-12 21:45:20 PST
Benjamin Poulain
Comment 10 2014-01-12 22:04:24 PST
Ryosuke Niwa
Comment 11 2014-01-13 08:40:06 PST
Comment on attachment 221004 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=221004&action=review > Source/WebCore/css/ElementRuleCollector.cpp:312 > + JSC::VM* vm = document().scriptExecutionContext()->vm(); We should be using a reference instead in all these places (probably should be done in a separate patch though). > Source/WebCore/css/ElementRuleCollector.cpp:321 > + SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, ruleData.compilationStatus); Do we really need this temporary variable? Also, isn't this the case where auto will be useful? Since this is a function pointer into a JIT'ed code, type doesn't give us any extra information anyway. > Source/WebCore/css/RuleSet.h:84 > +#if ENABLE(CSS_SELECTOR_JIT) > + mutable SelectorCompilationStatus compilationStatus; > + mutable JSC::MacroAssemblerCodeRef compiledSelectorCodeRef; > +#endif // ENABLE(CSS_SELECTOR_JIT) > + These should really be private and have accessors instead.
Benjamin Poulain
Comment 12 2014-01-13 16:23:46 PST
Note You need to log in before you can comment on or make changes to this bug.