| 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 15 matching lines...) Expand all Loading... |
| 59 switch (i) { | 61 switch (i) { |
| 60 case 0: assertEquals(h, frame.func().value()); break; | 62 case 0: assertEquals(h, frame.func().value()); break; |
| 61 case 1: assertEquals(g3, frame.func().value()); break; | 63 case 1: assertEquals(g3, frame.func().value()); break; |
| 62 case 2: assertEquals(g2, frame.func().value()); break; | 64 case 2: assertEquals(g2, frame.func().value()); break; |
| 63 case 3: assertEquals(g1, frame.func().value()); break; | 65 case 3: assertEquals(g1, frame.func().value()); break; |
| 64 case 4: assertEquals(f, frame.func().value()); break; | 66 case 4: assertEquals(f, frame.func().value()); break; |
| 65 case 5: break; | 67 case 5: break; |
| 66 default: assertUnreachable(); | 68 default: assertUnreachable(); |
| 67 } | 69 } |
| 68 | 70 |
| 71 // Check for construct call. |
| 72 assertEquals(testingConstructCall && i == 4, frame.isConstructCall()); |
| 73 |
| 69 // When function f is optimized (2 means YES, see runtime.cc) we | 74 // When function f is optimized (2 means YES, see runtime.cc) we |
| 70 // expect an optimized frame for f with g1, g2 and g3 inlined. | 75 // expect an optimized frame for f with g1, g2 and g3 inlined. |
| 71 if (%GetOptimizationStatus(f) == 2) { | 76 if (%GetOptimizationStatus(f) == 2) { |
| 72 if (i == 1 || i == 2 || i == 3) { | 77 if (i == 1 || i == 2 || i == 3) { |
| 73 assertTrue(frame.isOptimizedFrame()); | 78 assertTrue(frame.isOptimizedFrame()); |
| 74 assertTrue(frame.isInlinedFrame()); | 79 assertTrue(frame.isInlinedFrame()); |
| 75 } else if (i == 4) { | 80 } else if (i == 4) { |
| 76 assertTrue(frame.isOptimizedFrame()); | 81 assertTrue(frame.isOptimizedFrame()); |
| 77 assertFalse(frame.isInlinedFrame()); | 82 assertFalse(frame.isInlinedFrame()); |
| 78 } else { | 83 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 var b = 8; | 125 var b = 8; |
| 121 g2(a, b); | 126 g2(a, b); |
| 122 }; | 127 }; |
| 123 | 128 |
| 124 function f(x, y) { | 129 function f(x, y) { |
| 125 var a = 9; | 130 var a = 9; |
| 126 var b = 10; | 131 var b = 10; |
| 127 g1(a, b); | 132 g1(a, b); |
| 128 }; | 133 }; |
| 129 | 134 |
| 135 // Test calling f normally and as a constructor. |
| 130 f(11, 12); | 136 f(11, 12); |
| 137 testingConstructCall = true; |
| 138 new f(11, 12); |
| 131 | 139 |
| 132 // Make sure that the debug event listener vas invoked. | 140 // Make sure that the debug event listener vas invoked. |
| 133 assertFalse(exception, "exception in listener " + exception) | 141 assertFalse(exception, "exception in listener " + exception) |
| 134 assertTrue(listenerComplete); | 142 assertTrue(listenerComplete); |
| 135 | 143 |
| 136 Debug.setListener(null); | 144 Debug.setListener(null); |
| OLD | NEW |