Bug 126185 - Use the Selector Code Generator for matching in SelectorQuery
Summary: Use the Selector Code Generator for matching in SelectorQuery
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-23 15:17 PST by Benjamin Poulain
Modified: 2014-01-13 03:23 PST (History)
19 users (show)

See Also:


Attachments
Patch (25.57 KB, patch)
2013-12-23 15:21 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (25.48 KB, patch)
2013-12-26 06:43 PST, Benjamin Poulain
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
Patch (25.48 KB, patch)
2014-01-02 03:42 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (25.87 KB, patch)
2014-01-03 06:59 PST, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2013-12-23 15:17:11 PST
Use the Selector Code Generator for matching in SelectorQuery
Comment 1 Benjamin Poulain 2013-12-23 15:21:02 PST
Created attachment 219936 [details]
Patch
Comment 2 Ryosuke Niwa 2013-12-23 16:05:29 PST
Comment on attachment 219936 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=219936&action=review

> Source/WebCore/dom/SelectorQuery.cpp:329
> +#if ENABLE(CSS_SELECTOR_JIT)
> +            void* compiledSelectorChecker = selectorData.compiledSelectorCodeRef.code().executableAddress();
> +            if (!compiledSelectorChecker && selectorData.compilationStatus == SelectorCompilationStatus::NotCompiled) {
> +                JSC::VM* vm = rootNode.document().scriptExecutionContext()->vm();
> +                selectorData.compilationStatus = SelectorCompiler::compileSelector(selectorData.selector, vm, selectorData.compiledSelectorCodeRef);
> +            }
> +
> +            if (compiledSelectorChecker) {
> +                if (selectorData.compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) {
> +                    SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, selectorData.compilationStatus);
> +                    executeCompiledSimpleSelectorChecker<SelectorQueryTrait>(rootNode, selectorChecker, output);
> +                } else {
> +                    ASSERT(selectorData.compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
> +                    SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::selectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, selectorData.compilationStatus);
> +
> +                    SelectorCompiler::CheckingContext context;
> +                    context.elementStyle = nullptr;
> +                    context.resolvingMode = SelectorChecker::QueryingRules;
> +                    executeCompiledSelectorCheckerWithContext<SelectorQueryTrait>(rootNode, selectorChecker, context, output);
> +                }
> +                return;
> +            }
> +#endif // ENABLE(CSS_SELECTOR_JIT)

This function is getting really big now. Would it make sense to extract this as a separate inline function instead?

> Source/WebCore/dom/SelectorQuery.h:63
> +        mutable SelectorCompilationStatus compilationStatus;
> +        mutable JSC::MacroAssemblerCodeRef compiledSelectorCodeRef;

It seems like we could encapsulate these two variables into one struct in SelectorCompiler.h

> LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking.html:4
> +<script src="../../resources/js-test-pre.js"></script>

We can put this in the body.

> LayoutTests/fast/selectors/querySelector-long-child-backtracking.html:4
> +<script src="../../resources/js-test-pre.js"></script>

Ditto.

> LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking.html:4
> +<script src="../../resources/js-test-pre.js"></script>

Ditto.

> LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking.html:4
> +<script src="../../resources/js-test-pre.js"></script>

Ditto.

> LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking.html:3
> +<head>

Ditto.

> LayoutTests/fast/selectors/querySelector-simple-child-backtracking.html:4
> +<script src="../../resources/js-test-pre.js"></script>

Ditto.
Comment 3 EFL EWS Bot 2013-12-23 16:27:59 PST
Comment on attachment 219936 [details]
Patch

Attachment 219936 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/49998311
Comment 4 kov's GTK+ EWS bot 2013-12-23 18:16:17 PST
Comment on attachment 219936 [details]
Patch

Attachment 219936 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/48148598
Comment 5 EFL EWS Bot 2013-12-23 19:35:49 PST
Comment on attachment 219936 [details]
Patch

Attachment 219936 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/51288044
Comment 6 Benjamin Poulain 2013-12-26 06:43:52 PST
Created attachment 220032 [details]
Patch
Comment 7 EFL EWS Bot 2013-12-26 06:50:03 PST
Comment on attachment 220032 [details]
Patch

Attachment 220032 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/6529312899465216
Comment 8 EFL EWS Bot 2013-12-26 06:51:28 PST
Comment on attachment 220032 [details]
Patch

Attachment 220032 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/4545682790678528
Comment 9 kov's GTK+ EWS bot 2013-12-26 06:52:29 PST
Comment on attachment 220032 [details]
Patch

Attachment 220032 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/5407948478087168
Comment 10 Antti Koivisto 2013-12-26 12:19:51 PST
Comment on attachment 220032 [details]
Patch

Looks good!
Comment 11 Benjamin Poulain 2014-01-02 03:42:59 PST
Created attachment 220216 [details]
Patch

Let's see if GTK and EFL build now...
Comment 12 EFL EWS Bot 2014-01-02 04:02:26 PST
Comment on attachment 220216 [details]
Patch

Attachment 220216 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/6374351821602816
Comment 13 kov's GTK+ EWS bot 2014-01-02 04:04:27 PST
Comment on attachment 220216 [details]
Patch

Attachment 220216 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/4966976938049536
Comment 14 EFL EWS Bot 2014-01-02 04:05:55 PST
Comment on attachment 220216 [details]
Patch

Attachment 220216 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/6346239650037760
Comment 15 Csaba Osztrogonác 2014-01-02 08:48:26 PST
Comment on attachment 220216 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=220216&action=review

> Source/WebCore/dom/SelectorQuery.h:32
> +#include <JavaScriptCore/MacroAssemblerCodeRef.h>

This kind of include is supported only by Mac, because 
forwarding headers aren't generated for WebCore.
Comment 16 Philippe Normand 2014-01-02 09:18:12 PST
Comment on attachment 220216 [details]
Patch

It seems that Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h is not referenced in Source/JavaScriptCore/GNUmakefile.list.am. Can you please add it? Not sure it would fix the build though.
Comment 17 Gyuyoung Kim 2014-01-02 17:09:13 PST
(In reply to comment #15)
> (From update of attachment 220216 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=220216&action=review
> 
> > Source/WebCore/dom/SelectorQuery.h:32
> > +#include <JavaScriptCore/MacroAssemblerCodeRef.h>
> 
> This kind of include is supported only by Mac, because 
> forwarding headers aren't generated for WebCore.

EFL port already includes "JavaScriptCore/assembler". So, if you modify to include the "MacroAssemblerCodeRef.h" as below, it works fine.

#include "MacroAssemblerCodeRef.h"
Comment 18 Benjamin Poulain 2014-01-03 06:59:27 PST
Created attachment 220301 [details]
Patch
Comment 19 Benjamin Poulain 2014-01-12 15:01:30 PST
Committed r161839: <http://trac.webkit.org/changeset/161839>
Comment 20 Csaba Osztrogonác 2014-01-13 03:23:05 PST
(In reply to comment #19)
> Committed r161839: <http://trac.webkit.org/changeset/161839>

It broke the WinCairo build:

     1>c:\projects\buildslave\win-cairo-release\build\webkitbuild\release_wincairo\include\private\javascriptcore\X86Assembler.h(2348): warning C4309: 'argument' : truncation of constant value (..\dom\DOMAllInOne.cpp)
     1>c:\projects\buildslave\win-cairo-release\build\source\webcore\dom\SelectorQuery.h(31): fatal error C1083: Cannot open include file: 'SelectorCompiler.h': No such file or directory (..\dom\DOMAllInOne.cpp)
     1>Done Building Project "C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj" (Build target(s)) -- FAILED.