summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6
diff options
context:
space:
mode:
authorMyles Borins <mylesborins@google.com>2018-04-10 21:39:51 -0400
committerMyles Borins <mylesborins@google.com>2018-04-11 13:22:42 -0400
commit12a1b9b8049462e47181a298120243dc83e81c55 (patch)
tree8605276308c8b4e3597516961266bae1af57557a /deps/v8/test/mjsunit/es6
parent78cd8263354705b767ef8c6a651740efe4931ba0 (diff)
downloadandroid-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.tar.gz
android-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.tar.bz2
android-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.zip
deps: update V8 to 6.6.346.23
PR-URL: https://github.com/nodejs/node/pull/19201 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/mjsunit/es6')
-rw-r--r--deps/v8/test/mjsunit/es6/array-from.js8
-rw-r--r--deps/v8/test/mjsunit/es6/array-iterator.js4
-rw-r--r--deps/v8/test/mjsunit/es6/classof-proxy.js27
-rw-r--r--deps/v8/test/mjsunit/es6/collection-iterator.js2
-rw-r--r--deps/v8/test/mjsunit/es6/collections-constructor-custom-iterator.js65
-rw-r--r--deps/v8/test/mjsunit/es6/collections-constructor-iterator-side-effect.js80
-rw-r--r--deps/v8/test/mjsunit/es6/collections-constructor-with-modified-array-prototype.js65
-rw-r--r--deps/v8/test/mjsunit/es6/collections-constructor-with-modified-protoype.js76
-rw-r--r--deps/v8/test/mjsunit/es6/collections.js11
-rw-r--r--deps/v8/test/mjsunit/es6/generators-objects.js1
-rw-r--r--deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect.js48
-rw-r--r--deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect2.js53
-rw-r--r--deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect3.js43
-rw-r--r--deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect4.js53
-rw-r--r--deps/v8/test/mjsunit/es6/promise-resolve-thenable-job.js127
-rw-r--r--deps/v8/test/mjsunit/es6/proxies.js4
-rw-r--r--deps/v8/test/mjsunit/es6/proxy-function-tostring.js7
-rw-r--r--deps/v8/test/mjsunit/es6/spread-array-mutated-prototype.js236
-rw-r--r--deps/v8/test/mjsunit/es6/spread-array-pristine-prototype.js (renamed from deps/v8/test/mjsunit/es6/spread-array.js)8
-rw-r--r--deps/v8/test/mjsunit/es6/spread-array-prototype-proxy.js21
-rw-r--r--deps/v8/test/mjsunit/es6/spread-array-prototype-setter1.js22
-rw-r--r--deps/v8/test/mjsunit/es6/spread-array-prototype-setter2.js22
-rw-r--r--deps/v8/test/mjsunit/es6/symbols.js2
-rw-r--r--deps/v8/test/mjsunit/es6/templates.js162
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like.js63
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-every.js1
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-filter.js111
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-foreach.js1
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-from.js140
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-of.js16
-rw-r--r--deps/v8/test/mjsunit/es6/unicode-regexp-restricted-syntax.js1
31 files changed, 1403 insertions, 77 deletions
diff --git a/deps/v8/test/mjsunit/es6/array-from.js b/deps/v8/test/mjsunit/es6/array-from.js
index c483d3deb6..02a599d4ca 100644
--- a/deps/v8/test/mjsunit/es6/array-from.js
+++ b/deps/v8/test/mjsunit/es6/array-from.js
@@ -161,6 +161,14 @@ assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError);
// The setter wasn't called
assertEquals(0, setterCalled);
+// Non-callable iterators should cause a TypeError before calling the target
+// constructor.
+items = {};
+items[Symbol.iterator] = 7;
+function TestError() {}
+function ArrayLike() { throw new TestError() }
+assertThrows(function() { Array.from.call(ArrayLike, items); }, TypeError);
+
// Check that array properties defined are writable, enumerable, configurable
function ordinary() { }
var x = Array.from.call(ordinary, [2]);
diff --git a/deps/v8/test/mjsunit/es6/array-iterator.js b/deps/v8/test/mjsunit/es6/array-iterator.js
index d2d19b059d..b143c8c034 100644
--- a/deps/v8/test/mjsunit/es6/array-iterator.js
+++ b/deps/v8/test/mjsunit/es6/array-iterator.js
@@ -152,10 +152,6 @@ function TestArrayIteratorPrototype() {
assertEquals(Object.prototype, ArrayIteratorPrototype.__proto__);
- assertEquals('Array Iterator', %_ClassOf(array[Symbol.iterator]()));
- assertEquals('Array Iterator', %_ClassOf(array.keys()));
- assertEquals('Array Iterator', %_ClassOf(array.entries()));
-
assertFalse(ArrayIteratorPrototype.hasOwnProperty('constructor'));
assertArrayEquals(['next'],
Object.getOwnPropertyNames(ArrayIteratorPrototype));
diff --git a/deps/v8/test/mjsunit/es6/classof-proxy.js b/deps/v8/test/mjsunit/es6/classof-proxy.js
deleted file mode 100644
index 02043614ba..0000000000
--- a/deps/v8/test/mjsunit/es6/classof-proxy.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2015 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.
-
-// Flags: --allow-natives-syntax
-
-function test_function(o) {
- if (%_ClassOf(o) === "Function") {
- return true;
- } else {
- return false;
- }
-}
-
-var non_callable = new Proxy({}, {});
-var callable = new Proxy(function(){}.__proto__, {});
-var constructable = new Proxy(function(){}, {});
-
-assertFalse(test_function(non_callable));
-assertTrue(test_function(callable));
-assertTrue(test_function(constructable));
-
-%OptimizeFunctionOnNextCall(test_function);
-
-assertFalse(test_function(non_callable));
-assertTrue(test_function(callable));
-assertTrue(test_function(constructable));
diff --git a/deps/v8/test/mjsunit/es6/collection-iterator.js b/deps/v8/test/mjsunit/es6/collection-iterator.js
index 5a9b2f54e6..8257d96664 100644
--- a/deps/v8/test/mjsunit/es6/collection-iterator.js
+++ b/deps/v8/test/mjsunit/es6/collection-iterator.js
@@ -14,7 +14,6 @@ function test(f) {
test(function TestSetIterator() {
var s = new Set;
var iter = s.values();
- assertEquals('Set Iterator', %_ClassOf(iter));
var SetIteratorPrototype = iter.__proto__;
assertFalse(SetIteratorPrototype.hasOwnProperty('constructor'));
@@ -160,7 +159,6 @@ test(function TestSetIteratorSymbol() {
test(function TestMapIterator() {
var m = new Map;
var iter = m.values();
- assertEquals('Map Iterator', %_ClassOf(iter));
var MapIteratorPrototype = iter.__proto__;
assertFalse(MapIteratorPrototype.hasOwnProperty('constructor'));
diff --git a/deps/v8/test/mjsunit/es6/collections-constructor-custom-iterator.js b/deps/v8/test/mjsunit/es6/collections-constructor-custom-iterator.js
new file mode 100644
index 0000000000..e4b52bc5c5
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/collections-constructor-custom-iterator.js
@@ -0,0 +1,65 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestSetWithCustomIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const entries = [k1];
+ let callCount = 0;
+ entries[Symbol.iterator] = () => ({
+ next: () =>
+ callCount++ === 0
+ ? { value: k2, done: false }
+ : { done: true }
+ });
+ const set = new ctor(entries);
+ assertFalse(set.has(k1));
+ assertTrue(set.has(k2));
+ assertEquals(2, callCount);
+}
+TestSetWithCustomIterator(Set);
+TestSetWithCustomIterator(Set);
+TestSetWithCustomIterator(Set);
+%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
+TestSetWithCustomIterator(Set);
+assertOptimized(TestSetWithCustomIterator);
+
+TestSetWithCustomIterator(WeakSet);
+TestSetWithCustomIterator(WeakSet);
+TestSetWithCustomIterator(WeakSet);
+%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
+TestSetWithCustomIterator(WeakSet);
+assertOptimized(TestSetWithCustomIterator);
+
+function TestMapWithCustomIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const entries = [[k1, 1]];
+ let callCount = 0;
+ entries[Symbol.iterator] = () => ({
+ next: () =>
+ callCount++ === 0
+ ? { value: [k2, 2], done: false }
+ : { done: true }
+ });
+ const map = new ctor(entries);
+ assertFalse(map.has(k1));
+ assertEquals(2, map.get(k2));
+ assertEquals(2, callCount);
+}
+TestMapWithCustomIterator(Map);
+TestMapWithCustomIterator(Map);
+TestMapWithCustomIterator(Map);
+%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
+TestMapWithCustomIterator(Map);
+assertOptimized(TestMapWithCustomIterator);
+
+TestMapWithCustomIterator(WeakMap);
+TestMapWithCustomIterator(WeakMap);
+TestMapWithCustomIterator(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
+TestMapWithCustomIterator(WeakMap);
+assertOptimized(TestMapWithCustomIterator);
diff --git a/deps/v8/test/mjsunit/es6/collections-constructor-iterator-side-effect.js b/deps/v8/test/mjsunit/es6/collections-constructor-iterator-side-effect.js
new file mode 100644
index 0000000000..50308fdde3
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/collections-constructor-iterator-side-effect.js
@@ -0,0 +1,80 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestSetWithModifiedIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const entries = [k1, k2];
+ const arrayIteratorProto = Object.getPrototypeOf(entries[Symbol.iterator]());
+ const originalNext = arrayIteratorProto.next;
+ let callCount = 0;
+ arrayIteratorProto.next = function() {
+ callCount++;
+ return originalNext.call(this);
+ };
+
+ const set = new ctor(entries);
+ assertEquals(3, callCount); // +1 for iterator done
+
+ if('size' in set) assertEquals(2, set.size);
+ assertTrue(set.has(k1));
+ assertTrue(set.has(k2));
+
+ arrayIteratorProto.next = originalNext;
+}
+TestSetWithModifiedIterator(Set);
+TestSetWithModifiedIterator(Set);
+TestSetWithModifiedIterator(Set);
+%OptimizeFunctionOnNextCall(TestSetWithModifiedIterator);
+TestSetWithModifiedIterator(Set);
+assertOptimized(TestSetWithModifiedIterator);
+%DeoptimizeFunction(TestSetWithModifiedIterator);
+
+TestSetWithModifiedIterator(WeakSet);
+TestSetWithModifiedIterator(WeakSet);
+TestSetWithModifiedIterator(WeakSet);
+%OptimizeFunctionOnNextCall(TestSetWithModifiedIterator);
+TestSetWithModifiedIterator(WeakSet);
+assertOptimized(TestSetWithModifiedIterator);
+%DeoptimizeFunction(TestSetWithModifiedIterator);
+
+
+function TestMapWithModifiedIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const entries = [[k1, 1], [k2, 2]];
+ const arrayIteratorProto = Object.getPrototypeOf(entries[Symbol.iterator]());
+ const originalNext = arrayIteratorProto.next;
+ let callCount = 0;
+ arrayIteratorProto.next = function() {
+ callCount++;
+ return originalNext.call(this);
+ };
+
+ const set = new ctor(entries);
+ assertEquals(3, callCount); // +1 for iterator done
+
+ if('size' in set) assertEquals(2, set.size);
+ assertEquals(1, set.get(k1));
+ assertEquals(2, set.get(k2));
+
+ arrayIteratorProto.next = originalNext;
+}
+TestMapWithModifiedIterator(Map);
+TestMapWithModifiedIterator(Map);
+TestMapWithModifiedIterator(Map);
+%OptimizeFunctionOnNextCall(TestMapWithModifiedIterator);
+TestMapWithModifiedIterator(Map);
+assertOptimized(TestMapWithModifiedIterator);
+%DeoptimizeFunction(TestMapWithModifiedIterator);
+
+TestMapWithModifiedIterator(WeakMap);
+TestMapWithModifiedIterator(WeakMap);
+TestMapWithModifiedIterator(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapWithModifiedIterator);
+TestMapWithModifiedIterator(WeakMap);
+assertOptimized(TestMapWithModifiedIterator);
+%DeoptimizeFunction(TestMapWithModifiedIterator);
diff --git a/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-array-prototype.js b/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-array-prototype.js
new file mode 100644
index 0000000000..cc441b1ad4
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-array-prototype.js
@@ -0,0 +1,65 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestSetWithCustomIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ let callCount = 0;
+ Array.prototype[Symbol.iterator] = () => ({
+ next: () =>
+ callCount++ === 0
+ ? { value: k2, done: false }
+ : { done: true }
+ });
+ const entries = [k1];
+ const set = new ctor(entries);
+ assertFalse(set.has(k1));
+ assertTrue(set.has(k2));
+ assertEquals(2, callCount);
+}
+TestSetWithCustomIterator(Set);
+TestSetWithCustomIterator(Set);
+TestSetWithCustomIterator(Set);
+%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
+TestSetWithCustomIterator(Set);
+assertOptimized(TestSetWithCustomIterator);
+
+TestSetWithCustomIterator(WeakSet);
+TestSetWithCustomIterator(WeakSet);
+TestSetWithCustomIterator(WeakSet);
+%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
+TestSetWithCustomIterator(WeakSet);
+assertOptimized(TestSetWithCustomIterator);
+
+function TestMapWithCustomIterator(ctor) {
+ const k1 = {};
+ const k2 = {};
+ let callCount = 0;
+ Array.prototype[Symbol.iterator] = () => ({
+ next: () =>
+ callCount++ === 0
+ ? { value: [k2, 2], done: false }
+ : { done: true }
+ });
+ const entries = [[k1, 1]];
+ const map = new ctor(entries);
+ assertFalse(map.has(k1));
+ assertEquals(2, map.get(k2));
+ assertEquals(2, callCount);
+}
+TestMapWithCustomIterator(Map);
+TestMapWithCustomIterator(Map);
+TestMapWithCustomIterator(Map);
+%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
+TestMapWithCustomIterator(Map);
+assertOptimized(TestMapWithCustomIterator);
+
+TestMapWithCustomIterator(WeakMap);
+TestMapWithCustomIterator(WeakMap);
+TestMapWithCustomIterator(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
+TestMapWithCustomIterator(WeakMap);
+assertOptimized(TestMapWithCustomIterator);
diff --git a/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-protoype.js b/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-protoype.js
new file mode 100644
index 0000000000..a427895243
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/collections-constructor-with-modified-protoype.js
@@ -0,0 +1,76 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestSetPrototypeModified(ctor) {
+ const originalPrototypeAdd = ctor.prototype.add;
+ const k1 = {};
+ const k2 = {};
+ const entries = [k1, k2];
+ let addCount = 0;
+
+ ctor.prototype.add = function(value) {
+ addCount++;
+ originalPrototypeAdd.call(this, value);
+ entries.length = 1;
+ };
+ const set = new ctor(entries);
+
+ assertEquals(1, addCount);
+ assertTrue(set.has(k1));
+ assertFalse(set.has(k2));
+
+ ctor.prototype.add = originalPrototypeAdd;
+}
+TestSetPrototypeModified(Set);
+TestSetPrototypeModified(Set);
+TestSetPrototypeModified(Set);
+%OptimizeFunctionOnNextCall(TestSetPrototypeModified);
+TestSetPrototypeModified(Set);
+assertOptimized(TestSetPrototypeModified);
+%DeoptimizeFunction(TestSetPrototypeModified);
+
+TestSetPrototypeModified(WeakSet);
+TestSetPrototypeModified(WeakSet);
+TestSetPrototypeModified(WeakSet);
+%OptimizeFunctionOnNextCall(TestSetPrototypeModified);
+TestSetPrototypeModified(WeakSet);
+assertOptimized(TestSetPrototypeModified);
+%DeoptimizeFunction(TestSetPrototypeModified);
+
+function TestMapPrototypeModified(ctor) {
+ const originalPrototypeSet = ctor.prototype.set;
+ const k1 = {};
+ const k2 = {};
+ const entries = [[k1, 1], [k2, 2]];
+ let setCount = 0;
+
+ ctor.prototype.set = function(key, value) {
+ setCount++;
+ originalPrototypeSet.call(this, key, value);
+ entries.length = 1;
+ };
+ const map = new ctor(entries);
+
+ assertEquals(1, setCount);
+ assertTrue(map.has(k1));
+ assertFalse(map.has(k2));
+
+ ctor.prototype.set = originalPrototypeSet;
+}
+TestMapPrototypeModified(Map);
+TestMapPrototypeModified(Map);
+TestMapPrototypeModified(Map);
+%OptimizeFunctionOnNextCall(TestMapPrototypeModified);
+TestMapPrototypeModified(Map);
+assertOptimized(TestMapPrototypeModified);
+%DeoptimizeFunction(TestMapPrototypeModified);
+
+TestMapPrototypeModified(WeakMap);
+TestMapPrototypeModified(WeakMap);
+TestMapPrototypeModified(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapPrototypeModified);
+TestMapPrototypeModified(WeakMap);
+assertOptimized(TestMapPrototypeModified);
diff --git a/deps/v8/test/mjsunit/es6/collections.js b/deps/v8/test/mjsunit/es6/collections.js
index 1664a93bde..feae629439 100644
--- a/deps/v8/test/mjsunit/es6/collections.js
+++ b/deps/v8/test/mjsunit/es6/collections.js
@@ -307,17 +307,6 @@ assertTrue(WeakSet.prototype.has instanceof Function)
assertTrue(WeakSet.prototype.delete instanceof Function)
-// Test class of instance and prototype.
-assertEquals("Set", %_ClassOf(new Set))
-assertEquals("Object", %_ClassOf(Set.prototype))
-assertEquals("Map", %_ClassOf(new Map))
-assertEquals("Object", %_ClassOf(Map.prototype))
-assertEquals("WeakMap", %_ClassOf(new WeakMap))
-assertEquals("Object", %_ClassOf(WeakMap.prototype))
-assertEquals("WeakSet", %_ClassOf(new WeakSet))
-assertEquals("Object", %_ClassOf(WeakMap.prototype))
-
-
// Test name of constructor.
assertEquals("Set", Set.name);
assertEquals("Map", Map.name);
diff --git a/deps/v8/test/mjsunit/es6/generators-objects.js b/deps/v8/test/mjsunit/es6/generators-objects.js
index 2cc359f911..ff216d43e4 100644
--- a/deps/v8/test/mjsunit/es6/generators-objects.js
+++ b/deps/v8/test/mjsunit/es6/generators-objects.js
@@ -55,7 +55,6 @@ function TestGeneratorObject() {
var iter = g();
assertSame(g.prototype, Object.getPrototypeOf(iter));
assertTrue(iter instanceof g);
- assertEquals("Generator", %_ClassOf(iter));
assertEquals("[object Generator]", String(iter));
assertEquals([], Object.getOwnPropertyNames(iter));
assertTrue(iter !== g());
diff --git a/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect.js b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect.js
new file mode 100644
index 0000000000..813fffccf7
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect.js
@@ -0,0 +1,48 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestMapConstructorEntrySideEffect(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const k3 = {};
+ let callCount = 0;
+ const input = [
+ Object.defineProperty([, 1], "0", {
+ get() {
+ input.length = 2;
+ return k1;
+ }
+ }),
+ [k2, 2],
+ Object.defineProperty([, 3], "0", {
+ get() {
+ callCount++;
+ return k3;
+ }
+ })
+ ];
+ const col = new ctor(input);
+
+ assertEquals(0, callCount);
+ if ('size' in col) assertEquals(2, col.size);
+ assertEquals(col.get(k1), 1);
+ assertEquals(col.get(k2), 2);
+ assertFalse(col.has(k3));
+}
+
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(Map);
+assertOptimized(TestMapConstructorEntrySideEffect);
+
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(WeakMap);
+assertOptimized(TestMapConstructorEntrySideEffect);
diff --git a/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect2.js b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect2.js
new file mode 100644
index 0000000000..0c167c1bfa
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect2.js
@@ -0,0 +1,53 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestMapConstructorEntrySideEffect(ctor) {
+ const originalPrototypeSet = ctor.prototype.set;
+ const k1 = {};
+ const k2 = {};
+ let callCount = 0;
+ const input = [
+ Object.defineProperty([, 1], "0", {
+ get() {
+ // Verify continuation retains original set function
+ ctor.prototype.set = () => {
+ callCount++;
+ };
+ return k1;
+ }
+ }),
+ [k2, 2]
+ ];
+ const col = new ctor(input);
+
+ assertEquals(0, callCount);
+ if ('size' in col) assertEquals(2, col.size);
+ assertTrue(col.has(k1));
+ assertTrue(col.has(k2));
+
+ const col2 = new ctor(input);
+
+ assertEquals(2, callCount);
+ if ('size' in col) assertEquals(0, col2.size);
+ assertFalse(col2.has(k1));
+ assertFalse(col2.has(k2));
+
+ ctor.prototype.set = originalPrototypeSet;
+}
+
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(Map);
+assertOptimized(TestMapConstructorEntrySideEffect);
+
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(WeakMap);
+assertOptimized(TestMapConstructorEntrySideEffect);
diff --git a/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect3.js b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect3.js
new file mode 100644
index 0000000000..7dd7aa7852
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect3.js
@@ -0,0 +1,43 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestMapConstructorEntrySideEffect(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const k3 = {};
+ const input = [
+ Object.defineProperty([, 1], "0", {
+ get() {
+ // Verify continuation accesses properly accesses subsequent entries
+ Object.defineProperty(input, "1", {
+ get: () => [k3, 3]
+ });
+ return k1;
+ }
+ }),
+ [k2, 2]
+ ];
+ const col = new ctor(input);
+
+ if ('size' in col) assertEquals(2, col.size);
+ assertTrue(col.has(k1));
+ assertFalse(col.has(k2));
+ assertTrue(col.has(k3));
+}
+
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(Map);
+assertOptimized(TestMapConstructorEntrySideEffect);
+
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(WeakMap);
+assertOptimized(TestMapConstructorEntrySideEffect);
diff --git a/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect4.js b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect4.js
new file mode 100644
index 0000000000..ebf8c790ed
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/map-constructor-entry-side-effect4.js
@@ -0,0 +1,53 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax --opt
+
+function TestMapConstructorEntrySideEffect(ctor) {
+ const k1 = {};
+ const k2 = {};
+ const k3 = {};
+ let firstEntryCallCount = 0;
+ let lastEntryCallCount = 0;
+ const input = [
+ Object.defineProperty([, 1], "0", {
+ get() {
+ // Verify handling of a non-Smi array length
+ input.length = 2 ** 32 - 2;
+ firstEntryCallCount++;
+ return k1;
+ }
+ }),
+ [k2, 2],
+ Object.defineProperty([k3, ], "1", {
+ get() {
+ input.length = 1;
+ lastEntryCallCount++;
+ return 3;
+ }
+ })
+ ];
+ const col = new ctor(input);
+
+ assertEquals(1, firstEntryCallCount,);
+ assertEquals(1, lastEntryCallCount);
+ if ('size' in col) assertEquals(3, col.size);
+ assertEquals(1, col.get(k1));
+ assertEquals(2, col.get(k2));
+ assertEquals(3, col.get(k3));
+}
+
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+TestMapConstructorEntrySideEffect(Map);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(Map);
+assertOptimized(TestMapConstructorEntrySideEffect);
+
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+TestMapConstructorEntrySideEffect(WeakMap);
+%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
+TestMapConstructorEntrySideEffect(WeakMap);
+assertOptimized(TestMapConstructorEntrySideEffect);
diff --git a/deps/v8/test/mjsunit/es6/promise-resolve-thenable-job.js b/deps/v8/test/mjsunit/es6/promise-resolve-thenable-job.js
new file mode 100644
index 0000000000..70ab6cda96
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/promise-resolve-thenable-job.js
@@ -0,0 +1,127 @@
+// Copyright 2018 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.
+
+(function() {
+ let resolve;
+ let onFulfilledValue;
+ const p = new Promise(r => resolve = r);
+ resolve(Promise.resolve(1));
+ p.then(
+ v => {
+ onFulfilledValue = v;
+ },
+ e => {
+ assertUnreachable();
+ });
+ setTimeout(_ => assertEquals(1, onFulfilledValue));
+})();
+
+(function() {
+ let resolve;
+ let onRejectedReason;
+ const p = new Promise(r => resolve = r);
+ resolve(Promise.reject(1));
+ p.then(
+ v => {
+ assertUnreachable();
+ },
+ e => {
+ onRejectedReason = e;
+ });
+ setTimeout(_ => assertEquals(1, onRejectedReason));
+})();
+
+(function() {
+ let onFulfilledValue;
+ (async () => Promise.resolve(1))().then(
+ v => {
+ onFulfilledValue = v;
+ },
+ e => {
+ assertUnreachable();
+ });
+ setTimeout(_ => assertEquals(1, onFulfilledValue));
+})();
+
+(function() {
+ let onRejectedReason;
+ (async () => Promise.reject(1))().then(
+ v => {
+ assertUnreachable();
+ },
+ e => {
+ onRejectedReason = e;
+ });
+ setTimeout(_ => assertEquals(1, onRejectedReason));
+})();
+
+(function() {
+ let resolve;
+ let onFulfilledValue;
+ const p = new Promise(r => resolve = r);
+ resolve({
+ then(onFulfilled, onRejected) {
+ onFulfilled(1);
+ }
+ });
+ p.then(
+ v => {
+ onFulfilledValue = v;
+ },
+ e => {
+ assertUnreachable();
+ });
+ setTimeout(_ => assertEquals(1, onFulfilledValue));
+})();
+
+(function() {
+ let resolve;
+ let onRejectedReason;
+ const p = new Promise(r => resolve = r);
+ resolve({
+ then(onFulfilled, onRejected) {
+ onRejected(1);
+ }
+ });
+ p.then(
+ v => {
+ assertUnreachable();
+ },
+ e => {
+ onRejectedReason = e;
+ });
+ setTimeout(_ => assertEquals(1, onRejectedReason));
+})();
+
+(function() {
+ let onFulfilledValue;
+ (async () => ({
+ then(onFulfilled, onRejected) {
+ onFulfilled(1);
+ }
+ }))().then(
+ v => {
+ onFulfilledValue = v;
+ },
+ e => {
+ assertUnreachable();
+ });
+ setTimeout(_ => assertEquals(1, onFulfilledValue));
+})();
+
+(function() {
+ let onRejectedReason;
+ (async () => ({
+ then(onFulfilled, onRejected) {
+ onRejected(1);
+ }
+ }))().then(
+ v => {
+ assertUnreachable();
+ },
+ e => {
+ onRejectedReason = e;
+ });
+ setTimeout(_ => assertEquals(1, onRejectedReason));
+})();
diff --git a/deps/v8/test/mjsunit/es6/proxies.js b/deps/v8/test/mjsunit/es6/proxies.js
index 75a80a15bd..f67f9df41e 100644
--- a/deps/v8/test/mjsunit/es6/proxies.js
+++ b/deps/v8/test/mjsunit/es6/proxies.js
@@ -1287,8 +1287,7 @@ TestKeysThrow({
// ---------------------------------------------------------------------------
// String conversion (Object.prototype.toString,
-// Object.prototype.toLocaleString,
-// Function.prototype.toString)
+// Object.prototype.toLocaleString)
var key
@@ -1306,7 +1305,6 @@ function TestToString(handler) {
assertEquals(Symbol.toStringTag, key)
assertEquals("my_proxy", Object.prototype.toLocaleString.call(f))
assertEquals("toString", key)
- assertThrows(function(){ Function.prototype.toString.call(f) })
var o = Object.create(p)
key = ""
diff --git a/deps/v8/test/mjsunit/es6/proxy-function-tostring.js b/deps/v8/test/mjsunit/es6/proxy-function-tostring.js
new file mode 100644
index 0000000000..d859822df0
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/proxy-function-tostring.js
@@ -0,0 +1,7 @@
+// Copyright 2018 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.
+//
+// Flags: --noharmony-function-tostring
+
+assertThrows(() => new Proxy(function() {}, {}).toString(), TypeError);
diff --git a/deps/v8/test/mjsunit/es6/spread-array-mutated-prototype.js b/deps/v8/test/mjsunit/es6/spread-array-mutated-prototype.js
new file mode 100644
index 0000000000..5d29e7a8f0
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/spread-array-mutated-prototype.js
@@ -0,0 +1,236 @@
+// Copyright 2015 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.
+
+// Flags: --allow-natives-syntax
+
+// NOTE:
+// Tests in this file are meant to run in the presence of an invalidated
+// NoElementsProtector, as effected by the following line.
+Array.prototype[0] = 42;
+delete Array.prototype[0];
+
+
+(function TestBasics() {
+ var a = [1, 2];
+ var b = [...a];
+ assertArrayEquals([1, 2], b)
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e', 'f'],
+ ['a', ...'bc', 'd', ...'ef'])
+})();
+
+
+var log = [];
+
+function* gen(n) {
+ log.push(n, 1);
+ yield 1;
+ log.push(n, 2);
+ yield 2;
+ log.push(n, 3);
+ yield 3;
+ log.push(n, 'done');
+}
+
+function id(v) {
+ log.push(v);
+ return v;
+}
+
+
+(function TestGenerator() {
+ assertArrayEquals([1, 2, 3], [...gen('a')]);
+ assertArrayEquals(['x', 1, 2, 3, 'y', 1, 2, 3, 'z'],
+ ['x', ...gen('a'), 'y', ...gen('b'), 'z']);
+})();
+
+
+(function TestOrderOfExecution() {
+ log = [];
+ assertArrayEquals(['x', 1, 2, 3, 'y', 1, 2, 3, 'z'],
+ [id('x'), ...gen('a'), id('y'), ...gen('b'), id('z')]);
+ assertArrayEquals([
+ 'x', 'a', 1, 'a', 2, 'a', 3, 'a', 'done',
+ 'y', 'b', 1, 'b', 2, 'b', 3, 'b', 'done',
+ 'z'
+ ], log);
+})();
+
+
+(function TestNotIterable() {
+ var a;
+ assertThrows(function() {
+ a = [...42];
+ }, TypeError);
+ assertSame(undefined, a);
+
+
+})();
+
+
+(function TestInvalidIterator() {
+ var iter = {
+ [Symbol.iterator]: 42
+ };
+ var a;
+ assertThrows(function() {
+ a = [...iter];
+ }, TypeError);
+ assertSame(undefined, a);
+})();
+
+
+(function TestIteratorNotAnObject() {
+ var iter = {
+ [Symbol.iterator]() {
+ return 42;
+ }
+ };
+ var a;
+ assertThrows(function() {
+ a = [...iter];
+ }, TypeError);
+ assertSame(undefined, a);
+})();
+
+
+(function TestIteratorNoNext() {
+ var iter = {
+ [Symbol.iterator]() {
+ return {};
+ }
+ };
+ var a;
+ assertThrows(function() {
+ a = [...iter];
+ }, TypeError);
+ assertSame(undefined, a);
+})();
+
+
+(function TestIteratorResultDoneThrows() {
+ function MyError() {}
+ var iter = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ return {
+ get done() {
+ throw new MyError();
+ }
+ }
+ }
+ };
+ }
+ };
+ var a;
+ assertThrows(function() {
+ a = [...iter];
+ }, MyError);
+ assertSame(undefined, a);
+})();
+
+
+(function TestIteratorResultValueThrows() {
+ function MyError() {}
+ var iter = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ return {
+ done: false,
+ get value() {
+ throw new MyError();
+ }
+ }
+ }
+ };
+ }
+ };
+ var a;
+ assertThrows(function() {
+ a = [...iter];
+ }, MyError);
+ assertSame(undefined, a);
+})();
+
+
+(function TestOptimize() {
+ function f() {
+ return [...'abc'];
+ }
+ assertArrayEquals(['a', 'b', 'c'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c'], f());
+})();
+
+
+(function TestDeoptimize() {
+ var iter = {
+ [Symbol.iterator]() {
+ var i = 0;
+ return {
+ next() {
+ %DeoptimizeFunction(f);
+ return {value: ++i, done: i === 3};
+ }
+ };
+ }
+ };
+ function f() {
+ return [0, ...iter];
+ }
+
+ assertArrayEquals([0, 1, 2], f());
+})();
+
+
+(function TestPrototypeSetter1() {
+ Object.defineProperty(Array.prototype, 3, {set() {throw 666}})
+ Object.defineProperty(Array.prototype, 4, {set() {throw 666}})
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ delete Array.prototype[3];
+ delete Array.prototype[4];
+})();
+
+
+(function TestPrototypeSetter2() {
+ Object.defineProperty(Array.prototype.__proto__, 3, {set() {throw 666}})
+ Object.defineProperty(Array.prototype.__proto__, 4, {set() {throw 666}})
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ delete Array.prototype.__proto__[3];
+ delete Array.prototype.__proto__[4];
+})();
+
+
+(function TestPrototypeProxy() {
+ const backup = Array.prototype.__proto__;
+ Array.prototype.__proto__ = new Proxy({}, {set() {throw 666}});
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ Object.setPrototypeOf(Array.prototype, backup);
+})();
diff --git a/deps/v8/test/mjsunit/es6/spread-array.js b/deps/v8/test/mjsunit/es6/spread-array-pristine-prototype.js
index d112422b78..ea4d133703 100644
--- a/deps/v8/test/mjsunit/es6/spread-array.js
+++ b/deps/v8/test/mjsunit/es6/spread-array-pristine-prototype.js
@@ -4,6 +4,10 @@
// Flags: --allow-natives-syntax
+// NOTE:
+// Tests in this file are meant to run in the presence of a valid
+// NoElementsProtector. Do not touch Array.prototype here.
+
(function TestBasics() {
var a = [1, 2];
var b = [...a];
@@ -165,7 +169,7 @@ function id(v) {
var i = 0;
return {
next() {
- $DeoptimizeFunction(f);
+ %DeoptimizeFunction(f);
return {value: ++i, done: i === 3};
}
};
@@ -176,4 +180,4 @@ function id(v) {
}
assertArrayEquals([0, 1, 2], f());
-});
+})();
diff --git a/deps/v8/test/mjsunit/es6/spread-array-prototype-proxy.js b/deps/v8/test/mjsunit/es6/spread-array-prototype-proxy.js
new file mode 100644
index 0000000000..ed38228c28
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/spread-array-prototype-proxy.js
@@ -0,0 +1,21 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax
+
+
+(function TestPrototypeProxy() {
+ const backup = Array.prototype.__proto__;
+ Array.prototype.__proto__ = new Proxy({}, {set() {throw 666}});
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ Object.setPrototypeOf(Array.prototype, backup);
+})();
diff --git a/deps/v8/test/mjsunit/es6/spread-array-prototype-setter1.js b/deps/v8/test/mjsunit/es6/spread-array-prototype-setter1.js
new file mode 100644
index 0000000000..2ca9e21787
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/spread-array-prototype-setter1.js
@@ -0,0 +1,22 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax
+
+
+(function TestPrototypeSetter1() {
+ Object.defineProperty(Array.prototype, 3, {set() {throw 666}})
+ Object.defineProperty(Array.prototype, 4, {set() {throw 666}})
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ delete Array.prototype[3];
+ delete Array.prototype[4];
+})();
diff --git a/deps/v8/test/mjsunit/es6/spread-array-prototype-setter2.js b/deps/v8/test/mjsunit/es6/spread-array-prototype-setter2.js
new file mode 100644
index 0000000000..736d50b46b
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/spread-array-prototype-setter2.js
@@ -0,0 +1,22 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax
+
+
+(function TestPrototypeSetter2() {
+ Object.defineProperty(Array.prototype.__proto__, 3, {set() {throw 666}})
+ Object.defineProperty(Array.prototype.__proto__, 4, {set() {throw 666}})
+
+ function f() {
+ return ['a', ...['b', 'c', 'd'], 'e']
+ }
+
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+ %OptimizeFunctionOnNextCall(f);
+ assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
+
+ delete Array.prototype.__proto__[3];
+ delete Array.prototype.__proto__[4];
+})();
diff --git a/deps/v8/test/mjsunit/es6/symbols.js b/deps/v8/test/mjsunit/es6/symbols.js
index d83e2174ec..a6c12909b4 100644
--- a/deps/v8/test/mjsunit/es6/symbols.js
+++ b/deps/v8/test/mjsunit/es6/symbols.js
@@ -67,8 +67,6 @@ function TestType() {
assertEquals("symbol", typeof symbols[i])
assertTrue(typeof symbols[i] === "symbol")
assertFalse(%SymbolIsPrivate(symbols[i]))
- assertEquals(null, %_ClassOf(symbols[i]))
- assertEquals("Symbol", %_ClassOf(Object(symbols[i])))
}
}
TestType()
diff --git a/deps/v8/test/mjsunit/es6/templates.js b/deps/v8/test/mjsunit/es6/templates.js
index 3eb73e4d16..3e113cb829 100644
--- a/deps/v8/test/mjsunit/es6/templates.js
+++ b/deps/v8/test/mjsunit/es6/templates.js
@@ -342,27 +342,30 @@ var obj = {
var a = 1;
var b = 2;
- tag`head${a}tail`;
- tag`head${b}tail`;
-
+ // Call-sites are cached by ParseNode. Same tag call in a loop
+ // means same template object
+ for (var i = 0; i < 2; ++i) {
+ tag`head${i == 0 ? a : b}tail`;
+ }
assertEquals(2, callSites.length);
assertSame(callSites[0], callSites[1]);
- eval("tag`head${a}tail`");
- assertEquals(3, callSites.length);
- assertSame(callSites[1], callSites[2]);
-
- eval("tag`head${b}tail`");
+ // Tag calls within eval() never have the same ParseNode as the same tag
+ // call from a different eval() invocation.
+ for (var i = 0; i < 2; ++i) {
+ eval("tag`head${i == 0 ? a : b}tail`");
+ }
assertEquals(4, callSites.length);
- assertSame(callSites[2], callSites[3]);
+ assertTrue(callSites[1] !== callSites[2]);
+ assertTrue(callSites[2] !== callSites[3]);
(new Function("tag", "a", "b", "return tag`head${a}tail`;"))(tag, 1, 2);
assertEquals(5, callSites.length);
- assertSame(callSites[3], callSites[4]);
+ assertTrue(callSites[3] !== callSites[4]);
(new Function("tag", "a", "b", "return tag`head${b}tail`;"))(tag, 1, 2);
assertEquals(6, callSites.length);
- assertSame(callSites[4], callSites[5]);
+ assertTrue(callSites[4] !== callSites[5]);
callSites = [];
@@ -374,17 +377,19 @@ var obj = {
callSites = [];
- eval("tag`\\\r\n\\\n\\\r`");
- eval("tag`\\\r\n\\\n\\\r`");
+ for (var i = 0; i < 2; ++i) {
+ eval("tag`\\\r\n\\\n\\\r`");
+ }
assertEquals(2, callSites.length);
- assertSame(callSites[0], callSites[1]);
+ assertTrue(callSites[0] !== callSites[1]);
assertEquals("", callSites[0][0]);
assertEquals("\\\n\\\n\\\n", callSites[0].raw[0]);
callSites = [];
- tag`\uc548\ub155`;
- tag`\uc548\ub155`;
+ for (var i = 0; i < 2; ++i) {
+ tag`\uc548\ub155`;
+ }
assertEquals(2, callSites.length);
assertSame(callSites[0], callSites[1]);
assertEquals("안녕", callSites[0][0]);
@@ -735,3 +740,128 @@ var global = this;
assertThrows(() => Function("f`foo`--"), ReferenceError);
assertThrows(() => Function("f`foo` = 1"), ReferenceError);
})();
+
+// Disable eval caching if a tagged template occurs in a nested function
+var v = 0;
+var templates = [];
+function tag(callSite) { templates.push(callSite); }
+for (v = 0; v < 6; v += 2) {
+ eval("(function() { for (var i = 0; i < 2; ++i) tag`Hello${v}world` })()");
+ assertSame(templates[v], templates[v + 1]);
+}
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+
+function makeSource1(id) {
+ return `function f() {
+ for (var i = 0; i < 2; ++i) tag\`Hello${id}world\`;
+ }
+ f();`;
+}
+templates = [];
+for (v = 0; v < 6; v += 2) {
+ eval(makeSource1(v));
+ assertSame(templates[v], templates[v + 1]);
+}
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+
+templates = [];
+eval("(function() { for (var i = 0; i < 2; ++i) tag`Hello${1}world` })()");
+eval("(function() { for (var i = 0; i < 2; ++i) tag`Hello${2}world` })()");
+eval("(function() { for (var i = 0; i < 2; ++i) tag`Hello${2}world` })()");
+assertSame(templates[0], templates[1]);
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertSame(templates[2], templates[3]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+assertSame(templates[4],templates[5]);
+
+templates = [];
+eval(makeSource1(1));
+eval(makeSource1(2));
+eval(makeSource1(3));
+assertSame(templates[0], templates[1]);
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertSame(templates[2], templates[3]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+assertSame(templates[4],templates[5]);
+
+// Disable eval caching if a tagged template occurs in an even deeper nested function
+var v = 0;
+templates = [];
+for (v = 0; v < 6; v += 2) {
+ eval("(function() { (function() { for (var i = 0; i < 2; ++i) tag`Hello${v}world` })() })()");
+ if (!v) continue;
+ assertNotSame(templates[v], templates[v - 1]);
+}
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+
+function makeSource2(id) {
+ return `function f() {
+ function innerF() {
+ for (var i = 0; i < 2; ++i) tag\`Hello${id}world\`;
+ }
+ return innerF();
+ }
+ f();`;
+}
+templates = [];
+for (v = 0; v < 6; v += 2) {
+ eval(makeSource2(v));
+ assertSame(templates[v], templates[v + 1]);
+}
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+
+templates = [];
+eval("(function() { (function() { for (var i = 0; i < 2; ++i) tag`Hello${1}world` })() })()");
+eval("(function() { (function() { for (var i = 0; i < 2; ++i) tag`Hello${2}world` })() })()");
+eval("(function() { (function() { for (var i = 0; i < 2; ++i) tag`Hello${2}world` })() })()");
+assertSame(templates[0], templates[1]);
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertSame(templates[2], templates[3]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+assertSame(templates[4], templates[5]);
+
+templates = [];
+eval(makeSource2(1));
+eval(makeSource2(2));
+eval(makeSource2(3));
+assertSame(templates[0], templates[1]);
+assertNotSame(templates[0], templates[2]);
+assertNotSame(templates[0], templates[4]);
+assertNotSame(templates[1], templates[3]);
+assertNotSame(templates[1], templates[5]);
+assertSame(templates[2], templates[3]);
+assertNotSame(templates[2], templates[4]);
+assertNotSame(templates[3], templates[5]);
+assertSame(templates[4], templates[5]);
diff --git a/deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like.js b/deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like.js
index 66316f300e..6573f2635d 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like.js
@@ -120,6 +120,31 @@ tests.push(function TestConstructFromArrayNoIteratorWithGetter(constr) {
assertArrayEquals([1, 2, 22], ta);
});
+tests.push(function TestConstructFromArrayNullIterator(constr) {
+ var arr = [1, 2, 3];
+ arr[Symbol.iterator] = null;
+
+ var ta = new Uint8Array(arr);
+
+ assertArrayEquals([1, 2, 3], ta);
+});
+
+tests.push(function TestConstructFromArrayUndefinedIterator(constr) {
+ var arr = [1, 2, 3];
+ arr[Symbol.iterator] = undefined;
+
+ var ta = new Uint8Array(arr);
+
+ assertArrayEquals([1, 2, 3], ta);
+});
+
+tests.push(function TestConstructFromArrayNonCallableIterator(constr) {
+ var arr = [1, 2, 3];
+ arr[Symbol.iterator] = 1;
+
+ assertThrows(() => new Uint8Array(arr), TypeError);
+});
+
tests.push(function TestConstructFromArray(constr) {
var n = 64;
var jsArray = [];
@@ -150,6 +175,44 @@ tests.push(function TestConstructFromTypedArray(constr) {
}
});
+tests.push(function TestFromTypedArraySpecies(constr) {
+ var b = new ArrayBuffer(16);
+ var a1 = new constr(b);
+
+ var constructor_read = 0;
+ var cons = b.constructor;
+
+ Object.defineProperty(b, 'constructor', {
+ get: function() {
+ constructor_read++;
+ return cons;
+ }
+ });
+
+ var a2 = new constr(a1);
+
+ assertEquals(1, constructor_read);
+});
+
+tests.push(function TestFromTypedArraySpeciesNeutersBuffer(constr) {
+ var b = new ArrayBuffer(16);
+ var a1 = new constr(b);
+
+ var constructor_read = 0;
+ var cons = b.constructor;
+
+ Object.defineProperty(b, 'constructor', {
+ get: function() {
+ %ArrayBufferNeuter(b);
+ return cons;
+ }
+ });
+
+ var a2 = new constr(a1);
+
+ assertArrayEquals([], a2);
+});
+
tests.push(function TestLengthIsMaxSmi(constr) {
var myObject = { 0: 5, 1: 6, length: %_MaxSmi() + 1 };
diff --git a/deps/v8/test/mjsunit/es6/typedarray-every.js b/deps/v8/test/mjsunit/es6/typedarray-every.js
index a3498f5786..968078988f 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-every.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-every.js
@@ -132,7 +132,6 @@ function TestTypedArrayForEach(constructor) {
});
assertEquals(2, count);
assertTrue(!!buffer);
- assertEquals("ArrayBuffer", %_ClassOf(buffer));
assertSame(buffer, a.buffer);
// The %TypedArray%.every() method should not work when
diff --git a/deps/v8/test/mjsunit/es6/typedarray-filter.js b/deps/v8/test/mjsunit/es6/typedarray-filter.js
new file mode 100644
index 0000000000..0f25c362ec
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-filter.js
@@ -0,0 +1,111 @@
+// Copyright 2018 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.
+
+// Flags: --allow-natives-syntax
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function TestTypedArrayFilter(constructor) {
+ assertEquals(1, constructor.prototype.filter.length);
+
+ // Throw type error if source array is detached while executing a callback
+ let ta1 = new constructor(10);
+ assertThrows(() =>
+ ta1.filter(() => %ArrayBufferNeuter(ta1.buffer))
+ , TypeError);
+
+ // A new typed array should be created after finishing callbacks
+ var speciesCreated = 0;
+
+ class MyTypedArray extends constructor {
+ static get [Symbol.species]() {
+ return function() {
+ speciesCreated++;
+ return new constructor(10);
+ };
+ }
+ }
+
+ new MyTypedArray(10).filter(() => {
+ assertEquals(0, speciesCreated);
+ return true;
+ });
+ assertEquals(1, speciesCreated);
+
+ // A new typed array should be initialized to 0s
+ class LongTypedArray extends constructor {
+ static get [Symbol.species]() {
+ return function(len) {
+ return new constructor(len * 2);
+ }
+ }
+ }
+ let ta2 = new LongTypedArray(3).fill(1);
+ let ta3 = ta2.filter((val, index, array) => val > 0);
+ assertArrayEquals(ta3, [1, 1, 1, 0, 0, 0]);
+ assertEquals(ta3.constructor, constructor);
+
+ // Throw if a new typed array is too small
+ class ShortTypedArray extends constructor {
+ static get [Symbol.species]() {
+ return function(len) {
+ return new constructor(len/2);
+ }
+ }
+ }
+ assertThrows(() => new ShortTypedArray(10).filter(() => true));
+
+ // Throw if callback is not callable
+ assertThrows(() => new constructor(10).filter(123));
+ assertThrows(() => new constructor(10).filter({}));
+
+ // Empty result
+ assertEquals(new constructor(10).filter(() => false), new constructor(0));
+
+ // If a new typed array shares a buffer with a source array
+ let ab = new ArrayBuffer(100);
+ class SharedBufferTypedArray extends constructor {
+ static get [Symbol.species]() {
+ return function(len) {
+ return new constructor(ab, 0, 5);
+ }
+ }
+ }
+ let ta4 = new SharedBufferTypedArray(ab, 0, 5).fill(1);
+ let ta5 = ta4.filter(() => {
+ ta4[0] = 123;
+ ta4[2] = 123;
+ return true;
+ });
+ assertEquals(ta4.buffer, ta5.buffer);
+ assertArrayEquals(ta4, [1, 1, 123, 1, 1]);
+ assertArrayEquals(ta5, [1, 1, 123, 1, 1]);
+
+ // If a new typed array has a different type with source array
+ for (let j = 0; j < typedArrayConstructors.length; j++) {
+ let otherConstructor = typedArrayConstructors[j];
+ class OtherTypedArray extends constructor {
+ static get [Symbol.species]() {
+ return function(len) {
+ return new otherConstructor(len);
+ }
+ }
+ }
+ let ta6 = new OtherTypedArray(10).fill(123);
+ assertEquals(ta6.filter(() => true), new otherConstructor(10).fill(123));
+ }
+}
+
+for (i = 0; i < typedArrayConstructors.length; i++) {
+ TestTypedArrayFilter(typedArrayConstructors[i]);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-foreach.js b/deps/v8/test/mjsunit/es6/typedarray-foreach.js
index 7a846b1ac7..252706a9b5 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-foreach.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-foreach.js
@@ -121,7 +121,6 @@ function TestTypedArrayForEach(constructor) {
});
assertEquals(2, count);
assertTrue(!!buffer);
- assertEquals("ArrayBuffer", %_ClassOf(buffer));
assertSame(buffer, a.buffer);
// The %TypedArray%.forEach() method should not work when
diff --git a/deps/v8/test/mjsunit/es6/typedarray-from.js b/deps/v8/test/mjsunit/es6/typedarray-from.js
index 709c453379..8157658249 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-from.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-from.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Flags: --allow-natives-syntax
+
var typedArrayConstructors = [
Uint8Array,
Int8Array,
@@ -14,19 +16,65 @@ var typedArrayConstructors = [
Float64Array
];
+function defaultValue(constr) {
+ if (constr == Float32Array || constr == Float64Array) return NaN;
+ return 0;
+}
+
+function assertArrayLikeEquals(value, expected, type) {
+ assertEquals(value.__proto__, type.prototype);
+ assertEquals(expected.length, value.length);
+ for (var i = 0; i < value.length; ++i) {
+ assertEquals(expected[i], value[i]);
+ }
+}
+
+(function() {
+ var source = [-0, 0, 2**40, 2**41, 2**42];
+ var arr = Float64Array.from(source);
+ assertArrayLikeEquals(arr, source, Float64Array);
+
+ arr = Float32Array.from(source);
+ assertArrayLikeEquals(arr, source, Float32Array);
+})();
+
+(function() {
+ var source = [-0, 0, , 2**42];
+ var expected = [-0, 0, NaN, 2**42];
+ var arr = Float64Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float64Array);
+
+ arr = Float32Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float32Array);
+})();
+
+(function() {
+ var source = {0: -0, 1: 0, 2: 2**40, 3: 2**41, 4: 2**42, length: 5};
+ var expected = [-0, 0, 2**40, 2**41, 2**42];
+ var arr = Float64Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float64Array);
+
+ arr = Float32Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float32Array);
+})();
+
+(function() {
+ var source = [-0, 0, , 2**42];
+ Object.getPrototypeOf(source)[2] = 27;
+ var expected = [-0, 0, 27, 2**42];
+ var arr = Float64Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float64Array);
+
+ arr = Float32Array.from(source);
+ assertArrayLikeEquals(arr, expected, Float32Array);
+})();
+
for (var constructor of typedArrayConstructors) {
assertEquals(1, constructor.from.length);
// TypedArray.from only callable on this subclassing %TypedArray%
assertThrows(function () {constructor.from.call(Array, [])}, TypeError);
- function assertArrayLikeEquals(value, expected, type) {
- assertEquals(value.__proto__, type.prototype);
- assertEquals(expected.length, value.length);
- for (var i = 0; i < value.length; ++i) {
- assertEquals(expected[i], value[i]);
- }
- }
// Assert that calling mapfn with / without thisArg in sloppy and strict modes
// works as expected.
@@ -47,6 +95,14 @@ for (var constructor of typedArrayConstructors) {
assertThrows(function() {constructor.from.call(1, [])}, TypeError);
assertThrows(function() {constructor.from.call(undefined, [])}, TypeError);
+ // Use a map function that returns non-numbers.
+ function mapper(value, index) {
+ return String.fromCharCode(value);
+ }
+ var d = defaultValue(constructor);
+ assertArrayLikeEquals(
+ constructor.from([72, 69, 89], mapper), [d, d, d], constructor);
+
// Converting from various other types, demonstrating that it can
// operate on array-like objects as well as iterables.
// TODO(littledan): constructors should have similar flexibility.
@@ -72,12 +128,62 @@ for (var constructor of typedArrayConstructors) {
assertArrayLikeEquals(constructor.from(generator()),
[4, 5, 6], constructor);
+ // Check mapper is used for non-iterator case.
+ function mapper2(value, index) {
+ return value + 1;
+ }
+ var array_like = {
+ 0: 1,
+ 1: 2,
+ 2: 3,
+ length: 3
+ };
+ assertArrayLikeEquals(constructor.from(array_like, mapper2),
+ [2, 3, 4], constructor);
+
+ // With a smi source. Step 10 will set len = 0.
+ var source = 1;
+ assertArrayLikeEquals(constructor.from(source), [], constructor);
+
assertThrows(function() { constructor.from(null); }, TypeError);
assertThrows(function() { constructor.from(undefined); }, TypeError);
assertThrows(function() { constructor.from([], null); }, TypeError);
assertThrows(function() { constructor.from([], 'noncallable'); },
TypeError);
+ source = [1, 2, 3];
+ var proxy = new Proxy(source, {});
+ assertArrayLikeEquals(constructor.from(proxy), source, constructor);
+
+ proxy = new Proxy(source, {
+ get: function(target, name) {
+ if (name === Symbol.iterator) return target[name];
+ if (name === "length") return 3;
+ return target[name] + 1;
+ }
+ });
+ assertArrayLikeEquals(constructor.from(proxy), [2, 3, 4], constructor);
+}
+
+// Tests that modify global state in a way that affects fast paths e.g. by
+// invalidating protectors or changing prototypes.
+for (var constructor of typedArrayConstructors) {
+ source = [1, 2, 3];
+ source[Symbol.iterator] = undefined;
+ assertArrayLikeEquals(constructor.from(source), source, constructor);
+
+ source = [{ valueOf: function(){ return 42; }}];
+ source[Symbol.iterator] = undefined;
+ assertArrayLikeEquals(constructor.from(source), [42], constructor);
+
+ Number.prototype[Symbol.iterator] = function* () {
+ yield 1;
+ yield 2;
+ yield 3;
+ }
+ assertArrayLikeEquals(constructor.from(1), [1, 2, 3], constructor);
+ assertArrayLikeEquals(constructor.from(1.1), [1, 2, 3], constructor);
+
var nullIterator = {};
nullIterator[Symbol.iterator] = null;
assertArrayLikeEquals(constructor.from(nullIterator), [],
@@ -90,6 +196,26 @@ for (var constructor of typedArrayConstructors) {
assertThrows(function() { constructor.from([], null); }, TypeError);
+ d = defaultValue(constructor);
+ let ta1 = new constructor(3).fill(1);
+ Object.defineProperty(ta1, "length", {get: function() {
+ return 6;
+ }});
+ delete ta1[Symbol.iterator];
+ delete ta1.__proto__[Symbol.iterator];
+ delete ta1.__proto__.__proto__[Symbol.iterator];
+ assertArrayLikeEquals(constructor.from(ta1), [1, 1, 1, d, d, d], constructor);
+
+ let ta2 = new constructor(3).fill(1);
+ Object.defineProperty(ta2, "length", {get: function() {
+ %ArrayBufferNeuter(ta2.buffer);
+ return 6;
+ }});
+ assertArrayLikeEquals(constructor.from(ta2), [d, d, d, d, d, d], constructor);
+
+ var o1 = {0: 0, 1: 1, 2: 2, length: 6};
+ assertArrayLikeEquals(constructor.from(o1), [0, 1, 2, d, d, d], constructor);
+
// Ensure iterator is only accessed once, and only invoked once
var called = 0;
var arr = [1, 2, 3];
diff --git a/deps/v8/test/mjsunit/es6/typedarray-of.js b/deps/v8/test/mjsunit/es6/typedarray-of.js
index eaa7bde11b..8ae590a849 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-of.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-of.js
@@ -1,6 +1,8 @@
// 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.
+//
+// Flags: --expose-gc
// Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/collections
@@ -130,6 +132,20 @@ function TestTypedArrayOf(constructor) {
for (var x of [undefined, null, false, true, "cow", 42, 3.14]) {
assertThrows(function () { constructor.of.call(x); }, TypeError);
}
+
+ // Check if it's correctly accessing new typed array elements even after
+ // garbage collection is invoked in ToNumber.
+ var not_number = {
+ [Symbol.toPrimitive]() {
+ gc();
+ return 123;
+ }
+ };
+ var dangerous_array = new Array(64).fill(not_number);
+ var a = constructor.of(...dangerous_array);
+ for (var i = 0; i < 64; i++) {
+ assertEquals(123, a[i]);
+ }
}
for (var constructor of typedArrayConstructors) {
diff --git a/deps/v8/test/mjsunit/es6/unicode-regexp-restricted-syntax.js b/deps/v8/test/mjsunit/es6/unicode-regexp-restricted-syntax.js
index dd4fa39ab5..1cc46df1b6 100644
--- a/deps/v8/test/mjsunit/es6/unicode-regexp-restricted-syntax.js
+++ b/deps/v8/test/mjsunit/es6/unicode-regexp-restricted-syntax.js
@@ -13,6 +13,7 @@ assertThrows("/\\c/u", SyntaxError);
assertThrows("/\\c0/u", SyntaxError);
// test262/built-ins/RegExp/unicode_restricted_quantifiable_assertion
assertThrows("/(?=.)*/u", SyntaxError);
+assertThrows("/(?=.){1,2}/u", SyntaxError);
// test262/built-ins/RegExp/unicode_restricted_octal_escape
assertThrows("/[\\1]/u", SyntaxError);
assertThrows("/\\00/u", SyntaxError);