summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/deopt-bool2.js
blob: 0967112360670fd5b0f7226d8d3c9274974be781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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(expected, x) {
  var passed = expected.length == x.length;
  for (var i = 0; i < expected.length; i++) {
    if (passed)
      passed = expected[i] == x[i];
  }
  print("a");
  print(passed);

  %DeoptimizeFunction(foo);

  print("b");
  print(passed);
  return passed;
}

%PrepareFunctionForOptimization(foo);

assertTrue(foo([0,1], [0,1]));
assertTrue(foo([0,2], [0,2]));
assertFalse(foo([0,2.25], [0,2.75]));

%OptimizeFunctionOnNextCall(foo);

assertTrue(foo([0,1], [0,1]));
assertTrue(foo([0,2], [0,2]));
assertFalse(foo([0,2.25], [0,2.75]));