Changeset 209165 in webkit


Ignore:
Timestamp:
Nov 30, 2016 5:03:02 PM (7 years ago)
Author:
jfbastien@apple.com
Message:

WebAssembly builder: don't throw when checker not implemented
https://bugs.webkit.org/show_bug.cgi?id=165219

Reviewed by Mark Lam.

We should perform whichever checks we've implemented, and assume the rest are OK until bug #163421 is fixed.

  • wasm/Builder.js:
  • wasm/README.md:
  • wasm/function-tests/add-12.js:
  • wasm/function-tests/br-if-loop-less-than.js:
  • wasm/function-tests/brTableAsIf.js:
  • wasm/function-tests/brTableManyValues.js:
  • wasm/function-tests/brTableWithLoop.js:
  • wasm/function-tests/dumb-eq-if-then-else.js:
  • wasm/function-tests/dumb-less-than-fallthrough.js:
  • wasm/function-tests/dumb-less-than-ite.js:
  • wasm/function-tests/eqz.js:
  • wasm/function-tests/factorial.js:
  • wasm/function-tests/float-sub.js:
  • wasm/function-tests/i32-load.js:
  • wasm/function-tests/i32-load8-s.js:
  • wasm/function-tests/if-then-else-fallthrough.js:
  • wasm/function-tests/if-then-fallthrough.js:
  • wasm/function-tests/loop-mult.js:
  • wasm/function-tests/loop-sum.js:
  • wasm/function-tests/max.js:
  • wasm/function-tests/min.js:
  • wasm/function-tests/ret5.js:
  • wasm/function-tests/select.js:
  • wasm/self-test/test_BuilderJSON.js:
