Bug 177044 - WSL needs a way to verify that structs are not cyclic
Summary: WSL needs a way to verify that structs are not cyclic
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords: InRadar
Depends on:
Blocks: 176199
  Show dependency treegraph
 
Reported: 2017-09-16 19:18 PDT by Filip Pizlo
Modified: 2018-10-13 16:36 PDT (History)
2 users (show)

See Also:


Attachments
the patch (19.21 KB, patch)
2017-09-20 23:00 PDT, Filip Pizlo
mmaxfield: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2017-09-16 19:18:18 PDT
...
Comment 1 Filip Pizlo 2017-09-20 23:00:46 PDT
Created attachment 321412 [details]
the patch
Comment 2 Myles C. Maxfield 2017-09-21 09:29:05 PDT
Comment on attachment 321412 [details]
the patch

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

> Tools/WebGPUShadingLanguageRI/Checker.js:64
> +        let shaderType = node;

This doesn’t seem right. Should this be shaderType = node.shaderType;?

> Tools/WebGPUShadingLanguageRI/Checker.js:85
>          switch (node.shaderType) {

... and you can use it here?

> Tools/WebGPUShadingLanguageRI/RecursiveTypeChecker.js:44
> +        this._visiting.doVisit(node, () => super.visitStructType(node));

So linked lists will work, but struct Foo { Foo x; int y; } won’t.

> Tools/WebGPUShadingLanguageRI/Test.js:4436
> +        () => checkInt(program, callFunction(program, "foo", [], []), -511),

I thought callFunction() caught theTrapError?

> Tools/WebGPUShadingLanguageRI/Test.js:4463
> +}

Can we test linked lists?

> Tools/WebGPUShadingLanguageRI/Visitor.js:-98
> -        Node.visit(node.type, this);

Why not? Because this type would be visited in some other part of the tree?
Comment 3 Filip Pizlo 2017-09-21 09:43:11 PDT
(In reply to Myles C. Maxfield from comment #2)
> Comment on attachment 321412 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=321412&action=review
> 
> > Tools/WebGPUShadingLanguageRI/Checker.js:64
> > +        let shaderType = node;
> 
> This doesn’t seem right. Should this be shaderType = node.shaderType;?

This should say "let shaderFunc = node"

> 
> > Tools/WebGPUShadingLanguageRI/Checker.js:85
> >          switch (node.shaderType) {
> 
> ... and you can use it here?
> 
> > Tools/WebGPUShadingLanguageRI/RecursiveTypeChecker.js:44
> > +        this._visiting.doVisit(node, () => super.visitStructType(node));
> 
> So linked lists will work, but struct Foo { Foo x; int y; } won’t.

Yeah

> 
> > Tools/WebGPUShadingLanguageRI/Test.js:4436
> > +        () => checkInt(program, callFunction(program, "foo", [], []), -511),
> 
> I thought callFunction() caught theTrapError?

I will fix this.  We need two versions of callFunction():

- A low-level version that does not catch trap error.
- A high-level version that does catch trap error.

We need the low-level one to write tests.

> 
> > Tools/WebGPUShadingLanguageRI/Test.js:4463
> > +}
> 
> Can we test linked lists?

I can add that.

> 
> > Tools/WebGPUShadingLanguageRI/Visitor.js:-98
> > -        Node.visit(node.type, this);
> 
> Why not? Because this type would be visited in some other part of the tree?

If we visit it here, then we'll get a JS stack overflow error anytime we try to typecheck a program with a linked list.
Comment 4 Filip Pizlo 2017-09-21 10:21:40 PDT
(In reply to Filip Pizlo from comment #3)
> (In reply to Myles C. Maxfield from comment #2)
> > Comment on attachment 321412 [details]
> > the patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=321412&action=review
> > 
> > > Tools/WebGPUShadingLanguageRI/Checker.js:64
> > > +        let shaderType = node;
> > 
> > This doesn’t seem right. Should this be shaderType = node.shaderType;?
> 
> This should say "let shaderFunc = node"
> 
> > 
> > > Tools/WebGPUShadingLanguageRI/Checker.js:85
> > >          switch (node.shaderType) {
> > 
> > ... and you can use it here?
> > 
> > > Tools/WebGPUShadingLanguageRI/RecursiveTypeChecker.js:44
> > > +        this._visiting.doVisit(node, () => super.visitStructType(node));
> > 
> > So linked lists will work, but struct Foo { Foo x; int y; } won’t.
> 
> Yeah
> 
> > 
> > > Tools/WebGPUShadingLanguageRI/Test.js:4436
> > > +        () => checkInt(program, callFunction(program, "foo", [], []), -511),
> > 
> > I thought callFunction() caught theTrapError?
> 
> I will fix this.  We need two versions of callFunction():
> 
> - A low-level version that does not catch trap error.
> - A high-level version that does catch trap error.
> 
> We need the low-level one to write tests.

Oh snap.  This "worked" because you added a TrapException instead of using WTrapError, and then you didn't convert all of the places that used WTrapError to use TrapException.

Please use WTrapError. :-)  I'll fix that part of your code, and refactor callFunction.
Comment 5 Filip Pizlo 2017-09-21 10:41:33 PDT
Landed in https://trac.webkit.org/changeset/222328/webkit
Comment 6 Radar WebKit Bug Importer 2017-09-27 12:56:07 PDT
<rdar://problem/34694297>
Comment 7 Myles C. Maxfield 2018-10-13 16:36:45 PDT
Migrated to https://github.com/gpuweb/WHLSL/issues/130