regress-6989.js 2.25 KB
Newer Older
1 2 3 4 5 6 7 8 9
// 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.

// Flags: --allow-natives-syntax --opt

(function() {
  function foo(o) { o["x"] = 1; }

10
  %PrepareFunctionForOptimization(foo);
11 12 13 14 15 16 17 18 19 20
  assertThrows(() => foo(undefined));
  assertThrows(() => foo(undefined));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(undefined));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { o["x"] = 1; }

21
  %PrepareFunctionForOptimization(foo);
22 23 24 25 26 27 28 29 30 31
  assertThrows(() => foo(null));
  assertThrows(() => foo(null));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(null));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { return o["x"]; }

32
  %PrepareFunctionForOptimization(foo);
33 34 35 36 37 38 39 40 41 42
  assertThrows(() => foo(undefined));
  assertThrows(() => foo(undefined));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(undefined));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { return o["x"]; }

43
  %PrepareFunctionForOptimization(foo);
44 45 46 47 48 49 50 51 52 53
  assertThrows(() => foo(null));
  assertThrows(() => foo(null));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(null));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { o.x = 1; }

54
  %PrepareFunctionForOptimization(foo);
55 56 57 58 59 60 61 62 63 64
  assertThrows(() => foo(undefined));
  assertThrows(() => foo(undefined));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(undefined));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { o.x = 1; }

65
  %PrepareFunctionForOptimization(foo);
66 67 68 69 70 71 72 73 74 75
  assertThrows(() => foo(null));
  assertThrows(() => foo(null));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(null));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { return o.x; }

76
  %PrepareFunctionForOptimization(foo);
77 78 79 80 81 82 83 84 85 86
  assertThrows(() => foo(undefined));
  assertThrows(() => foo(undefined));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(undefined));
  assertOptimized(foo);
})();

(function() {
  function foo(o) { return o.x; }

87
  %PrepareFunctionForOptimization(foo);
88 89 90 91 92 93
  assertThrows(() => foo(null));
  assertThrows(() => foo(null));
  %OptimizeFunctionOnNextCall(foo);
  assertThrows(() => foo(null));
  assertOptimized(foo);
})();