1// Copyright 2014 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 6// TODO(titzer): enable --turbo-osr when nested OSR works. 7 8function f1(a,b,c) { 9 var x = 0; 10 var y = 0; 11 var z = 0; 12 for (var i = 0; i < 2; i++) { 13 while (a > 0) { x += 19; a--; } 14 while (b > 0) { y += 23; b--; } 15 while (c > 0) { z += 29; c--; } 16 } 17 return x + y + z; 18} 19 20function f2(a,b,c) { 21 var x = 0; 22 var y = 0; 23 var z = 0; 24 for (var i = 0; i < 2; i++) { 25 while (a > 0) { x += 19; a--; } 26 while (b > 0) { y += 23; b--; } 27 while (c > 0) { z += 29; c--; } 28 } 29 return x + y + z; 30} 31 32 33function f3(a,b,c) { 34 var x = 0; 35 var y = 0; 36 var z = 0; 37 for (var i = 0; i < 2; i++) { 38 while (a > 0) { x += 19; a--; } 39 while (b > 0) { y += 23; b--; } 40 while (c > 0) { z += 29; c--; } 41 } 42 return x + y + z; 43} 44 45function check(f,a,b,c) { 46 assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c)); 47} 48 49check(f1, 50000, 5, 6); 50check(f2, 4, 50000, 6); 51check(f3, 11, 12, 50000); 52