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 26 matching lines...) Expand all Loading... |
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 { | 41 { |
42 assertEquals(6, exec_state.frameCount()); | 42 assertEquals(6, exec_state.frameCount()); |
43 | 43 |
44 for (var i = 0; i < exec_state.frameCount(); i++) { | 44 for (var i = 0; i < exec_state.frameCount(); i++) { |
45 var frame = exec_state.frame(i); | 45 var frame = exec_state.frame(i); |
46 if (i < exec_state.frameCount() - 1) { | 46 if (i < exec_state.frameCount() - 1) { |
| 47 var expected_a = i * 2 + 1; |
| 48 var expected_b = i * 2 + 2; |
| 49 var expected_x = (i + 1) * 2 + 1; |
| 50 var expected_y = (i + 1) * 2 + 2; |
| 51 |
47 // All frames except the bottom one has normal variables a and b. | 52 // All frames except the bottom one has normal variables a and b. |
48 assertEquals('a', frame.localName(0)); | 53 assertEquals('a', frame.localName(0)); |
49 assertEquals('b', frame.localName(1)); | 54 assertEquals('b', frame.localName(1)); |
50 assertEquals(i * 2 + 1, frame.localValue(0).value()); | 55 assertEquals(expected_a, frame.localValue(0).value()); |
51 assertEquals(i * 2 + 2, frame.localValue(1).value()); | 56 assertEquals(expected_b, frame.localValue(1).value()); |
52 | 57 |
53 // All frames except the bottom one has arguments variables x and y. | 58 // All frames except the bottom one has arguments variables x and y. |
54 assertEquals('x', frame.argumentName(0)); | 59 assertEquals('x', frame.argumentName(0)); |
55 assertEquals('y', frame.argumentName(1)); | 60 assertEquals('y', frame.argumentName(1)); |
56 assertEquals((i + 1) * 2 + 1, frame.argumentValue(0).value()); | 61 assertEquals(expected_x, frame.argumentValue(0).value()); |
57 assertEquals((i + 1) * 2 + 2, frame.argumentValue(1).value()); | 62 assertEquals(expected_y, frame.argumentValue(1).value()); |
| 63 |
| 64 // All frames except the bottom one have two scopes. |
| 65 assertEquals(2, frame.scopeCount()); |
| 66 assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType()); |
| 67 assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType()); |
| 68 assertEquals(expected_a, frame.scope(0).scopeObject().value()['a']); |
| 69 assertEquals(expected_b, frame.scope(0).scopeObject().value()['b']); |
| 70 assertEquals(expected_x, frame.scope(0).scopeObject().value()['x']); |
| 71 assertEquals(expected_y, frame.scope(0).scopeObject().value()['y']); |
| 72 |
| 73 // Evaluate in the inlined frame. |
| 74 assertEquals(expected_a, frame.evaluate('a').value()); |
| 75 assertEquals(expected_x, frame.evaluate('x').value()); |
| 76 assertEquals(expected_a + expected_b + expected_x + expected_y, |
| 77 frame.evaluate('a + b + x + y').value()); |
| 78 assertEquals(expected_x + expected_y, |
| 79 frame.evaluate('arguments[0] + arguments[1]').value()); |
| 80 } else { |
| 81 // The bottom frame only have the global scope. |
| 82 assertEquals(1, frame.scopeCount()); |
| 83 assertEquals(debug.ScopeType.Global, frame.scope(0).scopeType()); |
58 } | 84 } |
59 | 85 |
60 // Check the frame function. | 86 // Check the frame function. |
61 switch (i) { | 87 switch (i) { |
62 case 0: assertEquals(h, frame.func().value()); break; | 88 case 0: assertEquals(h, frame.func().value()); break; |
63 case 1: assertEquals(g3, frame.func().value()); break; | 89 case 1: assertEquals(g3, frame.func().value()); break; |
64 case 2: assertEquals(g2, frame.func().value()); break; | 90 case 2: assertEquals(g2, frame.func().value()); break; |
65 case 3: assertEquals(g1, frame.func().value()); break; | 91 case 3: assertEquals(g1, frame.func().value()); break; |
66 case 4: assertEquals(f, frame.func().value()); break; | 92 case 4: assertEquals(f, frame.func().value()); break; |
67 case 5: break; | 93 case 5: break; |
68 default: assertUnreachable(); | 94 default: assertUnreachable(); |
69 } | 95 } |
70 | 96 |
71 // Check for construct call. | 97 // Check for construct call. |
72 assertEquals(testingConstructCall && i == 4, frame.isConstructCall()); | 98 assertEquals(testingConstructCall && i == 4, frame.isConstructCall()); |
73 | 99 |
74 // When function f is optimized (2 means YES, see runtime.cc) we | 100 // When function f is optimized (1 means YES, see runtime.cc) we |
75 // expect an optimized frame for f with g1, g2 and g3 inlined. | 101 // expect an optimized frame for f with g1, g2 and g3 inlined. |
76 if (%GetOptimizationStatus(f) == 2) { | 102 if (%GetOptimizationStatus(f) == 1) { |
77 if (i == 1 || i == 2 || i == 3) { | 103 if (i == 1 || i == 2 || i == 3) { |
78 assertTrue(frame.isOptimizedFrame()); | 104 assertTrue(frame.isOptimizedFrame()); |
79 assertTrue(frame.isInlinedFrame()); | 105 assertTrue(frame.isInlinedFrame()); |
| 106 assertEquals(4 - i, frame.inlinedFrameIndex()); |
80 } else if (i == 4) { | 107 } else if (i == 4) { |
81 assertTrue(frame.isOptimizedFrame()); | 108 assertTrue(frame.isOptimizedFrame()); |
82 assertFalse(frame.isInlinedFrame()); | 109 assertFalse(frame.isInlinedFrame()); |
83 } else { | 110 } else { |
84 assertFalse(frame.isOptimizedFrame()); | 111 assertFalse(frame.isOptimizedFrame()); |
85 assertFalse(frame.isInlinedFrame()); | 112 assertFalse(frame.isInlinedFrame()); |
86 } | 113 } |
87 } | 114 } |
88 } | 115 } |
89 | 116 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Test calling f normally and as a constructor. | 162 // Test calling f normally and as a constructor. |
136 f(11, 12); | 163 f(11, 12); |
137 testingConstructCall = true; | 164 testingConstructCall = true; |
138 new f(11, 12); | 165 new f(11, 12); |
139 | 166 |
140 // Make sure that the debug event listener vas invoked. | 167 // Make sure that the debug event listener vas invoked. |
141 assertFalse(exception, "exception in listener " + exception) | 168 assertFalse(exception, "exception in listener " + exception) |
142 assertTrue(listenerComplete); | 169 assertTrue(listenerComplete); |
143 | 170 |
144 Debug.setListener(null); | 171 Debug.setListener(null); |
OLD | NEW |