[WHLSL] ReadModifyWriteExpression always has a result and new value expression master
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 May 2019 08:19:07 +0000 (08:19 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 May 2019 08:19:07 +0000 (08:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198079

Reviewed by Myles Maxfield.

Let's not pretend it might not.

* Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:
(WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::takeNewValueExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::takeResultExpression):
* Modules/webgpu/WHLSL/WHLSLASTDumper.cpp:
(WebCore::WHLSL::ASTDumper::visit):
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::Checker::visit):
* Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:
(WebCore::WHLSL::PropertyResolver::visit):
* Modules/webgpu/WHLSL/WHLSLVisitor.cpp:
(WebCore::WHLSL::Visitor::visit):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245745 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDumper.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp

index 3f931ca..c9098ae 100644 (file)
@@ -1,3 +1,26 @@
+2019-05-24  Saam barati  <sbarati@apple.com>
+
+        [WHLSL] ReadModifyWriteExpression always has a result and new value expression
+        https://bugs.webkit.org/show_bug.cgi?id=198079
+
+        Reviewed by Myles Maxfield.
+
+        Let's not pretend it might not.
+
+        * Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::takeNewValueExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::takeResultExpression):
+        * Modules/webgpu/WHLSL/WHLSLASTDumper.cpp:
+        (WebCore::WHLSL::ASTDumper::visit):
+        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
+        (WebCore::WHLSL::Checker::visit):
+        * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:
+        (WebCore::WHLSL::PropertyResolver::visit):
+        * Modules/webgpu/WHLSL/WHLSLVisitor.cpp:
+        (WebCore::WHLSL::Visitor::visit):
+
 2019-05-23  Simon Fraser  <simon.fraser@apple.com>
 
         With async overflow scrolling, programmatic scroll to a negative offset fails to clamp the scroll offset
index b6662a3..ede2b6e 100644 (file)
@@ -86,13 +86,31 @@ public:
     Expression& leftValue() { return m_leftValue; }
     VariableDeclaration& oldValue() { return m_oldValue; }
     VariableDeclaration& newValue() { return m_newValue; }
-    Expression* newValueExpression() { return m_newValueExpression ? &*m_newValueExpression : nullptr; }
-    Expression* resultExpression() { return m_resultExpression ? &*m_resultExpression : nullptr; }
+    Expression& newValueExpression()
+    {
+        ASSERT(m_newValueExpression);
+        return *m_newValueExpression;
+    }
+    Expression& resultExpression()
+    {
+        ASSERT(m_resultExpression);
+        return *m_resultExpression;
+    }
     UniqueRef<Expression> takeLeftValue() { return WTFMove(m_leftValue); }
     UniqueRef<VariableDeclaration> takeOldValue() { return WTFMove(m_oldValue); }
     UniqueRef<VariableDeclaration> takeNewValue() { return WTFMove(m_newValue); }
-    Optional<UniqueRef<Expression>> takeNewValueExpression() { return WTFMove(m_newValueExpression); }
-    Optional<UniqueRef<Expression>> takeResultExpression() { return WTFMove(m_resultExpression); }
+    UniqueRef<Expression> takeNewValueExpression()
+    {
+        auto result = WTFMove(m_newValueExpression.value());
+        m_newValueExpression.reset();
+        return result;
+    }
+    UniqueRef<Expression> takeResultExpression()
+    {
+        auto result = WTFMove(m_resultExpression.value());
+        m_resultExpression.reset();
+        return result;
+    }
 
 private:
     template<class U, class... Args> friend UniqueRef<U> WTF::makeUniqueRef(Args&&...);
index 963e7aa..3eb153c 100644 (file)
@@ -625,7 +625,7 @@ void ASTDumper::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression)
 
     visit(newVariable.get());
     m_out.print(" = ");
-    visit(*readModifyWriteExpression.newValueExpression());
+    visit(readModifyWriteExpression.newValueExpression());
     m_out.print(", ");
 
     visit(readModifyWriteExpression.leftValue());
@@ -633,7 +633,7 @@ void ASTDumper::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression)
     visit(newVariable.get());
     m_out.print(", ");
 
-    visit(*readModifyWriteExpression.resultExpression());
+    visit(readModifyWriteExpression.resultExpression());
     m_out.print(")");
 }
 
index 6ab503a..1dedcf0 100644 (file)
@@ -847,7 +847,7 @@ void Checker::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression)
 
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198166 Figure out what to do with the ReadModifyWriteExpression's AnonymousVariables.
 
-    auto newValueInfo = recurseAndGetInfo(*readModifyWriteExpression.newValueExpression());
+    auto newValueInfo = recurseAndGetInfo(readModifyWriteExpression.newValueExpression());
     if (!newValueInfo)
         return;
 
@@ -856,7 +856,7 @@ void Checker::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression)
         return;
     }
 
