benjamin@webkit.org | 974298e | 2016-02-26 18:51:08 +0000 | [diff] [blame] | 1 | |
| 2 | class A { |
| 3 | constructor() { } |
| 4 | } |
| 5 | |
| 6 | class B extends A { |
| 7 | constructor(iterationCount) { |
| 8 | let values = []; |
| 9 | |
| 10 | for (let i = 2; i < iterationCount; ++i) { |
| 11 | // Let's keep the loop busy. |
| 12 | let divided = false; |
| 13 | for (let j = i - 1; j > 1; --j) { |
| 14 | if (!(i % j)) { |
| 15 | divided = true; |
| 16 | break; |
| 17 | } |
| 18 | } |
| 19 | if (!divided) |
| 20 | values.push(i); |
| 21 | |
| 22 | if (!(i % (iterationCount - 2))) |
| 23 | print(this); |
| 24 | else if (values.length == iterationCount) |
| 25 | super(values); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | noInline(B); |
| 31 | |
| 32 | // Small warm up with small iteration count. Try to get to DFG. |
| 33 | for (var i = 0; i < 30; ++i) { |
| 34 | var exception = null; |
| 35 | try { |
| 36 | new B(10); |
| 37 | } catch (e) { |
| 38 | exception = e; |
| 39 | if (!(e instanceof ReferenceError)) |
| 40 | throw "Exception thrown in iteration " + i + " was not a reference error"; |
| 41 | } |
| 42 | if (!exception) |
| 43 | throw "Exception not thrown for an unitialized this at iteration " + i; |
| 44 | } |
| 45 | |
| 46 | // Now try to go to FTL in the constructor. |
| 47 | for (var i = 0; i < 2; ++i) { |
| 48 | var exception = null; |
| 49 | try { |
| 50 | new B(7e3); |
| 51 | } catch (e) { |
| 52 | exception = e; |
| 53 | if (!(e instanceof ReferenceError)) |
| 54 | throw "Exception thrown in iteration " + i + " was not a reference error"; |
| 55 | } |
| 56 | if (!exception) |
| 57 | throw "Exception not thrown for an unitialized this at iteration " + i; |
| 58 | } |