| 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 |
| 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 |
| 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 | 37 |
| 38 function listener(event, exec_state, event_data, data) { | 38 function listener(event, exec_state, event_data, data) { |
| 39 try { | 39 try { |
| 40 if (event == Debug.DebugEvent.Break) | 40 if (event == Debug.DebugEvent.Break) { |
| 41 { | |
| 42 assertEquals(6, exec_state.frameCount()); | 41 assertEquals(6, exec_state.frameCount()); |
| 43 | 42 |
| 44 for (var i = 0; i < exec_state.frameCount(); i++) { | 43 for (var i = 0; i < exec_state.frameCount(); i++) { |
| 45 var frame = exec_state.frame(i); | 44 var frame = exec_state.frame(i); |
| 46 if (i < exec_state.frameCount() - 1) { | 45 if (i < exec_state.frameCount() - 1) { |
| 47 var expected_a = i * 2 + 1; | 46 var expected_a = i * 2 + 1; |
| 48 var expected_b = i * 2 + 2; | 47 var expected_b = i * 2 + 2; |
| 49 var expected_x = (i + 1) * 2 + 1; | 48 var expected_x = (i + 1) * 2 + 1; |
| 50 var expected_y = (i + 1) * 2 + 2; | 49 var expected_y = (i + 1) * 2 + 2; |
| 51 | 50 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 assertFalse(frame.isOptimizedFrame()); | 111 assertFalse(frame.isOptimizedFrame()); |
| 113 assertFalse(frame.isInlinedFrame()); | 112 assertFalse(frame.isInlinedFrame()); |
| 114 } | 113 } |
| 115 } | 114 } |
| 116 } | 115 } |
| 117 | 116 |
| 118 // Indicate that all was processed. | 117 // Indicate that all was processed. |
| 119 listenerComplete = true; | 118 listenerComplete = true; |
| 120 } | 119 } |
| 121 } catch (e) { | 120 } catch (e) { |
| 122 exception = e | 121 exception = e; |
| 123 }; | 122 } |
| 124 }; | 123 } |
| 125 | 124 |
| 126 f();f();f(); | 125 f(); |
| 126 f(); |
| 127 f(); |
| 127 %OptimizeFunctionOnNextCall(f); | 128 %OptimizeFunctionOnNextCall(f); |
| 128 f(); | 129 f(); |
| 129 | 130 |
| 130 // Add the debug event listener. | 131 // Add the debug event listener. |
| 131 Debug.setListener(listener); | 132 Debug.setListener(listener); |
| 132 | 133 |
| 133 function h(x, y) { | 134 function h(x, y) { |
| 134 var a = 1; | 135 var a = 1; |
| 135 var b = 2; | 136 var b = 2; |
| 136 debugger; // Breakpoint. | 137 debugger; // Breakpoint. |
| 137 }; | 138 } |
| 138 | 139 |
| 139 function g3(x, y) { | 140 function g3(x, y) { |
| 140 var a = 3; | 141 var a = 3; |
| 141 var b = 4; | 142 var b = 4; |
| 142 h(a, b); | 143 h(a, b); |
| 143 }; | 144 } |
| 144 | 145 |
| 145 function g2(x, y) { | 146 function g2(x, y) { |
| 146 var a = 5; | 147 var a = 5; |
| 147 var b = 6; | 148 var b = 6; |
| 148 g3(a, b); | 149 g3(a, b); |
| 149 }; | 150 } |
| 150 | 151 |
| 151 function g1(x, y) { | 152 function g1(x, y) { |
| 152 var a = 7; | 153 var a = 7; |
| 153 var b = 8; | 154 var b = 8; |
| 154 g2(a, b); | 155 g2(a, b); |
| 155 }; | 156 } |
| 156 | 157 |
| 157 function f(x, y) { | 158 function f(x, y) { |
| 158 var a = 9; | 159 var a = 9; |
| 159 var b = 10; | 160 var b = 10; |
| 160 g1(a, b); | 161 g1(a, b); |
| 161 }; | 162 } |
| 162 | 163 |
| 163 // Test calling f normally and as a constructor. | 164 // Test calling f normally and as a constructor. |
| 164 f(11, 12); | 165 f(11, 12); |
| 165 testingConstructCall = true; | 166 testingConstructCall = true; |
| 166 new f(11, 12); | 167 new f(11, 12); |
| 167 | 168 |
| 168 // Make sure that the debug event listener vas invoked. | 169 // Make sure that the debug event listener vas invoked. |
| 169 assertFalse(exception, "exception in listener " + exception) | 170 assertFalse(exception, "exception in listener " + exception); |
| 170 assertTrue(listenerComplete); | 171 assertTrue(listenerComplete); |
| 171 | 172 |
| 172 Debug.setListener(null); | 173 Debug.setListener(null); |
| OLD | NEW |