Bug 198426 - [WHLSL] Auto initialize local variables
Summary: [WHLSL] Auto initialize local variables
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:
Blocks: 195771
  Show dependency treegraph
 
Reported: 2019-05-31 10:47 PDT by Saam Barati
Modified: 2019-06-10 12:59 PDT (History)
8 users (show)

See Also:


Attachments
patch (40.32 KB, patch)
2019-05-31 10:59 PDT, Saam Barati
mmaxfield: review+
Details | Formatted Diff | Diff
patch for landing (40.50 KB, patch)
2019-06-10 11:52 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch for landing (40.49 KB, patch)
2019-06-10 11:54 PDT, Saam Barati
no flags 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-05-31 10:47:14 PDT
...
Comment 1 Saam Barati 2019-05-31 10:59:38 PDT
Created attachment 371069 [details]
patch
Comment 2 Saam Barati 2019-05-31 11:00:27 PDT
Comment on attachment 371069 [details]
patch

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

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp:66
> +        StringPrintStream printStream;
> +        printStream.print(TypeDumper(*type));

Is this overkill just to get a nice function name? I could make this happen just on debug builds, and use some constant name for release builds.
Comment 3 Myles C. Maxfield 2019-06-06 06:28:18 PDT
Comment on attachment 371069 [details]
patch

Please see my comments in https://bugs.webkit.org/show_bug.cgi?id=195771. Should that bug be marked as a duplicate of this one?
Comment 4 Saam Barati 2019-06-10 11:34:36 PDT
(In reply to Myles C. Maxfield from comment #5)
> Comment on attachment 371047 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=371047&action=review
> 
> Does the Metal compiler still produce warnings now?
> GPURenderPipelineMetal.mm has a FIXME with a link to this bug.
> 
> > Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp:54
> > +        // Skip argument declarations.
> 
> Cool.
> 
> > Source/WebCore/Modules/webgpu/WHLSL/WHLSLAutoInitializeVariables.cpp:66
> > +        printStream.print(TypeDumper(*type));
> 
> 🤔 This seems unwise, though I do understand how it isn't observable. Are
> you confident this is a good idea?
I will make this debug builds only.

> 
> > Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp:-360
> > -        auto* overload = resolveFunctionOverloadImpl(*getterFuncs, argumentTypeReferences, nullptr);
> 
> Excellent.
> 
> > Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:73
> > +    void setInitializer(UniqueRef<Expression> expression)
> 
> Doesn't this need to take an rvalue reference? UniqueRef is move-only (I
> think???)
Rvalue references are just a cast. What happens here is a caller must move the argument into this value, calling the move constructor.

> 
> > Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:453
> >          m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(*variableDeclaration.type()), ' ', variableName, ";\n"));
> 
> Is this dead code now?
No. Since there are passes that run after this that create variables without initializers.

> 
> > Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:110
> > +            stringBuilder.append(makeString("    for (size_t i = 0; i < sizeof(", metalReturnName, "); ++i) {\n"));
> > +            stringBuilder.append("        ptr[i] = 0;\n");
> > +            stringBuilder.append("    }\n");
> 
> Can we remove the { } and pull it up into one line?

Sure!
Comment 5 Saam Barati 2019-06-10 11:52:37 PDT
Created attachment 371767 [details]
patch for landing
Comment 6 Saam Barati 2019-06-10 11:54:15 PDT
Created attachment 371768 [details]
patch for landing
Comment 7 WebKit Commit Bot 2019-06-10 12:58:25 PDT
Comment on attachment 371768 [details]
patch for landing

Clearing flags on attachment: 371768

Committed r246273: <https://trac.webkit.org/changeset/246273>
Comment 8 WebKit Commit Bot 2019-06-10 12:58:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2019-06-10 12:59:17 PDT
<rdar://problem/51593411>