Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 27 | |
| 28 // Flags: --expose-debug-as debug --allow-natives-syntax | |
| 29 // Get the Debug object exposed from the debug context global object. | |
| 30 Debug = debug.Debug | |
| 31 | |
| 32 listenerComplete = false; | |
| 33 exception = false; | |
| 34 | |
| 35 | |
| 36 function listener(event, exec_state, event_data, data) { | |
| 37 try { | |
| 38 if (event == Debug.DebugEvent.Break) | |
| 39 { | |
| 40 assertEquals(6, exec_state.frameCount()); | |
| 41 | |
| 42 for (var i = 0; i < exec_state.frameCount(); i++) { | |
| 43 var frame = exec_state.frame(i); | |
| 44 // All frames except the bottom one has normal variables a and b. | |
| 45 if (i < exec_state.frameCount() - 1) { | |
| 46 assertEquals('a', frame.localName(0)); | |
| 47 assertEquals('b', frame.localName(1)); | |
| 48 assertEquals(i * 2 + 1 + (i * 2 + 1) / 100, frame.localValue(0).value( )); | |
|
fschneider
2011/06/29 10:47:35
Long line.
Søren Thygesen Gjesse
2011/06/29 12:42:10
Done.
| |
| 49 assertEquals(i * 2 + 2 + (i * 2 + 2) / 100, frame.localValue(1).value( )); | |
|
fschneider
2011/06/29 10:47:35
Long line.
Søren Thygesen Gjesse
2011/06/29 12:42:10
Done.
| |
| 50 } | |
| 51 | |
| 52 // When function f is optimized (2 means YES, see runtime.cc) we | |
| 53 // expect an optimized frame for f with g1, g2 and g3 inlined. | |
| 54 if (%GetOptimizationStatus(f) == 2) { | |
| 55 if (i == 1 || i == 2 || i == 3) { | |
| 56 assertTrue(frame.isOptimizedFrame()); | |
| 57 assertTrue(frame.isInlinedFrame()); | |
| 58 } else if (i == 4) { | |
| 59 assertTrue(frame.isOptimizedFrame()); | |
| 60 assertFalse(frame.isInlinedFrame()); | |
| 61 } else { | |
| 62 assertFalse(frame.isOptimizedFrame()); | |
| 63 assertFalse(frame.isInlinedFrame()); | |
| 64 } | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 // Indicate that all was processed. | |
| 69 listenerComplete = true; | |
| 70 } | |
| 71 } catch (e) { | |
| 72 exception = e | |
| 73 }; | |
| 74 }; | |
| 75 | |
| 76 f();f();f(); | |
| 77 %OptimizeFunctionOnNextCall(f); | |
| 78 f(); | |
| 79 | |
| 80 // Add the debug event listener. | |
| 81 Debug.setListener(listener); | |
| 82 | |
| 83 function h(x, y) { | |
| 84 var a = 1; | |
| 85 var b = 2; | |
| 86 a = a + a / 100; | |
| 87 b = b + b / 100; | |
| 88 debugger; // Breakpoint. | |
| 89 }; | |
| 90 | |
| 91 function g3(x, y) { | |
| 92 var a = 3; | |
| 93 var b = 4; | |
| 94 a = a + a / 100; | |
| 95 b = b + b / 100; | |
| 96 h(a, b); | |
| 97 return a+b; | |
| 98 }; | |
| 99 | |
| 100 function g2(x, y) { | |
| 101 var a = 5; | |
| 102 var b = 6; | |
| 103 a = a + a / 100; | |
| 104 b = b + b / 100; | |
| 105 g3(a, b); | |
| 106 }; | |
| 107 | |
| 108 function g1(x, y) { | |
| 109 var a = 7; | |
| 110 var b = 8; | |
| 111 a = a + a / 100; | |
| 112 b = b + b / 100; | |
| 113 g2(a, b); | |
| 114 }; | |
| 115 | |
| 116 function f(x, y) { | |
| 117 var a = 9; | |
| 118 var b = 10; | |
| 119 a = a + a / 100; | |
| 120 b = b + b / 100; | |
| 121 g1(a, b); | |
| 122 }; | |
| 123 | |
| 124 f(11.11, 12.12); | |
| 125 | |
| 126 // Make sure that the debug event listener vas invoked. | |
| 127 assertFalse(exception, "exception in listener " + exception) | |
| 128 assertTrue(listenerComplete); | |
| 129 | |
| 130 Debug.setListener(null); | |
| OLD | NEW |