stress-deopt-count-2.js 1.04 KB
Newer Older
1 2 3 4
// Copyright 2017 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.

5
// Flags: --allow-natives-syntax --opt --no-always-opt --deopt-every-n-times=6
6 7 8 9 10 11 12 13

// Check that stress deopt count resets correctly

// Function with two deopt points
function f(x) {
  return x + 1;
}

14
%PrepareFunctionForOptimization(f);
15 16 17
f(1);
%OptimizeFunctionOnNextCall(f);

18
// stress_deopt_count == 6
19 20 21 22

f(1);
assertOptimized(f, undefined, undefined, false);

23
// stress_deopt_count == 4
24 25 26 27

f(1);
assertOptimized(f, undefined, undefined, false);

28
// stress_deopt_count == 2
29 30 31 32 33

f(1);
// deopt & counter reset
assertUnoptimized(f, undefined, undefined, false);

34
// stress_deopt_count == 6
35

36
%PrepareFunctionForOptimization(f);
37 38 39 40
%OptimizeFunctionOnNextCall(f);
f(1);
assertOptimized(f, undefined, undefined, false);

41
// stress_deopt_count == 4
42 43 44 45

f(1);
assertOptimized(f, undefined, undefined, false);

46
// stress_deopt_count == 2
47 48 49 50

f(1);
// deopt & counter reset
assertUnoptimized(f, undefined, undefined, false);