tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

many-outstanding.js (980B)


      1 // Create a bunch of outstanding suspended stacks and test GC behaviour.
      2 
      3 let promises = [];
      4 function js_import() {
      5  return Promise.resolve(13);
      6 }
      7 let wasm_js_import = new WebAssembly.Suspending(js_import);
      8 
      9 var ins = wasmEvalText(`(module
     10  (import "m" "import" (func (result externref)))
     11  (global (export "outstanding") (mut i32) (i32.const 0))
     12  (func (export "test") (param externref) (result externref)
     13    local.get 0
     14 
     15    global.get 0
     16    i32.const 1
     17    i32.add
     18    global.set 0
     19 
     20    call 0
     21    drop
     22 
     23    global.get 0
     24    i32.const 1
     25    i32.sub
     26    global.set 0
     27 
     28    return
     29  )
     30 )`, {
     31  m: {
     32    import: wasm_js_import
     33  },
     34 });
     35 
     36 let wrapped_export = WebAssembly.promising(ins.exports.test);
     37 
     38 assertEq(ins.exports.outstanding.value, 0);
     39 
     40 let count = 100;
     41 for (let i = 0; i < count; i++) {
     42  wrapped_export({i}).then((x) => assertEq(x.i, i));
     43 }
     44 
     45 assertEq(ins.exports.outstanding.value, count);
     46 
     47 gczeal(10, 2);
     48 drainJobQueue();
     49 
     50 assertEq(ins.exports.outstanding.value, 0);