deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / test / mjsunit / compiler / osr-infinite.js
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 --allow-natives-syntax --turbo-osr
6
7 var global_counter = 0;
8
9 function thrower() {
10   var x = global_counter++;
11   if (x == 5)  %OptimizeOsr(thrower.caller);
12   if (x == 10) throw "terminate";
13 }
14
15 %NeverOptimizeFunction(thrower);  // Don't want to inline the thrower.
16 %NeverOptimizeFunction(test);     // Don't want to inline the func into test.
17
18 function test(func) {
19   for (var i = 0; i < 3; i++) {
20     global_counter = 0;
21     assertThrows(func);
22   }
23 }
24
25 function n1() {
26   while (true) thrower();
27 }
28
29 function n2() {
30   while (true) while (true) thrower();
31 }
32
33 function n3() {
34   while (true) while (true) while (true) thrower();
35 }
36
37 function n4() {
38   while (true) while (true) while (true) while (true) thrower();
39 }
40
41 function b1(a) {
42   while (true) {
43     thrower();
44     if (a) break
45   }
46 }
47
48
49 function b2(a) {
50   while (true) {
51     while (true) {
52       thrower();
53       if (a) break
54     }
55   }
56 }
57
58
59 function b3(a) {
60   while (true) {
61     while (true) {
62       while (true) {
63         thrower();
64         if (a) break
65       }
66       if (a) break
67     }
68   }
69 }
70
71
72 test(n1);
73 test(n2);
74 test(n3);
75 test(n4);
76 test(b1);
77 test(b2);
78 test(b3);