Debian Codegraph @

js/src/jit-test/tests/for-of/iterclose-dynamic-slot-throw.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 throw "good";
27 }
28 }
29 }
30
31 function test() {
32 with ({}) {}
33 counter = 0;
34 for (var i = 0; i < 100; i++) {
35 var caught = "bad";
36 try {
37 closeIter(iterable)
38 } catch (e) {
39 caught = e;
40 }
41 assertEq(caught, "good");
42 }
43 assertEq(counter, 100)
44 }
45
46 with ({}) {}
47
48 test();
49
50 // Force an IC in Ion.
51 try {
52 closeIter([1,2,3]);
53 } catch {}
54
55 test();