Unreviewed, rolling out r249758.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 16:01:33 +0000 (16:01 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Sep 2019 16:01:33 +0000 (16:01 +0000)
Breaks the watchOS build.

Reverted changeset:

"[WHLSL] Ensure structs/arrays with pointers as fields are
disallowed"
https://bugs.webkit.org/show_bug.cgi?id=201525
https://trac.webkit.org/changeset/249758

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl/array-spec-tests.html
LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage-expected.txt [deleted file]
LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage.html [deleted file]
LayoutTests/webgpu/whlsl/js/test-harness.js
LayoutTests/webgpu/whlsl/pointer-spec-tests.html
LayoutTests/webgpu/whlsl/test-harness-test.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp [deleted file]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.h [deleted file]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj

index 3486249..cd5b170 100644 (file)
@@ -1,3 +1,16 @@
+2019-09-11  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r249758.
+
+        Breaks the watchOS build.
+
+        Reverted changeset:
+
+        "[WHLSL] Ensure structs/arrays with pointers as fields are
+        disallowed"
+        https://bugs.webkit.org/show_bug.cgi?id=201525
+        https://trac.webkit.org/changeset/249758
+
 2019-09-11  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, re-skip service worker test that was unskipped in r249716
index ad1531b..d6e77ef 100644 (file)
@@ -29,7 +29,7 @@ whlslTests.arrayRefToArrayRef = async () => {
             return result;
         }
     `;
-    await checkFail(program);
+    assert_equals(await callIntFunction(program, "foo", []), 76 + 39 + 83);
 }
 
 whlslTests.assignLength = async () => {
diff --git a/LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage-expected.txt b/LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage-expected.txt
deleted file mode 100644 (file)
index a4f09bd..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-PASS noPointersInStructOrArray 
-
diff --git a/LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage.html b/LayoutTests/webgpu/whlsl/ensure-proper-pointer-usage.html
deleted file mode 100644 (file)
index 0272d1c..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<!DOCTYPE html>
-<html>
-<meta charset=utf-8>
-<meta name="timeout" content="long">
-<title>correct pointer usage.</title>
-<script src="js/test-harness.js"></script>
-<script src="../js/webgpu-functions.js"></script>
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-<script>
-const whlslTests = {};
-
-whlslTests.noPointersInStructOrArray = async () => {
-    await checkFail(`
-        struct S { int x; thread int* ptr; }
-        void foo() { }
-    `);
-
-    await checkFail(`
-        typedef T = thread int*;
-        struct S { int x; T ptr; }
-        void foo() { }
-    `);
-
-    await checkFail(`
-        struct S { thread int*[42] arr; }
-        void foo() { }
-    `);
-
-
-    await checkFail(`
-        void foo() {
-            thread int*[42] arr;
-        }
-    `);
-
-    await checkFail(`
-        typedef T = thread int*;
-        void foo() {
-            T[42] arr;
-        }
-    `);
-
-    await checkFail(`
-        typedef T = thread int*[42];
-        void foo() { }
-    `);
-
-    await checkFail(`
-        void foo() {
-            int x;
-            thread int* ptr = &x;
-            (&ptr);
-        }
-    `);
-
-    await checkFail(`
-        typedef T = thread int*[];
-        void foo() { }
-    `);
-
-    await checkFail(`
-        typedef I = int;
-        typedef T = thread I*[];
-        void foo() { }
-    `);
-
-    await checkFail(`
-        typedef I = thread int*;
-        typedef T = thread I[];
-        void foo() { }
-    `);
-
-    await checkFail(`
-        typedef I = thread int[];
-        typedef T = thread I[];
-        void foo() { }
-    `);
-
-    await checkFail(`
-        typedef I = thread int*;
-        typedef T = thread I*;
-        void foo() { }
-    `);
-
-    await checkFail(`
-        void foo() {
-            int x;
-            thread int[] arr = @x;
-            (@arr);
-        }
-    `);
-
-    await checkFail(`
-        void foo() {
-            int x;
-            thread int[] arr = @x;
-            (&arr);
-        }
-    `);
-
-    await checkFail(`
-        typedef I = thread int[];
-        typedef T = thread I*;
-        void foo() { }
-    `);
-};
-
-runTests(whlslTests);
-</script>
-</html>
index 2d56c96..67bfb1a 100644 (file)
@@ -158,7 +158,6 @@ class Data {
 class Harness {
     constructor ()
     {
-        this._loaded = false;
     }
 
     async requestDevice()
@@ -170,8 +169,6 @@ class Harness {
             // WebGPU is not supported.
             // FIXME: Add support for GPUAdapterRequestOptions and GPUDeviceDescriptor,
             // and differentiate between descriptor validation errors and no WebGPU support.
-        } finally {
-            this._loaded = true;
         }
     }
 
@@ -185,9 +182,6 @@ class Harness {
      */
     async callTypedFunction(type, functions, name, args)
     {   
-        if (!this._loaded)
-            throw new Error("GPU device not loaded.");
-
         if (this._device === undefined)
             throw new WebGPUUnsupportedError();
 
@@ -269,11 +263,8 @@ compute void _compute_main(${argsDeclarations.join(", ")})
      */
     async checkCompileFail(source)
     {
-        if (!this._loaded)
-            throw new Error("GPU device not loaded.");
-
         if (this._device === undefined)
-            throw new WebGPUUnsupportedError();
+            return;
         
         let entryPointCode = `
 [numthreads(1, 1, 1)]
@@ -528,7 +519,6 @@ const webGPUPromiseTest = (testFunc, msg) => {
 
 function runTests(obj) {
     window.addEventListener("load", async () => {
-        await harness.requestDevice();
         try {
             for (const name in obj) {
                 if (!name.startsWith("_")) 
index 6b8550b..5404a44 100644 (file)
@@ -29,8 +29,8 @@ whlslTests.pointerToPointer = async () =>
             result += x;
             return result;
         }
-    `;
-    await checkFail(program);
+    `;;
+    assert_equals(await callIntFunction(program, "foo", []), 76 + 39 + 83);
 }
 
 whlslTests.pointerToMember = async () =>
index 8083987..e51db36 100644 (file)
@@ -186,9 +186,8 @@ whlslTests.checkFailTests = () => {
     }, "Successfully compiling code in checkFail is an error.")
 };
 
-window.addEventListener("load", async () => {
+window.addEventListener("load", () => {
     try {
-        await harness.requestDevice();
         for (const name in whlslTests) {
             if (!name.startsWith("_"))
                 whlslTests[name]();
index bfb5dd8..d62fba3 100644 (file)
@@ -1,3 +1,16 @@
+2019-09-11  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r249758.
+
+        Breaks the watchOS build.
+
+        Reverted changeset:
+
+        "[WHLSL] Ensure structs/arrays with pointers as fields are
+        disallowed"
+        https://bugs.webkit.org/show_bug.cgi?id=201525
+        https://trac.webkit.org/changeset/249758
+
 2019-09-11  Ali Juma  <ajuma@chromium.org>
 
         Prevent reentrancy FrameLoader::dispatchUnloadEvents()
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp
deleted file mode 100644 (file)
index f7be93c..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 "WHLSLCheckReferenceTypes.h"
-
-#if ENABLE(WEBGPU)
-
-#include "WHLSLAST.h"
-#include "WHLSLVisitor.h"
-
-namespace WebCore {
-
-namespace WHLSL {
-
-class ReferenceTypeChecker final : public Visitor {
-public:
-    ReferenceTypeChecker() = default;
-    virtual ~ReferenceTypeChecker() = default;
-
-private:
-    ALWAYS_INLINE void checkType(AST::UnnamedType& type, CodeLocation codeLocation, const char* error)
-    {
-        auto& unifiedType = type.unifyNode();
-        if (is<AST::ReferenceType>(unifiedType)) {
-            setError(Error(error, codeLocation));
-            return;
-        }
-
-        if (is<AST::UnnamedType>(unifiedType))
-            checkErrorAndVisit(downcast<AST::UnnamedType>(unifiedType));
-    }
-
-    void visit(AST::ReferenceType& referenceType) override
-    {
-        checkType(referenceType.elementType(), referenceType.codeLocation(), "reference type cannot have another reference type as an inner type");
-    }
-
-    void visit(AST::ArrayType& arrayType) override
-    {
-        checkType(arrayType.type(), arrayType.codeLocation(), "array type cannot have a reference type as its inner type");
-    }
-
-    void visit(AST::StructureElement& structureElement) override
-    {
-        checkType(structureElement.type(), structureElement.codeLocation(), "cannot have a structure field which is a reference type");
-    }
-
-    void visit(AST::Expression& expression) override
-    {
-        Visitor::visit(expression);
-        checkErrorAndVisit(expression.resolvedType());
-    }
-};
-
-Expected<void, Error> checkReferenceTypes(Program& program)
-{
-    // This pass does these things:
-    // 1. Disallow structs to have fields which are references. This prevents us from having to
-    // figure out how to default initialize such a struct. We could relax this in the future if we
-    // did an analysis on which structs contain reference fields, and ensure such struct variables
-    // always have initializers. This would also require us to create constructors for structs which
-    // initialize each field.
-    // 2. We also do the same for arrays.
-    // 3. References can only be one level deep. So no pointers to pointers. No references to
-    // references, etc. This is to support logical mode.
-    ReferenceTypeChecker referenceTypeChecker;
-    referenceTypeChecker.checkErrorAndVisit(program);
-    return referenceTypeChecker.result();
-}
-
-} // namespace WHLSL
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.h
deleted file mode 100644 (file)
index 427fda2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 "WHLSLError.h"
-#include <wtf/Expected.h>
-
-namespace WebCore {
-
-namespace WHLSL {
-
-class Program;
-
-Expected<void, Error> checkReferenceTypes(Program&);
-
-}
-
-}
-
-#endif
index 90a0a45..fb44780 100644 (file)
@@ -936,6 +936,7 @@ void Checker::visit(AST::MakeArrayReferenceExpression& makeArrayReferenceExpress
         auto& unnamedType = downcast<AST::UnnamedType>(unifyNode);
         if (is<AST::PointerType>(unnamedType)) {
             auto& pointerType = downcast<AST::PointerType>(unnamedType);
+            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198163 Save the fact that we're not targetting the item; we're targetting the item's inner element.
             assignConcreteType(makeArrayReferenceExpression, AST::ArrayReferenceType::create(makeArrayReferenceExpression.codeLocation(), pointerType.addressSpace(), pointerType.elementType()));
             return;
         }
index 2b72fe9..b56798b 100644 (file)
@@ -31,7 +31,6 @@
 #include "WHLSLASTDumper.h"
 #include "WHLSLCheckDuplicateFunctions.h"
 #include "WHLSLCheckTextureReferences.h"
-#include "WHLSLCheckReferenceTypes.h"
 #include "WHLSLChecker.h"
 #include "WHLSLComputeDimensions.h"
 #include "WHLSLFunctionStageChecker.h"
@@ -232,7 +231,6 @@ static Expected<Program, String> prepareShared(PhaseTimes& phaseTimes, const Str
 
     RUN_PASS(checkLiteralTypes, program);
     CHECK_PASS(checkTextureReferences, program);
-    CHECK_PASS(checkReferenceTypes, program);
     RUN_PASS(resolveProperties, program);
     RUN_PASS(findHighZombies, program);
     CHECK_PASS(checkStatementBehavior, program);
index 57e750e..c9accc0 100644 (file)
@@ -313,7 +313,6 @@ Modules/webgpu/WHLSL/WHLSLLexer.cpp
 Modules/webgpu/WHLSL/WHLSLParser.cpp
 Modules/webgpu/WHLSL/WHLSLPruneUnreachableStandardLibraryFunctions.cpp
 Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp
-Modules/webgpu/WHLSL/WHLSLCheckReferenceTypes.cpp
 Modules/webgpu/WHLSL/WHLSLChecker.cpp
 Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp
 Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp
index f874214..b8d27fc 100644 (file)
                522DA3D3229E1D390042D151 /* WHLSLGlobalVariableReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLGlobalVariableReference.h; sourceTree = "<group>"; };
                522E1A172297D6D400E5D36A /* WHLSLPreserveVariableLifetimes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLPreserveVariableLifetimes.cpp; sourceTree = "<group>"; };
                522E1A192297D6D400E5D36A /* WHLSLPreserveVariableLifetimes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLPreserveVariableLifetimes.h; sourceTree = "<group>"; };
-               524BD47E23277E15008F56C1 /* WHLSLCheckReferenceTypes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLCheckReferenceTypes.cpp; sourceTree = "<group>"; };
-               524BD48023277E16008F56C1 /* WHLSLCheckReferenceTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCheckReferenceTypes.h; sourceTree = "<group>"; };
                526724F11CB2FDF60075974D /* TextTrackRepresentationCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextTrackRepresentationCocoa.mm; sourceTree = "<group>"; };
                526724F21CB2FDF60075974D /* TextTrackRepresentationCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentationCocoa.h; sourceTree = "<group>"; };
                526B3F0122FB7BDD0076D37D /* WHLSLPruneUnreachableStandardLibraryFunctions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLPruneUnreachableStandardLibraryFunctions.cpp; sourceTree = "<group>"; };
                                1C840B9721EC400700D0500D /* WHLSLChecker.h */,
                                1C281C6D22B87B9800691C00 /* WHLSLCheckTextureReferences.cpp */,
                                1C281C6E22B87B9800691C00 /* WHLSLCheckTextureReferences.h */,
-                               524BD47E23277E15008F56C1 /* WHLSLCheckReferenceTypes.cpp */,
-                               524BD48023277E16008F56C1 /* WHLSLCheckReferenceTypes.h */,
                                522BAB9622E6A36200C54CE9 /* WHLSLCodeLocation.h */,
                                1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */,
                                1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */,