OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --expose-debug-as debug --allow-natives-syntax | 28 // Flags: --expose-debug-as debug --allow-natives-syntax --inline-construct |
29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
30 Debug = debug.Debug | 30 Debug = debug.Debug |
31 | 31 |
32 var listenerComplete = false; | 32 var listenerComplete = false; |
33 var exception = false; | 33 var exception = false; |
34 | 34 |
35 var testingConstructCall = false; | 35 var testingConstructCall = false; |
36 | 36 |
37 var expected = [ | 37 var expected = [ |
38 { locals: {a0: 1, b0: 2}, args: { names: ["i", "x0", "y0"], values: [0, 3, 4]
} }, | 38 { locals: {a0: 1, b0: 2}, args: { names: ["i", "x0", "y0"], values: [0, 3, 4]
} }, |
(...skipping 84 matching lines...) Loading... |
123 case 0: assertEquals(h, frame.func().value()); break; | 123 case 0: assertEquals(h, frame.func().value()); break; |
124 case 1: assertEquals(g3, frame.func().value()); break; | 124 case 1: assertEquals(g3, frame.func().value()); break; |
125 case 2: assertEquals(g2, frame.func().value()); break; | 125 case 2: assertEquals(g2, frame.func().value()); break; |
126 case 3: assertEquals(g1, frame.func().value()); break; | 126 case 3: assertEquals(g1, frame.func().value()); break; |
127 case 4: assertEquals(f, frame.func().value()); break; | 127 case 4: assertEquals(f, frame.func().value()); break; |
128 case 5: break; | 128 case 5: break; |
129 default: assertUnreachable(); | 129 default: assertUnreachable(); |
130 } | 130 } |
131 | 131 |
132 // Check for construct call. | 132 // Check for construct call. |
133 assertEquals(testingConstructCall && i == 4, frame.isConstructCall()); | 133 if (i == 4) { |
| 134 assertEquals(testingConstructCall, frame.isConstructCall()); |
| 135 } else if (i == 2) { |
| 136 assertTrue(frame.isConstructCall()); |
| 137 } else { |
| 138 assertFalse(frame.isConstructCall()); |
| 139 } |
134 | 140 |
135 // When function f is optimized (1 means YES, see runtime.cc) we | 141 // When function f is optimized (1 means YES, see runtime.cc) we |
136 // expect an optimized frame for f with g1, g2 and g3 inlined. | 142 // expect an optimized frame for f with g1, g2 and g3 inlined. |
137 if (%GetOptimizationStatus(f) == 1) { | 143 if (%GetOptimizationStatus(f) == 1) { |
138 if (i == 1 || i == 2 || i == 3) { | 144 if (i == 1 || i == 2 || i == 3) { |
139 assertTrue(frame.isOptimizedFrame()); | 145 assertTrue(frame.isOptimizedFrame()); |
140 assertTrue(frame.isInlinedFrame()); | 146 assertTrue(frame.isInlinedFrame()); |
141 assertEquals(4 - i, frame.inlinedFrameIndex()); | 147 assertEquals(4 - i, frame.inlinedFrameIndex()); |
142 } else if (i == 4) { | 148 } else if (i == 4) { |
143 assertTrue(frame.isOptimizedFrame()); | 149 assertTrue(frame.isOptimizedFrame()); |
(...skipping 34 matching lines...) Loading... |
178 | 184 |
179 function g2(i) { | 185 function g2(i) { |
180 var a2 = expected[i].locals.a2; | 186 var a2 = expected[i].locals.a2; |
181 var b2 = expected[i].locals.b2; | 187 var b2 = expected[i].locals.b2; |
182 g3(i - 1, a2, b2); | 188 g3(i - 1, a2, b2); |
183 } | 189 } |
184 | 190 |
185 function g1(i, x3, y3, z3) { | 191 function g1(i, x3, y3, z3) { |
186 var a3 = expected[i].locals.a3; | 192 var a3 = expected[i].locals.a3; |
187 var b3 = expected[i].locals.b3; | 193 var b3 = expected[i].locals.b3; |
188 g2(i - 1, a3, b3); | 194 new g2(i - 1, a3, b3); |
189 } | 195 } |
190 | 196 |
191 function f(i, x4, y4) { | 197 function f(i, x4, y4) { |
192 var a4 = expected[i].locals.a4; | 198 var a4 = expected[i].locals.a4; |
193 var b4 = expected[i].locals.b4; | 199 var b4 = expected[i].locals.b4; |
194 g1(i - 1, a4, b4); | 200 g1(i - 1, a4, b4); |
195 } | 201 } |
196 | 202 |
197 // Test calling f normally and as a constructor. | 203 // Test calling f normally and as a constructor. |
198 f(expected.length - 1, 11, 12); | 204 f(expected.length - 1, 11, 12); |
199 f(expected.length - 1, 11, 12, 0); | 205 f(expected.length - 1, 11, 12, 0); |
200 testingConstructCall = true; | 206 testingConstructCall = true; |
201 new f(expected.length - 1, 11, 12); | 207 new f(expected.length - 1, 11, 12); |
202 new f(expected.length - 1, 11, 12, 0); | 208 new f(expected.length - 1, 11, 12, 0); |
203 | 209 |
204 // Make sure that the debug event listener vas invoked. | 210 // Make sure that the debug event listener was invoked. |
205 assertFalse(exception, "exception in listener " + exception) | 211 assertFalse(exception, "exception in listener " + exception) |
206 assertTrue(listenerComplete); | 212 assertTrue(listenerComplete); |
207 | 213 |
208 Debug.setListener(null); | 214 Debug.setListener(null); |
OLD | NEW |