blob: de7ec243fe614273104e424628eaecc258f904ac [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
Ben Murdochc5610432016-08-08 18:44:38 +01005// Flags: --allow-natives-syntax --use-osr
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00006
7var counter = 188;
8
9function gen(w) { // defeat compiler cache.
10 var num = counter++;
11 var Z = [ "", "", "", ];
12 Z[w] = "%OptimizeOsr()";
13 var src =
14 "function f" + num + "(a,b,c) {" +
15 " var x = 0;" +
16 " var y = 0;" +
17 " var z = 0;" +
18 " while (a > 0) { " + Z[0] + "; x += 19; a--; var j=2; while(j--); }" +
19 " while (b > 0) { " + Z[1] + "; y += 23; b--; var j=2; while(j--); }" +
20 " while (c > 0) { " + Z[2] + "; z += 29; c--; var j=2; while(j--); }" +
21 " return x + y + z;" +
22 "} f" + num;
23 return eval(src);
24}
25
26function check(x,a,b,c) {
27 for (var i = 0; i < 3; i++) {
28 var f = gen(i);
29 assertEquals(x, f(a, b, c));
30 }
31}
32
33check(213, 3,3,3);
34check(365, 4,5,6);
35check(6948, 99,98,97);