Debian Codegraph @

js/src/jit-test/tests/ion/spreadcall-not-optimized-static-6b.js

raw
1 // Tests when JSOP_OPTIMIZE_SPREADCALL can't be applied during the initial
2 // Ion compilation.
3
4 // JSOP_OPTIMIZE_SPREADCALL can be optimised when the following conditions
5 // are fulfilled:
6 // (1) the argument is an array
7 // (2) the array has no hole
8 // (3) array[@@iterator] is not modified
9 // (4) the array's prototype is Array.prototype
10 // (5) Array.prototype[@@iterator] is not modified
11 // (6) %ArrayIteratorPrototype%.next is not modified
12
13 function add(a, b) {
14 return a + b;
15 }
16
17 // %ArrayIteratorPrototype%.next was modified.
18 function test() {
19 var ArrayIteratorPrototype = Object.getPrototypeOf(Array.prototype[Symbol.iterator]());
20 var ArrayIteratorPrototypeNext = ArrayIteratorPrototype.next;
21 ArrayIteratorPrototype.next = function() {
22 var res = ArrayIteratorPrototypeNext.call(this);
23 if (!res.done) {
24 res.value += 2;
25 }
26 return res;
27 };
28 function fn(...rest) {
29 return add(...rest);
30 }
31 for (var i = 0; i < 2000; ++i) {
32 assertEq(fn(1, 2), 7);
33 }
34 }
35 test();