Title: [247254] trunk
Revision
247254
Author
[email protected]
Date
2019-07-08 22:32:26 -0700 (Mon, 08 Jul 2019)

Log Message

[WHLSL Import 23 new JS reference spec tests
https://bugs.webkit.org/show_bug.cgi?id=199604

Reviewed by Myles C. Maxfield.

Source/WebCore:

This patch imports a bunch of JS reference spec tests on our way to
completing https://bugs.webkit.org/show_bug.cgi?id=199595

It also fixes the recursion checker phase. That phase had two bugs:
1. We'd assert after visiting the function declaration that it was
still in the set. However, it will not be in the set when we actually
detect recursion.
2. We would not visit the arguments to a call, so if they contained other
calls which were recursive, we would not detect such recursive calls.

Tests: webgpu/whlsl-int-literal-compare.html
       webgpu/whlsl-simple-tests.html
       webgpu/whlsl-type-mismatch.html
       webgpu/whlsl-uint-bitwise.html

* Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:

LayoutTests:

This moves some stuff down into whlsl-test-harness which are needed by
all tests. This also adds a new checkFail that ensures the program never
runs (e.g, it has a compile error).

* webgpu/js/whlsl-test-harness.js:
(async.checkFail):
(const.webGPUPromiseTest):
* webgpu/whlsl-bitwise-bool-ops-expected.txt:
* webgpu/whlsl-bitwise-bool-ops.html:
* webgpu/whlsl-int-literal-compare-expected.txt: Added.
* webgpu/whlsl-int-literal-compare.html: Added.
* webgpu/whlsl-simple-tests-expected.txt: Added.
* webgpu/whlsl-simple-tests.html: Added.
* webgpu/whlsl-type-mismatch-expected.txt: Added.
* webgpu/whlsl-type-mismatch.html: Added.
* webgpu/whlsl-uint-bitwise-expected.txt: Added.
* webgpu/whlsl-uint-bitwise.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (247253 => 247254)


--- trunk/LayoutTests/ChangeLog	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/ChangeLog	2019-07-09 05:32:26 UTC (rev 247254)
@@ -1,3 +1,28 @@
+2019-07-08  Saam Barati  <[email protected]>
+
+        [WHLSL Import 23 new JS reference spec tests
+        https://bugs.webkit.org/show_bug.cgi?id=199604
+
+        Reviewed by Myles C. Maxfield.
+
+        This moves some stuff down into whlsl-test-harness which are needed by
+        all tests. This also adds a new checkFail that ensures the program never
+        runs (e.g, it has a compile error).
+
+        * webgpu/js/whlsl-test-harness.js:
+        (async.checkFail):
+        (const.webGPUPromiseTest):
+        * webgpu/whlsl-bitwise-bool-ops-expected.txt:
+        * webgpu/whlsl-bitwise-bool-ops.html:
+        * webgpu/whlsl-int-literal-compare-expected.txt: Added.
+        * webgpu/whlsl-int-literal-compare.html: Added.
+        * webgpu/whlsl-simple-tests-expected.txt: Added.
+        * webgpu/whlsl-simple-tests.html: Added.
+        * webgpu/whlsl-type-mismatch-expected.txt: Added.
+        * webgpu/whlsl-type-mismatch.html: Added.
+        * webgpu/whlsl-uint-bitwise-expected.txt: Added.
+        * webgpu/whlsl-uint-bitwise.html: Added.
+
 2019-07-08  Wenson Hsieh  <[email protected]>
 
         [iOS 13] paste-does-not-fire-promises-while-sanitizing-web-content.html times out when run with multiple iterations

Modified: trunk/LayoutTests/webgpu/js/whlsl-test-harness.js (247253 => 247254)


--- trunk/LayoutTests/webgpu/js/whlsl-test-harness.js	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/webgpu/js/whlsl-test-harness.js	2019-07-09 05:32:26 UTC (rev 247254)
@@ -509,6 +509,63 @@
     return (await harness.callTypedFunction(Types.FLOAT4X4, functions, name, args)).subarray(0, 16);
 }
 
+async function checkFail(source) {
+    // FIXME: Make this handle errors with proper messages once we implement the API for that.
+    const name = "____test_name____";
+    const program = `
+        ${source}
+
+        [numthreads(1, 1, 1)]
+        compute void ${name}(device int[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) {
+            buffer[0] = 1;
+        }
+    `;
+    const device = await getBasicDevice();
+    const shaderModule = device.createShaderModule({code: program, isWHLSL: true});
+    const computeStage = {module: shaderModule, entryPoint: name};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
+    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
+
+    const size = Int32Array.BYTES_PER_ELEMENT * 1;
+
+    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
+    const buffer = device.createBuffer(bufferDescriptor);
+    const bufferArrayBuffer = await buffer.mapWriteAsync();
+    const bufferInt32Array = new Int32Array(bufferArrayBuffer);
+    bufferInt32Array[0] = 0;
+    buffer.unmap();
+
+    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
+    const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
+
+    const bufferBinding = {buffer: resultsBuffer, size};
+    const bindGroupBinding = {binding: 0, resource: bufferBinding};
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size);
+    const computePassEncoder = commandEncoder.beginComputePass();
+    computePassEncoder.setPipeline(computePipeline);
+    computePassEncoder.setBindGroup(0, bindGroup);
+    computePassEncoder.dispatch(1, 1, 1);
+    computePassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    const resultsArrayBuffer = await resultsBuffer.mapReadAsync();
+    let resultsInt32Array = new Int32Array(resultsArrayBuffer);
+    if (resultsInt32Array[0] !== 0)
+        throw new Error("program did not fail to compile");
+    resultsBuffer.unmap();
+}
+
 /**
  * Does not return a Promise. To observe the results of a call, 
  * call 'getArrayBuffer' on the Data object retaining your output buffer.
@@ -517,3 +574,29 @@
 {
     harness.callVoidFunction(functions, name, args);
 }
+
+const webGPUPromiseTest = (testFunc, msg) => {
+    promise_test(async () => { 
+        return testFunc().catch(e => {
+        if (!(e instanceof WebGPUUnsupportedError))
+            throw e;
+        });
+    }, msg);
+}
+
+function runTests(obj) {
+    window.addEventListener("load", async () => {
+        try {
+            for (const name in obj) {
+                if (!name.startsWith("_")) 
+                    await webGPUPromiseTest(obj[name], name);
+            }
+        } catch (e) {
+            if (window.testRunner)
+                testRunner.notifyDone();
+            
+            throw e;
+        }
+    });
+}
+

Modified: trunk/LayoutTests/webgpu/msl-harness-test.html (247253 => 247254)


--- trunk/LayoutTests/webgpu/msl-harness-test.html	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/webgpu/msl-harness-test.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -205,14 +205,5 @@
         });
     }, "Return an expected float4 value.");
 }
-
-const webGPUPromiseTest = (testFunc, msg) => {
-    promise_test(async () => { 
-        return testFunc().catch(e => {
-        if (!(e instanceof WebGPUUnsupportedError))
-            throw e;
-        });
-    }, msg);
-}
 </script>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt (247253 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt	2019-07-09 05:32:26 UTC (rev 247254)
@@ -1,6 +1,6 @@
 
-PASS Bool bit and 
-PASS Bool bit or 
-PASS Bool bit or 
-PASS Bool bit not 
+PASS boolBitAnd 
+PASS boolBitOr 
+PASS boolBitXor 
+PASS boolBitNot 
 

Modified: trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops.html (247253 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops.html	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -11,7 +11,7 @@
 
 const whlslTests = {};
 
-whlslTests.boolBitAnd = () => {
+whlslTests.boolBitAnd = async () => {
     const source = `
         bool foo(bool a, bool b)
         {
@@ -19,35 +19,28 @@
         }
     `;
 
-    webGPUPromiseTest(async () => {
-        try {
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
-        } catch(e) {
-            if (!(e instanceof WebGPUUnsupportedError))
-                throw e;
-        }
-    }, "Bool bit and");
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 };
 
-whlslTests.boolBitOr = () => {
+whlslTests.boolBitOr = async () => {
     const source = `
         bool foo(bool a, bool b)
         {
@@ -55,35 +48,28 @@
         }
     `;
 
-    webGPUPromiseTest(async () => {
-        try {
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
-        } catch(e) {
-            if (!(e instanceof WebGPUUnsupportedError))
-                throw e;
-        }
-    }, "Bool bit or");
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 };
 
-whlslTests.boolBitXor = () => {
+whlslTests.boolBitXor = async () => {
     const source = `
         bool foo(bool a, bool b)
         {
@@ -91,35 +77,28 @@
         }
     `;
 
-    webGPUPromiseTest(async () => {
-        try {
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
-        } catch(e) {
-            if (!(e instanceof WebGPUUnsupportedError))
-                throw e;
-        }
-    }, "Bool bit or");
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 };
 
-whlslTests.boolBitNot = () => {
+whlslTests.boolBitNot = async () => {
     const source = `
         bool foo(bool a)
         {
@@ -127,49 +106,17 @@
         }
     `;
 
-    webGPUPromiseTest(async () => {
-        try {
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(true)]);
-                assert_equals(result, false, "Test returned expected value.");
-            }
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(true)]);
+        assert_equals(result, false, "Test returned expected value.");
+    }
 
-            {
-                let result = await callBoolFunction(source, "foo", [makeBool(false)]);
-                assert_equals(result, true, "Test returned expected value.");
-            }
-        } catch(e) {
-            if (!(e instanceof WebGPUUnsupportedError))
-                throw e;
-        }
-    }, "Bool bit not");
+    {
+        let result = await callBoolFunction(source, "foo", [makeBool(false)]);
+        assert_equals(result, true, "Test returned expected value.");
+    }
 };
 
-function runTests(obj) {
-    window.addEventListener("load", () => {
-        try {
-            for (const name in obj) {
-                if (!name.startsWith("_"))
-                    obj[name]();
-            }
-        } catch (e) {
-            if (window.testRunner)
-                testRunner.notifyDone();
-            
-            throw e;
-        }
-    });
-}
-
 runTests(whlslTests);
-
-const webGPUPromiseTest = (testFunc, msg) => {
-    promise_test(async () => { 
-        return testFunc().catch(e => {
-        if (!(e instanceof WebGPUUnsupportedError))
-            throw e;
-        });
-    }, msg);
-}
 </script>
 </html>

Added: trunk/LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,3 @@
+
+PASS twoIntLiterals 
+

Added: trunk/LayoutTests/webgpu/whlsl-int-literal-compare.html (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-int-literal-compare.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-int-literal-compare.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,24 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.twoIntLiterals = async () => {
+    let program = `
+        bool foo()
+        {
+            return 42 == 42;
+        }
+    `;
+    assert_equals(await callBoolFunction(program, "foo", []), true);
+}
+
+runTests(whlslTests);
+</script>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl-simple-tests-expected.txt (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-simple-tests-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-tests-expected.txt	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,7 @@
+
+PASS simpleUnreachableCode 
+PASS simpleNoReturn 
+PASS simpleRecursiveStruct 
+PASS simpleRecursion 
+PASS simpleRecursion2 
+

Added: trunk/LayoutTests/webgpu/whlsl-simple-tests.html (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-simple-tests.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-tests.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,63 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.simpleUnreachableCode = async () => {
+    await checkFail(
+        `
+            void foo()
+            {
+                return;
+                int x;
+            }
+        `);
+}
+
+whlslTests.simpleNoReturn = async () => {
+    await checkFail("int foo() { }");
+}
+
+whlslTests.simpleRecursiveStruct = async () => {
+    await checkFail(
+        `
+            struct Foo {
+                Foo foo;
+            }
+        `);
+}
+
+whlslTests.simpleRecursion = async () => {
+    await checkFail(
+        `
+            void foo(int x)
+            {
+                foo(x);
+            }
+        `);
+}
+
+whlslTests.simpleRecursion2 = async () => {
+    await checkFail(
+        `
+            int bar(int x) {
+                foo(x);
+                return x;
+            }
+            void foo(int x)
+            {
+                foo(bar(x));
+            }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>

Modified: trunk/LayoutTests/webgpu/whlsl-test-harness-test.html (247253 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-test-harness-test.html	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/LayoutTests/webgpu/whlsl-test-harness-test.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -262,14 +262,5 @@
     
     return [src, name, values];
 };
-
-const webGPUPromiseTest = (testFunc, msg) => {
-    promise_test(async () => { 
-        return testFunc().catch(e => {
-        if (!(e instanceof WebGPUUnsupportedError))
-            throw e;
-        });
-    }, msg);
-}
 </script>
 </html>

Added: trunk/LayoutTests/webgpu/whlsl-type-mismatch-expected.txt (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-type-mismatch-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-type-mismatch-expected.txt	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,6 @@
+
+PASS typeMismatchReturn 
+PASS typeMismatchVariableDecl 
+PASS typeMismatchAssignment 
+PASS typeMismatchReturnParam 
+

Added: trunk/LayoutTests/webgpu/whlsl-type-mismatch.html (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-type-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-type-mismatch.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,62 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+
+const whlslTests = {};
+
+whlslTests.typeMismatchReturn = async () =>
+{
+    await checkFail(
+        `
+            int foo()
+            {
+                return 10.5;
+            }
+        `);
+}
+
+whlslTests.typeMismatchVariableDecl = async () =>
+{
+    await checkFail(
+        `
+            void foo(uint x)
+            {
+                int y = x;
+            }
+        `);
+}
+
+whlslTests.typeMismatchAssignment = async () =>
+{
+    await checkFail(
+        `
+            void foo(uint x)
+            {
+                int y;
+                y = x;
+            }
+        `);
+}
+
+whlslTests.typeMismatchReturnParam = async () =>
+{
+    await checkFail(
+        `
+            int foo(uint x)
+            {
+                return x;
+            }
+        `);
+}
+
+runTests(whlslTests);
+
+</script>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,9 @@
+
+PASS uintBitAnd 
+PASS uintBitOr 
+PASS uintBitXor 
+PASS uintBitNot 
+PASS uintLShift 
+PASS uintRShift 
+PASS uintSimpleMath 
+

Added: trunk/LayoutTests/webgpu/whlsl-uint-bitwise.html (0 => 247254)


--- trunk/LayoutTests/webgpu/whlsl-uint-bitwise.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-uint-bitwise.html	2019-07-09 05:32:26 UTC (rev 247254)
@@ -0,0 +1,108 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.uintBitAnd = async () => {
+    let program = `
+        uint foo(uint a, uint b)
+        {
+            return a & b;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 1);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 42);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32) - 7)]), 4294967289);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 0);
+}
+
+whlslTests.uintBitOr = async () => {
+    let program = `
+        uint foo(uint a, uint b)
+        {
+            return a | b;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 7);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 65535);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32)  - 7)]), 4294967295);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 85732);
+}
+
+whlslTests.uintBitXor = async () => {
+    let program = `
+        uint foo(uint a, uint b)
+        {
+            return a ^ b;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 6);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 65493);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32) - 7)]), 6);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 85732);
+}
+
+whlslTests.uintBitNot = async () => { 
+    let program = `
+        uint foo(uint a)
+        {
+            return ~a;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1)]), 4294967294);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535)]), 4294901760);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1)]), 0);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0)]), 4294967295);
+}
+
+whlslTests.uintLShift = async () => {
+    let program = `
+        uint foo(uint a, uint b)
+        {
+            return a << b;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 128);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(2)]), 262140);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(5)]), 4294967264);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(3)]), 0);
+};
+
+whlslTests.uintRShift = async () => {
+    let program = `
+        uint foo(uint a, uint b)
+        {
+            return a >> b;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 0);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(2)]), 16383);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(5)]), 134217727);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(3)]), 0);
+};
+
+whlslTests.uintSimpleMath = async () => {
+    let program = "uint foo(uint x, uint y) { return x + y; }";
+    assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 12);
+
+    program = "uint foo(uint x, uint y) { return x - y; }";
+    assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 2);
+    assert_equals(await callUintFunction(program, "foo", [makeUint(5), makeUint(7)]), 4294967294);
+
+    program = "uint foo(uint x, uint y) { return x * y; }";
+    assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 35);
+
+    // FIXME: make this work: https://bugs.webkit.org/show_bug.cgi?id=199602
+    // program = "uint foo(uint x, uint y) { return x / y; }";
+    // assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(2)]), 3);
+}
+
+runTests(whlslTests);
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (247253 => 247254)


--- trunk/Source/WebCore/ChangeLog	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/Source/WebCore/ChangeLog	2019-07-09 05:32:26 UTC (rev 247254)
@@ -1,3 +1,27 @@
+2019-07-08  Saam Barati  <[email protected]>
+
+        [WHLSL Import 23 new JS reference spec tests
+        https://bugs.webkit.org/show_bug.cgi?id=199604
+
+        Reviewed by Myles C. Maxfield.
+
+        This patch imports a bunch of JS reference spec tests on our way to
+        completing https://bugs.webkit.org/show_bug.cgi?id=199595
+        
+        It also fixes the recursion checker phase. That phase had two bugs:
+        1. We'd assert after visiting the function declaration that it was
+        still in the set. However, it will not be in the set when we actually
+        detect recursion.
+        2. We would not visit the arguments to a call, so if they contained other
+        calls which were recursive, we would not detect such recursive calls.
+
+        Tests: webgpu/whlsl-int-literal-compare.html
+               webgpu/whlsl-simple-tests.html
+               webgpu/whlsl-type-mismatch.html
+               webgpu/whlsl-uint-bitwise.html
+
+        * Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:
+
 2019-07-08  Chris Dumez  <[email protected]>
 
         Make Document::postTask() safe to call from a background thread

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp (247253 => 247254)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp	2019-07-09 03:30:12 UTC (rev 247253)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp	2019-07-09 05:32:26 UTC (rev 247254)
@@ -49,6 +49,8 @@
         }
 
         Visitor::visit(functionDefinition);
+        if (error())
+            return;
 
         auto success = m_visitingSet.remove(&functionDefinition);
         ASSERT_UNUSED(success, success);
@@ -56,7 +58,9 @@
 
     void visit(AST::CallExpression& callExpression) override
     {
-        Visitor::visit(callExpression.function());
+        Visitor::visit(callExpression);
+        if (is<AST::FunctionDefinition>(callExpression.function()))
+            checkErrorAndVisit(downcast<AST::FunctionDefinition>(callExpression.function()));
     }
 
     HashSet<AST::FunctionDefinition*> m_visitingSet;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to