Changeset 209980 in webkit


Ignore:
Timestamp:
Dec 19, 2016 12:19:01 AM (7 years ago)
Author:
sbarati@apple.com
Message:

WebAssembly: Make running Wasm tests take less time by reducing some tests' iteration count and by splitting some tests into different files
https://bugs.webkit.org/show_bug.cgi?id=166017

Reviewed by Yusuke Suzuki.

  • wasm/function-tests/trap-load-2.js: Added.

(assert):
(wasmFrameCountFromError):
(continuation):
(i.catch):

  • wasm/function-tests/trap-load.js:

(assert.continuation): Deleted.

  • wasm/function-tests/trap-store-2.js: Added.

(import.Builder.from.string_appeared_here.assert):
(continuation):
(i.catch):

  • wasm/function-tests/trap-store.js:

(assert.continuation): Deleted.
(assert): Deleted.

  • wasm/js-api/test_memory.js:

(test):

Location:
trunk/JSTests
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209979 r209980  
     12016-12-19  Saam Barati  <sbarati@apple.com>
     2
     3        WebAssembly: Make running Wasm tests take less time by reducing some tests' iteration count and by splitting some tests into different files
     4        https://bugs.webkit.org/show_bug.cgi?id=166017
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * wasm/function-tests/trap-load-2.js: Added.
     9        (assert):
     10        (wasmFrameCountFromError):
     11        (continuation):
     12        (i.catch):
     13        * wasm/function-tests/trap-load.js:
     14        (assert.continuation): Deleted.
     15        * wasm/function-tests/trap-store-2.js: Added.
     16        (import.Builder.from.string_appeared_here.assert):
     17        (continuation):
     18        (i.catch):
     19        * wasm/function-tests/trap-store.js:
     20        (assert.continuation): Deleted.
     21        (assert): Deleted.
     22        * wasm/js-api/test_memory.js:
     23        (test):
     24
    1252016-12-18  Saam Barati  <sbarati@apple.com>
    226
  • trunk/JSTests/wasm/function-tests/trap-load-2.js

    r209979 r209980  
    1919    .End();
    2020
    21 const bin = builder.WebAssembly().get();
    22 const module = new WebAssembly.Module(bin);
    23 const foo = new WebAssembly.Instance(module, {a: {b: new WebAssembly.Memory({initial: numPages})}}).exports.foo;
    24 
    2521function assert(b) {
    2622    if (!b)
     
    3127    let stackFrames = e.stack.split("\n").filter((s) => s.indexOf("<wasm>@[wasm code]") !== -1);
    3228    return stackFrames.length;
    33 }
    34 
    35 for (let i = 0; i < 1000; i++) {
    36     let threw = false;
    37     try {
    38         foo(numPages * pageSize + 1);
    39     } catch(e) {
    40         assert(e instanceof WebAssembly.RuntimeError);
    41         assert(e.message === "Out of bounds memory access");
    42         threw = true;
    43         assert(wasmFrameCountFromError(e) === 2);
    44     }
    45     assert(threw);
    4629}
    4730
     
    8770    }
    8871
    89     for (let i = 0; i < 10000; i++) {
     72    for (let i = 0; i < 5000; i++) {
    9073        let threw = false;
    9174        try {
    92             foo(25, address);
     75            foo(5, address);
    9376        } catch(e) {
    9477            assert(e instanceof WebAssembly.RuntimeError);
    9578            assert(e.message === "Out of bounds memory access");
    96             // There are 25 total calls, and each call does:
     79            // There are 5 total calls, and each call does:
    9780            // JS entry, wasm entry, js call stub.
    9881            // The last call that traps just has JS entry and wasm entry.
    99             assert(wasmFrameCountFromError(e) === 25 * 3 + 2);
     82            assert(wasmFrameCountFromError(e) === 5 * 3 + 2);
    10083            threw = true;
    10184        }
  • trunk/JSTests/wasm/function-tests/trap-load.js

    r209696 r209980  
    4545    assert(threw);
    4646}
    47 
    48 {
    49     const builder = (new Builder())
    50         .Type().End()
    51         .Import()
    52             .Memory("imp", "mem", {initial: numPages})
    53             .Function("imp", "func", { params: ["i32"] })
    54         .End()
    55         .Function().End()
    56         .Export().Function("foo").End()
    57         .Code()
    58             .Function("foo", {params: ["i32", "i32"]})
    59                 .GetLocal(0)
    60                 .I32Const(0)
    61                 .I32Eq()
    62                 .If("void", b =>
    63                     b.GetLocal(1)
    64                     .GetLocal(1)
    65                     .I32Load(2, 0)
    66                     .Br(0)
    67                     .Else()
    68                         .GetLocal(0)
    69                         .Call(0)
    70                     .Br(0)
    71                    )
    72             .End()
    73         .End();
    74 
    75     const bin = builder.WebAssembly().get();
    76     const module = new WebAssembly.Module(bin);
    77     const imp = {
    78         imp: {
    79             mem: new WebAssembly.Memory({initial: numPages}),
    80             func: continuation
    81         }
    82     };
    83     const foo = new WebAssembly.Instance(module, imp).exports.foo;
    84     const address = numPages*pageSize + 1;
    85     function continuation(x) {
    86         foo(x - 1, address);
    87     }
    88 
    89     for (let i = 0; i < 10000; i++) {
    90         let threw = false;
    91         try {
    92             foo(25, address);
    93         } catch(e) {
    94             assert(e instanceof WebAssembly.RuntimeError);
    95             assert(e.message === "Out of bounds memory access");
    96             // There are 25 total calls, and each call does:
    97             // JS entry, wasm entry, js call stub.
    98             // The last call that traps just has JS entry and wasm entry.
    99             assert(wasmFrameCountFromError(e) === 25 * 3 + 2);
    100             threw = true;
    101         }
    102         assert(threw);
    103     }
    104 }
  • trunk/JSTests/wasm/function-tests/trap-store-2.js

    r209979 r209980  
    88const pageSize = 64 * 1024;
    99const numPages = 10;
    10 
    11 {
    12     const builder = (new Builder())
    13         .Type().End()
    14         .Import()
    15             .Memory("a", "b", {initial: numPages})
    16         .End()
    17         .Function().End()
    18         .Export().Function("foo").End()
    19         .Code()
    20             .Function("foo", {params: ["i32", "i32"]})
    21                 .GetLocal(1)
    22                 .GetLocal(0)
    23                 .I32Store(2, 0)
    24             .End()
    25         .End();
    26 
    27     const bin = builder.WebAssembly().get();
    28     const module = new WebAssembly.Module(bin);
    29     const foo = new WebAssembly.Instance(module, {a: {b: new WebAssembly.Memory({initial: numPages})}}).exports.foo;
    30 
    31     for (let i = 0; i < 10000; i++) {
    32         let threw = false;
    33         try {
    34             foo(i, numPages * pageSize + 1);
    35         } catch(e) {
    36             assert(e instanceof WebAssembly.RuntimeError);
    37             assert(e.message === "Out of bounds memory access");
    38             threw = true;
    39         }
    40         assert(threw);
    41     }
    42 }
    43 
    4410
    4511{
     
    8450    }
    8551
    86     for (let i = 0; i < 10000; i++) {
     52    for (let i = 0; i < 5000; i++) {
    8753        let threw = false;
    8854        try {
    89             foo(25, address);
     55            foo(6, address);
    9056        } catch(e) {
    9157            assert(e instanceof WebAssembly.RuntimeError);
  • trunk/JSTests/wasm/function-tests/trap-store.js

    r209696 r209980  
    4141    }
    4242}
    43 
    44 
    45 {
    46     const builder = (new Builder())
    47         .Type().End()
    48         .Import()
    49             .Memory("imp", "mem", {initial: numPages})
    50             .Function("imp", "func", { params: ["i32"] })
    51         .End()
    52         .Function().End()
    53         .Export().Function("foo").End()
    54         .Code()
    55             .Function("foo", {params: ["i32", "i32"]})
    56                 .GetLocal(0)
    57                 .I32Const(0)
    58                 .I32Eq()
    59                 .If("void", b =>
    60                     b.GetLocal(1)
    61                     .GetLocal(0)
    62                     .I32Store(2, 0)
    63                     .Br(0)
    64                     .Else()
    65                         .GetLocal(0)
    66                         .Call(0)
    67                     .Br(0)
    68                    )
    69             .End()
    70         .End();
    71 
    72     const bin = builder.WebAssembly().get();
    73     const module = new WebAssembly.Module(bin);
    74     const imp = {
    75         imp: {
    76             mem: new WebAssembly.Memory({initial: numPages}),
    77             func: continuation
    78         }
    79     };
    80     const foo = new WebAssembly.Instance(module, imp).exports.foo;
    81     const address = numPages*pageSize + 1;
    82     function continuation(x) {
    83         foo(x - 1, address);
    84     }
    85 
    86     for (let i = 0; i < 10000; i++) {
    87         let threw = false;
    88         try {
    89             foo(25, address);
    90         } catch(e) {
    91             assert(e instanceof WebAssembly.RuntimeError);
    92             assert(e.message === "Out of bounds memory access");
    93             threw = true;
    94         }
    95         assert(threw);
    96     }
    97 }
  • trunk/JSTests/wasm/js-api/test_memory.js

    r209850 r209980  
    137137
    138138test(function() {
    139     const memoryDescription = {initial: 20, maximum: 20};
     139    const memoryDescription = {initial: 2, maximum: 2};
    140140    const builder = (new Builder())
    141141        .Type().End()
     
    176176
    177177test(function() {
    178     const memoryDescription = {initial: 20, maximum: 20};
     178    const memoryDescription = {initial: 2, maximum: 2};
    179179    const builder = (new Builder())
    180180        .Type().End()
     
    216216
    217217test(function() {
    218     const memoryDescription = {initial: 20, maximum: 20};
     218    const memoryDescription = {initial: 2, maximum: 2};
    219219    const builder = (new Builder())
    220220        .Type().End()
     
    257257
    258258test(function() {
    259     const memoryDescription = {initial: 20, maximum: 20};
     259    const memoryDescription = {initial: 2, maximum: 2};
    260260    const builder = (new Builder())
    261261        .Type().End()
Note: See TracChangeset for help on using the changeset viewer.