Location:
trunk/JSTests
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209123 r209165  
     12016-11-30  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly builder: don't throw when checker not implemented
     4        https://bugs.webkit.org/show_bug.cgi?id=165219
     5
     6        Reviewed by Mark Lam.
     7
     8        We should perform whichever checks we've implemented, and assume the rest are OK until bug #163421 is fixed.
     9
     10        * wasm/Builder.js:
     11        * wasm/README.md:
     12        * wasm/function-tests/add-12.js:
     13        * wasm/function-tests/br-if-loop-less-than.js:
     14        * wasm/function-tests/brTableAsIf.js:
     15        * wasm/function-tests/brTableManyValues.js:
     16        * wasm/function-tests/brTableWithLoop.js:
     17        * wasm/function-tests/dumb-eq-if-then-else.js:
     18        * wasm/function-tests/dumb-less-than-fallthrough.js:
     19        * wasm/function-tests/dumb-less-than-ite.js:
     20        * wasm/function-tests/eqz.js:
     21        * wasm/function-tests/factorial.js:
     22        * wasm/function-tests/float-sub.js:
     23        * wasm/function-tests/i32-load.js:
     24        * wasm/function-tests/i32-load8-s.js:
     25        * wasm/function-tests/if-then-else-fallthrough.js:
     26        * wasm/function-tests/if-then-fallthrough.js:
     27        * wasm/function-tests/loop-mult.js:
     28        * wasm/function-tests/loop-sum.js:
     29        * wasm/function-tests/max.js:
     30        * wasm/function-tests/min.js:
     31        * wasm/function-tests/ret5.js:
     32        * wasm/function-tests/select.js:
     33        * wasm/self-test/test_BuilderJSON.js:
     34
    1352016-11-29  JF Bastien  <jfbastien@apple.com>
    236
  • trunk/JSTests/wasm/Builder.js

    r209123 r209165  
    191191            case "size": break; // FIXME implement size. https://bugs.webkit.org/show_bug.cgi?id=163421
    192192            default: throw new Error(`Implementation problem: unhandled meta-type "${expect}" on "${op}"`);
    193                                             }
     193            }
    194194        }
    195195    }
     
    197197
    198198const _checkImms = (op, imms, expectedImms, ret) => {
    199     assert.eq(imms.length, expectedImms.length, `"${op}" expects ${expectedImms.length} immediates, got ${imms.length}`);
     199    const minExpectedImms = expectedImms.filter(i => i.type.slice(-1) !== '*').length;
     200    if (minExpectedImms !== expectedImms.length)
     201        assert.ge(imms.length, minExpectedImms, `"${op}" expects at least ${minExpectedImms} immediate${minExpectedImms !== 1 ? 's' : ''}, got ${imms.length}`);
     202    else
     203         assert.eq(imms.length, minExpectedImms, `"${op}" expects exactly ${minExpectedImms} immediate${minExpectedImms !== 1 ? 's' : ''}, got ${imms.length}`);
    200204    for (let idx = 0; idx !== expectedImms.length; ++idx) {
    201205        const got = imms[idx];
     
    206210            // FIXME check function indices. https://bugs.webkit.org/show_bug.cgi?id=163421
    207211            break;
    208         case "local_index": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
    209         case "global_index": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
    210         case "type_index": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
     212        case "local_index": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
     213        case "global_index": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
     214        case "type_index": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
    211215        case "value":
    212216            assert.truthy(_isValidValue(got, ret[0]), `Invalid value on ${op}: got "${got}", expected ${ret[0]}`);
    213217            break;
    214         case "flags": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
    215         case "offset": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
     218        case "flags": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
     219        case "offset": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
    216220            // Control:
    217         case "default_target": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
    218         case "relative_depth": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
     221        case "default_target": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
     222        case "relative_depth": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
    219223        case "sig":
    220224            // FIXME this should be isValidBlockType https://bugs.webkit.org/show_bug.cgi?id=164724
    221             assert.truthy(WASM.isValidValueType(imms[idx]), `Invalid block type on ${op}: "${imms[idx]}"`);
     225            assert.truthy(imms[idx] === "void" || WASM.isValidValueType(imms[idx]), `Invalid block type on ${op}: "${imms[idx]}"`);
    222226            break;
    223         case "target_count": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
    224         case "target_table": throw new Error(`Unimplemented: "${expect.name}" on "${op}"`);
     227        case "target_count": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
     228        case "target_table": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421
    225229        default: throw new Error(`Implementation problem: unhandled immediate "${expect.name}" on "${op}"`);
    226230        }
  • trunk/JSTests/wasm/README.md

    r209123 r209165  
    3636// Construct the equivalent of: (module (func "answer" (i32.const 42) (return)))
    3737builder
    38     .setChecked(false) // FIXME remove once checking is better implemented.
    3938    // Declare a Type section, which the builder will auto-fill as functions are defined.
    4039    .Type().End()
  • trunk/JSTests/wasm/function-tests/add-12.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/br-if-loop-less-than.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/brTableAsIf.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/brTableManyValues.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/brTableWithLoop.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/dumb-eq-if-then-else.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/dumb-less-than-fallthrough.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/dumb-less-than-ite.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/eqz.js

    r209083 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/factorial.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/float-sub.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/i32-load.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/i32-load8-s.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/if-then-else-fallthrough.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/if-then-fallthrough.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/loop-mult.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/loop-sum.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/max.js

    r209083 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/min.js

    r209083 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/ret5.js

    r208634 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54let code = b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/function-tests/select.js

    r208719 r209165  
    22
    33const b = new Builder();
    4 b.setChecked(false);
    54b.Type().End()
    65    .Function().End()
  • trunk/JSTests/wasm/self-test/test_BuilderJSON.js

    r208634 r209165  
    404404
    405405(function CheckedOpcodeArgumentsTooMany() {
    406     assertOpThrows(f => f.Nop("uh-oh!"), `Not the same: "1" and "0": "nop" expects 0 immediates, got 1`);
     406    assertOpThrows(f => f.Nop("uh-oh!"), `Not the same: "1" and "0": "nop" expects exactly 0 immediates, got 1`);
    407407})();
    408408
     
    412412
    413413(function CheckedOpcodeArgumentsNotEnough() {
    414     assertOpThrows(f => f.I32Const(), `Not the same: "0" and "1": "i32.const" expects 1 immediates, got 0`);
     414    assertOpThrows(f => f.I32Const(), `Not the same: "0" and "1": "i32.const" expects exactly 1 immediate, got 0`);
    415415})();
    416416
Note: See TracChangeset for help on using the changeset viewer.