aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/osr-maze1.js
blob: 2f51d3de21efe163e684a10805b89aef42033782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax --use-osr

function bar(goal) {
  var count = 0;
  var sum = 11;
  var i = 35;
  while (i-- > 33) {
    if (count++ == goal) %OptimizeOsr();
    sum = sum + i;
  }
  while (i-- > 31) {
    if (count++ == goal) %OptimizeOsr();
    j = 9;
    while (j-- > 7) {
      if (count++ == goal) %OptimizeOsr();
      sum = sum + j * 3;
    }
    while (j-- > 5) {
      if (count++ == goal) %OptimizeOsr();
      sum = sum + j * 5;
    }
  }
  while (i-- > 29) {
    if (count++ == goal) %OptimizeOsr();
    while (j-- > 3) {
      var k = 10;
      if (count++ == goal) %OptimizeOsr();
      while (k-- > 8) {
        if (count++ == goal) %OptimizeOsr();
        sum = sum + k * 11;
      }
    }
    while (j-- > 1) {
      if (count++ == goal) %OptimizeOsr();
      while (k-- > 6) {
        if (count++ == goal) %OptimizeOsr();
        sum = sum + j * 13;
      }
    }
  }
  return sum;
}
%PrepareFunctionForOptimization(bar);

for (var i = 0; i < 13; i++) {
  %DeoptimizeFunction(bar);
  assertEquals(348, bar(i));
}