Bug 162941 - [DOMJIT] Add initial CheckDOM and CallDOM implementations
Summary: [DOMJIT] Add initial CheckDOM and CallDOM implementations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on: 162993
Blocks: 162544 162978
  Show dependency treegraph
 
Reported: 2016-10-04 14:48 PDT by Yusuke Suzuki
Modified: 2016-10-05 22:54 PDT (History)
14 users (show)

See Also:


Attachments
Patch (51.74 KB, patch)
2016-10-04 14:49 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (64.67 KB, patch)
2016-10-04 17:35 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (67.62 KB, patch)
2016-10-04 18:41 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (67.34 KB, patch)
2016-10-04 18:53 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (62.41 KB, patch)
2016-10-04 18:56 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (62.41 KB, patch)
2016-10-04 19:00 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (62.39 KB, patch)
2016-10-04 19:05 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (69.97 KB, patch)
2016-10-04 23:38 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (69.82 KB, patch)
2016-10-04 23:42 PDT, Yusuke Suzuki
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2016-10-04 14:48:51 PDT
[DOMJIT] Add initial CheckDOM and CallDOM implementations
Comment 1 Yusuke Suzuki 2016-10-04 14:49:13 PDT
Created attachment 290649 [details]
Patch

WIP
Comment 2 WebKit Commit Bot 2016-10-04 15:00:02 PDT
Attachment 290649 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 2 in 35 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Yusuke Suzuki 2016-10-04 17:35:42 PDT
Created attachment 290674 [details]
Patch

WIP
Comment 4 WebKit Commit Bot 2016-10-04 17:38:49 PDT
Attachment 290674 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 2 in 37 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Yusuke Suzuki 2016-10-04 18:41:04 PDT
Created attachment 290678 [details]
Patch
Comment 6 WebKit Commit Bot 2016-10-04 18:43:21 PDT
Attachment 290678 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 2 in 38 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Yusuke Suzuki 2016-10-04 18:44:57 PDT
Comment on attachment 290678 [details]
Patch

Fix build.
Comment 8 Yusuke Suzuki 2016-10-04 18:53:55 PDT
Created attachment 290680 [details]
Patch
Comment 9 Yusuke Suzuki 2016-10-04 18:56:52 PDT
Created attachment 290681 [details]
Patch
Comment 10 Yusuke Suzuki 2016-10-04 18:57:54 PDT
Comment on attachment 290681 [details]
Patch

Oops. Still fixing.
Comment 11 Yusuke Suzuki 2016-10-04 19:00:31 PDT
Created attachment 290682 [details]
Patch
Comment 12 WebKit Commit Bot 2016-10-04 19:02:01 PDT
Attachment 290682 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 2 in 37 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Yusuke Suzuki 2016-10-04 19:05:45 PDT
Created attachment 290683 [details]
Patch
Comment 14 WebKit Commit Bot 2016-10-04 19:09:00 PDT
Attachment 290683 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 2 in 37 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Yusuke Suzuki 2016-10-04 19:14:05 PDT
Comment on attachment 290683 [details]
Patch

Still fixing.......
Comment 16 Yusuke Suzuki 2016-10-04 23:38:22 PDT
Created attachment 290691 [details]
Patch
Comment 17 Yusuke Suzuki 2016-10-04 23:39:58 PDT
Rebasing
Comment 18 Yusuke Suzuki 2016-10-04 23:42:28 PDT
Created attachment 290692 [details]
Patch
Comment 19 WebKit Commit Bot 2016-10-04 23:44:36 PDT
Attachment 290692 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/bytecode/GetByIdStatus.h:47:  One space before end of line comments  [whitespace/comments] [5]
ERROR: Source/JavaScriptCore/dfg/DFGOpInfo.h:46:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/dfg/DFGNode.h:2458:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 3 in 40 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 20 Yusuke Suzuki 2016-10-05 01:41:30 PDT
Comment on attachment 290692 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:14
> +        JSNode::info().

Fan fact: This CheckDOM is almost always eliminated.
We typically write some DOM operation like,

node.firstChild

OR

document.getElementById("...");

