summaryrefslogtreecommitdiff
path: root/deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js')
-rw-r--r--deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js b/deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js
new file mode 100644
index 0000000000..bd59bba19e
--- /dev/null
+++ b/deps/v8/test/js-perf-test/SuperIC/megamorphic-mixin.js
@@ -0,0 +1,40 @@
+// Copyright 2020 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.
+
+const DETERMINISTIC_RUNS = 10000;
+new BenchmarkSuite(BENCHMARK_NAME, [1000], [
+ new Benchmark(BENCHMARK_NAME, false, false, DETERMINISTIC_RUNS,
+ runBenchmark)
+]);
+
+function createSubclass() {
+ class A { };
+ A.prototype.super_prop = 10;
+ class B extends A {
+ test() {
+ return super.super_prop;
+ }
+ };
+ return B;
+}
+
+const NO_CLASSES = 10;
+let objects = [];
+for (let i = 0; i < NO_CLASSES; ++i) {
+ const klass = createSubclass();
+ objects.push(new klass());
+}
+
+let ix = 0;
+const EXPECTED_VALUE = 10;
+
+function runBenchmark() {
+ const r = objects[ix].test();
+ if (r != EXPECTED_VALUE) {
+ throw new Error("Test error");
+ }
+ if (++ix == objects.length) {
+ ix = 0;
+ }
+}