OLD | NEW |
(Empty) | |
| 1 // 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 |
| 6 var 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 |
| 13 function Base() { } |
| 14 Base.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 |
| 25 Base.prototype.f = function() { |
| 26 return this._x++; |
| 27 }.toMethod(Base.prototype); |
| 28 |
| 29 function Derived() { |
| 30 this._x = 1; |
| 31 } |
| 32 Derived.prototype = Object.create(Base.prototype); |
| 33 Object.setPrototypeOf(Derived, Base); |
| 34 |
| 35 Derived.prototype.SuperCall = function() { |
| 36 return super.f(); |
| 37 }.toMethod(Derived.prototype); |
| 38 |
| 39 Derived.prototype.GetterCall = function() { |
| 40 return super.x; |
| 41 }.toMethod(Derived.prototype); |
| 42 |
| 43 Derived.prototype.SetterCall = function() { |
| 44 return super.x = 5; |
| 45 }.toMethod(Derived.prototype); |
| 46 |
| 47 var derived = new Derived(); |
| 48 |
| 49 function SuperMethodCall() { |
| 50 return derived.SuperCall(); |
| 51 } |
| 52 |
| 53 function SuperGetterCall() { |
| 54 return derived.GetterCall(); |
| 55 } |
| 56 |
| 57 function SuperSetterCall() { |
| 58 return derived.SetterCall(); |
| 59 } |
OLD | NEW |