blob: 041f6c2a57f06de23ce0945122ae6411c6a25fa1 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7(function TestDeoptInNamedSuperGetter() {
8 class C { m() { return 23 } }
9 class D extends C { f() { return super.boom() } }
10
11 var should_deoptimize_caller = false;
12 Object.defineProperty(C.prototype, "boom", { get: function() {
13 if (should_deoptimize_caller) %DeoptimizeFunction(D.prototype.f);
14 return this.m
15 }})
16
17 assertEquals(23, new D().f());
18 assertEquals(23, new D().f());
19 %OptimizeFunctionOnNextCall(D.prototype.f);
20 assertEquals(23, new D().f());
21 should_deoptimize_caller = true;
22 assertEquals(23, new D().f());
23})();
24
25(function TestDeoptInKeyedSuperGetter() {
26 class C { m() { return 23 } }
27 class D extends C { f(name) { return super[name]() } }
28
29 var should_deoptimize_caller = false;
30 Object.defineProperty(C.prototype, "boom", { get: function() {
31 if (should_deoptimize_caller) %DeoptimizeFunction(D.prototype.f);
32 return this.m
33 }})
34
35 assertEquals(23, new D().f("boom"));
36 assertEquals(23, new D().f("boom"));
37 %OptimizeFunctionOnNextCall(D.prototype.f);
38 assertEquals(23, new D().f("boom"));
39 should_deoptimize_caller = true;
40 assertEquals(23, new D().f("boom"));
41})();