blob: 9d0bb47a284ce60caadc49e1c487c49a4ee13b08 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
Ben Murdochc5610432016-08-08 18:44:38 +01005// Flags: --use-osr --allow-natives-syntax
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00006
7var global_counter = 0;
8
9function 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
18function test(func) {
19 for (var i = 0; i < 3; i++) {
20 global_counter = 0;
21 assertThrows(func);
22 }
23}
24
25function n1() {
26 while (true) thrower();
27}
28
29function n2() {
30 while (true) while (true) thrower();
31}
32
33function n3() {
34 while (true) while (true) while (true) thrower();
35}
36
37function n4() {
38 while (true) while (true) while (true) while (true) thrower();
39}
40
41function b1(a) {
42 while (true) {
43 thrower();
44 if (a) break
45 }
46}
47
48
49function b2(a) {
50 while (true) {
51 while (true) {
52 thrower();
53 if (a) break
54 }
55 }
56}
57
58
59function 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
72test(n1);
73test(n2);
74test(n3);
75test(n4);
76test(b1);
77test(b2);
78test(b3);