-    auto resultInfo = recurseAndGetInfo(*readModifyWriteExpression.resultExpression());
+    auto resultInfo = recurseAndGetInfo(readModifyWriteExpression.resultExpression());
     if (!resultInfo)
         return;
 
index 6beeaf5..fa069ca 100644 (file)
@@ -474,8 +474,7 @@ void PropertyResolver::visit(AST::ReadModifyWriteExpression& readModifyWriteExpr
             variableReference->setTypeAnnotation(AST::LeftValue { AST::AddressSpace::Thread }); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198169 Is this right?
 
             auto newValueExpression = readModifyWriteExpression.takeNewValueExpression();
-            ASSERT(newValueExpression); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198170 Relax this constraint.
-            auto assignmentExpression = makeUniqueRef<AST::AssignmentExpression>(Lexer::Token(readModifyWriteExpression.origin()), WTFMove(variableReference), WTFMove(*newValueExpression));
+            auto assignmentExpression = makeUniqueRef<AST::AssignmentExpression>(Lexer::Token(readModifyWriteExpression.origin()), WTFMove(variableReference), WTFMove(newValueExpression));
             assignmentExpression->setType(baseType->clone());
             assignmentExpression->setTypeAnnotation(AST::RightValue());
 
@@ -503,9 +502,8 @@ void PropertyResolver::visit(AST::ReadModifyWriteExpression& readModifyWriteExpr
         }
 
         auto resultExpression = readModifyWriteExpression.takeResultExpression();
-        ASSERT(resultExpression); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198170 Be resilient to this being null.
-        auto type = (*resultExpression)->resolvedType().clone();
-        expressions.append(WTFMove(*resultExpression));
+        auto type = resultExpression->resolvedType().clone();
+        expressions.append(WTFMove(resultExpression));
 
         UniqueRef<AST::VariableDeclaration> oldVariableDeclaration = readModifyWriteExpression.takeOldValue();
         UniqueRef<AST::VariableDeclaration> newVariableDeclaration = readModifyWriteExpression.takeNewValue();
@@ -549,8 +547,7 @@ void PropertyResolver::visit(AST::ReadModifyWriteExpression& readModifyWriteExpr
             variableReference->setTypeAnnotation(AST::LeftValue { AST::AddressSpace::Thread }); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198169 Is this right?
 
             auto newValueExpression = readModifyWriteExpression.takeNewValueExpression();
-            ASSERT(newValueExpression); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198170 Relax this constraint
-            auto assignmentExpression = makeUniqueRef<AST::AssignmentExpression>(Lexer::Token(readModifyWriteExpression.leftValue().origin()), WTFMove(variableReference), WTFMove(*newValueExpression));
+            auto assignmentExpression = makeUniqueRef<AST::AssignmentExpression>(Lexer::Token(readModifyWriteExpression.leftValue().origin()), WTFMove(variableReference), WTFMove(newValueExpression));
             assignmentExpression->setType(readModifyWriteExpression.leftValue().resolvedType().clone());
             assignmentExpression->setTypeAnnotation(AST::RightValue());
 
@@ -567,9 +564,8 @@ void PropertyResolver::visit(AST::ReadModifyWriteExpression& readModifyWriteExpr
     simplifyLeftValue(modifyResult->innerLeftValue);
 
     auto resultExpression = readModifyWriteExpression.takeResultExpression();
-    ASSERT(resultExpression); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198170 Be resilient to this being null.
-    auto type = (*resultExpression)->resolvedType().clone();
-    modifyResult->expressions.append(WTFMove(*resultExpression));
+    auto type = resultExpression->resolvedType().clone();
+    modifyResult->expressions.append(WTFMove(resultExpression));
 
     UniqueRef<AST::VariableDeclaration> oldVariableDeclaration = readModifyWriteExpression.takeOldValue();
     UniqueRef<AST::VariableDeclaration> newVariableDeclaration = readModifyWriteExpression.takeNewValue();
index 7d0ee35..9277f84 100644 (file)
@@ -536,10 +536,8 @@ void Visitor::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression)
     checkErrorAndVisit(readModifyWriteExpression.leftValue());
     checkErrorAndVisit(readModifyWriteExpression.oldValue());
     checkErrorAndVisit(readModifyWriteExpression.newValue());
-    if (readModifyWriteExpression.newValueExpression())
-        checkErrorAndVisit(*readModifyWriteExpression.newValueExpression());
-    if (readModifyWriteExpression.resultExpression())
-        checkErrorAndVisit(*readModifyWriteExpression.resultExpression());
+    checkErrorAndVisit(readModifyWriteExpression.newValueExpression());
+    checkErrorAndVisit(readModifyWriteExpression.resultExpression());
 }
 
 void Visitor::visit(AST::TernaryExpression& ternaryExpression)