default-nospec.js 2.21 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, b, c) {
    return String.prototype.indexOf.call(a, b, c);
  }
11
  %PrepareFunctionForOptimization(f);
12 13 14 15
  f("abc", "de", 1);
  f("abc", "de", 1);
  %OptimizeFunctionOnNextCall(f);
  f("abc", "de", {});
16
  %PrepareFunctionForOptimization(f);
17 18 19 20 21 22 23 24 25
  %OptimizeFunctionOnNextCall(f);
  f("abc", "de", {});
  assertOptimized(f);
})();

(()=> {
  function f(a, b, c) {
    return String.prototype.indexOf.apply(a, [b, c]);
  }
26
  %PrepareFunctionForOptimization(f);
27 28 29 30
  f("abc", "de", 1);
  f("abc", "de", 1);
  %OptimizeFunctionOnNextCall(f);
  f("abc", {}, 1);
31
  %PrepareFunctionForOptimization(f);
32 33 34 35 36 37 38 39 40
  %OptimizeFunctionOnNextCall(f);
  f("abc", {}, 1);
  assertOptimized(f);
})();

(()=> {
  function f(a, b, c) {
    return Reflect.apply(String.prototype.indexOf, a, [b, c]);
  }
41
  %PrepareFunctionForOptimization(f);
42 43
  f("abc", "de", 1);
  f("abc", "de", 1);
44
  %PrepareFunctionForOptimization(f);
45 46
  %OptimizeFunctionOnNextCall(f);
  f({}, "de", 1);
47
  %PrepareFunctionForOptimization(f);
48 49 50 51 52 53 54 55 56
  %OptimizeFunctionOnNextCall(f);
  f({}, "de", 1);
  assertOptimized(f);
})();

(()=> {
  function f(a, b) {
    return String.fromCharCode.call(a, b);
  }
57
  %PrepareFunctionForOptimization(f);
58 59 60 61
  f("abc", 1);
  f("abc", 1);
  %OptimizeFunctionOnNextCall(f);
  f("abc", {});
62
  %PrepareFunctionForOptimization(f);
63 64 65 66 67 68 69 70 71
  %OptimizeFunctionOnNextCall(f);
  f({}, {});
  assertOptimized(f);
})();

(()=> {
  function f(a, b) {
    return String.fromCharCode.apply(undefined, [b, {}]);
  }
72
  %PrepareFunctionForOptimization(f);
73 74 75 76
  f("abc", 1);
  f("abc", 1);
  %OptimizeFunctionOnNextCall(f);
  f("abc", {});
77
  %PrepareFunctionForOptimization(f);
78 79 80 81 82 83 84 85 86 87
  %OptimizeFunctionOnNextCall(f);
  f("abc", {});
  assertOptimized(f);
})();


(()=> {
  function f(a, b) {
    return Reflect.apply(String.fromCharCode, a, [b, {}]);
  }
88
  %PrepareFunctionForOptimization(f);
89 90 91 92
  f("abc", 1);
  f("abc", 1);
  %OptimizeFunctionOnNextCall(f);
  f("abc", {});
93
  %PrepareFunctionForOptimization(f);
94 95 96 97
  %OptimizeFunctionOnNextCall(f);
  f("abc", {});
  assertOptimized(f);
})();