Title: [246524] trunk/Source/WebCore
- Revision
- 246524
- Author
- [email protected]
- Date
- 2019-06-17 17:06:17 -0700 (Mon, 17 Jun 2019)
Log Message
[WHLSL] The name resolver does not deal with nativeFunctionDeclaration
https://bugs.webkit.org/show_bug.cgi?id=198306
Reviewed by Saam Barati.
We currently have a crash in the nameResolver when trying to use the full standard library.
What is happening is that because we don't specify anything to do to nativeFunctionDeclarations, names in their parameters
are added to the global environment. And so as soon as we have two such parameters with the same name, the name resolver fails.
Tested by adding two native functions that share a parameter name to the standard library.
* Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
(WebCore::WHLSL::NameResolver::visit):
* Modules/webgpu/WHLSL/WHLSLNameResolver.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (246523 => 246524)
--- trunk/Source/WebCore/ChangeLog 2019-06-17 23:42:41 UTC (rev 246523)
+++ trunk/Source/WebCore/ChangeLog 2019-06-18 00:06:17 UTC (rev 246524)
@@ -1,5 +1,22 @@
2019-06-17 Robin Morisset <[email protected]>
+ [WHLSL] The name resolver does not deal with nativeFunctionDeclaration
+ https://bugs.webkit.org/show_bug.cgi?id=198306
+
+ Reviewed by Saam Barati.
+
+ We currently have a crash in the nameResolver when trying to use the full standard library.
+ What is happening is that because we don't specify anything to do to nativeFunctionDeclarations, names in their parameters
+ are added to the global environment. And so as soon as we have two such parameters with the same name, the name resolver fails.
+
+ Tested by adding two native functions that share a parameter name to the standard library.
+
+ * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
+ (WebCore::WHLSL::NameResolver::visit):
+ * Modules/webgpu/WHLSL/WHLSLNameResolver.h:
+
+2019-06-17 Robin Morisset <[email protected]>
+
[WHLSL] Remove backtracking from parseAttributeBlock
https://bugs.webkit.org/show_bug.cgi?id=198934
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp (246523 => 246524)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp 2019-06-17 23:42:41 UTC (rev 246523)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp 2019-06-18 00:06:17 UTC (rev 246524)
@@ -94,6 +94,16 @@
newNameResolver.checkErrorAndVisit(functionDefinition.block());
}
+void NameResolver::visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration)
+{
+ NameContext newNameContext(&m_nameContext);
+ NameResolver newNameResolver(newNameContext);
+ newNameResolver.setCurrentFunctionDefinition(m_currentFunction);
+ checkErrorAndVisit(nativeFunctionDeclaration.type());
+ for (auto& parameter : nativeFunctionDeclaration.parameters())
+ newNameResolver.checkErrorAndVisit(parameter);
+}
+
void NameResolver::visit(AST::Block& block)
{
NameContext nameContext(&m_nameContext);
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h (246523 => 246524)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h 2019-06-17 23:42:41 UTC (rev 246523)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h 2019-06-18 00:06:17 UTC (rev 246524)
@@ -43,8 +43,6 @@
virtual ~NameResolver() = default;
- void visit(AST::FunctionDefinition&) override;
-
void setCurrentFunctionDefinition(AST::FunctionDefinition* functionDefinition)
{
m_currentFunction = functionDefinition;
@@ -51,6 +49,8 @@
}
private:
+ void visit(AST::FunctionDefinition&) override;
+ void visit(AST::NativeFunctionDeclaration&) override;
void visit(AST::TypeReference&) override;
void visit(AST::Block&) override;
void visit(AST::IfStatement&) override;
Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt (246523 => 246524)
--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt 2019-06-17 23:42:41 UTC (rev 246523)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt 2019-06-18 00:06:17 UTC (rev 246524)
@@ -625,4 +625,7 @@
return result;
}
+native ushort Sample(Texture1D<ushort>, sampler, float location);
+native ushort Sample(Texture1D<ushort>, sampler, float location, int offset);
+
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=192890 Insert the rest of the standard library once the parser is fast enough
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes