blob: a9ec7666884a8f9b683075885c7c7c170ccd38af [file] [log] [blame]
Emily Bernier958fae72015-03-24 16:35:39 -04001// Copyright 2014 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'use strict';
5
6var SuperBenchmark = new BenchmarkSuite('Super', [100], [
7 new Benchmark('SuperMethodCall', false, false, 0, SuperMethodCall),
8 new Benchmark('SuperGetterCall', false, false, 0, SuperGetterCall),
9 new Benchmark('SuperSetterCall', false, false, 0, SuperSetterCall),
10]);
11
12
13function Base() { }
14Base.prototype = {
15 constructor: Base,
16 get x() {
17 return this._x++;
18 },
19 set x(v) {
20 this._x += v;
21 return this._x;
22 }
23}
24
25Base.prototype.f = function() {
26 return this._x++;
27}.toMethod(Base.prototype);
28
29function Derived() {
30 this._x = 1;
31}
32Derived.prototype = Object.create(Base.prototype);
33Object.setPrototypeOf(Derived, Base);
34
35Derived.prototype.SuperCall = function() {
36 return super.f();
37}.toMethod(Derived.prototype);
38
39Derived.prototype.GetterCall = function() {
40 return super.x;
41}.toMethod(Derived.prototype);
42
43Derived.prototype.SetterCall = function() {
44 return super.x = 5;
45}.toMethod(Derived.prototype);
46
47var derived = new Derived();
48
49function SuperMethodCall() {
50 return derived.SuperCall();
51}
52
53function SuperGetterCall() {
54 return derived.GetterCall();
55}
56
57function SuperSetterCall() {
58 return derived.SetterCall();
59}