Upgrade V8 to 5.1.281.57
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
diff --git a/test/js-perf-test/Object/ObjectTests.json b/test/js-perf-test/Object/ObjectTests.json
new file mode 100644
index 0000000..1c0e5ed
--- /dev/null
+++ b/test/js-perf-test/Object/ObjectTests.json
@@ -0,0 +1,31 @@
+{
+ "name": "ObjectTests",
+ "run_count": 5,
+ "run_count_android_arm": 3,
+ "run_count_android_arm64": 3,
+ "timeout": 120,
+ "units": "score",
+ "total": true,
+ "resources": ["base.js"],
+ "tests": [
+ {
+ "name": "Object",
+ "path": ["."],
+ "main": "run.js",
+ "flags": ["--harmony"],
+ "resources": [
+ "assign.js",
+ "values.js",
+ "entries.js"
+ ],
+ "results_regexp": "^%s\\-Object\\(Score\\): (.+)$",
+ "tests": [
+ {"name": "Assign"},
+ {"name": "Entries"},
+ {"name": "EntriesMegamorphic"},
+ {"name": "Values"},
+ {"name": "ValuesMegamorphic"}
+ ]
+ }
+ ]
+}
diff --git a/test/js-perf-test/Object/entries.js b/test/js-perf-test/Object/entries.js
new file mode 100644
index 0000000..0658b79
--- /dev/null
+++ b/test/js-perf-test/Object/entries.js
@@ -0,0 +1,75 @@
+// Copyright 2016 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.
+
+new BenchmarkSuite('Entries', [1000], [
+ new Benchmark('Basic', false, false, 0, Basic, BasicSetup, BasicTearDown)
+]);
+
+var object;
+var expected;
+var result;
+var symbol1;
+
+function Basic() {
+ result = Object.entries(object);
+}
+
+
+function BasicSetup() {
+ result = undefined;
+ symbol1 = Symbol('test');
+ object = { a: 10 };
+ object[26.0] = 'third';
+ object.b = 72;
+ object[symbol1] = 'TEST';
+ Object.defineProperty(object, 'not-enumerable', {
+ enumerable: false, value: 'nope', writable: true, configurable: true });
+}
+
+
+function BasicTearDown() {
+ result = result.map(entry => `[${[String(entry[0]), String(entry[1])]}]`);
+ return result.length === 3 &&
+ result.join(', ') === '[a, 10], [26.0, third], [b, 72]';
+}
+
+// ----------------------------------------------------------------------------
+
+new BenchmarkSuite('EntriesMegamorphic', [1000], [
+ new Benchmark('BasicMegamorphic', false, false, 0, BasicMegamorphic,
+ BasicMegamorphicSetup, BasicMegamorphicTearDown)
+]);
+
+function BasicMegamorphic() {
+ for (var i = 0; i < object.length; ++i) {
+ result[i] = Object.entries(object[i]);
+ }
+}
+
+
+function BasicMegamorphicSetup() {
+ // Create 1k objects with different maps.
+ object = [];
+ expected = [];
+ result = [];
+ for (var i=0; i<1000; i++) {
+ var obj = {};
+ var exp = [];
+ for (var j=0; j<10; j++) {
+ obj['key-'+i+'-'+j] = 'property-'+i+'-'+j;
+ exp[j] = ['key-'+i+'-'+j, 'property-'+i+'-'+j];
+ }
+ object[i] = obj;
+ expected[i] = exp;
+ }
+}
+
+
+function BasicMegamorphicTearDown() {
+ if (JSON.stringify(expected) !== JSON.stringify(result)) {
+ throw new Error("FAILURE");
+ }
+ object = result = expected = undefined;
+ return true;
+}
diff --git a/test/js-perf-test/Object/run.js b/test/js-perf-test/Object/run.js
index 15c31ba..f25bee4 100644
--- a/test/js-perf-test/Object/run.js
+++ b/test/js-perf-test/Object/run.js
@@ -4,7 +4,10 @@
load('../base.js');
+
load('assign.js');
+load('values.js');
+load('entries.js');
var success = true;
diff --git a/test/js-perf-test/Object/values.js b/test/js-perf-test/Object/values.js
new file mode 100644
index 0000000..acdec49
--- /dev/null
+++ b/test/js-perf-test/Object/values.js
@@ -0,0 +1,75 @@
+// Copyright 2016 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.
+
+new BenchmarkSuite('Values', [1000], [
+ new Benchmark('Basic', false, false, 0, Basic, BasicSetup, BasicTearDown),
+]);
+
+var object;
+var expected;
+var result;
+var symbol1;
+
+function Basic() {
+ result = Object.values(object);
+}
+
+
+function BasicSetup() {
+ result = undefined;
+ symbol1 = Symbol('test');
+ object = { a: 10 };
+ object[26.0] = 'third';
+ object.b = 72;
+ object[symbol1] = 'TEST';
+ Object.defineProperty(object, 'not-enumerable', {
+ enumerable: false, value: 'nope', writable: true, configurable: true });
+}
+
+
+function BasicTearDown() {
+ return result.length === 3 && result[0] === 10 && result[1] === 'third' &&
+ result[2] === 72;
+}
+
+// ----------------------------------------------------------------------------
+
+new BenchmarkSuite('ValuesMegamorphic', [1000], [
+ new Benchmark('BasicMegamorphic', false, false, 0, BasicMegamorphic,
+ BasicMegamorphicSetup, BasicMegamorphicTearDown)
+]);
+
+
+function BasicMegamorphic() {
+ for (var i = 0; i < object.length; ++i) {
+ result[i] = Object.values(object[i]);
+ }
+}
+
+
+function BasicMegamorphicSetup() {
+ // Create 1k objects with different maps.
+ object = [];
+ expected = [];
+ result = [];
+ for (var i=0; i<1000; i++) {
+ var obj = {};
+ var exp = [];
+ for (var j=0; j<10; j++) {
+ obj['key-'+i+'-'+j] = 'property-'+i+'-'+j;
+ exp[j] = 'property-'+i+'-'+j;
+ }
+ object[i] = obj;
+ expected[i] = exp;
+ }
+}
+
+
+function BasicMegamorphicTearDown() {
+ if (JSON.stringify(expected) !== JSON.stringify(result)) {
+ throw new Error("FAILURE");
+ }
+ object = result = expected = undefined;
+ return true;
+}