tor-browser

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

bug1858423.js (932B)


      1 // |jit-test| skip-if: !wasmCachingEnabled()
      2 
      3 const code = wasmTextToBinary(`(module
      4  (type $t (struct (field i32) (field anyref)))
      5  (type $t2 (struct (field f32) (field externref)))
      6  (func (export "test") (param externref) (result externref)
      7    i32.const 42
      8    f32.const 1.0
      9    local.get 0
     10    struct.new $t2
     11    struct.new $t
     12    extern.convert_any
     13  )
     14 
     15  (func (export "check") (param externref) (result externref)
     16    local.get 0
     17    any.convert_extern
     18    ref.cast (ref $t)
     19    struct.get $t 1
     20    ref.cast (ref $t2)
     21    struct.get $t2 1
     22  )
     23 )`);
     24 
     25 function instantiateCached(code, imports) {
     26  // Cache the code.
     27  wasmCompileInSeparateProcess(code);
     28  // Load from cache.
     29  let m = wasmCompileInSeparateProcess(code);
     30  assertEq(wasmLoadedFromCache(m), true);
     31  return new WebAssembly.Instance(m, imports);
     32 }
     33 
     34 const {test,check} = instantiateCached(code).exports;
     35 let obj = test({i:1});
     36 gc();
     37 assertEq(check(obj).i, 1);