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 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Let's trigger optimization for another type. | 174 // Let's trigger optimization for another type. |
175 for (var i = 0; i < 5; i++) f("a"); | 175 for (var i = 0; i < 5; i++) f("a"); |
176 | 176 |
177 %OptimizeFunctionOnNextCall(f); | 177 %OptimizeFunctionOnNextCall(f); |
178 f("b"); | 178 f("b"); |
179 | 179 |
180 tracker.AssertOptCount(f, 2); | 180 tracker.AssertOptCount(f, 2); |
181 tracker.AssertIsOptimized(f, true); | 181 tracker.AssertIsOptimized(f, true); |
182 tracker.AssertDeoptHappened(f, true); | 182 tracker.AssertDeoptHappened(f, true); |
183 tracker.AssertDeoptCount(f, 1); | 183 tracker.AssertDeoptCount(f, 1); |
| 184 |
| 185 |
| 186 function deoptTest() { |
| 187 function k(a) { |
| 188 return a / 10; |
| 189 } |
| 190 |
| 191 function f(a) { |
| 192 return k(a); |
| 193 } |
| 194 |
| 195 var tracker = new OptTracker(); |
| 196 tracker.CheckpointOptCount(f); |
| 197 |
| 198 f(10); |
| 199 %OptimizeFunctionOnNextCall(f); |
| 200 f(10); |
| 201 |
| 202 tracker.AssertOptCount(f, 1); |
| 203 tracker.AssertIsOptimized(f, true); |
| 204 tracker.AssertDeoptHappened(f, false); |
| 205 tracker.AssertDeoptCount(f, 0); |
| 206 |
| 207 try { |
| 208 f('a'); |
| 209 } catch(e) { |
| 210 } |
| 211 |
| 212 tracker.AssertIsOptimized(f, false); |
| 213 tracker.AssertDeoptHappened(f, true); |
| 214 tracker.AssertDeoptCount(f, 1); |
| 215 } |
| 216 |
| 217 deoptTest(); |
OLD | NEW |