Title: [235753] trunk/Tools
Revision
235753
Author
[email protected]
Date
2018-09-06 13:36:41 -0700 (Thu, 06 Sep 2018)

Log Message

[WHLSL] Call arguments should be copied as soon as they are evaluated
https://bugs.webkit.org/show_bug.cgi?id=189360

Patch by Thomas Denney <[email protected]> on 2018-09-06
Reviewed by Myles C. Maxfield.

Previously all call arguments were evaluated and then their results were
copied into new buffers for the call. However, the results are not
necessarily independent, so the result should be copied immediately
after evaluation.

* WebGPUShadingLanguageRI/Evaluator.js:
(Evaluator.prototype.visitCallExpression): Move location of copy.
(Evaluator):
* WebGPUShadingLanguageRI/Test.js: Add new test to verify correct
behavior.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (235752 => 235753)


--- trunk/Tools/ChangeLog	2018-09-06 19:59:33 UTC (rev 235752)
+++ trunk/Tools/ChangeLog	2018-09-06 20:36:41 UTC (rev 235753)
@@ -1,5 +1,23 @@
 2018-09-06  Thomas Denney  <[email protected]>
 
+        [WHLSL] Call arguments should be copied as soon as they are evaluated
+        https://bugs.webkit.org/show_bug.cgi?id=189360
+
+        Reviewed by Myles C. Maxfield.
+
+        Previously all call arguments were evaluated and then their results were
+        copied into new buffers for the call. However, the results are not
+        necessarily independent, so the result should be copied immediately
+        after evaluation.
+
+        * WebGPUShadingLanguageRI/Evaluator.js:
+        (Evaluator.prototype.visitCallExpression): Move location of copy.
+        (Evaluator):
+        * WebGPUShadingLanguageRI/Test.js: Add new test to verify correct
+        behavior.
+
+2018-09-06  Thomas Denney  <[email protected]>
+
         [WHLSL] The test suite should log the compile time for the standard library
         https://bugs.webkit.org/show_bug.cgi?id=189354
 

Modified: trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js (235752 => 235753)


--- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js	2018-09-06 19:59:33 UTC (rev 235752)
+++ trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js	2018-09-06 20:36:41 UTC (rev 235753)
@@ -320,17 +320,9 @@
             let argumentValue = argument.visit(this);
             if (!argumentValue)
                 throw new Error("Null argument value, i = " + i + ", node = " + node);
-            callArguments.push(() => {
-                let result = this._snapshot(type, null, argumentValue);
-                return result;
-            });
+            callArguments.push(EBuffer.allowAllocation(() => this._snapshot(type, null, argumentValue)));
         }
-        
-        // For simplicity, we allow intrinsics to just allocate new buffers, and we allocate new
-        // buffers when snapshotting their arguments. This is not observable to the user, so it's OK.
-        let result = EBuffer.allowAllocation(
-            () => node.func.implementation(callArguments.map(thunk => thunk()), node));
-        
+        let result = EBuffer.allowAllocation(() => node.func.implementation(callArguments, node));
         result = this._snapshot(node.func.returnType, node.resultEPtr, result);
         return result;
     }

Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (235752 => 235753)


--- trunk/Tools/WebGPUShadingLanguageRI/Test.js	2018-09-06 19:59:33 UTC (rev 235752)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js	2018-09-06 20:36:41 UTC (rev 235753)
@@ -7626,6 +7626,23 @@
         (e) => e instanceof WLexicalError);
 }
 
+tests.callArgumentsAreCopiedImmediatelyAfterEvaluation = () => {
+    let program = doPrep(`
+        int foo()
+        {
+            return *bar(5) + *bar(7);
+        }
+
+        thread int* bar(int value)
+        {
+            int x = value;
+            return &x;
+        }
+    `);
+
+    checkInt(program, callFunction(program, "foo", []), 12);
+};
+
 okToTest = true;
 
 let testFilter = /.*/; // run everything by default
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to