regress-4971.js 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2016 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 TestDeoptInNamedSuperGetter() {
  class C { m() { return 23 } }
  class D extends C { f() { return super.boom() } }

  var should_deoptimize_caller = false;
  Object.defineProperty(C.prototype, "boom", { get: function() {
    if (should_deoptimize_caller) %DeoptimizeFunction(D.prototype.f);
    return this.m
15
  }});
16

17
  %PrepareFunctionForOptimization(D.prototype.f);
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  assertEquals(23, new D().f());
  assertEquals(23, new D().f());
  %OptimizeFunctionOnNextCall(D.prototype.f);
  assertEquals(23, new D().f());
  should_deoptimize_caller = true;
  assertEquals(23, new D().f());
})();

(function TestDeoptInKeyedSuperGetter() {
  class C { m() { return 23 } }
  class D extends C { f(name) { return super[name]() } }

  var should_deoptimize_caller = false;
  Object.defineProperty(C.prototype, "boom", { get: function() {
    if (should_deoptimize_caller) %DeoptimizeFunction(D.prototype.f);
    return this.m
34
  }});
35

36
  %PrepareFunctionForOptimization(D.prototype.f);
37 38 39 40 41 42 43
  assertEquals(23, new D().f("boom"));
  assertEquals(23, new D().f("boom"));
  %OptimizeFunctionOnNextCall(D.prototype.f);
  assertEquals(23, new D().f("boom"));
  should_deoptimize_caller = true;
  assertEquals(23, new D().f("boom"));
})();