deopt-bool.js 632 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// 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

function foo(a, b) {
  var passed = a == 3;
  if (passed) {
    if (passed) {
      passed = b == 4;
    }
  }
  %DeoptimizeFunction(foo);
  return passed;
}

18 19
%PrepareFunctionForOptimization(foo);

20 21 22 23 24 25 26 27 28 29 30
assertTrue(foo(3, 4));
assertTrue(foo(3, 4));
assertFalse(foo(3.1, 4));
assertFalse(foo(3, 4.1));

%OptimizeFunctionOnNextCall(foo);

assertTrue(foo(3, 4));
assertTrue(foo(3, 4));
assertFalse(foo(3.1, 4));
assertFalse(foo(3, 4.1));