| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 return r.join(''); | 244 return r.join(''); |
| 245 }); | 245 }); |
| 246 | 246 |
| 247 // Test OSR inside for-in. | 247 // Test OSR inside for-in. |
| 248 function osr_inner(t, limit) { | 248 function osr_inner(t, limit) { |
| 249 var r = 1; | 249 var r = 1; |
| 250 for (var x in t) { | 250 for (var x in t) { |
| 251 if (t.hasOwnProperty(x)) { | 251 if (t.hasOwnProperty(x)) { |
| 252 for (var i = 0; i < t[x].length; i++) { | 252 for (var i = 0; i < t[x].length; i++) { |
| 253 r += t[x][i]; | 253 r += t[x][i]; |
| 254 if (i === limit) { | 254 if (i === limit) %OptimizeOsr(); |
| 255 %OptimizeFunctionOnNextCall(osr_inner, "osr"); | |
| 256 } | |
| 257 } | 255 } |
| 258 r += x; | 256 r += x; |
| 259 } | 257 } |
| 260 } | 258 } |
| 261 return r; | 259 return r; |
| 262 } | 260 } |
| 263 | 261 |
| 264 function osr_outer(t, osr_after) { | 262 function osr_outer(t, osr_after) { |
| 265 var r = 1; | 263 var r = 1; |
| 266 for (var x in t) { | 264 for (var x in t) { |
| 267 for (var i = 0; i < t[x].length; i++) { | 265 for (var i = 0; i < t[x].length; i++) { |
| 268 r += t[x][i]; | 266 r += t[x][i]; |
| 269 } | 267 } |
| 270 if (x === osr_after) { | 268 if (x === osr_after) %OptimizeOsr(); |
| 271 %OptimizeFunctionOnNextCall(osr_outer, "osr"); | |
| 272 } | |
| 273 r += x; | 269 r += x; |
| 274 } | 270 } |
| 275 return r; | 271 return r; |
| 276 } | 272 } |
| 277 | 273 |
| 278 function osr_outer_and_deopt(t, osr_after) { | 274 function osr_outer_and_deopt(t, osr_after) { |
| 279 var r = 1; | 275 var r = 1; |
| 280 for (var x in t) { | 276 for (var x in t) { |
| 281 r += x; | 277 r += x; |
| 282 if (x == osr_after) { | 278 if (x == osr_after) %OptimizeOsr(); |
| 283 %OptimizeFunctionOnNextCall(osr_outer_and_deopt, "osr"); | |
| 284 } | |
| 285 } | 279 } |
| 286 return r; | 280 return r; |
| 287 } | 281 } |
| 288 | 282 |
| 289 function test_osr() { | 283 function test_osr() { |
| 290 with ({}) {} // Disable optimizations of this function. | 284 with ({}) {} // Disable optimizations of this function. |
| 291 var arr = new Array(20); | 285 var arr = new Array(20); |
| 292 for (var i = 0; i < arr.length; i++) { | 286 for (var i = 0; i < arr.length; i++) { |
| 293 arr[i] = i + 1; | 287 arr[i] = i + 1; |
| 294 } | 288 } |
| 295 arr.push(":"); // Force deopt at the end of the loop. | 289 arr.push(":"); // Force deopt at the end of the loop. |
| 296 assertEquals("211:x1234567891011121314151617181920:y", osr_inner({x: arr, y: a
rr}, (arr.length / 2) | 0)); | 290 assertEquals("211:x1234567891011121314151617181920:y", osr_inner({x: arr, y: a
rr}, (arr.length / 2) | 0)); |
| 297 assertEquals("7x456y", osr_outer({x: [1,2,3], y: [4,5,6]}, "x")); | 291 assertEquals("7x456y", osr_outer({x: [1,2,3], y: [4,5,6]}, "x")); |
| 298 assertEquals("101234567", osr_outer_and_deopt([1,2,3,4,5,6,7,8], "5")); | 292 assertEquals("101234567", osr_outer_and_deopt([1,2,3,4,5,6,7,8], "5")); |
| 299 } | 293 } |
| 300 | 294 |
| 301 test_osr(); | 295 test_osr(); |
| OLD | NEW |