Title: [248382] trunk/Source/WebCore
- Revision
- 248382
- Author
- [email protected]
- Date
- 2019-08-07 12:48:29 -0700 (Wed, 07 Aug 2019)
Log Message
[WHLSL] checkRecursion, checkTextureReferences, and EscapedVariableCollector should skip stdlib functions
https://bugs.webkit.org/show_bug.cgi?id=200510
Reviewed by Myles C. Maxfield.
We can skip walking the stdlib part of the AST in various semantic checking phases:
- checkRecursion: the stdlib does not have recursion
- checkTextureReferences: the stdlib does not have references to textures
- EscapedVariableCollector: this is used inside preserveVariableLifetimes, and
the stdlib never escapes any variables.
This patch speeds up checkRecursion, checkTextureReferences, and preserveVariableLifetimes
by about 1ms each, leading to a 3ms compile time speedup in compute_boids.
* Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp:
(WebCore::WHLSL::TextureReferencesChecker::visit):
* Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp:
(WebCore::WHLSL::preserveVariableLifetimes):
(WebCore::WHLSL::EscapedVariableCollector::escapeVariableUse): Deleted.
(WebCore::WHLSL::EscapedVariableCollector::takeEscapedVariables): Deleted.
* Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (248381 => 248382)
--- trunk/Source/WebCore/ChangeLog 2019-08-07 19:43:51 UTC (rev 248381)
+++ trunk/Source/WebCore/ChangeLog 2019-08-07 19:48:29 UTC (rev 248382)
@@ -1,5 +1,29 @@
2019-08-07 Saam Barati <[email protected]>
+ [WHLSL] checkRecursion, checkTextureReferences, and EscapedVariableCollector should skip stdlib functions
+ https://bugs.webkit.org/show_bug.cgi?id=200510
+
+ Reviewed by Myles C. Maxfield.
+
+ We can skip walking the stdlib part of the AST in various semantic checking phases:
+ - checkRecursion: the stdlib does not have recursion
+ - checkTextureReferences: the stdlib does not have references to textures
+ - EscapedVariableCollector: this is used inside preserveVariableLifetimes, and
+ the stdlib never escapes any variables.
+
+ This patch speeds up checkRecursion, checkTextureReferences, and preserveVariableLifetimes
+ by about 1ms each, leading to a 3ms compile time speedup in compute_boids.
+
+ * Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp:
+ (WebCore::WHLSL::TextureReferencesChecker::visit):
+ * Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp:
+ (WebCore::WHLSL::preserveVariableLifetimes):
+ (WebCore::WHLSL::EscapedVariableCollector::escapeVariableUse): Deleted.
+ (WebCore::WHLSL::EscapedVariableCollector::takeEscapedVariables): Deleted.
+ * Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:
+
+2019-08-07 Saam Barati <[email protected]>
+
[WHLSL] cache results of argumentTypeForAndOverload inside Checker
https://bugs.webkit.org/show_bug.cgi?id=200462
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp (248381 => 248382)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp 2019-08-07 19:43:51 UTC (rev 248381)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp 2019-08-07 19:48:29 UTC (rev 248382)
@@ -39,7 +39,7 @@
namespace WHLSL {
-class TextureReferencesChecker : public Visitor {
+class TextureReferencesChecker final : public Visitor {
public:
TextureReferencesChecker() = default;
@@ -50,6 +50,8 @@
void visit(AST::ArrayReferenceType&) override;
void visit(AST::ArrayType&) override;
void visit(AST::_expression_&) override;
+ void visit(AST::FunctionDefinition&) override;
+ void visit(AST::NativeFunctionDeclaration&) override;
bool containsTextureOrSampler(AST::UnnamedType&);
};
@@ -114,6 +116,16 @@
checkErrorAndVisit(_expression_.resolvedType());
}
+void TextureReferencesChecker::visit(AST::FunctionDefinition& functionDefinition)
+{
+ if (functionDefinition.parsingMode() != ParsingMode::StandardLibrary)
+ Visitor::visit(functionDefinition);
+}
+
+void TextureReferencesChecker::visit(AST::NativeFunctionDeclaration&)
+{
+}
+
Expected<void, Error> checkTextureReferences(Program& program)
{
TextureReferencesChecker textureReferencesChecker;
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp (248381 => 248382)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp 2019-08-07 19:43:51 UTC (rev 248381)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp 2019-08-07 19:48:29 UTC (rev 248382)
@@ -54,7 +54,7 @@
// "x". If "x" is a function parameter, we store to "struct->x" as the first
// thing we do in the function body.
-class EscapedVariableCollector : public Visitor {
+class EscapedVariableCollector final : public Visitor {
using Base = Visitor;
public:
@@ -87,6 +87,12 @@
escapeVariableUse(makeArrayReferenceExpression.leftValue());
}
+ void visit(AST::FunctionDefinition& functionDefinition) override
+ {
+ if (functionDefinition.parsingMode() != ParsingMode::StandardLibrary)
+ Base::visit(functionDefinition);
+ }
+
HashMap<AST::VariableDeclaration*, String> takeEscapedVariables() { return WTFMove(m_escapedVariables); }
private:
@@ -253,7 +259,8 @@
HashMap<AST::VariableDeclaration*, String> escapedVariables;
{
EscapedVariableCollector collector;
- collector.Visitor::visit(program);
+ for (size_t i = 0; i < program.functionDefinitions().size(); ++i)
+ collector.visit(program.functionDefinitions()[i]);
escapedVariables = collector.takeEscapedVariables();
}
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp (248381 => 248382)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp 2019-08-07 19:43:51 UTC (rev 248381)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp 2019-08-07 19:48:29 UTC (rev 248382)
@@ -39,7 +39,7 @@
namespace WHLSL {
// Makes sure there is no function recursion.
-class RecursionChecker : public Visitor {
+class RecursionChecker final : public Visitor {
private:
void visit(Program& program) override
{
@@ -58,7 +58,8 @@
return;
}
- Visitor::visit(functionDefinition);
+ if (functionDefinition.parsingMode() != ParsingMode::StandardLibrary)
+ Visitor::visit(functionDefinition);
{
auto addResult = m_finishedVisiting.add(&functionDefinition);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes