RESOLVED DUPLICATE of bug 188641 189326
[WHLSL] The interpreter should evaluate arguments right-to-left
https://bugs.webkit.org/show_bug.cgi?id=189326
Summary [WHLSL] The interpreter should evaluate arguments right-to-left
Thomas Denney
Reported 2018-09-05 16:17:52 PDT
In order to be consistent with C, the arguments of function calls should be evaluated right-to-left. C doesn’t define an evaluation order for operators (like +) but because we treat them as “native functions” we should strictly evaluate them right-to-left.
Attachments
Patch (3.40 KB, patch)
2018-09-05 16:21 PDT, Thomas Denney
no flags
Patch (3.75 KB, patch)
2018-09-05 17:12 PDT, Thomas Denney
no flags
WIP (4.83 KB, patch)
2018-09-06 11:24 PDT, Thomas Denney
no flags
Thomas Denney
Comment 1 2018-09-05 16:21:52 PDT
Thomas Denney
Comment 2 2018-09-05 17:12:43 PDT
Alex Christensen
Comment 3 2018-09-05 18:20:20 PDT
Comment on attachment 348982 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=348982&action=review This order is not determined in C or C++, but it is commonly evaluated in a consistent order for reasons. See https://en.cppreference.com/w/c/language/eval_order I think it would be great if WHLSL had a defined order, but don't claim it's to be consistent with C. > Tools/ChangeLog:8 > + The behavior of the interpreter now matches the behavior of the compiler What compiler are you talking about? It's possible the behavior of that compiler is unspecified but it happens to be right-to-left in all the cases you've checked.
Myles C. Maxfield
Comment 4 2018-09-05 19:12:39 PDT
Comment on attachment 348982 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=348982&action=review > Tools/WebGPUShadingLanguageRI/Test.js:7637 > + int foo() { return *bar(10) + *bar(20); } > + > + thread int* bar(int value) > + { > + int x = value; > + return &x; > + } I don't think we should commit a test that is fundamentally wrong.
Thomas Denney
Comment 5 2018-09-05 19:26:10 PDT
(In reply to Alex Christensen from comment #3) > Comment on attachment 348982 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=348982&action=review > > This order is not determined in C or C++, but it is commonly evaluated in a > consistent order for reasons. See > https://en.cppreference.com/w/c/language/eval_order > I think it would be great if WHLSL had a defined order, but don't claim it's > to be consistent with C. > > > Tools/ChangeLog:8 > > + The behavior of the interpreter now matches the behavior of the compiler > > What compiler are you talking about? It's possible the behavior of that > compiler is unspecified but it happens to be right-to-left in all the cases > you've checked. The WHLSL -> Metal code generation generates code so that the arguments are explicitly evaluated right-to-left before the function call and are then passed separately.
Thomas Denney
Comment 6 2018-09-06 11:24:10 PDT
Thomas Denney
Comment 7 2018-09-10 16:22:43 PDT
The most recent patch of https://bugs.webkit.org/show_bug.cgi?id=188641 resolves this, and it would only be a two line change to that patch to resolve this bug. *** This bug has been marked as a duplicate of bug 188641 ***
Radar WebKit Bug Importer
Comment 8 2018-09-12 18:41:25 PDT
Myles C. Maxfield
Comment 9 2018-10-13 14:35:40 PDT
Note You need to log in before you can comment on or make changes to this bug.