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.
Created attachment 348978 [details] Patch
Created attachment 348982 [details] Patch
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.
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.
(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.
Created attachment 349046 [details] WIP
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 ***
<rdar://problem/44402790>
Migrated to https://github.com/gpuweb/WHLSL/issues/42