Debian Codegraph @

js/src/jit-test/tests/sharedbuf/inline-access.js

raw
1 // |jit-test| slow; skip-if: !this.SharedArrayBuffer
2 //
3 // This is for testing inlining behavior in the jits.
4 //
5 // For Baseline, run:
6 // $ IONFLAGS=bl-ic .../js --ion-off --baseline-eager inline-access.js
7 // Then inspect the output, there should be calls to "GetElem(TypedArray[Int32])",
8 // "GetProp(NativeObj/NativeGetter 0x...)", and "SetElem_TypedArray stub"
9 // for the read access, length access, and write access respectively, within f.
10 //
11 // For Ion, run:
12 // $ IONFLAGS=logs .../js --ion-offthread-compile=off inline-access.js
13 // Then postprocess with iongraph and verify (by inspecting MIR late in the pipeline)
14 // that it contains instructions like "typedarraylength", "loadtypedarrayelement",
15 // and "storetypedarrayelement".
16
17 function f(ta) {
18 return (ta[2] = ta[0] + ta[1] + ta.length);
19 }
20
21 var v = new Int32Array(new SharedArrayBuffer(4096));
22 var sum = 0;
23 var iter = 1000;
24 for ( var i=0 ; i < iter ; i++ )
25 sum += f(v);
26 assertEq(sum, v.length * iter);