Debian Codegraph @

js/src/jit-test/tests/atomics/inline-cmpxchg.js

raw
1 // |jit-test| slow;
2 //
3 // This is intended to be run manually with IONFLAGS=logs and
4 // postprocessing by iongraph to verify manually (by inspecting the
5 // MIR) that:
6 //
7 // - the cmpxchg operation is inlined as it should be
8 // - loads and stores are not moved across the cmpxchg
9 //
10 // Be sure to run with --ion-eager --ion-offthread-compile=off.
11
12 function cmpxchg(ta) {
13 var x = ta[0];
14 Atomics.compareExchange(ta, 86, 37, 42);
15 var y = ta[1];
16 var z = y + 1;
17 var w = x + z;
18 return w;
19 }
20
21 var sab = new SharedArrayBuffer(4096);
22 var ia = new Int32Array(sab);
23 for ( var i=0, limit=ia.length ; i < limit ; i++ )
24 ia[i] = 37;
25 var v = 0;
26 for ( var i=0 ; i < 1000 ; i++ )
27 v += cmpxchg(ia);
28 //print(v);