OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 | 28 // Flags: --expose-debug-as debug --allow-natives-syntax |
29 | 29 |
30 // This test tests that full code compiled without debug break slots | 30 // This test tests that deoptimization due to debug breaks works for |
31 // is recompiled with debug break slots when debugging is started. | 31 // inlined functions where the full-code is generated before the |
| 32 // debugger is attached. |
| 33 // |
| 34 //See http://code.google.com/p/chromium/issues/detail?id=105375 |
32 | 35 |
33 // Get the Debug object exposed from the debug context global object. | 36 // Get the Debug object exposed from the debug context global object. |
34 Debug = debug.Debug | 37 Debug = debug.Debug; |
35 | 38 |
36 var bp; | 39 var count = 0; |
37 var done = false; | 40 var break_count = 0; |
38 var step_count = 0; | |
39 var set_bp = false | |
40 | 41 |
41 // Debug event listener which steps until the global variable done is true. | 42 // Debug event listener which sets a breakpoint first time it is hit |
| 43 // and otherwise counts break points hit and checks that the expected |
| 44 // state is reached. |
42 function listener(event, exec_state, event_data, data) { | 45 function listener(event, exec_state, event_data, data) { |
43 if (event == Debug.DebugEvent.Break) { | 46 if (event == Debug.DebugEvent.Break) { |
44 if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); | 47 break_count++; |
45 step_count++; | 48 if (break_count == 1) { |
| 49 Debug.setBreakPoint(g, 3); |
| 50 |
| 51 for (var i = 0; i < exec_state.frameCount(); i++) { |
| 52 var frame = exec_state.frame(i); |
| 53 // When function f is optimized (1 means YES, see runtime.cc) we |
| 54 // expect an optimized frame for f and g. |
| 55 if (%GetOptimizationStatus(f) == 1) { |
| 56 if (i == 1) { |
| 57 assertTrue(frame.isOptimizedFrame()); |
| 58 assertTrue(frame.isInlinedFrame()); |
| 59 assertEquals(4 - i, frame.inlinedFrameIndex()); |
| 60 } else if (i == 2) { |
| 61 assertTrue(frame.isOptimizedFrame()); |
| 62 assertFalse(frame.isInlinedFrame()); |
| 63 } else { |
| 64 assertFalse(frame.isOptimizedFrame()); |
| 65 assertFalse(frame.isInlinedFrame()); |
| 66 } |
| 67 } |
| 68 } |
| 69 } |
46 } | 70 } |
47 }; | |
48 | |
49 // Set the global variables state to prpare the stepping test. | |
50 function prepare_step_test() { | |
51 done = false; | |
52 step_count = 0; | |
53 } | 71 } |
54 | 72 |
55 // Test function to step through. | |
56 function f() { | 73 function f() { |
57 var a = 0; | 74 g(); |
58 if (set_bp) { bp = Debug.setBreakPoint(f, 3); } | 75 } |
59 var i = 1; | |
60 var j = 2; | |
61 done = true; | |
62 }; | |
63 | 76 |
64 prepare_step_test(); | 77 function g() { |
| 78 count++; |
| 79 h(); |
| 80 var b = 1; // Break point is set here. |
| 81 } |
| 82 |
| 83 function h() { |
| 84 debugger; |
| 85 } |
| 86 |
| 87 f();f();f(); |
| 88 %OptimizeFunctionOnNextCall(f); |
65 f(); | 89 f(); |
66 | 90 |
67 // Add the debug event listener. | 91 // Add the debug event listener. |
68 Debug.setListener(listener); | 92 Debug.setListener(listener); |
69 | 93 |
70 // Make f set a breakpoint with an activation on the stack. | |
71 prepare_step_test(); | |
72 set_bp = true; | |
73 f(); | 94 f(); |
74 // TODO(1782): Fix issue to bring back this assert. | |
75 //assertEquals(4, step_count); | |
76 Debug.clearBreakPoint(bp); | |
77 | 95 |
78 // Set a breakpoint on the first var statement (line 1). | 96 assertEquals(5, count); |
79 set_bp = false; | 97 assertEquals(2, break_count); |
80 bp = Debug.setBreakPoint(f, 3); | |
81 | |
82 // Step through the function ensuring that the var statements are hit as well. | |
83 prepare_step_test(); | |
84 f(); | |
85 // TODO(1782): Fix issue to bring back this assert. | |
86 //assertEquals(4, step_count); | |
87 | |
88 // Clear the breakpoint and check that no stepping happens. | |
89 Debug.clearBreakPoint(bp); | |
90 prepare_step_test(); | |
91 f(); | |
92 assertEquals(0, step_count); | |
93 | 98 |
94 // Get rid of the debug event listener. | 99 // Get rid of the debug event listener. |
95 Debug.setListener(null); | 100 Debug.setListener(null); |
OLD | NEW |