OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --allow-natives-syntax --use-osr --turbo-osr | 5 // Flags: --allow-natives-syntax --use-osr --turbo-osr |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 function foo() { | 9 function foo() { |
10 var result; | 10 var result; |
11 { | 11 { |
12 let sum = 0; | 12 let sum = 0; |
13 for (var i = 0; i < 100; i++) { | 13 for (var i = 0; i < 100; i++) { |
14 if (i == 50) %OptimizeOsr(); | 14 if (i == 50) %OptimizeOsr(); |
15 sum += i; | 15 sum += i; |
16 } | 16 } |
17 result = ret; | 17 result = ret; |
18 function ret() { | 18 function ret() { |
19 return sum; | 19 return sum; |
20 } | 20 } |
21 } | 21 } |
22 return result; | 22 return result; |
23 } | 23 } |
24 | 24 |
25 assertEquals(4950, foo()()); | 25 assertEquals(4950, foo()()); |
26 assertEquals(4950, foo()()); | 26 assertEquals(4950, foo()()); |
27 assertEquals(4950, foo()()); | 27 assertEquals(4950, foo()()); |
28 | |
29 function bar() { | |
30 var result; | |
31 { | |
32 let sum = 0; | |
33 for (let i = 0; i < 90; i++) { | |
34 sum += i; | |
35 if (i == 45) %OptimizeOsr(); | |
36 } | |
37 result = ret; | |
38 function ret() { | |
39 return sum; | |
40 } | |
41 } | |
42 return result; | |
43 } | |
44 | |
45 assertEquals(4005, bar()()); | |
46 assertEquals(4005, bar()()); | |
47 assertEquals(4005, bar()()); | |
OLD | NEW |