Modified: trunk/Tools/ChangeLog (234000 => 234001)
--- trunk/Tools/ChangeLog 2018-07-19 20:36:13 UTC (rev 234000)
+++ trunk/Tools/ChangeLog 2018-07-19 20:42:20 UTC (rev 234001)
@@ -1,3 +1,15 @@
+2018-07-19 Thomas Denney <[email protected]>
+
+ [WHLSL] The interpreter doesn't support boolean short-circuiting
+ https://bugs.webkit.org/show_bug.cgi?id=187779
+
+ Reviewed by Alex Christensen.
+
+ * WebGPUShadingLanguageRI/Evaluator.js:
+ (Evaluator.prototype.visitLogicalExpression): RHS is only evaluated when necessary
+ * WebGPUShadingLanguageRI/Test.js:
+ (tests.booleanShortcircuiting): Adds 4 tests for the evaluation of logical expresions
+
2018-07-19 Dean Jackson <[email protected]>
Provide an lldb type summary for WebCore::Color
Modified: trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js (234000 => 234001)
--- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2018-07-19 20:36:13 UTC (rev 234000)
+++ trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2018-07-19 20:42:20 UTC (rev 234001)
@@ -177,14 +177,13 @@
visitLogicalExpression(node)
{
let lhs = node.left.visit(this).loadValue();
- let rhs = node.right.visit(this).loadValue();
let result;
switch (node.text) {
case "&&":
- result = lhs && rhs;
+ result = lhs && node.right.visit(this).loadValue();
break;
case "||":
- result = lhs || rhs;
+ result = lhs || node.right.visit(this).loadValue();
break;
default:
throw new Error("Unknown type of logical _expression_");
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (234000 => 234001)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-07-19 20:36:13 UTC (rev 234000)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-07-19 20:42:20 UTC (rev 234001)
@@ -3824,6 +3824,50 @@
checkBool(program, callFunction(program, "foo8", [], []), false);
}
+tests.booleanShortcircuiting = function()
+{
+ let program = doPrep(`
+ bool set(thread int* ptr, int value, bool retValue)
+ {
+ *ptr = value;
+ return retValue;
+ }
+
+ int andTrue()
+ {
+ int x;
+ bool y = set(&x, 1, true) && set(&x, 2, false);
+ return x;
+ }
+
+ int andFalse()
+ {
+ int x;
+ bool y = set(&x, 1, false) && set(&x, 2, false);
+ return x;
+ }
+
+ int orTrue()
+ {
+ int x;
+ bool y = set(&x, 1, true) || set(&x, 2, false);
+ return x;
+ }
+
+ int orFalse()
+ {
+ int x;
+ bool y = set(&x, 1, false) || set(&x, 2, false);
+ return x;
+ }
+ `);
+
+ checkInt(program, callFunction(program, "andTrue", [], []), 2);
+ checkInt(program, callFunction(program, "andFalse", [], []), 1);
+ checkInt(program, callFunction(program, "orTrue", [], []), 1);
+ checkInt(program, callFunction(program, "orFalse", [], []), 2);
+}
+
tests.typedefArray = function()
{
let program = doPrep(`