| 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 + (i * 2 + 1) / 100; | 46 var expected_a = i * 2 + 1 + (i * 2 + 1) / 100; |
| 48 var expected_b = i * 2 + 2 + (i * 2 + 2) / 100; | 47 var expected_b = i * 2 + 2 + (i * 2 + 2) / 100; |
| 49 var expected_x = (i + 1) * 2 + 1 + ((i + 1) * 2 + 1) / 100; | 48 var expected_x = (i + 1) * 2 + 1 + ((i + 1) * 2 + 1) / 100; |
| 50 var expected_y = (i + 1) * 2 + 2 + ((i + 1) * 2 + 2) / 100; | 49 var expected_y = (i + 1) * 2 + 2 + ((i + 1) * 2 + 2) / 100; |
| 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 a = a + a / 100; | 137 a = a + a / 100; |
| 137 b = b + b / 100; | 138 b = b + b / 100; |
| 138 debugger; // Breakpoint. | 139 debugger; // Breakpoint. |
| 139 }; | 140 } |
| 140 | 141 |
| 141 function g3(x, y) { | 142 function g3(x, y) { |
| 142 var a = 3; | 143 var a = 3; |
| 143 var b = 4; | 144 var b = 4; |
| 144 a = a + a / 100; | 145 a = a + a / 100; |
| 145 b = b + b / 100; | 146 b = b + b / 100; |
| 146 h(a, b); | 147 h(a, b); |
| 147 return a+b; | 148 return a+b; |
| 148 }; | 149 } |
| 149 | 150 |
| 150 function g2(x, y) { | 151 function g2(x, y) { |
| 151 var a = 5; | 152 var a = 5; |
| 152 var b = 6; | 153 var b = 6; |
| 153 a = a + a / 100; | 154 a = a + a / 100; |
| 154 b = b + b / 100; | 155 b = b + b / 100; |
| 155 g3(a, b); | 156 g3(a, b); |
| 156 }; | 157 } |
| 157 | 158 |
| 158 function g1(x, y) { | 159 function g1(x, y) { |
| 159 var a = 7; | 160 var a = 7; |
| 160 var b = 8; | 161 var b = 8; |
| 161 a = a + a / 100; | 162 a = a + a / 100; |
| 162 b = b + b / 100; | 163 b = b + b / 100; |
| 163 g2(a, b); | 164 g2(a, b); |
| 164 }; | 165 } |
| 165 | 166 |
| 166 function f(x, y) { | 167 function f(x, y) { |
| 167 var a = 9; | 168 var a = 9; |
| 168 var b = 10; | 169 var b = 10; |
| 169 a = a + a / 100; | 170 a = a + a / 100; |
| 170 b = b + b / 100; | 171 b = b + b / 100; |
| 171 g1(a, b); | 172 g1(a, b); |
| 172 }; | 173 } |
| 173 | 174 |
| 174 // Test calling f normally and as a constructor. | 175 // Test calling f normally and as a constructor. |
| 175 f(11.11, 12.12); | 176 f(11.11, 12.12); |
| 176 testingConstructCall = true; | 177 testingConstructCall = true; |
| 177 new f(11.11, 12.12); | 178 new f(11.11, 12.12); |
| 178 | 179 |
| 179 // Make sure that the debug event listener vas invoked. | 180 // Make sure that the debug event listener vas invoked. |
| 180 assertFalse(exception, "exception in listener " + exception) | 181 assertFalse(exception, "exception in listener " + exception); |
| 181 assertTrue(listenerComplete); | 182 assertTrue(listenerComplete); |
| 182 | 183 |
| 183 Debug.setListener(null); | 184 Debug.setListener(null); |
| OLD | NEW |