[WHLSL] Metal code generation #109
Comments
At 2018-07-17T18:43:10Z, tdenney@apple.com wrote: |
At 2018-07-17T18:45:29Z, ews@webkit.org wrote: ERROR: Tools/WebGPUShadingLanguageRI/Metal/tsconfig.json:14: Expecting property name enclosed in double quotes: line 14 column 9 (char 309) [json/syntax] [5] If any of these errors are false positives, please file a bug against check-webkit-style. |
At 2018-07-17T20:25:55Z, ews@webkit.org wrote: Attachment 345174 did not pass win-ews (win): New failing tests: |
At 2018-07-17T20:26:06Z, ews@webkit.org wrote: The attached test failures were seen while running run-webkit-tests on the win-ews. |
At 2018-07-17T21:24:11Z, dino@apple.com wrote: View in context: https://bugs.webkit.org/attachment.cgi?id=345174&action=review Can we have some tests that check input v expected output?
While this isn't C++ code, and also isn't JS code, we should probably still follow the coding guidelines. That would mean using // and ending the sentence with a full stop (period). The same goes for other comments in the patch.
Single line conditionals.
Single line conditionals don't use {} in WebKit.
No need for temporary local variable.
I assume TypeScript doesn't need break in cases?
Single line statement.
Ditto.
Use lineNumbers and lineNumber.
Single line.
Single line.
Single line.
Should you return if it isn't one of these types?
SIngle line.
Ditto.
For things like this we normally do early returns. e.g. if (this.ancestorReturnType.name === "void") { const resultVar.... Also, you don't need a `` string for the "return". I'm not sure there is really a performance win though.
Single line conditionals.
Single line.
Single line.
Single line.
Single line.
Again.
Again.
Again. I'll stop pointing them out now. |
At 2018-07-18T00:10:55Z, tdenney@apple.com wrote: |
At 2018-07-18T00:14:49Z, ews@webkit.org wrote: ERROR: Tools/WebGPUShadingLanguageRI/Metal/tsconfig.json:14: Expecting property name enclosed in double quotes: line 14 column 9 (char 309) [json/syntax] [5] If any of these errors are false positives, please file a bug against check-webkit-style. |
At 2018-07-18T02:28:40Z, tdenney@apple.com wrote: |
At 2018-07-18T02:30:04Z, tdenney@apple.com wrote: |
At 2018-08-28T03:06:19Z, tdenney@apple.com wrote: |
At 2018-08-29T17:03:51Z, tdenney@apple.com wrote: |
At 2018-09-01T03:22:53Z, tdenney@apple.com wrote: |
At 2018-09-04T22:05:35Z, tdenney@apple.com wrote: |
At 2018-09-04T23:31:17Z, tdenney@apple.com wrote: |
At 2018-09-05T01:43:19Z, ews@webkit.org wrote: Attachment 348869 did not pass mac-wk2-ews (mac-wk2): New failing tests: |
At 2018-09-05T01:43:21Z, ews@webkit.org wrote: The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. |
At 2018-09-06T23:57:22Z, mmaxfield@apple.com wrote: View in context: https://bugs.webkit.org/attachment.cgi?id=348869&action=review Halfway done reviewing
Why is this necessary to do in the constructor? Our code should be resilient to TypeRefs.
Can't we do this with a virtual function instead of hardcoding type names?
Why is this in its own file? It's only called in one place.
Does Javascript have the concept of namespaces? We want to make sure that the Metal backend's classes don't collide with any other codegen's classes. If there aren't real namespaces, we should prefix the names that get put in the global scope (probably except for whlslToMsl()).
Does this actually work? Is this tested? We should make sure this file and https://bugs.webkit.org/show_bug.cgi?id=189029 stay in sync
We should make a bug to add whatever infrastructure is necessary to allow inlining for every function.
Why not use the .origin property on parsed nodes? For every expression, you'll know where it came from in the source. No need to calculate it twice.
This is a layering inversion. The mangler is only used here for a single place; why doesn't whoever constructs a MSLFunctionDeclaration pass in the mangled name? This could also apply to the other arguments here.
Similar to above; this seems upside-down.
Do we have a bug for this? Seems important.
Doesn't Javascript have a better way to do string building? Even appending a bunch of strings to an array and then joining the array at the last minute would be better.
:( Open a bug?
Seems over-engineered. Getters/setters of a Number seems simpler.
If it can be inlined, then inline it? That seems like a non-optimal heuristic. We should have an explicit step to record whether or not each function should be inlined, and then this step will just consult that list. Initially, inlining nothing seems like the safest bet.
Samplers, textures
Bool matrices don't exist
Functions that don't return a sentinel don't need to be named "try"
Comments should answer "why," not "how." I recommend deleting these.
How about findReachableFunctions()?
We should probably allow Arrays (in addition to ArrayRefs). They are strictly less powerful.
This notion is better encapsulated with names (either of variables or the class)
I'm not sure why this is necessary. I think we should make the Checker always attach the type of everything to itself. It could be implemented with a getter that's overridden by every class.
Doesn't seem right. The type of an array ref is not equal to the inner type.
Why isn't the type of a BoolLiteral a bool? NullLiteral has a type...
Why not call super? (And ditto for all the other occurrences in this file)
I think this has been renamed to numElementsValue
Why just MakeArrayRefExpression? Shouldn't we be visiting every expression? Similarly, we should make sure every expression has a .type property.
Seems like this set will always have the exact same set of things as in declSet. Why have two?
We already have a WHLSL lexer. Why reimplement it?
I'd recommend a better name for this file. Also, using correct casing.
We've really got to find a better way to do this. https://bugs.webkit.org/show_bug.cgi?id=189378
:(
Why?
These have been moved to Casts.js
Are you are the extra argument to callFunction is right? Can we delete checkNumber()?
Ditto.
I've since deleted this, I think you'll need to rebase.
Why?
Why? |
At 2018-09-08T00:46:03Z, mmaxfield@apple.com wrote: View in context: https://bugs.webkit.org/attachment.cgi?id=348869&action=review
Why? For loops are implemented in the interpreter, why shouldn't they be implemented in Metal?
Wha happens if a continue is inside a switch inside a loop?
No need to smoosh together "statement" into "stmt"
Why don't blocks emit "{"?
What's the difference between _resultVar and the returned value?
All expressions should be saved into variables.
Should just assume this is bool. We prove that elsewhere.
I'd recommend putting this kind of thing in a follow-up patch.
All expressions should be saved into local variables.
We should be mapping variables to names, not names to names. That way we can unify these paths.
Anonymous variables should be treated exactly the same as regular variables.
I think you mean lhs here
Without inlining, this is no longer correct.
This isn't right. This should be a trap, the whole program should stop executing. We want more than just the current function to return zeroes.
Ditto.
Ditto
Why does the field access care what type the inner thing is? We should try to make it so that we can just do a recursive call here and the right thing happens.
Which anders aren't implemented in the language?
Yes please. See the above comment for _handleFieldAccess
Why doesn't this get saved into a variable?
Why is it necessary to create a new MSLStatementEmitter? Why can't we just keep recursing?
Why?
No need for this comment
Why parentheses?
There should be a function which takes a lambda that does the indent/unindent for you
We should throw exceptions for these. Writing out the location might be valuable for your own debugging, but it isn't for committing |
At 2018-09-08T00:52:52Z, tdenney@apple.com wrote:
The initializer, condition, or the increment of the for loop may be a compound expression in WHLSL that has to compile to several statements in Metal. It is awkward to retain the for loop structure in Metal. |
At 2018-09-08T02:21:03Z, mmaxfield@apple.com wrote:
👍 |
At 2018-09-11T16:40:48Z, tdenney@apple.com wrote:
They’re still in master. |
At 2018-09-12T02:35:16Z, tdenney@apple.com wrote: |
At 2018-09-12T06:02:55Z, ews@webkit.org wrote: Attachment 349505 did not pass mac-wk2-ews (mac-wk2): New failing tests: |
At 2018-09-12T06:02:57Z, ews@webkit.org wrote: The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. |
At 2018-09-12T20:57:03Z, tdenney@apple.com wrote:
I think this is OK. In WHLSL/C/C++ using a continue in a switch in a loop still affects the outer loop. _emitLoopBodyEnd just emits the loop increment statement and the condition statement, so the semantics are retained. |
At 2018-09-13T01:52:23Z, webkit-bug-importer@group.apple.com wrote: |
At 2018-09-13T02:10:43Z, tdenney@apple.com wrote: |
At 2018-09-13T20:50:55Z, tdenney@apple.com wrote: |
At 2018-09-14T02:37:58Z, tdenney@apple.com wrote:
MSLFunctionForwardDeclaration and MSLFunctionDefinition are concrete subclasses of this class, and they each use all of the parameters; the former uses them for correctly constructing all of the parameters (e.g. with attributes) whilst the latter needs to pass all of them to its internal MSLStatementEmitter, which then needs to use the function name mangler for function calls, the parameter map for extending to the internal variable map, and the type attributes for correctly accessing type properties. |
At 2018-09-14T04:49:13Z, tdenney@apple.com wrote: |
At 2018-09-14T06:04:59Z, tdenney@apple.com wrote: |
At 2018-09-14T22:19:59Z, tdenney@apple.com wrote: |
At 2018-09-14T23:18:34Z, tdenney@apple.com wrote: |
At 2018-09-15T00:40:14Z, ews@webkit.org wrote: Attachment 349826 did not pass mac-wk2-ews (mac-wk2): New failing tests: |
At 2018-09-15T00:40:16Z, ews@webkit.org wrote: The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. |
Committed r236299: https://trac.webkit.org/changeset/236299 |
Migrated from https://bugs.webkit.org/show_bug.cgi?id=187735:
At 2018-07-17T18:42:47Z, tdenney@apple.com wrote:
Adding WHLSL compiler
The text was updated successfully, but these errors were encountered: