math-deopt.js 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2018 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 --opt --no-always-opt

(()=> {
  function f(a) {
    return Math.abs(a);
  }
11
  %PrepareFunctionForOptimization(f);
12 13 14 15
  f(1);
  f(1);
  %OptimizeFunctionOnNextCall(f);
  f("100");
16
  %PrepareFunctionForOptimization(f);
17 18 19 20 21 22 23 24 25
  %OptimizeFunctionOnNextCall(f);
  f("100");
  assertOptimized(f);
})();

(()=> {
  function f(a) {
    return Math.min(1,a);
  }
26
  %PrepareFunctionForOptimization(f);
27 28 29 30
  f(1);
  f(1);
  %OptimizeFunctionOnNextCall(f);
  f("100");
31
  %PrepareFunctionForOptimization(f);
32 33 34 35 36 37 38 39 40
  %OptimizeFunctionOnNextCall(f);
  f("100");
  assertOptimized(f);
})();

(()=> {
  function f(a) {
    return Math.pow(a,10);
  }
41
  %PrepareFunctionForOptimization(f);
42 43 44 45
  f(1);
  f(1);
  %OptimizeFunctionOnNextCall(f);
  f("100");
46
  %PrepareFunctionForOptimization(f);
47 48 49 50 51 52 53 54 55
  %OptimizeFunctionOnNextCall(f);
  f("100");
  assertOptimized(f);
})();

(()=> {
  function f(a) {
    return Math.clz32(a);
  }
56
  %PrepareFunctionForOptimization(f);
57 58 59 60
  f(1);
  f(1);
  %OptimizeFunctionOnNextCall(f);
  f("100");
61
  %PrepareFunctionForOptimization(f);
62 63 64 65 66 67 68 69 70
  %OptimizeFunctionOnNextCall(f);
  f("100");
  assertOptimized(f);
})();

(()=> {
  function f(a) {
    return Math.imul(a, 10);
  }
71
  %PrepareFunctionForOptimization(f);
72 73 74 75
  f(1);
  f(1);
  %OptimizeFunctionOnNextCall(f);
  f("100");
76
  %PrepareFunctionForOptimization(f);
77 78 79 80
  %OptimizeFunctionOnNextCall(f);
  f("100");
  assertOptimized(f);
})();