blob: dd1ba8d969b5f28b8239aeb65e183511120fcd98 [file] [log] [blame]
Ben Murdochda12d292016-06-02 14:46:10 +01001// Copyright 2016 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
6
7var f1 = function() { while (1) { } }
8
9function g1() {
10 var s = "hey";
11 f1 = function() { return true; }
12 if (f1()) { return s; }
13}
14
15%OptimizeFunctionOnNextCall(g1);
16assertEquals("hey", g1());
17
18var f2 = function() { do { } while (1); }
19
20function g2() {
21 var s = "hey";
22 f2 = function() { return true; }
23 if (f2()) { return s; }
24}
25
26%OptimizeFunctionOnNextCall(g2);
27assertEquals("hey", g2());
28
29var f3 = function() { for (;;); }
30
31function g3() {
32 var s = "hey";
33 f3 = function() { return true; }
34 if (f3()) { return s; }
35}
36
37%OptimizeFunctionOnNextCall(g3);
38assertEquals("hey", g3());
39
40var f4 = function() { for (;;); }
41
42function g4() {
43 var s = "hey";
44 f4 = function() { return true; }
45 while (f4()) { return s; }
46}
47
48%OptimizeFunctionOnNextCall(g4);
49assertEquals("hey", g4());