Changeset 246625 in webkit


Ignore:
Timestamp:
Jun 19, 2019 7:05:28 PM (5 years ago)
Author:
sbarati@apple.com
Message:

[WHLSL] The checker needs to resolve types for the anonymous variables in ReadModifyWrite expressions
https://bugs.webkit.org/show_bug.cgi?id=198988

Reviewed by Dean Jackson and Myles C. Maxfield.

Source/WebCore:

This patch makes it so that the Checker assigns types to the internal variables
in a read modify write expression. These were the only variables that didn't have
types ascribed to them.

This patch also does a fly by fix where we kept pointers to value types
in a HashMap in the checker. This is wrong precisely when the HashMap gets
resized. Instead, we now just store the value itself since we're just
dealing with a simple Variant that wraps either an empty struct or an
enum.

Test: webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables.html

  • Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:

(WebCore::WHLSL::AST::VariableDeclaration::setType):
(WebCore::WHLSL::AST::VariableDeclaration::type const):

  • Modules/webgpu/WHLSL/WHLSLASTDumper.cpp: Make it obvious that read

modify write expressions are such by prefixing them with "RMW".
(WebCore::WHLSL::ASTDumper::visit):

  • Modules/webgpu/WHLSL/WHLSLChecker.cpp:

(WebCore::WHLSL::Checker::visit):

LayoutTests:

  • webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables-expected.txt: Added.
  • webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246621 r246625  
     12019-06-19  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL] The checker needs to resolve types for the anonymous variables in ReadModifyWrite expressions
     4        https://bugs.webkit.org/show_bug.cgi?id=198988
     5
     6        Reviewed by Dean Jackson and Myles C. Maxfield.
     7
     8        * webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables-expected.txt: Added.
     9        * webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables.html: Added.
     10
    1112019-06-19  Nikita Vasilyev  <nvasilyev@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r246616 r246625  
     12019-06-19  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL] The checker needs to resolve types for the anonymous variables in ReadModifyWrite expressions
     4        https://bugs.webkit.org/show_bug.cgi?id=198988
     5
     6        Reviewed by Dean Jackson and Myles C. Maxfield.
     7
     8        This patch makes it so that the Checker assigns types to the internal variables
     9        in a read modify write expression. These were the only variables that didn't have
     10        types ascribed to them.
     11
     12        This patch also does a fly by fix where we kept pointers to value types
     13        in a HashMap in the checker. This is wrong precisely when the HashMap gets
     14        resized. Instead, we now just store the value itself since we're just
     15        dealing with a simple Variant that wraps either an empty struct or an
     16        enum.
     17
     18        Test: webgpu/whlsl-checker-should-set-type-of-read-modify-write-variables.html
     19
     20        * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
     21        (WebCore::WHLSL::AST::VariableDeclaration::setType):
     22        (WebCore::WHLSL::AST::VariableDeclaration::type const):
     23        * Modules/webgpu/WHLSL/WHLSLASTDumper.cpp: Make it obvious that read
     24        modify write expressions are such by prefixing them with "RMW".
     25        (WebCore::WHLSL::ASTDumper::visit):
     26        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
     27        (WebCore::WHLSL::Checker::visit):
     28
    1292019-06-19  Devin Rousso  <drousso@apple.com>
    230
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h

    r246273 r246625  
    6565    String& name() { return m_name; }
    6666
    67     const Optional<UniqueRef<UnnamedType>>& type() const { return m_type; } // Anonymous variables inside ReadModifyWriteExpressions have their type set by the type checker.
     67    // We use this for ReadModifyWrite expressions, since we don't know the type of their
     68    // internal variables until the checker runs. All other variables should start life out
     69    // with a type.
     70    void setType(UniqueRef<UnnamedType> type)
     71    {
     72        ASSERT(!m_type);
     73        m_type = WTFMove(type);
     74    }
     75    const Optional<UniqueRef<UnnamedType>>& type() const { return m_type; }
    6876    UnnamedType* type() { return m_type ? &*m_type : nullptr; }
    6977    Optional<Semantic>& semantic() { return m_semantic; }
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDumper.cpp

    r246121 r246625  
    640640    auto newVariable = readModifyWriteExpression.newVariableReference();
    641641
    642     m_out.print("(");
     642    m_out.print("RMW(");
    643643    visit(oldVariable.get());
    644644    m_out.print(" = ");
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp

    r246579 r246625  
    464464    struct RecurseInfo {
    465465        ResolvingType& resolvingType;
    466         AST::TypeAnnotation& typeAnnotation;
     466        const AST::TypeAnnotation typeAnnotation;
    467467    };
    468468    Optional<RecurseInfo> recurseAndGetInfo(AST::Expression&, bool requiresLeftValue = false);
     
    860860        return;
    861861
    862     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198166 Figure out what to do with the ReadModifyWriteExpression's AnonymousVariables.
     862    readModifyWriteExpression.oldValue().setType(leftValueInfo->resolvingType.getUnnamedType()->clone());
    863863
    864864    auto newValueInfo = recurseAndGetInfo(readModifyWriteExpression.newValueExpression());
     
    866866        return;
    867867
    868     if (!matchAndCommit(leftValueInfo->resolvingType, newValueInfo->resolvingType)) {
     868    if (Optional<UniqueRef<AST::UnnamedType>> matchedType = matchAndCommit(leftValueInfo->resolvingType, newValueInfo->resolvingType))
     869        readModifyWriteExpression.newValue().setType(WTFMove(matchedType.value()));
     870    else {
    869871        setError();
    870872        return;
     
    11321134   
    11331135    AST::TypeAnnotation typeAnnotation = AST::RightValue();
    1134     if (!variableReference.variable()->isAnonymous()) // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198166 This doesn't seem right.
    1135         typeAnnotation = AST::LeftValue { AST::AddressSpace::Thread };
     1136    typeAnnotation = AST::LeftValue { AST::AddressSpace::Thread };
    11361137    assignType(variableReference, variableReference.variable()->type()->clone(), WTFMove(typeAnnotation));
    11371138}
Note: See TracChangeset for help on using the changeset viewer.