diff --git a/implementation-contributed/v8/mjsunit/compiler/lazy-deopt-async-function-resolve.js b/implementation-contributed/v8/mjsunit/compiler/lazy-deopt-async-function-resolve.js new file mode 100644 index 0000000000..faa5e63239 --- /dev/null +++ b/implementation-contributed/v8/mjsunit/compiler/lazy-deopt-async-function-resolve.js @@ -0,0 +1,27 @@ +// 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 + +// Test that the lazy deoptimization point for JSAsyncFunctionResolve +// works correctly, aka that we return the promise and not the result +// of the JSResolvePromise operation. +(function() { + async function foo(x) { + return x; + } + + assertPromiseResult((async () => { + await foo(1); + await foo(2); + %OptimizeFunctionOnNextCall(foo); + const p = new Proxy({}, { + get(...args) { + %DeoptimizeFunction(foo); + return Reflect.get(...args); + } + }); + assertEquals(p, await foo(p)); + })()); +})(); diff --git a/implementation-contributed/v8/mjsunit/compiler/number-multiply.js b/implementation-contributed/v8/mjsunit/compiler/number-multiply.js new file mode 100644 index 0000000000..5b644974ec --- /dev/null +++ b/implementation-contributed/v8/mjsunit/compiler/number-multiply.js @@ -0,0 +1,59 @@ +// 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 + +// Test the extreme case where -0 is produced by rounding errors. +(function() { + function bar(x) { + return 1e-308 * x; + } + bar(1); + + function foo() { + return Object.is(-0, bar(-1e-308)); + } + + assertTrue(foo()); + assertTrue(foo()); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo()); +})(); + +// Test that multiplication of integer by 0 produces the correct results. +(function() { + function foo(x) { + return 0 * Math.round(x); + } + + assertEquals(0, foo(0.1)); + assertEquals(-0, foo(-0.1)); + assertEquals(NaN, foo(NaN)); + assertEquals(NaN, foo(Infinity)); + assertEquals(NaN, foo(-Infinity)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo(0.1)); + assertEquals(-0, foo(-0.1)); + assertEquals(NaN, foo(NaN)); + assertEquals(NaN, foo(Infinity)); + assertEquals(NaN, foo(-Infinity)); +})(); + +// Test that multiplication properly preserves -0 and NaN, and doesn't +// cut it short incorrectly. +(function() { + function foo(x, y) { + x = Math.sign(x); + y = Math.sign(y); + return Math.min(x * y, 0); + } + + assertEquals(0, foo(1, 0)); + assertEquals(-0, foo(1, -0)); + assertEquals(NaN, foo(NaN, -0)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo(1, 0)); + assertEquals(-0, foo(1, -0)); + assertEquals(NaN, foo(NaN, -0)); +})(); diff --git a/implementation-contributed/v8/mjsunit/es6/map-iterator-1.js b/implementation-contributed/v8/mjsunit/es6/map-iterator-1.js new file mode 100644 index 0000000000..50d37726a9 --- /dev/null +++ b/implementation-contributed/v8/mjsunit/es6/map-iterator-1.js @@ -0,0 +1,23 @@ +// 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 --no-stress-opt + +var map = new Map([[1,2], [2,3], [3,4]]); + +assertEquals([[1,2], [2,3], [3,4]], [...map]); +assertEquals([[1,2], [2,3], [3,4]], [...map.entries()]); +assertEquals([1,2,3], [...map.keys()]); +assertEquals([2,3,4], [...map.values()]); +assertTrue(%MapIteratorProtector()); +assertTrue(%SetIteratorProtector()); + +map[Symbol.iterator] = () => ({next: () => ({done: true})}); + +assertTrue(%MapIteratorProtector()); +assertTrue(%SetIteratorProtector()); +assertEquals([], [...map]); +assertEquals([[1,2], [2,3], [3,4]], [...map.entries()]); +assertEquals([1,2,3], [...map.keys()]); +assertEquals([2,3,4], [...map.values()]); diff --git a/implementation-contributed/v8/mjsunit/regress/regress-8237.js b/implementation-contributed/v8/mjsunit/regress/regress-8237.js deleted file mode 100644 index c3abd17e8a..0000000000 --- a/implementation-contributed/v8/mjsunit/regress/regress-8237.js +++ /dev/null @@ -1,57 +0,0 @@ -// 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 --no-always-opt -// Files: test/mjsunit/code-coverage-utils.js - -%DebugToggleBlockCoverage(true); - -TestCoverage( -"Repro for the bug", -` -function lib (n) { // 0000 - if (n >= 0) { // 0050 - if (n < 0) { // 0100 - return; // 0150 - } // 0200 - } else if (foo()) { // 0250 - } // 0300 -} // 0350 -function foo () { // 0400 - console.log('foo') // 0450 - return false // 0500 -} // 0550 -lib(1) // 0600 -`, -[{"start":0,"end":649,"count":1}, -{"start":0,"end":351,"count":1}, -{"start":115,"end":205,"count":0}, -{"start":253,"end":303,"count":0}, -{"start":400,"end":551,"count":0}] -); - -TestCoverage( -"Variant with omitted brackets", -` -function lib (n) { // 0000 - if (n >= 0) { // 0050 - if (n < 0) // 0100 - return; // 0150 - } // 0200 - else if (foo()); // 0250 -} // 0300 -function foo () { // 0350 - console.log('foo') // 0400 - return false // 0450 -} // 0500 -lib(1) // 0550 -`, -[{"start":0,"end":599,"count":1}, -{"start":0,"end":301,"count":1}, -{"start":156,"end":163,"count":0}, -{"start":203,"end":268,"count":0}, -{"start":350,"end":501,"count":0}] -); - -%DebugToggleBlockCoverage(false); diff --git a/implementation-contributed/v8/mjsunit/regress/wasm/regress-739768.js b/implementation-contributed/v8/mjsunit/regress/wasm/regress-739768.js index bcf3ceeca2..52985c3297 100644 --- a/implementation-contributed/v8/mjsunit/regress/wasm/regress-739768.js +++ b/implementation-contributed/v8/mjsunit/regress/wasm/regress-739768.js @@ -16,7 +16,7 @@ builder0.addFunction('main', kSig_i_i) kExprCallIndirect, sig_index, kTableZero ]) // -- .exportAs('main'); -builder0.setFunctionTableBounds(3, 3); +builder0.setTableBounds(3, 3); builder0.addExportOfKind('table', kExternalTable); let module0 = new WebAssembly.Module(builder0.toBuffer()); let instance0 = new WebAssembly.Instance(module0); @@ -25,7 +25,7 @@ let builder1 = new WasmModuleBuilder(); builder1.setName('module_1'); builder1.addFunction('main', kSig_i_v).addBody([kExprUnreachable]); builder1.addImportedTable('z', 'table'); -builder1.addFunctionTableInit(0, false, [0], true); +builder1.addElementSegment(0, false, [0], true); let module1 = new WebAssembly.Module(builder1.toBuffer()); let instance1 = new WebAssembly.Instance(module1, {z: {table: instance0.exports.table}}); diff --git a/implementation-contributed/v8/mjsunit/regress/wasm/regress-803788.js b/implementation-contributed/v8/mjsunit/regress/wasm/regress-803788.js index 8edec7c464..e7fa3aaa8f 100644 --- a/implementation-contributed/v8/mjsunit/regress/wasm/regress-803788.js +++ b/implementation-contributed/v8/mjsunit/regress/wasm/regress-803788.js @@ -12,7 +12,7 @@ let q_table = builder.addImportedTable("q", "table") let q_base = builder.addImportedGlobal("q", "base", kWasmI32); let q_fun = builder.addImport("q", "fun", kSig_v_v); builder.addType(kSig_i_ii); -builder.addFunctionTableInit(q_base, true, [ q_fun ]) +builder.addElementSegment(q_base, true, [ q_fun ]) let module = new WebAssembly.Module(builder.toBuffer()); let table = new WebAssembly.Table({ element: "anyfunc", diff --git a/implementation-contributed/v8/mjsunit/regress/wasm/regress-808980.js b/implementation-contributed/v8/mjsunit/regress/wasm/regress-808980.js index 884572b895..ecf6476c37 100644 --- a/implementation-contributed/v8/mjsunit/regress/wasm/regress-808980.js +++ b/implementation-contributed/v8/mjsunit/regress/wasm/regress-808980.js @@ -17,7 +17,7 @@ builder.addFunction('main', kSig_i_ii).addBody([ sig_index1, kTableZero ]).exportAs('main'); -builder.setFunctionTableBounds(kTableSize, kTableSize); +builder.setTableBounds(kTableSize, kTableSize); var m1_bytes = builder.toBuffer(); var m1 = new WebAssembly.Module(m1_bytes); diff --git a/implementation-contributed/v8/mjsunit/regress/wasm/regress-817380.js b/implementation-contributed/v8/mjsunit/regress/wasm/regress-817380.js index e6047ea231..2cf50892fc 100644 --- a/implementation-contributed/v8/mjsunit/regress/wasm/regress-817380.js +++ b/implementation-contributed/v8/mjsunit/regress/wasm/regress-817380.js @@ -20,6 +20,6 @@ const builder2 = new WasmModuleBuilder(); const mul_import = builder2.addImport('q', 'wasm_mul', kSig_i_ii); builder2.addImportedTable('q', 'table'); const glob_import = builder2.addImportedGlobal('q', 'glob', kWasmI32); -builder2.addFunctionTableInit(glob_import, true, [mul_import]); +builder2.addElementSegment(glob_import, true, [mul_import]); builder2.instantiate( {q: {glob: 0, js_div: i => i, wasm_mul: mul, table: table}}); diff --git a/implementation-contributed/v8/mjsunit/regress/wasm/regress-834619.js b/implementation-contributed/v8/mjsunit/regress/wasm/regress-834619.js index 5ddc9dd9c4..378e38e03c 100644 --- a/implementation-contributed/v8/mjsunit/regress/wasm/regress-834619.js +++ b/implementation-contributed/v8/mjsunit/regress/wasm/regress-834619.js @@ -33,7 +33,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); kExprCallIndirect, 0, kTableZero ]) .exportFunc(); - builder.addFunctionTableInit(0, false, [0, 1, 1, 0]); + builder.addElementSegment(0, false, [0, 1, 1, 0]); return builder.instantiate({q: {f2: i1.exports.f2, f1: i1.exports.f1}}); })(); diff --git a/implementation-contributed/v8/test262/testcfg.py b/implementation-contributed/v8/test262/testcfg.py index 105f6713f2..5c74cb734f 100644 --- a/implementation-contributed/v8/test262/testcfg.py +++ b/implementation-contributed/v8/test262/testcfg.py @@ -56,10 +56,10 @@ FEATURE_FLAGS = { 'Symbol.prototype.description': '--harmony-symbol-description', 'globalThis': '--harmony-global', 'well-formed-json-stringify': '--harmony-json-stringify', + 'export-star-as-namespace-from-module': '--harmony-namespace-exports', } SKIPPED_FEATURES = set(['Object.fromEntries', - 'export-star-as-namespace-from-module', 'class-fields-private', 'class-static-fields-private', 'class-methods-private',