tor-browser

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

inline-add2.js (882B)


      1 // |jit-test| slow;
      2 //
      3 // Like inline-add, but with Uint32Array, which is a special case
      4 // because the value is representable only as a Number.  All this
      5 // tests is that the Uint32 path is being triggered.
      6 //
      7 // This is intended to be run manually with IONFLAGS=logs and
      8 // postprocessing by iongraph to verify manually (by inspecting the
      9 // MIR) that:
     10 //
     11 //  - the add operation is inlined as it should be, with
     12 //    a return type 'Double'
     13 //  - loads and stores are not moved across the add
     14 //
     15 // Be sure to run with --ion-eager --ion-offthread-compile=off.
     16 
     17 function add(ta) {
     18    return Atomics.add(ta, 86, 6);
     19 }
     20 
     21 var sab = new SharedArrayBuffer(4096);
     22 var ia = new Uint32Array(sab);
     23 for ( var i=0, limit=ia.length ; i < limit ; i++ )
     24    ia[i] = 0xdeadbeef;		// Important: Not an int32-capable value
     25 var v = 0;
     26 for ( var i=0 ; i < 1000 ; i++ )
     27    v += add(ia);
     28 //print(v);