regress-599710.js 1.19 KB
Newer Older
1 2 3 4 5 6
// Copyright 2016 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

7 8 9 10
var f1 = function() {
  while (1) {
  }
};
11 12 13

function g1() {
  var s = "hey";
14 15 16 17 18 19 20 21
  f1 = function() {
    return true;
  };
  if (f1()) {
    return s;
  }
};
%PrepareFunctionForOptimization(g1);
22 23 24
%OptimizeFunctionOnNextCall(g1);
assertEquals("hey", g1());

25 26 27 28
var f2 = function() {
  do {
  } while (1);
};
29 30 31

function g2() {
  var s = "hey";
32 33 34 35 36 37 38 39
  f2 = function() {
    return true;
  };
  if (f2()) {
    return s;
  }
};
%PrepareFunctionForOptimization(g2);
40 41 42
%OptimizeFunctionOnNextCall(g2);
assertEquals("hey", g2());

43 44 45 46
var f3 = function() {
  for (;;)
    ;
};
47 48 49

function g3() {
  var s = "hey";
50 51 52 53 54 55 56 57
  f3 = function() {
    return true;
  };
  if (f3()) {
    return s;
  }
};
%PrepareFunctionForOptimization(g3);
58 59 60
%OptimizeFunctionOnNextCall(g3);
assertEquals("hey", g3());

61 62 63 64
var f4 = function() {
  for (;;)
    ;
};
65 66 67

function g4() {
  var s = "hey";
68 69 70 71 72 73 74 75
  f4 = function() {
    return true;
  };
  while (f4()) {
    return s;
  }
};
%PrepareFunctionForOptimization(g4);
76 77
%OptimizeFunctionOnNextCall(g4);
assertEquals("hey", g4());