closure-04.js (650B)
1 var depth = 0; 2 test(); 3 function test() { 4 // |test()| is called recursively. When the generator runs in the JIT, the 5 // recursion limit is ~20x higher than in the interpreter. Limit the depth 6 // here so that the test doesn't timeout or becomes extremely slow. 7 if (++depth > 400) 8 return; 9 10 var catch1, catch2, catch3, finally1, finally2, finally3; 11 function* gen() { 12 yield 1; 13 try { 14 try { 15 try { 16 yield 1; 17 } finally { 18 test(); 19 } 20 } catch (e) { 21 finally2 = true; 22 } 23 } catch (e) { } 24 } 25 iter = gen(); 26 iter.next(); 27 iter.next(); 28 iter.return(); 29 gc(); 30 }