Debian Codegraph @

js/src/jit-test/tests/cacheir/int32-property-key.js

raw
1 function test(n) {
2 // Test keys from -n to n.
3 // We will attach n GetDynamicSlot stubs for negative values,
4 // and one GetDenseElementResult stub for non-negative values.
5 let arr = [];
6 for (let i = -n; i <= n; i++) {
7 arr[i] = i;
8 }
9 let range = n * 2 + 1;
10
11 for (let i = 0; i < 10 * range; i++) {
12 let index = i % range - n;
13 arr[index] = arr[index] + 1;
14 }
15
16 for (let i = -n * 2; i <= n * 2; i++) {
17 let shouldContain = i >= -n && i <= n;
18 assertEq(i in arr, shouldContain);
19 if (shouldContain) {
20 assertEq(arr[i], i + 10);
21 }
22 }
23
24 }
25
26 // Specialized
27 test(2);
28
29 // Megomorphic
30 test(10);