summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/harmony
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/harmony')
-rw-r--r--deps/v8/test/mjsunit/harmony/bigint/rematerialize-on-deopt.js28
-rw-r--r--deps/v8/test/mjsunit/harmony/global-configurable.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/global-writable.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/global.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/hashbang-eval.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/module-parsing-eval.mjs (renamed from deps/v8/test/mjsunit/harmony/module-parsing-eval.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-1.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-1.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-10.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-10.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-11.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-11.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-12.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-12.js)4
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-13.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-13.js)8
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-14.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-14.js)8
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-15.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-15.js)8
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-16.js36
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-16.mjs36
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-17.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-17.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-2.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-2.js)4
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-3.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-3.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-4.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-4.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-5.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-5.js)4
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-6.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-6.js)4
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-7.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-7.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-8.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-8.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-9.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-9.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-large.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-large.js)6
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-meta.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-meta.js)8
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-import-namespace.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-import-namespace.js)4
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-1.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-1.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-10.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-10.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-11.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-11.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-12.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-12.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-13.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-13.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-2.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-2.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-3.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-3.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-4.js6
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-4.mjs6
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-5.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-5.js)6
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-6.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-6.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-7.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-7.js)2
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-8.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-8.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-9.js5
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-9.mjs5
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-empty.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-empty.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-large1.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-large1.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/modules-skip-large2.mjs (renamed from deps/v8/test/mjsunit/harmony/modules-skip-large2.js)0
-rw-r--r--deps/v8/test/mjsunit/harmony/object-fromentries.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/private-fields-special-object.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/private-methods.js228
-rw-r--r--deps/v8/test/mjsunit/harmony/regexp-overriden-exec.js26
-rw-r--r--deps/v8/test/mjsunit/harmony/regress/regress-912504.js2
-rw-r--r--deps/v8/test/mjsunit/harmony/sharedarraybuffer-stress.js36
-rw-r--r--deps/v8/test/mjsunit/harmony/sharedarraybuffer-worker-gc-stress.js22
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/basics.js32
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome-2.js31
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome.js10
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-after-cleanup.js3
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-before-cleanup.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-called-twice.js6
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup1.js3
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup2.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup3.js3
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup4.js6
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup5.js48
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-many.js3
-rw-r--r--deps/v8/test/mjsunit/harmony/weakrefs/unregister-when-cleanup-already-scheduled.js3
69 files changed, 554 insertions, 146 deletions
diff --git a/deps/v8/test/mjsunit/harmony/bigint/rematerialize-on-deopt.js b/deps/v8/test/mjsunit/harmony/bigint/rematerialize-on-deopt.js
new file mode 100644
index 0000000000..cee915ccaf
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/bigint/rematerialize-on-deopt.js
@@ -0,0 +1,28 @@
+// Copyright 2019 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 test(a, b, c) {
+ let x = BigInt.asUintN(64, a + b);
+ console.log(x);
+ try {
+ return BigInt.asUintN(64, x + c);
+ } catch(_) {
+ return x;
+ }
+ }
+
+ %PrepareFunctionForOptimization(test);
+ test(3n, 4n, 5n);
+ test(6n, 7n, 8n);
+ test(9n, 2n, 1n);
+ %OptimizeFunctionOnNextCall(test);
+ test(1n, 2n, 3n);
+ test(3n, 2n, 1n);
+
+ assertEquals(6n, test(1n, 3n, 2n));
+ assertEquals(5n, test(2n, 3n, 2));
+}
diff --git a/deps/v8/test/mjsunit/harmony/global-configurable.js b/deps/v8/test/mjsunit/harmony/global-configurable.js
index dd823f1531..d7a80579aa 100644
--- a/deps/v8/test/mjsunit/harmony/global-configurable.js
+++ b/deps/v8/test/mjsunit/harmony/global-configurable.js
@@ -2,7 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-global
-
assertTrue(delete globalThis);
assertEquals(this.globalThis, undefined);
diff --git a/deps/v8/test/mjsunit/harmony/global-writable.js b/deps/v8/test/mjsunit/harmony/global-writable.js
index f0c2d754bb..e4bce2b245 100644
--- a/deps/v8/test/mjsunit/harmony/global-writable.js
+++ b/deps/v8/test/mjsunit/harmony/global-writable.js
@@ -2,7 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-global
-
globalThis = '[[Writable]]';
assertEquals(globalThis, '[[Writable]]');
diff --git a/deps/v8/test/mjsunit/harmony/global.js b/deps/v8/test/mjsunit/harmony/global.js
index 3d43864c47..60a12fe8f5 100644
--- a/deps/v8/test/mjsunit/harmony/global.js
+++ b/deps/v8/test/mjsunit/harmony/global.js
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-global
-
assertEquals(globalThis, this);
assertEquals(this.globalThis, this);
assertEquals(globalThis.globalThis, this);
diff --git a/deps/v8/test/mjsunit/harmony/hashbang-eval.js b/deps/v8/test/mjsunit/harmony/hashbang-eval.js
index f30ebd0c45..645ecdaea6 100644
--- a/deps/v8/test/mjsunit/harmony/hashbang-eval.js
+++ b/deps/v8/test/mjsunit/harmony/hashbang-eval.js
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-hashbang
-
// Hashbang syntax is allowed in eval.
assertEquals(eval("#!"), undefined);
assertEquals(eval("#!\n"), undefined);
diff --git a/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js
index 49570b51de..8caf588606 100644
--- a/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js
+++ b/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js
@@ -5,8 +5,8 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var error1, error2;
-import('modules-skip-12.js').catch(e => error1 = e);
-import('modules-skip-12.js').catch(e => error2 = e);
+import('modules-skip-12.mjs').catch(e => error1 = e);
+import('modules-skip-12.mjs').catch(e => error2 = e);
%PerformMicrotaskCheckpoint();
assertEquals(error1, error2);
diff --git a/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js
index 87dbc0a6aa..e39ce7ca4f 100644
--- a/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js
+++ b/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js
@@ -5,8 +5,8 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var error1, error2;
-import('modules-skip-11.js').catch(e => error1 = e);
-import('modules-skip-11.js').catch(e => error2 = e);
+import('modules-skip-11.mjs').catch(e => error1 = e);
+import('modules-skip-11.mjs').catch(e => error2 = e);
%PerformMicrotaskCheckpoint();
assertEquals(error1, error2);
diff --git a/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js
index 2cdbaaea32..958ba55e5e 100644
--- a/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js
+++ b/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js
@@ -5,8 +5,8 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var error1, error2;
-import('modules-skip-10.js').catch(e => error1 = e);
-import('modules-skip-10.js').catch(e => error2 = e);
+import('modules-skip-10.mjs').catch(e => error1 = e);
+import('modules-skip-10.mjs').catch(e => error2 = e);
%PerformMicrotaskCheckpoint();
assertEquals(error1, error2);
diff --git a/deps/v8/test/mjsunit/harmony/module-parsing-eval.js b/deps/v8/test/mjsunit/harmony/module-parsing-eval.mjs
index 6c080dbf44..6c080dbf44 100644
--- a/deps/v8/test/mjsunit/harmony/module-parsing-eval.js
+++ b/deps/v8/test/mjsunit/harmony/module-parsing-eval.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-1.js b/deps/v8/test/mjsunit/harmony/modules-import-1.mjs
index f62d4d7b32..954ed9e63e 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-1.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-1.mjs
@@ -5,7 +5,7 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var life;
-import('modules-skip-1.js').then(namespace => life = namespace.life());
+import('modules-skip-1.mjs').then(namespace => life = namespace.life());
%PerformMicrotaskCheckpoint();
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-10.js b/deps/v8/test/mjsunit/harmony/modules-import-10.mjs
index eda4aaf7f9..539a63dc6a 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-10.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-10.mjs
@@ -5,7 +5,7 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var life;
-import('modules-skip-6.js').then(namespace => life = namespace.life);
+import('modules-skip-6.mjs').then(namespace => life = namespace.life);
assertEquals(undefined, Object.life);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-11.js b/deps/v8/test/mjsunit/harmony/modules-import-11.mjs
index ffba6a0722..bcbc419503 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-11.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-11.mjs
@@ -8,7 +8,7 @@ var ran = false;
async function test() {
try {
- let namespace = await import('modules-skip-7.js');
+ let namespace = await import('modules-skip-7.mjs');
let life = await namespace.getLife();
assertEquals(42, life);
ran = true;
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-12.js b/deps/v8/test/mjsunit/harmony/modules-import-12.mjs
index d898c984ad..9f6dba6cc4 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-12.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-12.mjs
@@ -4,10 +4,10 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
-ran = false;
+let ran = false;
async function test() {
try {
- let namespace = await import('modules-skip-empty.js');
+ let namespace = await import('modules-skip-empty.mjs');
ran = true;
} catch(e) {
%AbortJS('failure: '+ e);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-13.js b/deps/v8/test/mjsunit/harmony/modules-import-13.mjs
index 52518350ba..dcbc04223f 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-13.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-13.mjs
@@ -3,12 +3,12 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax --harmony-dynamic-import
-// Resources: test/mjsunit/harmony/modules-skip-1.js
+// Resources: test/mjsunit/harmony/modules-skip-1.mjs
-ran = false;
+let ran = false;
async function test1() {
try {
- let x = { toString() { return 'modules-skip-1.js' } };
+ let x = { toString() { return 'modules-skip-1.mjs' } };
let namespace = await import(x);
let life = namespace.life();
assertEquals(42, life);
@@ -25,7 +25,7 @@ assertTrue(ran);
ran = false;
async function test2() {
try {
- let x = { get toString() { return () => 'modules-skip-1.js' } };
+ let x = { get toString() { return () => 'modules-skip-1.mjs' } };
let namespace = await import(x);
let life = namespace.life();
assertEquals(42, life);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-14.js b/deps/v8/test/mjsunit/harmony/modules-import-14.mjs
index 32b307eb3b..6c176eaef1 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-14.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-14.mjs
@@ -8,12 +8,12 @@ var ran = false;
async function test() {
try {
- let x = await import('modules-skip-1.js');
- // modules-skip-5.js statically imports modules-skip-1.js
- let y = await import('modules-skip-5.js');
+ let x = await import('modules-skip-1.mjs');
+ // modules-skip-5.mjs statically imports modules-skip-1.mjs
+ let y = await import('modules-skip-5.mjs');
assertSame(x, y.static_life);
- let z = await import('modules-skip-1.js');
+ let z = await import('modules-skip-1.mjs');
assertSame(x, z);
ran = true;
} catch(e) {
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-15.js b/deps/v8/test/mjsunit/harmony/modules-import-15.mjs
index d041add3db..b4febd5787 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-15.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-15.mjs
@@ -8,7 +8,7 @@ var ran = false;
async function test1() {
try {
- let x = await import('modules-skip-8.js');
+ let x = await import('modules-skip-8.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertEquals('Unexpected reserved word', e.message);
@@ -24,12 +24,12 @@ ran = false;
async function test2() {
try {
- let x = await import('modules-skip-9.js');
+ let x = await import('modules-skip-9.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertInstanceof(e, SyntaxError);
assertEquals(
- "The requested module 'modules-skip-empty.js' does not provide an " +
+ "The requested module 'modules-skip-empty.mjs' does not provide an " +
"export named 'default'",
e.message);
ran = true;
@@ -44,7 +44,7 @@ ran = false;
async function test3() {
try {
- let x = await import('nonexistent-file.js');
+ let x = await import('nonexistent-file.mjs');
%AbortJS('failure: should be unreachable');
} catch(e) {
assertTrue(e.startsWith('Error reading'));
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-16.js b/deps/v8/test/mjsunit/harmony/modules-import-16.js
deleted file mode 100644
index 18ad445a84..0000000000
--- a/deps/v8/test/mjsunit/harmony/modules-import-16.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 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 --harmony-dynamic-import
-
-var ran = false;
-var x;
-
-var body = "import('modules-skip-1.js').then(ns => { x = ns.life();" +
- " ran = true;} ).catch(err => %AbortJS(err))"
-var func = new Function(body);
-func();
-
-%PerformMicrotaskCheckpoint();
-assertEquals(42, x);
-assertTrue(ran);
-
-var ran = false;
-var body = "import('modules-skip-1.js').then(ns => { x = ns.life();" +
- " ran = true;} ).catch(err => %AbortJS(err))"
-eval("var func = new Function(body); func();");
-
-%PerformMicrotaskCheckpoint();
-assertEquals(42, x);
-assertTrue(ran);
-
-var ran = false;
-var body = "eval(import('modules-skip-1.js').then(ns => { x = ns.life();" +
- " ran = true;} ).catch(err => %AbortJS(err)))"
-var func = new Function(body);
-func();
-
-%PerformMicrotaskCheckpoint();
-assertEquals(42, x);
-assertTrue(ran);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-16.mjs b/deps/v8/test/mjsunit/harmony/modules-import-16.mjs
new file mode 100644
index 0000000000..411bb1b5e4
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/modules-import-16.mjs
@@ -0,0 +1,36 @@
+// Copyright 2017 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 --harmony-dynamic-import
+
+globalThis.ran = false;
+globalThis.x = undefined;
+
+let body = "import('modules-skip-1.mjs').then(ns => { x = ns.life();" +
+ " ran = true;} ).catch(err => %AbortJS(err))"
+let func = new Function(body);
+func();
+
+%PerformMicrotaskCheckpoint();
+assertEquals(42, globalThis.x);
+assertTrue(globalThis.ran);
+
+globalThis.ran = false;
+body = "import('modules-skip-1.mjs').then(ns => { x = ns.life();" +
+ " ran = true;} ).catch(err => %AbortJS(err))"
+eval("var func = new Function(body); func();");
+
+%PerformMicrotaskCheckpoint();
+assertEquals(42, globalThis.x);
+assertTrue(globalThis.ran);
+
+globalThis.ran = false;
+body = "eval(import('modules-skip-1.mjs').then(ns => { x = ns.life();" +
+ " ran = true;} ).catch(err => %AbortJS(err)))"
+func = new Function(body);
+func();
+
+%PerformMicrotaskCheckpoint();
+assertEquals(42, globalThis.x);
+assertTrue(globalThis.ran);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-17.js b/deps/v8/test/mjsunit/harmony/modules-import-17.mjs
index 606ebcd385..7c7eb2e55f 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-17.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-17.mjs
@@ -5,7 +5,7 @@
// Flags: --allow-natives-syntax --harmony-namespace-exports
var ns;
-import('modules-skip-13.js').then(x => ns = x);
+import('modules-skip-13.mjs').then(x => ns = x);
%PerformMicrotaskCheckpoint();
assertEquals(42, ns.default);
assertEquals(ns, ns.self);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-2.js b/deps/v8/test/mjsunit/harmony/modules-import-2.mjs
index a3fe0bc601..2b0ee5b420 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-2.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-2.mjs
@@ -6,8 +6,8 @@
var life;
var msg;
-import('modules-skip-1.js').then(namespace => life = namespace.life());
-import('modules-skip-2.js').catch(err => msg = err.message);
+import('modules-skip-1.mjs').then(namespace => life = namespace.life());
+import('modules-skip-2.mjs').catch(err => msg = err.message);
assertEquals(undefined, life);
assertEquals(undefined, msg);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-3.js b/deps/v8/test/mjsunit/harmony/modules-import-3.mjs
index d8cbe2a228..3cfb442e37 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-3.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-3.mjs
@@ -7,7 +7,7 @@
var ran = false;
async function foo () {
try {
- let life = await import('modules-skip-2.js');
+ let life = await import('modules-skip-2.mjs');
assertUnreachable();
} catch(e) {
assertEquals('42 is not the answer', e.message);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-4.js b/deps/v8/test/mjsunit/harmony/modules-import-4.mjs
index 38a80b30e8..38a80b30e8 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-4.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-4.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-5.js b/deps/v8/test/mjsunit/harmony/modules-import-5.mjs
index c868a0c63f..33991efdc5 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-5.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-5.mjs
@@ -5,9 +5,9 @@
// Flags: --allow-natives-syntax --harmony-dynamic-import
var life;
-let x = 'modules-skip-1.js';
+let x = 'modules-skip-1.mjs';
import(x).then(namespace => life = namespace.life());
-x = 'modules-skip-2.js';
+x = 'modules-skip-2.mjs';
%PerformMicrotaskCheckpoint();
assertEquals(42, life);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-6.js b/deps/v8/test/mjsunit/harmony/modules-import-6.mjs
index 02fdf1b5fa..ae389301e6 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-6.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-6.mjs
@@ -9,8 +9,8 @@ var ran = false;
async function test() {
try {
let [namespace1, namespace2] = await Promise.all([
- import('modules-skip-1.js'),
- import('modules-skip-3.js')
+ import('modules-skip-1.mjs'),
+ import('modules-skip-3.mjs')
]);
let life = namespace1.life();
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-7.js b/deps/v8/test/mjsunit/harmony/modules-import-7.mjs
index 8df8ddcdb2..df16460f72 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-7.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-7.mjs
@@ -8,7 +8,7 @@ var ran = false;
async function test() {
try {
- let namespace = await import('modules-skip-4.js');
+ let namespace = await import('modules-skip-4.mjs');
assertEquals(42, namespace.life());
assertEquals("42", namespace.stringlife);
ran = true;
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-8.js b/deps/v8/test/mjsunit/harmony/modules-import-8.mjs
index ac21a8c9e9..ac21a8c9e9 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-8.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-8.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-9.js b/deps/v8/test/mjsunit/harmony/modules-import-9.mjs
index 664416f0eb..c3a19af2c5 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-9.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-9.mjs
@@ -8,7 +8,7 @@ var ran = false;
async function test() {
try {
- let namespace = await import('modules-skip-5.js').then(x => x);
+ let namespace = await import('modules-skip-5.mjs').then(x => x);
assertSame(namespace.static_life, namespace.dynamic_life);
assertSame(namespace.relative_static_life, namespace.dynamic_life);
ran = true;
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-large.js b/deps/v8/test/mjsunit/harmony/modules-import-large.mjs
index 250a41bd82..761f598b43 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-large.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-large.mjs
@@ -1,13 +1,11 @@
// Copyright 2017 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.
-//
-// MODULE
// Flags: --allow-natives-syntax
-import * as m1 from "modules-skip-large1.js";
-import * as m2 from "modules-skip-large2.js";
+import * as m1 from "modules-skip-large1.mjs";
+import * as m2 from "modules-skip-large2.mjs";
assertFalse(%HasFastProperties(m1));
assertFalse(%HasFastProperties(m2));
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-meta.js b/deps/v8/test/mjsunit/harmony/modules-import-meta.mjs
index 5ea8a686f2..ab2ac04a57 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-meta.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-meta.mjs
@@ -1,11 +1,9 @@
// Copyright 2017 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.
-
-// MODULE
// Flags: --harmony-import-meta
-import foreign, { url as otherUrl } from './modules-skip-export-import-meta.js';
+import foreign, { url as otherUrl } from './modules-skip-export-import-meta.mjs';
assertEquals("object", typeof import.meta);
assertEquals(null, Object.getPrototypeOf(import.meta));
@@ -24,7 +22,7 @@ loadImportMetaFn();
assertSame(loadImportMetaFn(), import.meta);
// This property isn't part of the spec itself but is mentioned as an example
-assertMatches(/\/modules-import-meta\.js$/, import.meta.url);
+assertMatches(/\/modules-import-meta\.mjs$/, import.meta.url);
import.meta.x = 42;
assertEquals(42, import.meta.x);
@@ -40,5 +38,5 @@ assertThrows(() => eval('import.meta'), SyntaxError);
assertThrows(() => new Function('return import.meta;'), SyntaxError);
assertNotEquals(foreign, import.meta);
-assertMatches(/\/modules-skip-export-import-meta\.js$/, foreign.url);
+assertMatches(/\/modules-skip-export-import-meta\.mjs$/, foreign.url);
assertEquals(foreign.url, otherUrl);
diff --git a/deps/v8/test/mjsunit/harmony/modules-import-namespace.js b/deps/v8/test/mjsunit/harmony/modules-import-namespace.mjs
index fd0ad05fa4..5dbe84ccd0 100644
--- a/deps/v8/test/mjsunit/harmony/modules-import-namespace.js
+++ b/deps/v8/test/mjsunit/harmony/modules-import-namespace.mjs
@@ -1,12 +1,10 @@
// 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.
-//
-// MODULE
// Flags: --allow-natives-syntax
-import * as m from "modules-skip-3.js";
+import * as m from "modules-skip-3.mjs";
function get() {
return m.stringlife;
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-1.js b/deps/v8/test/mjsunit/harmony/modules-skip-1.mjs
index ee854b69d2..ee854b69d2 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-1.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-1.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-10.js b/deps/v8/test/mjsunit/harmony/modules-skip-10.mjs
index fff168a581..692dc384c4 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-10.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-10.mjs
@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import {x} from "./modules-skip-10.js"
+import {x} from "./modules-skip-10.mjs"
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-11.js b/deps/v8/test/mjsunit/harmony/modules-skip-11.mjs
index 8981f50ad4..8981f50ad4 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-11.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-11.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-12.js b/deps/v8/test/mjsunit/harmony/modules-skip-12.mjs
index 05fedfa8d1..05fedfa8d1 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-12.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-12.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-13.js b/deps/v8/test/mjsunit/harmony/modules-skip-13.mjs
index d823a283f8..1575a54edd 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-13.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-13.mjs
@@ -2,5 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-export * as self from "./modules-skip-13.js";
+export * as self from "./modules-skip-13.mjs";
export default 42;
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-2.js b/deps/v8/test/mjsunit/harmony/modules-skip-2.mjs
index 6ff97a9893..6ff97a9893 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-2.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-2.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-3.js b/deps/v8/test/mjsunit/harmony/modules-skip-3.mjs
index 6f9984ed51..6f9984ed51 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-3.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-3.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-4.js b/deps/v8/test/mjsunit/harmony/modules-skip-4.js
deleted file mode 100644
index 761153671c..0000000000
--- a/deps/v8/test/mjsunit/harmony/modules-skip-4.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2017 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.
-
-export * from 'modules-skip-1.js';
-export * from 'modules-skip-3.js';
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-4.mjs b/deps/v8/test/mjsunit/harmony/modules-skip-4.mjs
new file mode 100644
index 0000000000..d962bfe291
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-4.mjs
@@ -0,0 +1,6 @@
+// Copyright 2017 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.
+
+export * from 'modules-skip-1.mjs';
+export * from 'modules-skip-3.mjs';
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-5.js b/deps/v8/test/mjsunit/harmony/modules-skip-5.mjs
index 879445977f..fc1eebb82a 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-5.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-5.mjs
@@ -6,9 +6,9 @@
var dynamic_life;
-import * as static_life from 'modules-skip-1.js';
-import * as relative_static_life from './modules-skip-1.js';
-import('modules-skip-1.js').then(namespace => dynamic_life = namespace);
+import * as static_life from 'modules-skip-1.mjs';
+import * as relative_static_life from './modules-skip-1.mjs';
+import('modules-skip-1.mjs').then(namespace => dynamic_life = namespace);
export { static_life };
export { relative_static_life };
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-6.js b/deps/v8/test/mjsunit/harmony/modules-skip-6.mjs
index 6acc2b8499..6acc2b8499 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-6.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-6.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-7.js b/deps/v8/test/mjsunit/harmony/modules-skip-7.mjs
index 4d3a952e92..4733c46e24 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-7.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-7.mjs
@@ -6,7 +6,7 @@
export async function getLife() {
try {
- let namespace = await import('modules-skip-1.js');
+ let namespace = await import('modules-skip-1.mjs');
return namespace.life();
} catch (e) {
%AbortJS('failure: ' + e);
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-8.js b/deps/v8/test/mjsunit/harmony/modules-skip-8.mjs
index 816cf2cdb7..816cf2cdb7 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-8.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-8.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-9.js b/deps/v8/test/mjsunit/harmony/modules-skip-9.js
deleted file mode 100644
index c474988833..0000000000
--- a/deps/v8/test/mjsunit/harmony/modules-skip-9.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2017 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.
-
-import x from 'modules-skip-empty.js';
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-9.mjs b/deps/v8/test/mjsunit/harmony/modules-skip-9.mjs
new file mode 100644
index 0000000000..cca36f988e
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-9.mjs
@@ -0,0 +1,5 @@
+// Copyright 2017 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.
+
+import x from 'modules-skip-empty.mjs';
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-empty.js b/deps/v8/test/mjsunit/harmony/modules-skip-empty.mjs
index 4af874cfa7..4af874cfa7 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-empty.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-empty.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.js b/deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.mjs
index e58e5018af..e58e5018af 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-export-import-meta.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-large1.js b/deps/v8/test/mjsunit/harmony/modules-skip-large1.mjs
index e643df32a9..e643df32a9 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-large1.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-large1.mjs
diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-large2.js b/deps/v8/test/mjsunit/harmony/modules-skip-large2.mjs
index 2c03557197..2c03557197 100644
--- a/deps/v8/test/mjsunit/harmony/modules-skip-large2.js
+++ b/deps/v8/test/mjsunit/harmony/modules-skip-large2.mjs
diff --git a/deps/v8/test/mjsunit/harmony/object-fromentries.js b/deps/v8/test/mjsunit/harmony/object-fromentries.js
index 8bbd6317c6..86733b150c 100644
--- a/deps/v8/test/mjsunit/harmony/object-fromentries.js
+++ b/deps/v8/test/mjsunit/harmony/object-fromentries.js
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-object-from-entries
-
const fromEntries = Object.fromEntries;
const ObjectPrototype = Object.prototype;
const ObjectPrototypeHasOwnProperty = ObjectPrototype.hasOwnProperty;
diff --git a/deps/v8/test/mjsunit/harmony/private-fields-special-object.js b/deps/v8/test/mjsunit/harmony/private-fields-special-object.js
index a85019dd45..4e6801e469 100644
--- a/deps/v8/test/mjsunit/harmony/private-fields-special-object.js
+++ b/deps/v8/test/mjsunit/harmony/private-fields-special-object.js
@@ -8,7 +8,7 @@ load('test/mjsunit/test-async.js');
async function f(assert) {
try {
- module_namespace_obj = await import('modules-skip-1.js');
+ module_namespace_obj = await import('modules-skip-1.mjs');
} catch(e) {
%AbortJS(e);
}
diff --git a/deps/v8/test/mjsunit/harmony/private-methods.js b/deps/v8/test/mjsunit/harmony/private-methods.js
index e7784a29f5..360b065f17 100644
--- a/deps/v8/test/mjsunit/harmony/private-methods.js
+++ b/deps/v8/test/mjsunit/harmony/private-methods.js
@@ -6,57 +6,211 @@
"use strict";
+// Basic private method test
{
+ let calledWith;
class C {
- #a() {}
+ #a(arg) { calledWith = arg; }
+ callA(arg) { this.#a(arg); }
+ }
+
+ const c = new C;
+ assertEquals(undefined, c.a);
+ assertEquals(undefined, calledWith);
+ c.callA(1);
+ assertEquals(1, calledWith);
+}
+
+// Call private method in another instance
+{
+ class C {
+ #a(arg) { this.calledWith = arg; }
+ callAIn(obj, arg) { obj.#a(arg); }
}
- new C;
+
+ const c = new C;
+ const c2 = new C;
+
+ assertEquals(undefined, c.a);
+ assertEquals(undefined, c.calledWith);
+ assertEquals(undefined, c2.calledWith);
+
+ c2.callAIn(c, 'fromC2');
+ assertEquals('fromC2', c.calledWith);
+ assertEquals(undefined, c2.calledWith);
+
+ c2.callAIn(c2, 'c2');
+ assertEquals('fromC2', c.calledWith);
+ assertEquals('c2', c2.calledWith);
+
+ assertThrows(() => { c2.callAIn({}); }, TypeError);
}
+// Private methods and private fields
{
class C {
- #a() {
+ #a;
+ constructor(a) {
+ this.#a = a;
+ }
+ #getAPlus1() {
+ return this.#a + 1;
+ }
+ equals(obj) {
+ return this.#getAPlus1() === obj.#getAPlus1();
+ }
+ }
+ const c = new C(0);
+ const c2 = new C(2);
+ const c3 = new C(2);
+ assertEquals(true, c2.equals(c3));
+ assertEquals(false, c2.equals(c));
+ assertEquals(false, c3.equals(c));
+}
+
+// Class inheritance
+{
+ class A {
+ #val;
+ constructor(a) {
+ this.#val = a;
+ }
+ #a() { return this.#val; }
+ getA() { return this.#a(); }
+ }
+ class B extends A {
+ constructor(b) {
+ super(b);
+ }
+ b() { return this.getA() }
+ }
+ const b = new B(1);
+ assertEquals(1, b.b());
+}
+
+// Private members should be accessed according to the class the
+// invoked method is in.
+{
+ class A {
+ #val;
+ constructor(a) {
+ this.#val = a;
+ }
+ #getVal() { return this.#val; }
+ getA() { return this.#getVal(); }
+ getVal() { return this.#getVal(); }
+ }
+
+ class B extends A {
+ #val;
+ constructor(a, b) {
+ super(a);
+ this.#val = b;
+ }
+ #getVal() { return this.#val; }
+ getB() { return this.#getVal(); }
+ getVal() { return this.#getVal(); }
+ }
+
+ const b = new B(1, 2);
+ assertEquals(1, b.getA());
+ assertEquals(2, b.getB());
+ assertEquals(1, A.prototype.getVal.call(b));
+ assertEquals(2, B.prototype.getVal.call(b));
+ const a = new A(1);
+ assertEquals(1, a.getA());
+ assertThrows(() => B.prototype.getB.call(a), TypeError);
+}
+
+// Private methods in nested classes.
+{
+ class C {
+ #b() {
class B {
- #a() { }
+ #foo(arg) { return arg; }
+ callFoo(arg) { return this.#foo(arg); }
}
- new B;
+ return new B();
}
+ createB() { return this.#b(); }
}
- new C;
+ const c = new C;
+ const b = c.createB();
+ assertEquals(1, b.callFoo(1));
}
+// Private methods in nested classes with inheritance.
{
- class A {
- #a() {
- class C extends A {
- #c() { }
+ class C {
+ #b() {
+ class B extends C {
+ #foo(arg) { return arg; }
+ callFoo(arg) { return this.#foo(arg); }
}
- new C;
+ return new B();
}
+ createB() { return this.#b(); }
}
- new A;
+ const c = new C;
+ const b = c.createB();
+ assertEquals(1, b.callFoo(1));
+ const b2 = b.createB();
+ assertEquals(1, b2.callFoo(1));
}
+// Class expressions.
{
const C = class {
- #a() { }
- }
- new C;
+ #a() { return 1; }
+ callA(obj) { return obj.#a() }
+ };
+ const c = new C;
+ const c2 = new C;
+ assertEquals(1, c.callA(c));
+ assertEquals(1, c.callA(c2));
}
+// Nested class expressions.
{
const C = class {
- #a() {
+ #b() {
const B = class {
- #a() { }
+ #foo(arg) { return arg; }
+ callFoo(arg) { return this.#foo(arg); }
+ };
+ return new B();
+ }
+ createB() { return this.#b(); }
+ };
+
+ const c = new C;
+ const b = c.createB();
+ assertEquals(1, b.callFoo(1));
+}
+
+
+// Nested class expressions with hierarchy.
+{
+ const C = class {
+ #b() {
+ const B = class extends C {
+ #foo(arg) { return arg; }
+ callFoo(arg) { return this.#foo(arg); }
}
- new B;
+ return new B();
}
+ createB() { return this.#b(); }
}
- new C;
+
+ const c = new C;
+ const b = c.createB();
+ assertEquals(1, b.callFoo(1));
+ const b2 = b.createB();
+ assertEquals(1, b2.callFoo(1));
}
+// Adding the brand twice on the same object should throw.
{
class A {
constructor(arg) {
@@ -72,11 +226,45 @@
}
}
- // Add the brand twice on the same object.
let c1 = new C({});
assertThrows(() => new C(c1), TypeError);
}
+// Private methods should be not visible to proxies.
+{
+ class X {
+ #x() {}
+ x() { this.#x(); };
+ callX(obj) { obj.#x(); }
+ }
+ let handlerCalled = false;
+ const x = new X();
+ let p = new Proxy(new X, {
+ apply(target, thisArg, argumentsList) {
+ handlerCalled = true;
+ Reflect.apply(target, thisArg, argumentsList);
+ }
+ });
+ assertThrows(() => p.x(), TypeError);
+ assertThrows(() => x.callX(p), TypeError);
+ assertThrows(() => X.prototype.x.call(p), TypeError);
+ assertThrows(() => X.prototype.callX(p), TypeError);
+ assertEquals(false, handlerCalled);
+}
+
+// Reference outside of class.
+{
+ class C {
+ #a() {}
+ }
+ assertThrows('new C().#a()');
+}
+
+// Duplicate private names.
+{
+ assertThrows('class C { #a = 1; #a() {} }');
+}
+
{
// TODO(v8:9177): test extending a class expression that does not have
// a private method.
diff --git a/deps/v8/test/mjsunit/harmony/regexp-overriden-exec.js b/deps/v8/test/mjsunit/harmony/regexp-overriden-exec.js
new file mode 100644
index 0000000000..7aba0aebe7
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/regexp-overriden-exec.js
@@ -0,0 +1,26 @@
+// Copyright 2019 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 --no-always-opt --opt
+
+const r = RegExp('bla');
+
+function foo() {
+ r.test('string');
+}
+
+%PrepareFunctionForOptimization(foo);
+foo();
+foo();
+%OptimizeFunctionOnNextCall(foo);
+foo();
+assertOptimized(foo);
+
+r.__proto__.exec = function() {
+ return null;
+}
+Object.freeze(r.__proto__);
+
+foo();
+assertUnoptimized(foo);
diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-912504.js b/deps/v8/test/mjsunit/harmony/regress/regress-912504.js
index 78b1992b14..42428baa34 100644
--- a/deps/v8/test/mjsunit/harmony/regress/regress-912504.js
+++ b/deps/v8/test/mjsunit/harmony/regress/regress-912504.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --always-opt --harmony-object-from-entries --allow-natives-syntax
+// Flags: --always-opt --allow-natives-syntax
function test() {
Object.fromEntries([[]]);
diff --git a/deps/v8/test/mjsunit/harmony/sharedarraybuffer-stress.js b/deps/v8/test/mjsunit/harmony/sharedarraybuffer-stress.js
new file mode 100644
index 0000000000..24724eea14
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/sharedarraybuffer-stress.js
@@ -0,0 +1,36 @@
+// Copyright 2019 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 Alloc(size) {
+ let b = new SharedArrayBuffer(size);
+ let v = new Int32Array(b);
+ return {buffer : b, view : v};
+}
+
+function RunSomeAllocs(total, retained, size) {
+ print(`-------iterations = ${total}, retained = $ { retained } -------`);
+ var array = new Array(retained);
+ for (var i = 0; i < total; i++) {
+ if ((i % 25) == 0)
+ print(`iteration $ { i }`);
+ let pair = Alloc(size);
+ // For some iterations, retain the memory, view, or both.
+ switch (i % 3) {
+ case 0:
+ pair.memory = null;
+ break;
+ case 1:
+ pair.view = null;
+ break;
+ case 2:
+ break;
+ }
+ array[i % retained] = pair;
+ }
+}
+
+RunSomeAllocs(10, 1, 1024);
+RunSomeAllocs(100, 3, 2048);
+RunSomeAllocs(1000, 10, 16384);
+RunSomeAllocs(10000, 20, 32768);
diff --git a/deps/v8/test/mjsunit/harmony/sharedarraybuffer-worker-gc-stress.js b/deps/v8/test/mjsunit/harmony/sharedarraybuffer-worker-gc-stress.js
new file mode 100644
index 0000000000..7c86db7cfa
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/sharedarraybuffer-worker-gc-stress.js
@@ -0,0 +1,22 @@
+// Copyright 2019 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.
+
+load("test/mjsunit/worker-ping-test.js");
+
+let config = {
+ numThings: 4, // size of circular buffer
+ numWorkers: 4, // number of workers
+ numMessages: 10000, // number of messages sent to each worker
+ allocInterval: 11, // interval for allocating new things per worker
+ traceScript: false, // print the script
+ traceAlloc: false, // print each allocation attempt
+ traceIteration: 10, // print diagnostics every so many iterations
+ abortOnFail: true, // kill worker if allocation fails
+
+ AllocThing: function AllocThing(id) {
+ return new SharedArrayBuffer(10000);
+ },
+}
+
+RunWorkerPingTest(config);
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/basics.js b/deps/v8/test/mjsunit/harmony/weakrefs/basics.js
index c1ec4070f4..df599ebd40 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/basics.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/basics.js
@@ -85,7 +85,25 @@
(function TestUnregisterWithNonExistentKey() {
let fg = new FinalizationGroup(() => {});
- fg.unregister({"k": "whatever"});
+ let success = fg.unregister({"k": "whatever"});
+ assertFalse(success);
+})();
+
+(function TestUnregisterWithNonFinalizationGroup() {
+ assertThrows(() => FinalizationGroup.prototype.unregister.call({}, {}),
+ TypeError);
+})();
+
+(function TestUnregisterWithNonObjectUnregisterToken() {
+ let fg = new FinalizationGroup(() => {});
+ assertThrows(() => fg.unregister(1), TypeError);
+ assertThrows(() => fg.unregister(1n), TypeError);
+ assertThrows(() => fg.unregister('one'), TypeError);
+ assertThrows(() => fg.unregister(Symbol()), TypeError);
+ assertThrows(() => fg.unregister(true), TypeError);
+ assertThrows(() => fg.unregister(false), TypeError);
+ assertThrows(() => fg.unregister(undefined), TypeError);
+ assertThrows(() => fg.unregister(null), TypeError);
})();
(function TestWeakRefConstructor() {
@@ -138,3 +156,15 @@
let rv = FinalizationGroup.prototype.cleanupSome.call(fg);
assertEquals(undefined, rv);
})();
+
+(function TestCleanupSomeWithNonCallableCallback() {
+ let fg = new FinalizationGroup(() => {});
+ assertThrows(() => fg.cleanupSome(1), TypeError);
+ assertThrows(() => fg.cleanupSome(1n), TypeError);
+ assertThrows(() => fg.cleanupSome(Symbol()), TypeError);
+ assertThrows(() => fg.cleanupSome({}), TypeError);
+ assertThrows(() => fg.cleanupSome('foo'), TypeError);
+ assertThrows(() => fg.cleanupSome(true), TypeError);
+ assertThrows(() => fg.cleanupSome(false), TypeError);
+ assertThrows(() => fg.cleanupSome(null), TypeError);
+})();
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome-2.js b/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome-2.js
new file mode 100644
index 0000000000..67ed64e85a
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome-2.js
@@ -0,0 +1,31 @@
+// 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: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
+
+let cleanup_count = 0;
+let cleanup_holdings = [];
+let cleanup = function(iter) {
+ for (holdings of iter) {
+ cleanup_holdings.push(holdings);
+ }
+ ++cleanup_count;
+}
+
+let fg = new FinalizationGroup(cleanup);
+(function() {
+ let o = {};
+ fg.register(o, "holdings");
+
+ assertEquals(0, cleanup_count);
+})();
+
+// GC will detect o as dead.
+gc();
+
+// passing no callback, should trigger cleanup function
+fg.cleanupSome();
+assertEquals(1, cleanup_count);
+assertEquals(1, cleanup_holdings.length);
+assertEquals("holdings", cleanup_holdings[0]);
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome.js b/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome.js
index 1d3ceda3f2..06eb292dac 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/cleanupsome.js
@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-weak-refs --expose-gc --noincremental-marking
+// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleanup_holdings = [];
let cleanup = function(iter) {
+ %AbortJS("shouldn't be called");
+}
+
+let cleanup2 = function(iter) {
for (holdings of iter) {
cleanup_holdings.push(holdings);
}
@@ -19,14 +23,14 @@ let fg = new FinalizationGroup(cleanup);
fg.register(o, "holdings");
// cleanupSome won't do anything since there are no reclaimed targets.
- fg.cleanupSome();
+ fg.cleanupSome(cleanup2);
assertEquals(0, cleanup_count);
})();
// GC will detect o as dead.
gc();
-fg.cleanupSome();
+fg.cleanupSome(cleanup2);
assertEquals(1, cleanup_count);
assertEquals(1, cleanup_holdings.length);
assertEquals("holdings", cleanup_holdings[0]);
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-after-cleanup.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-after-cleanup.js
index f6480f86b6..3db18e016e 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-after-cleanup.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-after-cleanup.js
@@ -36,7 +36,8 @@ let timeout_func = function() {
assertEquals(1, cleanup_holdings_count);
// Unregister an already iterated over weak reference.
- fg.unregister(key);
+ let success = fg.unregister(key);
+ assertFalse(success);
// Assert that it didn't do anything.
setTimeout(() => { assertEquals(1, cleanup_call_count); }, 0);
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-before-cleanup.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-before-cleanup.js
index 10b8bc67ff..c54dbb25de 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-before-cleanup.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-before-cleanup.js
@@ -19,8 +19,8 @@ let key = {"k": "this is the key"};
fg.register(object, "my holdings", key);
// Clear the WeakCell before the GC has a chance to discover it.
- let return_value = fg.unregister(key);
- assertEquals(undefined, return_value);
+ let success = fg.unregister(key);
+ assertTrue(success);
// object goes out of scope.
})();
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-called-twice.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-called-twice.js
index e6ea150027..d1dd8f8b75 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-called-twice.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-called-twice.js
@@ -19,10 +19,12 @@ let key = {"k": "this is the key"};
fg.register(object, "holdings", key);
// Unregister before the GC has a chance to discover the object.
- fg.unregister(key);
+ let success = fg.unregister(key);
+ assertTrue(success);
// Call unregister again (just to assert we handle this gracefully).
- fg.unregister(key);
+ success = fg.unregister(key);
+ assertFalse(success);
// object goes out of scope.
})();
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup1.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup1.js
index aa9eab20ff..80ca85f619 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup1.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup1.js
@@ -8,7 +8,8 @@ let cleanup_call_count = 0;
let cleanup_holdings_count = 0;
let cleanup = function(iter) {
// Unregister before we've iterated through the holdings.
- fg.unregister(key);
+ let success = fg.unregister(key);
+ assertTrue(success);
for (wc of iter) {
++cleanup_holdings_count;
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup2.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup2.js
index 84ec3aaef8..038f5093e1 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup2.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup2.js
@@ -9,7 +9,9 @@ let cleanup_holdings_count = 0;
let cleanup = function(iter) {
for (holdings of iter) {
assertEquals(holdings, "holdings");
- fg.unregister(key);
+ let success = fg.unregister(key);
+ assertFalse(success);
+
++cleanup_holdings_count;
}
++cleanup_call_count;
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup3.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup3.js
index 39706a7b9b..af6b5c13ed 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup3.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup3.js
@@ -12,7 +12,8 @@ let cleanup = function(iter) {
++cleanup_holdings_count;
}
// Unregister an already iterated over weak reference.
- fg.unregister(key);
+ let success = fg.unregister(key);
+ assertFalse(success);
++cleanup_call_count;
}
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup4.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup4.js
index 67ed227502..8a0a5d5707 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup4.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup4.js
@@ -10,10 +10,12 @@ let cleanup = function(iter) {
for (holdings of iter) {
// See which target we're iterating over and unregister the other one.
if (holdings == 1) {
- fg.unregister(key2);
+ let success = fg.unregister(key2);
+ assertTrue(success);
} else {
assertSame(holdings, 2);
- fg.unregister(key1);
+ let success = fg.unregister(key1);
+ assertTrue(success);
}
++cleanup_holdings_count;
}
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup5.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup5.js
new file mode 100644
index 0000000000..974485e9cb
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-inside-cleanup5.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: --harmony-weak-refs --expose-gc --noincremental-marking
+
+let cleanup_call_count = 0;
+let cleanup_holdings_count = 0;
+let cleanup = function(iter) {
+ for (holdings of iter) {
+ assertEquals(holdings, "holdings");
+
+ // There's one more object with the same key that we haven't
+ // iterated over yet so we should be able to unregister the
+ // callback for that one.
+ let success = fg.unregister(key);
+ assertTrue(success);
+
+ ++cleanup_holdings_count;
+ }
+ ++cleanup_call_count;
+}
+
+let fg = new FinalizationGroup(cleanup);
+// Create an object and register it in the FinalizationGroup. The object needs to be inside
+// a closure so that we can reliably kill them!
+let key = {"k": "this is the key"};
+
+(function() {
+ let object = {};
+ let object2 = {};
+ fg.register(object, "holdings", key);
+ fg.register(object2, "holdings", key);
+
+ // object goes out of scope.
+})();
+
+// This GC will discover dirty WeakCells and schedule cleanup.
+gc();
+assertEquals(0, cleanup_call_count);
+
+// Assert that the cleanup function was called and iterated the WeakCell.
+let timeout_func = function() {
+ assertEquals(1, cleanup_call_count);
+ assertEquals(1, cleanup_holdings_count);
+}
+
+setTimeout(timeout_func, 0);
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-many.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-many.js
index 748b7065c6..8be0db1444 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-many.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-many.js
@@ -31,7 +31,8 @@ let key2 = {"k": "key2"};
fg.register(object2, "holdings2", key2);
// Unregister before the GC has a chance to discover the objects.
- fg.unregister(key1);
+ let success = fg.unregister(key1);
+ assertTrue(success);
// objects go out of scope.
})();
diff --git a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-when-cleanup-already-scheduled.js b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-when-cleanup-already-scheduled.js
index 2466568397..4ad4425a4c 100644
--- a/deps/v8/test/mjsunit/harmony/weakrefs/unregister-when-cleanup-already-scheduled.js
+++ b/deps/v8/test/mjsunit/harmony/weakrefs/unregister-when-cleanup-already-scheduled.js
@@ -26,7 +26,8 @@ gc();
assertEquals(0, cleanup_call_count);
// Unregister the object from the FinalizationGroup before cleanup has ran.
-fg.unregister(key);
+let success = fg.unregister(key);
+assertTrue(success);
// Assert that the cleanup function won't be called.
let timeout_func = function() {