WebKit Bugzilla
Attachment 359135 Details for
Bug 193434
: [WHLSL] Implement the loop checker
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193434-20190114213822.patch (text/plain), 10.57 KB, created by
Myles C. Maxfield
on 2019-01-14 21:38:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-01-14 21:38:22 PST
Size:
10.57 KB
patch
obsolete
>Subversion Revision: 239973 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d270af322118c720bc47256425e78e33f6f3af6c..187904575734d3cf56b6ab6881de09a58b7d14f6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-01-14 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Implement the loop checker >+ https://bugs.webkit.org/show_bug.cgi?id=193434 >+ >+ This is a translation of https://github.com/gpuweb/WHLSL/blob/master/Source/LoopChecker.mjs into C++. >+ >+ No new tests because it isn't hooked up yet. Not enough of the compiler exists to have any meaningful sort >+ of test. When enough of the compiler is present, I'll port the reference implementation's test suite. >+ >+ * Modules/webgpu/WHLSL/WHLSLLoopChecker.cpp: Added. >+ (WebCore::WHLSL::findHighZombies): >+ * Modules/webgpu/WHLSL/WHLSLLoopChecker.h: Added. >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2019-01-14 Simon Fraser <simon.fraser@apple.com> > > Only run the node comparison code in FrameSelection::respondToNodeModification() for range selections >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..84aed62116c5ca5b88fb5f8a78e702fc4de49de3 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.cpp >@@ -0,0 +1,151 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WHLSLLoopChecker.h" >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLBreak.h" >+#include "WHLSLContinue.h" >+#include "WHLSLDoWhileLoop.h" >+#include "WHLSLFallthrough.h" >+#include "WHLSLForLoop.h" >+#include "WHLSLSwitchStatement.h" >+#include "WHLSLVisitor.h" >+#include "WHLSLWhileLoop.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class LoopChecker : public Visitor { >+public: >+ LoopChecker() = default; >+ >+ virtual ~LoopChecker() = default; >+ >+private: >+ void visit(AST::FunctionDefinition& functionDefinition) override >+ { >+ if (m_loopDepth || m_switchDepth) { >+ setError(); >+ return; >+ } >+ Visitor::visit(functionDefinition); >+ } >+ >+ void visit(AST::WhileLoop& whileLoop) override >+ { >+ checkErrorAndVisit(whileLoop.conditional()); >+ >+ ++m_loopDepth; >+ checkErrorAndVisit(whileLoop.body()); >+ ASSERT(m_loopDepth); >+ --m_loopDepth; >+ } >+ >+ void visit(AST::DoWhileLoop& doWhileLoop) override >+ { >+ ++m_loopDepth; >+ checkErrorAndVisit(doWhileLoop.body()); >+ ASSERT(m_loopDepth); >+ --m_loopDepth; >+ >+ checkErrorAndVisit(doWhileLoop.conditional()); >+ } >+ >+ void visit(AST::ForLoop& forLoop) override >+ { >+ WTF::visit(WTF::makeVisitor([&](AST::VariableDeclarationsStatement& variableDeclarationsStatement) { >+ checkErrorAndVisit(variableDeclarationsStatement); >+ }, [&](UniqueRef<AST::Expression>& expression) { >+ checkErrorAndVisit(expression); >+ }), forLoop.initialization()); >+ if (forLoop.condition()) >+ checkErrorAndVisit(*forLoop.condition()); >+ if (forLoop.increment()) >+ checkErrorAndVisit(*forLoop.increment()); >+ >+ ++m_loopDepth; >+ checkErrorAndVisit(forLoop.body()); >+ ASSERT(m_loopDepth); >+ --m_loopDepth; >+ } >+ >+ void visit(AST::SwitchStatement& switchStatement) override >+ { >+ checkErrorAndVisit(switchStatement.value()); >+ >+ ++m_switchDepth; >+ for (auto& switchCase : switchStatement.switchCases()) >+ checkErrorAndVisit(switchCase); >+ ASSERT(m_switchDepth); >+ --m_switchDepth; >+ } >+ >+ void visit(AST::Break& breakStatement) override >+ { >+ if (!m_loopDepth && !m_switchDepth) { >+ setError(); >+ return; >+ } >+ Visitor::visit(breakStatement); >+ } >+ >+ void visit(AST::Continue& continueStatement) override >+ { >+ if (!m_loopDepth) { >+ setError(); >+ return; >+ } >+ Visitor::visit(continueStatement); >+ } >+ >+ void visit(AST::Fallthrough& fallthroughStatement) override >+ { >+ if (!m_switchDepth) { >+ setError(); >+ return; >+ } >+ Visitor::visit(fallthroughStatement); >+ } >+ >+ unsigned m_loopDepth { 0 }; >+ unsigned m_switchDepth { 0 }; >+}; >+ >+bool findHighZombies(Program& program) >+{ >+ LoopChecker loopChecker; >+ loopChecker.Visitor::visit(program); >+ return !loopChecker.error(); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.h >new file mode 100644 >index 0000000000000000000000000000000000000000..aeb4ddaf080588c1afc2c8acc2c247f55dcc594f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLoopChecker.h >@@ -0,0 +1,46 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLFunctionAttribute.h" >+#include "WHLSLSemantic.h" >+#include "WHLSLTypeArgument.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Program; >+ >+bool findHighZombies(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 0d256353d74abd62663024bd8054c950e0738103..3969387205e83cecef5ced54aa4f22c70bc87f29 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -320,6 +320,7 @@ Modules/webgpu/WHLSL/WHLSLNameContext.cpp > Modules/webgpu/WHLSL/WHLSLNameResolver.cpp > Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.cpp > Modules/webgpu/WHLSL/WHLSLVisitor.cpp >+Modules/webgpu/WHLSL/WHLSLLoopChecker.cpp > Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp > Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp > Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index f2f515a4e43e519f4f349474e71492539bf848fc..35650ba3843c10d2edd1ae1a6e2fee5757abf7e7 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6417,6 +6417,8 @@ > 1C840B7D21EBE0B800D0500D /* WHLSLEntryPointType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEntryPointType.h; sourceTree = "<group>"; }; > 1C840B9021EC30F900D0500D /* WHLSLAddressSpace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLAddressSpace.h; sourceTree = "<group>"; }; > 1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; }; >+ 1C9AE5CF21EDA27E0069D5F2 /* WHLSLLoopChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLLoopChecker.cpp; sourceTree = "<group>"; }; >+ 1C9AE5D021EDA27E0069D5F2 /* WHLSLLoopChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLoopChecker.h; sourceTree = "<group>"; }; > 1CA19E030DC255950065A994 /* EventLoopMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventLoopMac.mm; sourceTree = "<group>"; }; > 1CA19E150DC255CA0065A994 /* EventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoop.h; sourceTree = "<group>"; }; > 1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; }; >@@ -25422,6 +25424,8 @@ > C234A9B621E92CC0003C984D /* WHLSLIntrinsics.h */, > C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */, > C210E91221B4BD1000B7F83D /* WHLSLLexer.h */, >+ 1C9AE5CF21EDA27E0069D5F2 /* WHLSLLoopChecker.cpp */, >+ 1C9AE5D021EDA27E0069D5F2 /* WHLSLLoopChecker.h */, > C234A98D21E88884003C984D /* WHLSLNameContext.cpp */, > C234A98E21E88885003C984D /* WHLSLNameContext.h */, > C234A98A21E8883E003C984D /* WHLSLNameResolver.cpp */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
saam
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193434
: 359135