OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax --use-osr --turbo-osr |
| 6 |
| 7 "use strict"; |
| 8 |
| 9 function test(expected, func) { |
| 10 assertEquals(expected, func()); |
| 11 assertEquals(expected, func()); |
| 12 assertEquals(expected, func()); |
| 13 } |
| 14 |
| 15 function bar() { |
| 16 var result; |
| 17 { |
| 18 let sum = 0; |
| 19 for (let i = 0; i < 90; i++) { |
| 20 sum += i; |
| 21 if (i == 45) %OptimizeOsr(); |
| 22 } |
| 23 result = sum; |
| 24 } |
| 25 return result; |
| 26 } |
| 27 |
| 28 test(4005, bar); |
| 29 |
| 30 function baz() { |
| 31 let sum = 0; |
| 32 for (let i = 0; i < 2; i++) { |
| 33 sum = 2; |
| 34 %OptimizeOsr(); |
| 35 } |
| 36 return sum; |
| 37 } |
| 38 |
| 39 test(2, baz); |
| 40 |
| 41 function qux() { |
| 42 var result = 0; |
| 43 for (let i = 0; i < 2; i++) { |
| 44 result = i; |
| 45 %OptimizeOsr(); |
| 46 } |
| 47 return result; |
| 48 } |
| 49 |
| 50 test(1, qux); |
| 51 |
| 52 function nux() { |
| 53 var result = 0; |
| 54 for (let i = 0; i < 2; i++) { |
| 55 { |
| 56 let sum = i; |
| 57 %OptimizeOsr(); |
| 58 result = sum; |
| 59 } |
| 60 } |
| 61 return result; |
| 62 } |
| 63 |
| 64 test(1, nux); |
| 65 |
| 66 function blo() { |
| 67 var result; |
| 68 { |
| 69 let sum = 0; |
| 70 for (let i = 0; i < 90; i++) { |
| 71 sum += i; |
| 72 if (i == 45) %OptimizeOsr(); |
| 73 } |
| 74 result = ret; |
| 75 function ret() { |
| 76 return sum; |
| 77 } |
| 78 } |
| 79 return result; |
| 80 } |
| 81 |
| 82 test(4005, blo()); |
OLD | NEW |