Bug 201251 - [WHLSL] Add back a version of the property resolver
Summary: [WHLSL] Add back a version of the property resolver
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on: 201008
Blocks:
  Show dependency treegraph
 
Reported: 2019-08-28 16:53 PDT by Saam Barati
Modified: 2019-09-13 16:29 PDT (History)
8 users (show)

See Also:


Attachments
WIP (9.21 KB, patch)
2019-09-05 14:23 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (16.76 KB, patch)
2019-09-05 17:49 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
WIP (22.13 KB, patch)
2019-09-05 18:59 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch (29.32 KB, patch)
2019-09-06 16:30 PDT, Saam Barati
rmorisset: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2019-08-28 16:53:09 PDT
The goal will be to:
- make each property access's base effect free so metal codegen can emit 
- make the leftmost base of RMW effect free so we can emit the "leftValue()" twice
Comment 1 Saam Barati 2019-08-28 17:33:18 PDT
and add back all the property resolver tests that make sense in this new world
Comment 2 Saam Barati 2019-08-30 14:10:43 PDT
also we'll want the "high zombie finder" to have some new rules
Comment 3 Saam Barati 2019-09-05 14:23:14 PDT
Created attachment 378121 [details]
WIP

it begins
Comment 4 Saam Barati 2019-09-05 17:49:44 PDT
Created attachment 378142 [details]
WIP

it seems to work.
Comment 5 Saam Barati 2019-09-05 18:59:57 PDT
Created attachment 378151 [details]
WIP

I think it's done, I just want to write some more tests
Comment 6 Saam Barati 2019-09-06 16:30:01 PDT
Created attachment 378251 [details]
patch
Comment 7 Robin Morisset 2019-09-06 17:21:23 PDT
Comment on attachment 378251 [details]
patch

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

r=me

> Source/WebCore/ChangeLog:9
> +        The goal of the new property resolver phase is two allow two things:

two allow => to allow

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:90
> +        while (true) {

This pattern of
```
while(true) {
..
chain.append(current);
if (is<AST::PropertyAccessExpression>(current.base()))
  continue;
Tons of code that only executes once
break;
}
```
is not super readable. It is probably not worth modifying now, but I am curious, why not just use the loop to accumulate the chain:
```
while (is<AST::PropertyAccessExpression>(current.base())) {
  append to chain
  current = *currentPtr;
}
tons of code that manipulate current but are now outside of the loop
```

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:245
> +        RELEASE_ASSERT(m_variables.isEmpty());

There is no guarantee that the WTFMove later on will empty-out m_variables.
I think you need to either empty it by hand, or more simply to construct a different PropertyResolver for each function definition in resolveProperties.

> Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:63
> +    ReadModifyWriteExpression(CodeLocation location, UniqueRef<Expression> leftValue, UniqueRef<VariableDeclaration> oldValue, UniqueRef<VariableDeclaration> newValue)

I am unclear on whether it is better to pass UniqueRef<Expression> or UniqueRef<Expression>&& here.
Comment 8 Saam Barati 2019-09-08 20:12:17 PDT
Comment on attachment 378251 [details]
patch

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

>> Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:90
>> +        while (true) {
> 
> This pattern of
> ```
> while(true) {
> ..
> chain.append(current);
> if (is<AST::PropertyAccessExpression>(current.base()))
>   continue;
> Tons of code that only executes once
> break;
> }
> ```
> is not super readable. It is probably not worth modifying now, but I am curious, why not just use the loop to accumulate the chain:
> ```
> while (is<AST::PropertyAccessExpression>(current.base())) {
>   append to chain
>   current = *currentPtr;
> }
> tons of code that manipulate current but are now outside of the loop
> ```

fixed.

>> Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:245
>> +        RELEASE_ASSERT(m_variables.isEmpty());
> 
> There is no guarantee that the WTFMove later on will empty-out m_variables.
> I think you need to either empty it by hand, or more simply to construct a different PropertyResolver for each function definition in resolveProperties.

that's how move constructor of Vector works. It swaps with empty vector, so it should be emptied out.

>> Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:63
>> +    ReadModifyWriteExpression(CodeLocation location, UniqueRef<Expression> leftValue, UniqueRef<VariableDeclaration> oldValue, UniqueRef<VariableDeclaration> newValue)
> 
> I am unclear on whether it is better to pass UniqueRef<Expression> or UniqueRef<Expression>&& here.

I prefer what I did here since it expressed the fact that this function now has ownership over the UniqueRef. I'm not a fan of passing around rvalue refs since it doesn't actually guarantee that ownership will be transferred.
Comment 9 Saam Barati 2019-09-08 20:23:50 PDT
thanks for the review.


Landed in:
https://trac.webkit.org/changeset/249630/webkit
Comment 10 Saam Barati 2019-09-09 13:55:10 PDT
landed watchOS build fix in:
https://trac.webkit.org/changeset/249664/webkit
Comment 11 Radar WebKit Bug Importer 2019-09-09 13:56:19 PDT
<rdar://problem/55196672>
Comment 12 Robin Morisset 2019-09-13 16:29:50 PDT
This patch turns out to create comma expressions on the left-side of assignments.
It is not something which could otherwise happen. Do we want to support it, or to change this pass?