2014-10-17 09:26:55 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var SuperBenchmark = new BenchmarkSuite('Super', [100], [
|
|
|
|
new Benchmark('SuperMethodCall', false, false, 0, SuperMethodCall),
|
|
|
|
new Benchmark('SuperGetterCall', false, false, 0, SuperGetterCall),
|
|
|
|
new Benchmark('SuperSetterCall', false, false, 0, SuperSetterCall),
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2015-02-10 21:15:42 +00:00
|
|
|
class Base {
|
|
|
|
constructor() {}
|
2014-10-17 09:26:55 +00:00
|
|
|
get x() {
|
|
|
|
return this._x++;
|
2015-02-10 21:15:42 +00:00
|
|
|
}
|
2014-10-17 09:26:55 +00:00
|
|
|
set x(v) {
|
|
|
|
this._x += v;
|
|
|
|
return this._x;
|
|
|
|
}
|
2015-02-10 21:15:42 +00:00
|
|
|
f() {
|
|
|
|
return this._x++;
|
|
|
|
}
|
2014-10-17 09:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-10 21:15:42 +00:00
|
|
|
class Derived extends Base {
|
|
|
|
constructor() {
|
2015-02-13 18:34:52 +00:00
|
|
|
super();
|
2015-02-10 21:15:42 +00:00
|
|
|
this._x = 1;
|
|
|
|
}
|
|
|
|
SuperCall() {
|
|
|
|
return super.f();
|
|
|
|
}
|
|
|
|
GetterCall() {
|
|
|
|
return super.x;
|
|
|
|
}
|
|
|
|
SetterCall() {
|
|
|
|
return super.x = 5;
|
|
|
|
}
|
2014-10-17 09:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var derived = new Derived();
|
|
|
|
|
|
|
|
function SuperMethodCall() {
|
|
|
|
return derived.SuperCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
function SuperGetterCall() {
|
|
|
|
return derived.GetterCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
function SuperSetterCall() {
|
|
|
|
return derived.SetterCall();
|
|
|
|
}
|