OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 28 matching lines...) Expand all Loading... |
39 { locals: {a1: 3, b1: 4}, args: { names: ["i", "x1", "y1"], values: [1, 5, 6]
} }, | 39 { locals: {a1: 3, b1: 4}, args: { names: ["i", "x1", "y1"], values: [1, 5, 6]
} }, |
40 { locals: {a2: 5, b2: 6}, args: { names: ["i"], values: [2] } }, | 40 { locals: {a2: 5, b2: 6}, args: { names: ["i"], values: [2] } }, |
41 { locals: {a3: 7, b3: 8}, args: { names: ["i", "x3", "y3", "z3"], values: [3,
9, 10, undefined] } }, | 41 { locals: {a3: 7, b3: 8}, args: { names: ["i", "x3", "y3", "z3"], values: [3,
9, 10, undefined] } }, |
42 { locals: {a4: 9, b4: 10}, args: { names: ["i", "x4", "y4"], values: [4, 11, 1
2] } } | 42 { locals: {a4: 9, b4: 10}, args: { names: ["i", "x4", "y4"], values: [4, 11, 1
2] } } |
43 ]; | 43 ]; |
44 | 44 |
45 function arraySum(arr) { | 45 function arraySum(arr) { |
46 return arr.reduce(function (a, b) { return a + b; }, 0); | 46 return arr.reduce(function (a, b) { return a + b; }, 0); |
47 } | 47 } |
48 | 48 |
49 function isCurrentlyOptimized(fun) { | |
50 // See runtime.cc. | |
51 return (%GetOptimizationStatus(fun) & 1) != 0; | |
52 } | |
53 | |
54 function listener(event, exec_state, event_data, data) { | 49 function listener(event, exec_state, event_data, data) { |
55 try { | 50 try { |
56 if (event == Debug.DebugEvent.Break) | 51 if (event == Debug.DebugEvent.Break) |
57 { | 52 { |
58 assertEquals(6, exec_state.frameCount()); | 53 assertEquals(6, exec_state.frameCount()); |
59 | 54 |
60 for (var i = 0; i < exec_state.frameCount(); i++) { | 55 for (var i = 0; i < exec_state.frameCount(); i++) { |
61 var frame = exec_state.frame(i); | 56 var frame = exec_state.frame(i); |
62 if (i < exec_state.frameCount() - 1) { | 57 if (i < exec_state.frameCount() - 1) { |
63 var expected_args = expected[i].args; | 58 var expected_args = expected[i].args; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } else { | 137 } else { |
143 assertFalse(frame.isConstructCall()); | 138 assertFalse(frame.isConstructCall()); |
144 } | 139 } |
145 | 140 |
146 if (i > 4) { | 141 if (i > 4) { |
147 assertFalse(frame.isOptimizedFrame()); | 142 assertFalse(frame.isOptimizedFrame()); |
148 assertFalse(frame.isInlinedFrame()); | 143 assertFalse(frame.isInlinedFrame()); |
149 } | 144 } |
150 } | 145 } |
151 | 146 |
152 // When function f is optimized we expect an optimized frame for f. We | |
153 // can't say whether or not the top 3 frames (g1, g2 and g3) are | |
154 // optimized and inlined. | |
155 var frame4 = exec_state.frame(4); | |
156 | |
157 if (isCurrentlyOptimized(f)) { | |
158 assertTrue(frame4.isOptimizedFrame()); | |
159 assertFalse(frame4.isInlinedFrame()); | |
160 } | |
161 | |
162 // Indicate that all was processed. | 147 // Indicate that all was processed. |
163 listenerComplete = true; | 148 listenerComplete = true; |
164 } | 149 } |
165 } catch (e) { | 150 } catch (e) { |
166 exception = e.toString() + e.stack; | 151 exception = e.toString() + e.stack; |
167 }; | 152 }; |
168 }; | 153 }; |
169 | 154 |
170 for (var i = 0; i < 4; i++) f(expected.length - 1, 11, 12); | 155 for (var i = 0; i < 4; i++) f(expected.length - 1, 11, 12); |
171 %OptimizeFunctionOnNextCall(f); | 156 %OptimizeFunctionOnNextCall(f); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 new f(expected.length - 1, 11, 12, 0); | 197 new f(expected.length - 1, 11, 12, 0); |
213 | 198 |
214 // Make sure that the debug event listener was invoked. | 199 // Make sure that the debug event listener was invoked. |
215 assertFalse(exception, "exception in listener " + exception) | 200 assertFalse(exception, "exception in listener " + exception) |
216 assertTrue(listenerComplete); | 201 assertTrue(listenerComplete); |
217 | 202 |
218 // Throw away type information for next run. | 203 // Throw away type information for next run. |
219 gc(); | 204 gc(); |
220 | 205 |
221 Debug.setListener(null); | 206 Debug.setListener(null); |
OLD | NEW |