At that time, for node.firstChild GetById access, we typically emit CheckStructure for node.
AI in this patch completely recognizes it and drop CheckDOM if filtered Structures are subclass of ClassInfo.

But still CheckDOM is useful if we would like to handle super polymorphic case (Dromaeo's firstChild use).
Comment 21 Alex Christensen 2016-10-05 08:54:39 PDT
cool!
Comment 22 Filip Pizlo 2016-10-05 15:38:59 PDT
Comment on attachment 290692 [details]
Patch

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

Nice!!

> Source/JavaScriptCore/b3/B3Effects.h:81
> +    static Effects forCheck()

This is great!

> Source/JavaScriptCore/b3/B3Value.cpp:617
> +        result = Effects::forCheck();

Nice.

> Source/JavaScriptCore/dfg/DFGAbstractValue.cpp:315
> +    m_structure.filterClassInfo(classInfo);

I like this. Can you file a bug about putting a ClassInfo field into AbstractValue. Then AI could do type-based tracking of value sets even better than now. When merging we would pick the lowest common ancestor. 

No need to do it now. Worth a fixme and bug.

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:2688
> +    addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(variant.structureSet())), thisNode);

This is a bit unfortunate. Is there any way to only have the CheckDOM and not the structure check?

> Source/JavaScriptCore/domjit/DOMJITReg.h:41
> +class Reg {

Crazy!  I think it's a good idea to have this separate from JSC::Reg/JSValueRegs for now but it sure seems like the rest of JSC will want this eventually. Can you file a bug and put a fixme for eventually moving this to JSC so others can use it?  For example B3::ValueRep does some of the same stuff, maybe it could delegate to your Reg class eventually.
Comment 23 Yusuke Suzuki 2016-10-05 16:45:48 PDT
Comment on attachment 290692 [details]
Patch

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

Thanks!

>> Source/JavaScriptCore/dfg/DFGAbstractValue.cpp:315
>> +    m_structure.filterClassInfo(classInfo);
> 
> I like this. Can you file a bug about putting a ClassInfo field into AbstractValue. Then AI could do type-based tracking of value sets even better than now. When merging we would pick the lowest common ancestor. 
> 
> No need to do it now. Worth a fixme and bug.

Sure! I've just opened the bug for this. https://bugs.webkit.org/show_bug.cgi?id=162989
And noted FIXME here with this URL.

>> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:2688
>> +    addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(variant.structureSet())), thisNode);
> 
> This is a bit unfortunate. Is there any way to only have the CheckDOM and not the structure check?

Yes! This mechanism should be fixed definitely.
This CheckStrucutre guards against Object.defineProperty(object, 'customGetter', { ... }) case.
But as you know, due to this check, we give up optimization in Dromaeo dom-traverse. This is because we encounter bunch of Structures here (HTMLDivElement, HTMLAnchorElement, etc.).
After initial DOMJIT accessor is implemented in WebCore, I'm planning to implement some mechanism to allow optimization here. It should involve AccessCases etc.

I discussed with rniwa and keith_miller before. At that time, we come up with one idea: putting bloom filter in each Structure that tells us this Structure *must not* have properties related to the given name.
I'll mail to you and Saam about the idea.

>> Source/JavaScriptCore/domjit/DOMJITReg.h:41
>> +class Reg {
> 
> Crazy!  I think it's a good idea to have this separate from JSC::Reg/JSValueRegs for now but it sure seems like the rest of JSC will want this eventually. Can you file a bug and put a fixme for eventually moving this to JSC so others can use it?  For example B3::ValueRep does some of the same stuff, maybe it could delegate to your Reg class eventually.

Yup! Filed. https://bugs.webkit.org/show_bug.cgi?id=162990
Comment 24 Yusuke Suzuki 2016-10-05 22:22:48 PDT
Committed r206846: <http://trac.webkit.org/changeset/206846>
Comment 25 Yusuke Suzuki 2016-10-05 22:41:22 PDT
Committed r206847: <http://trac.webkit.org/changeset/206847>
Comment 26 Yusuke Suzuki 2016-10-05 22:54:25 PDT
Committed r206848: <http://trac.webkit.org/changeset/206848>