Debian Codegraph @

js/src/jit-test/tests/for-of/iterclose-dynamic-slot.js

raw
1 var counter = 0;
2 const iterable = {
3 [Symbol.iterator]() {
4 return {
5 i: 0,
6
7 // Force the return method into a dynamic slot.
8 x0: 0, x1: 0, x2: 0, x3: 0, x4: 0, x5: 0, x6: 0, x7: 0, x8: 0,
9 x9: 0, x10: 0, x11: 0, x12: 0, x13: 0, x14: 0, x15: 0, x16: 0,
10 x17: 0, x18: 0, x19: 0, x20: 0, x21: 0, x22: 0, x23: 0, x24: 0,
11
12 next() {
13 return { value: this.i++, done: false }
14 },
15 return() {
16 counter += 1;
17 return { value: undefined, done: true };
18 }
19 };
20 }
21 }
22
23 function closeIter(o) {
24 for (var x of o) {
25 if (x == 2) {
26 break;
27 }
28 }
29 }
30
31 function test() {
32 with ({}) {}
33 counter = 0;
34 for (var i = 0; i < 100; i++) {
35 closeIter(iterable)
36 }
37 assertEq(counter, 100)
38 }
39
40 with ({}) {}
41
42 test();
43
44 // Force an IC in Ion.
45 closeIter([1,2,3]);
46
47 test();