| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 { locals: {a3: 7.07, b3: 8.08}, args: { names: ["i", "x3", "y3", "z3"], | 49 { locals: {a3: 7.07, b3: 8.08}, args: { names: ["i", "x3", "y3", "z3"], |
| 50 values: [3, 9.09, 10.10, undefined] } | 50 values: [3, 9.09, 10.10, undefined] } |
| 51 }, | 51 }, |
| 52 { locals: {a4: 9.09, b4: 10.10}, args: { names: ["i", "x4", "y4"], values: [4,
11.11, 12.12] } } | 52 { locals: {a4: 9.09, b4: 10.10}, args: { names: ["i", "x4", "y4"], values: [4,
11.11, 12.12] } } |
| 53 ]; | 53 ]; |
| 54 | 54 |
| 55 function arraySum(arr) { | 55 function arraySum(arr) { |
| 56 return arr.reduce(function (a, b) { return a + b; }, 0); | 56 return arr.reduce(function (a, b) { return a + b; }, 0); |
| 57 } | 57 } |
| 58 | 58 |
| 59 function isCurrentlyOptimized(fun) { | |
| 60 // See runtime.cc. | |
| 61 return (%GetOptimizationStatus(fun) & 1) != 0; | |
| 62 } | |
| 63 | |
| 64 function listener(event, exec_state, event_data, data) { | 59 function listener(event, exec_state, event_data, data) { |
| 65 try { | 60 try { |
| 66 if (event == Debug.DebugEvent.Break) | 61 if (event == Debug.DebugEvent.Break) |
| 67 { | 62 { |
| 68 assertEquals(6, exec_state.frameCount()); | 63 assertEquals(6, exec_state.frameCount()); |
| 69 | 64 |
| 70 for (var i = 0; i < exec_state.frameCount(); i++) { | 65 for (var i = 0; i < exec_state.frameCount(); i++) { |
| 71 var frame = exec_state.frame(i); | 66 var frame = exec_state.frame(i); |
| 72 if (i < exec_state.frameCount() - 1) { | 67 if (i < exec_state.frameCount() - 1) { |
| 73 var expected_args = expected[i].args; | 68 var expected_args = expected[i].args; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } else { | 147 } else { |
| 153 assertFalse(frame.isConstructCall()); | 148 assertFalse(frame.isConstructCall()); |
| 154 } | 149 } |
| 155 | 150 |
| 156 if (i > 4) { | 151 if (i > 4) { |
| 157 assertFalse(frame.isOptimizedFrame()); | 152 assertFalse(frame.isOptimizedFrame()); |
| 158 assertFalse(frame.isInlinedFrame()); | 153 assertFalse(frame.isInlinedFrame()); |
| 159 } | 154 } |
| 160 } | 155 } |
| 161 | 156 |
| 162 // When function f is optimized we expect an optimized frame for f. We | |
| 163 // can't say whether or not the top 3 frames (g1, g2 and g3) are | |
| 164 // optimized and inlined. | |
| 165 var frame4 = exec_state.frame(4); | |
| 166 | |
| 167 if (isCurrentlyOptimized(f)) { | |
| 168 assertTrue(frame4.isOptimizedFrame()); | |
| 169 assertFalse(frame4.isInlinedFrame()); | |
| 170 } | |
| 171 | |
| 172 // Indicate that all was processed. | 157 // Indicate that all was processed. |
| 173 listenerComplete = true; | 158 listenerComplete = true; |
| 174 } | 159 } |
| 175 } catch (e) { | 160 } catch (e) { |
| 176 exception = e.toString() + e.stack; | 161 exception = e.toString() + e.stack; |
| 177 }; | 162 }; |
| 178 }; | 163 }; |
| 179 | 164 |
| 180 for (var i = 0; i < 4; i++) f(input.length - 1, 11.11, 12.12); | 165 for (var i = 0; i < 4; i++) f(input.length - 1, 11.11, 12.12); |
| 181 %OptimizeFunctionOnNextCall(f); | 166 %OptimizeFunctionOnNextCall(f); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 new f(input.length - 1, 11.11, 12.12, ""); | 218 new f(input.length - 1, 11.11, 12.12, ""); |
| 234 | 219 |
| 235 // Make sure that the debug event listener was invoked. | 220 // Make sure that the debug event listener was invoked. |
| 236 assertFalse(exception, "exception in listener " + exception) | 221 assertFalse(exception, "exception in listener " + exception) |
| 237 assertTrue(listenerComplete); | 222 assertTrue(listenerComplete); |
| 238 | 223 |
| 239 //Throw away type information for next run. | 224 //Throw away type information for next run. |
| 240 gc(); | 225 gc(); |
| 241 | 226 |
| 242 Debug.setListener(null); | 227 Debug.setListener(null); |
| OLD | NEW |