• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6
7function bar(goal) {
8  var count = 0;
9  var sum = 11;
10  var i = 35;
11  while (i-- > 33) {
12    if (count++ == goal) %OptimizeOsr();
13    sum = sum + i;
14  }
15  while (i-- > 31) {
16    if (count++ == goal) %OptimizeOsr();
17    j = 9;
18    while (j-- > 7) {
19      if (count++ == goal) %OptimizeOsr();
20      sum = sum + j * 3;
21    }
22    while (j-- > 5) {
23      if (count++ == goal) %OptimizeOsr();
24      sum = sum + j * 5;
25    }
26  }
27  while (i-- > 29) {
28    if (count++ == goal) %OptimizeOsr();
29    while (j-- > 3) {
30      var k = 10;
31      if (count++ == goal) %OptimizeOsr();
32      while (k-- > 8) {
33        if (count++ == goal) %OptimizeOsr();
34        sum = sum + k * 11;
35      }
36    }
37    while (j-- > 1) {
38      if (count++ == goal) %OptimizeOsr();
39      while (k-- > 6) {
40        if (count++ == goal) %OptimizeOsr();
41        sum = sum + j * 13;
42      }
43    }
44  }
45  return sum;
46}
47
48for (var i = 0; i < 13; i++) {
49  %DeoptimizeFunction(bar);
50  assertEquals(348, bar(i));
51}
52