Changeset 234001 in webkit


Ignore:
Timestamp:
Jul 19, 2018 1:42:20 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[WHLSL] The interpreter doesn't support boolean short-circuiting
https://bugs.webkit.org/show_bug.cgi?id=187779

Patch by Thomas Denney <tdenney@apple.com> on 2018-07-19
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

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r233988 r234001  
     12018-07-19  Thomas Denney  <tdenney@apple.com>
     2
     3        [WHLSL] The interpreter doesn't support boolean short-circuiting
     4        https://bugs.webkit.org/show_bug.cgi?id=187779
     5
     6        Reviewed by Alex Christensen.
     7
     8        * WebGPUShadingLanguageRI/Evaluator.js:
     9        (Evaluator.prototype.visitLogicalExpression): RHS is only evaluated when necessary
     10        * WebGPUShadingLanguageRI/Test.js:
     11        (tests.booleanShortcircuiting): Adds 4 tests for the evaluation of logical expresions
     12
    1132018-07-19  Dean Jackson  <dino@apple.com>
    214
  • trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js

    r222413 r234001  
    178178    {
    179179        let lhs = node.left.visit(this).loadValue();
    180         let rhs = node.right.visit(this).loadValue();
    181180        let result;
    182181        switch (node.text) {
    183182        case "&&":
    184             result = lhs && rhs;
     183            result = lhs && node.right.visit(this).loadValue();
    185184            break;
    186185        case "||":
    187             result = lhs || rhs;
     186            result = lhs || node.right.visit(this).loadValue();
    188187            break;
    189188        default:
  • trunk/Tools/WebGPUShadingLanguageRI/Test.js

    r222751 r234001  
    38253825}
    38263826
     3827tests.booleanShortcircuiting = function()
     3828{
     3829    let program = doPrep(`
     3830        bool set(thread int* ptr, int value, bool retValue)
     3831        {
     3832            *ptr = value;
     3833            return retValue;
     3834        }
     3835       
     3836        int andTrue()
     3837        {
     3838            int x;
     3839            bool y = set(&x, 1, true) && set(&x, 2, false);
     3840            return x;
     3841        }
     3842       
     3843        int andFalse()
     3844        {
     3845            int x;
     3846            bool y = set(&x, 1, false) && set(&x, 2, false);
     3847            return x;
     3848        }
     3849       
     3850        int orTrue()
     3851        {
     3852            int x;
     3853            bool y = set(&x, 1, true) || set(&x, 2, false);
     3854            return x;
     3855        }
     3856       
     3857        int orFalse()
     3858        {
     3859            int x;
     3860            bool y = set(&x, 1, false) || set(&x, 2, false);
     3861            return x;
     3862        }
     3863    `);
     3864
     3865    checkInt(program, callFunction(program, "andTrue", [], []), 2);
     3866    checkInt(program, callFunction(program, "andFalse", [], []), 1);
     3867    checkInt(program, callFunction(program, "orTrue", [], []), 1);
     3868    checkInt(program, callFunction(program, "orFalse", [], []), 2);
     3869}
     3870
    38273871tests.typedefArray = function()
    38283872{
Note: See TracChangeset for help on using the changeset viewer.