OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 |
(...skipping 11 matching lines...) Expand all Loading... |
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 |
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 listenerComplete = false; | 32 var listenerComplete = false; |
33 exception = false; | 33 var exception = false; |
| 34 |
| 35 var testingConstructCall = false; |
34 | 36 |
35 | 37 |
36 function listener(event, exec_state, event_data, data) { | 38 function listener(event, exec_state, event_data, data) { |
37 try { | 39 try { |
38 if (event == Debug.DebugEvent.Break) | 40 if (event == Debug.DebugEvent.Break) |
39 { | 41 { |
40 assertEquals(6, exec_state.frameCount()); | 42 assertEquals(6, exec_state.frameCount()); |
41 | 43 |
42 for (var i = 0; i < exec_state.frameCount(); i++) { | 44 for (var i = 0; i < exec_state.frameCount(); i++) { |
43 var frame = exec_state.frame(i); | 45 var frame = exec_state.frame(i); |
(...skipping 19 matching lines...) Expand all Loading... |
63 switch (i) { | 65 switch (i) { |
64 case 0: assertEquals(h, frame.func().value()); break; | 66 case 0: assertEquals(h, frame.func().value()); break; |
65 case 1: assertEquals(g3, frame.func().value()); break; | 67 case 1: assertEquals(g3, frame.func().value()); break; |
66 case 2: assertEquals(g2, frame.func().value()); break; | 68 case 2: assertEquals(g2, frame.func().value()); break; |
67 case 3: assertEquals(g1, frame.func().value()); break; | 69 case 3: assertEquals(g1, frame.func().value()); break; |
68 case 4: assertEquals(f, frame.func().value()); break; | 70 case 4: assertEquals(f, frame.func().value()); break; |
69 case 5: break; | 71 case 5: break; |
70 default: assertUnreachable(); | 72 default: assertUnreachable(); |
71 } | 73 } |
72 | 74 |
| 75 // Check for construct call. |
| 76 assertEquals(testingConstructCall && i == 4, frame.isConstructCall()); |
| 77 |
73 // When function f is optimized (2 means YES, see runtime.cc) we | 78 // When function f is optimized (2 means YES, see runtime.cc) we |
74 // expect an optimized frame for f with g1, g2 and g3 inlined. | 79 // expect an optimized frame for f with g1, g2 and g3 inlined. |
75 if (%GetOptimizationStatus(f) == 2) { | 80 if (%GetOptimizationStatus(f) == 2) { |
76 if (i == 1 || i == 2 || i == 3) { | 81 if (i == 1 || i == 2 || i == 3) { |
77 assertTrue(frame.isOptimizedFrame()); | 82 assertTrue(frame.isOptimizedFrame()); |
78 assertTrue(frame.isInlinedFrame()); | 83 assertTrue(frame.isInlinedFrame()); |
79 } else if (i == 4) { | 84 } else if (i == 4) { |
80 assertTrue(frame.isOptimizedFrame()); | 85 assertTrue(frame.isOptimizedFrame()); |
81 assertFalse(frame.isInlinedFrame()); | 86 assertFalse(frame.isInlinedFrame()); |
82 } else { | 87 } else { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }; | 140 }; |
136 | 141 |
137 function f(x, y) { | 142 function f(x, y) { |
138 var a = 9; | 143 var a = 9; |
139 var b = 10; | 144 var b = 10; |
140 a = a + a / 100; | 145 a = a + a / 100; |
141 b = b + b / 100; | 146 b = b + b / 100; |
142 g1(a, b); | 147 g1(a, b); |
143 }; | 148 }; |
144 | 149 |
| 150 // Test calling f normally and as a constructor. |
145 f(11.11, 12.12); | 151 f(11.11, 12.12); |
| 152 testingConstructCall = true; |
| 153 new f(11.11, 12.12); |
146 | 154 |
147 // Make sure that the debug event listener vas invoked. | 155 // Make sure that the debug event listener vas invoked. |
148 assertFalse(exception, "exception in listener " + exception) | 156 assertFalse(exception, "exception in listener " + exception) |
149 assertTrue(listenerComplete); | 157 assertTrue(listenerComplete); |
150 | 158 |
151 Debug.setListener(null); | 159 Debug.setListener(null); |
OLD | NEW |