Title: [247419] trunk/Source/WebCore
- Revision
- 247419
- Author
- [email protected]
- Date
- 2019-07-13 10:43:41 -0700 (Sat, 13 Jul 2019)
Log Message
[WHLSL] Return statements don't need to keep track of the function they're in
https://bugs.webkit.org/show_bug.cgi?id=199763
Reviewed by Myles C. Maxfield.
Return::m_function is only used in the Checker, and it can easily enough keep track of the current function.
This means we no longer need to keep track of the current function in the NameResolver, and we can save 8 bytes per Return
Since I was touching the NameResolver I also removed a few pointless overrides of Visitor::visit().
No new tests as there is no intended functional change.
* Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::Checker::visit):
* Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
(WebCore::WHLSL::NameResolver::NameResolver):
(WebCore::WHLSL::resolveTypeNamesInFunctions):
* Modules/webgpu/WHLSL/WHLSLNameResolver.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (247418 => 247419)
--- trunk/Source/WebCore/ChangeLog 2019-07-13 17:28:41 UTC (rev 247418)
+++ trunk/Source/WebCore/ChangeLog 2019-07-13 17:43:41 UTC (rev 247419)
@@ -1,3 +1,25 @@
+2019-07-13 Robin Morisset <[email protected]>
+
+ [WHLSL] Return statements don't need to keep track of the function they're in
+ https://bugs.webkit.org/show_bug.cgi?id=199763
+
+ Reviewed by Myles C. Maxfield.
+
+ Return::m_function is only used in the Checker, and it can easily enough keep track of the current function.
+ This means we no longer need to keep track of the current function in the NameResolver, and we can save 8 bytes per Return
+
+ Since I was touching the NameResolver I also removed a few pointless overrides of Visitor::visit().
+
+ No new tests as there is no intended functional change.
+
+ * Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
+ * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
+ (WebCore::WHLSL::Checker::visit):
+ * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
+ (WebCore::WHLSL::NameResolver::NameResolver):
+ (WebCore::WHLSL::resolveTypeNamesInFunctions):
+ * Modules/webgpu/WHLSL/WHLSLNameResolver.h:
+
2019-07-13 Andres Gonzalez <[email protected]>
Add accessibility support to WKDataListSuggestionsView.
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h (247418 => 247419)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h 2019-07-13 17:28:41 UTC (rev 247418)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h 2019-07-13 17:43:41 UTC (rev 247419)
@@ -56,12 +56,8 @@
_expression_* value() { return m_value.get(); }
- FunctionDefinition* function() { return m_function; }
- void setFunction(FunctionDefinition* functionDefinition) { m_function = functionDefinition; }
-
private:
std::unique_ptr<_expression_> m_value;
- FunctionDefinition* m_function { nullptr };
};
} // namespace AST
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (247418 => 247419)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp 2019-07-13 17:28:41 UTC (rev 247418)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp 2019-07-13 17:43:41 UTC (rev 247419)
@@ -517,6 +517,7 @@
HashSet<String> m_computeEntryPoints;
const Intrinsics& m_intrinsics;
Program& m_program;
+ AST::FunctionDefinition* m_currentFunction { nullptr };
};
void Checker::visit(Program& program)
@@ -572,6 +573,7 @@
void Checker::visit(AST::FunctionDefinition& functionDefinition)
{
+ m_currentFunction = &functionDefinition;
if (functionDefinition.entryPointType()) {
if (!checkShaderType(functionDefinition)) {
setError();
@@ -1144,12 +1146,12 @@
auto valueInfo = recurseAndGetInfo(*returnStatement.value());
if (!valueInfo)
return;
- if (!matchAndCommit(valueInfo->resolvingType, returnStatement.function()->type()))
+ if (!matchAndCommit(valueInfo->resolvingType, m_currentFunction->type()))
setError();
return;
}
- if (!matches(returnStatement.function()->type(), m_intrinsics.voidType()))
+ if (!matches(m_currentFunction->type(), m_intrinsics.voidType()))
setError();
}
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp (247418 => 247419)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp 2019-07-13 17:28:41 UTC (rev 247418)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp 2019-07-13 17:43:41 UTC (rev 247419)
@@ -28,7 +28,6 @@
#if ENABLE(WEBGPU)
-#include "WHLSLCallExpression.h"
#include "WHLSLDoWhileLoop.h"
#include "WHLSLDotExpression.h"
#include "WHLSLEnumerationDefinition.h"
@@ -38,10 +37,8 @@
#include "WHLSLIfStatement.h"
#include "WHLSLNameContext.h"
#include "WHLSLProgram.h"
-#include "WHLSLPropertyAccessExpression.h"
#include "WHLSLReplaceWith.h"
#include "WHLSLResolveOverloadImpl.h"
-#include "WHLSLReturn.h"
#include "WHLSLScopedSetAdder.h"
#include "WHLSLTypeReference.h"
#include "WHLSLVariableDeclaration.h"
@@ -61,7 +58,6 @@
: m_nameContext(nameContext)
, m_parentNameResolver(&parentResolver)
{
- setCurrentFunctionDefinition(parentResolver.m_currentFunction);
}
NameResolver::~NameResolver()
@@ -190,18 +186,6 @@
}
}
-void NameResolver::visit(AST::Return& returnStatement)
-{
- ASSERT(m_currentFunction);
- returnStatement.setFunction(m_currentFunction);
- Visitor::visit(returnStatement);
-}
-
-void NameResolver::visit(AST::PropertyAccessExpression& propertyAccessExpression)
-{
- Visitor::visit(propertyAccessExpression);
-}
-
void NameResolver::visit(AST::DotExpression& dotExpression)
{
if (is<AST::VariableReference>(dotExpression.base())) {
@@ -226,11 +210,6 @@
Visitor::visit(dotExpression);
}
-void NameResolver::visit(AST::CallExpression& callExpression)
-{
- Visitor::visit(callExpression);
-}
-
void NameResolver::visit(AST::EnumerationMemberLiteral& enumerationMemberLiteral)
{
if (enumerationMemberLiteral.enumerationMember())
@@ -288,12 +267,10 @@
bool resolveTypeNamesInFunctions(Program& program, NameResolver& nameResolver)
{
for (auto& functionDefinition : program.functionDefinitions()) {
- nameResolver.setCurrentFunctionDefinition(&functionDefinition);
nameResolver.checkErrorAndVisit(functionDefinition);
if (nameResolver.error())
return false;
}
- nameResolver.setCurrentFunctionDefinition(nullptr);
for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) {
nameResolver.checkErrorAndVisit(nativeFunctionDeclaration);
if (nameResolver.error())
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h (247418 => 247419)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h 2019-07-13 17:28:41 UTC (rev 247418)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h 2019-07-13 17:43:41 UTC (rev 247419)
@@ -44,11 +44,6 @@
virtual ~NameResolver();
- void setCurrentFunctionDefinition(AST::FunctionDefinition* functionDefinition)
- {
- m_currentFunction = functionDefinition;
- }
-
private:
void visit(AST::FunctionDefinition&) override;
void visit(AST::NativeFunctionDeclaration&) override;
@@ -60,15 +55,11 @@
void visit(AST::ForLoop&) override;
void visit(AST::VariableDeclaration&) override;
void visit(AST::VariableReference&) override;
- void visit(AST::Return&) override;
- void visit(AST::PropertyAccessExpression&) override;
void visit(AST::DotExpression&) override;
- void visit(AST::CallExpression&) override;
void visit(AST::EnumerationMemberLiteral&) override;
NameContext& m_nameContext;
HashSet<AST::TypeReference*> m_typeReferences;
- AST::FunctionDefinition* m_currentFunction { nullptr };
NameResolver* m_parentNameResolver { nullptr };
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes