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: --use-osr --turbo-osr |
| 6 |
| 7 function foo(a) { |
| 8 var sum = 0; |
| 9 var inc = a ? 100 : 200; |
| 10 for (var i = 0; i < 100000; i++) { |
| 11 sum += inc; |
| 12 } |
| 13 return sum + inc; |
| 14 } |
| 15 |
| 16 function bar(a) { |
| 17 var sum = 0; |
| 18 var inc = a ? 100 : 200; |
| 19 var x = a ? 5 : 6; |
| 20 var y = a ? 7 : 8; |
| 21 for (var i = 0; i < 100000; i++) { |
| 22 sum += inc; |
| 23 } |
| 24 return sum ? x : y; |
| 25 } |
| 26 |
| 27 function baz(a) { |
| 28 var limit = a ? 100001 : 100002; |
| 29 var r = 1; |
| 30 var x = a ? 1 : 2; |
| 31 var y = a ? 3 : 4; |
| 32 for (var i = 0; i < limit; i++) { |
| 33 r = r * -1; |
| 34 } |
| 35 return r > 0 ? x == y : x != y; |
| 36 } |
| 37 |
| 38 function qux(a) { |
| 39 var limit = a ? 100001 : 100002; |
| 40 var r = 1; |
| 41 var x = a ? 1 : 2; |
| 42 var y = a ? 3 : 4; |
| 43 for (var i = 0; i < limit; i++) { |
| 44 r = r * -1; |
| 45 } |
| 46 var w = r > 0 ? x : y; |
| 47 var z = r > 0 ? y : x; |
| 48 return w === z; |
| 49 } |
| 50 |
| 51 function test(func, tv, fv) { |
| 52 assertEquals(tv, func(true)); |
| 53 assertEquals(fv, func(false)); |
| 54 assertEquals(tv, func(true)); |
| 55 assertEquals(fv, func(false)); |
| 56 } |
| 57 |
| 58 test(foo, 10000100, 20000200); |
| 59 test(bar, 5, 6); |
| 60 test(baz, true, false); |
| 61 test(qux, false, false); |
OLD | NEW |