diff options
author | Myles Borins <mylesborins@google.com> | 2018-04-10 21:39:51 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-04-11 13:22:42 -0400 |
commit | 12a1b9b8049462e47181a298120243dc83e81c55 (patch) | |
tree | 8605276308c8b4e3597516961266bae1af57557a /deps/v8/test/mjsunit | |
parent | 78cd8263354705b767ef8c6a651740efe4931ba0 (diff) | |
download | android-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')
159 files changed, 6067 insertions, 1705 deletions
diff --git a/deps/v8/test/mjsunit/array-reduce.js b/deps/v8/test/mjsunit/array-reduce.js index 171a40f092..691cd54098 100644 --- a/deps/v8/test/mjsunit/array-reduce.js +++ b/deps/v8/test/mjsunit/array-reduce.js @@ -641,6 +641,54 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); assertEquals(total, g()); })(); +(function OptimizedReduceEagerDeoptMiddleOfIterationHoley() { + let deopt = false; + let array = [, ,11,22,,33,45,56,,6,77,84,93,101,]; + let f = (a,current) => { + if (current == 6 && deopt) {array[0] = 1.5; } + return a + current; + }; + let g = function() { + return array.reduce(f); + } + g(); g(); + let total = g(); + %OptimizeFunctionOnNextCall(g); + g(); + deopt = true; + g(); + deopt = false; + array = [11,22,33,45,56,6,77,84,93,101]; + %OptimizeFunctionOnNextCall(g); + g(); + deopt = true; + assertEquals(total, g()); +})(); + +(function OptimizedReduceRightEagerDeoptMiddleOfIterationHoley() { + let deopt = false; + let array = [, ,11,22,,33,45,56,,6,77,84,93,101,]; + let f = (a,current) => { + if (current == 6 && deopt) {array[array.length-1] = 1.5; } + return a + current; + }; + let g = function() { + return array.reduceRight(f); + } + g(); g(); + let total = g(); + %OptimizeFunctionOnNextCall(g); + g(); + deopt = true; + g(); + deopt = false; + array = [11,22,33,45,56,6,77,84,93,101]; + %OptimizeFunctionOnNextCall(g); + g(); + deopt = true; + assertEquals(total, g()); +})(); + (function ReduceCatch() { let f = (a,current) => { return a + current; @@ -1241,3 +1289,14 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); %OptimizeFunctionOnNextCall(__f_3253); assertEquals(18, __f_3253(__v_12258)); })(); + +(function ReduceMixedHoleyArrays() { + function r(a) { + return a.reduce((acc, i) => {acc[0]}); + } + r([[0]]); + r([[0]]); + r([0,,]); + %OptimizeFunctionOnNextCall(r); + r([,0,0]); +})(); diff --git a/deps/v8/test/mjsunit/array-sort.js b/deps/v8/test/mjsunit/array-sort.js index acc96117be..0454da8cae 100644 --- a/deps/v8/test/mjsunit/array-sort.js +++ b/deps/v8/test/mjsunit/array-sort.js @@ -503,6 +503,19 @@ function TestSortOnNonExtensible() { } TestSortOnNonExtensible(); +function TestSortOnTypedArray() { + var array = new Int8Array([10,9,8,7,6,5,4,3,2,1]); + Object.defineProperty(array, "length", {value: 5}); + Array.prototype.sort.call(array); + assertEquals(array, new Int8Array([10,6,7,8,9,5,4,3,2,1])); + + var array = new Int8Array([10,9,8,7,6,5,4,3,2,1]); + Object.defineProperty(array, "length", {value: 15}); + Array.prototype.sort.call(array); + assertEquals(array, new Int8Array([1,10,2,3,4,5,6,7,8,9])); +} +TestSortOnTypedArray(); + // Test special prototypes (function testSortSpecialPrototypes() { diff --git a/deps/v8/test/mjsunit/compiler/array-multiple-receiver-maps.js b/deps/v8/test/mjsunit/compiler/array-multiple-receiver-maps.js index 2ef0cc3a01..f615032d97 100644 --- a/deps/v8/test/mjsunit/compiler/array-multiple-receiver-maps.js +++ b/deps/v8/test/mjsunit/compiler/array-multiple-receiver-maps.js @@ -29,21 +29,23 @@ function runTest(f, message, mkICTraining, deoptArg) { // Make sure the optimized function can handle // all trained maps without deopt. for (let a of t3) { + message += " for args " + JSON.stringify(a) + " should have been optimized"; f(a.arr, () => a.el); - message += " for args " + JSON.stringify(a); - assertOptimized(f, undefined, message + " should have been optimized"); + assertOptimized(f, undefined, message); } } else { // Trigger deopt, causing no-speculation bit to be set. let a1 = deoptArg; let a2 = deoptArg; message += " for args " + JSON.stringify(a1); + message_unoptimized = message + " should have been unoptimized" + message_optimized = message + " should have been unoptimized" f(a1.arr, () => a1.el); - assertUnoptimized(f, undefined, message + " should have been unoptimized"); + assertUnoptimized(f, undefined, message_unoptimized); %OptimizeFunctionOnNextCall(f); // No speculation should protect against further deopts. f(a2.arr, () => a2.el); - assertOptimized(f, undefined, message + " should have been optimized"); + assertOptimized(f, undefined, message_optimized); } } diff --git a/deps/v8/test/mjsunit/compiler/promise-capability-default-closures.js b/deps/v8/test/mjsunit/compiler/promise-capability-default-closures.js new file mode 100644 index 0000000000..f4d8cd4e5d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-capability-default-closures.js @@ -0,0 +1,47 @@ +// 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() { + var resolve, value; + (new Promise(r => resolve = r)).then(v => value = v); + function foo() { resolve(1); } + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); + setTimeout(_ => assertEquals(1, value)); +})(); + +(function() { + var reject, value; + (new Promise((_, r) => reject = r)).catch(v => value = v); + function foo() { reject(1); } + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); + setTimeout(_ => assertEquals(1, value)); +})(); + +(function() { + var value; + function foo(x) { return new Promise((resolve, reject) => resolve(x)); } + foo(1); + foo(1); + %OptimizeFunctionOnNextCall(foo); + foo(1).then(v => value = v); + setTimeout(_ => assertEquals(1, value)); +})(); + +(function() { + var value; + function foo(x) { return new Promise((resolve, reject) => reject(x)); } + foo(1); + foo(1); + %OptimizeFunctionOnNextCall(foo); + foo(1).catch(v => value = v); + setTimeout(_ => assertEquals(1, value)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/promise-constructor.js b/deps/v8/test/mjsunit/compiler/promise-constructor.js new file mode 100644 index 0000000000..67677fad4b --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-constructor.js @@ -0,0 +1,198 @@ +// 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 --experimental-inline-promise-constructor + +// We have to patch mjsunit because normal assertion failures just throw +// exceptions which are swallowed in a then clause. +failWithMessage = (msg) => %AbortJS(msg); + +// Don't crash. +(function() { + function foo() { + let resolve, reject, promise; + promise = new Promise((a, b) => { resolve = a; reject = b; }); + + return {resolve, reject, promise}; + } + + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); + +// Check that when executor is non-callable, the constructor throws. +(function() { + function foo() { + return new Promise(1); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); +})(); + +// Check that when the promise constructor throws because the executor is +// non-callable, the stack contains 'new Promise'. +(function() { + function foo() { + return new Promise(1); + } + + let threw; + try { + threw = false; + foo(); + } catch (e) { + threw = true; + assertContains('new Promise', e.stack); + } finally { + assertTrue(threw); + } + try { + threw = false; + foo(); + } catch (e) { + threw = true; + assertContains('new Promise', e.stack); + } finally { + assertTrue(threw); + } + + %OptimizeFunctionOnNextCall(foo); + try { + threw = false; + foo(); + } catch (e) { + threw = true; + assertContains('new Promise', e.stack); + } finally { + assertTrue(threw); + } +})(); + +// Check that when executor throws, the promise is rejected. +(function() { + function foo() { + return new Promise((a, b) => { throw new Error(); }); + } + + function bar(i) { + let error = null; + foo().then(_ => error = 1, e => error = e); + setTimeout(_ => assertInstanceof(error, Error)); + if (i == 1) %OptimizeFunctionOnNextCall(foo); + if (i > 0) setTimeout(bar.bind(null, i - 1)); + } + bar(3); +})(); + +// Check that when executor causes lazy deoptimization of the inlined +// constructor, we return the promise value and not the return value of the +// executor function itself. +(function() { + function foo() { + let p; + try { + p = new Promise((a, b) => { %DeoptimizeFunction(foo); }); + } catch (e) { + // Nothing should throw + assertUnreachable(); + } + assertInstanceof(p, Promise); + } + + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); + +// The same as above, except that the executor function also creates a promise +// and both executor functions cause a lazy deopt of the calling function. +(function() { + function executor(a, b) { + %DeoptimizeFunction(foo); + let p = new Promise((a, b) => { %DeoptimizeFunction(executor); }); + } + function foo() { + let p; + try { + p = new Promise(executor); + } catch (e) { + // Nothing should throw + assertUnreachable(); + } + assertInstanceof(p, Promise); + } + + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); + +// Check that when the executor causes lazy deoptimization of the inlined +// constructor, and then throws, the deopt continuation catches and then calls +// the reject function instead of propagating the exception. +(function() { + function foo() { + let p; + try { + p = new Promise((a, b) => { + %DeoptimizeFunction(foo); + throw new Error(); + }); + } catch (e) { + // The promise constructor should catch the exception and reject the + // promise instead. + // TODO(petermarshall): This fails but should not. We need to fix deopts. + // assertUnreachable(); + } + // TODO(petermarshall): This fails but should not. + // assertInstanceof(p, Promise); + } + + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); + +// Test when the executor is not inlined. +(function() { + let resolve, reject, promise; + function bar(a, b) { + resolve = a; reject = b; + throw new Error(); + } + function foo() { + promise = new Promise(bar); + } + foo(); + foo(); + %NeverOptimizeFunction(bar); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); + +// Test that the stack trace contains 'new Promise' +(function() { + let resolve, reject, promise; + function bar(a, b) { + resolve = a; reject = b; + let stack = new Error().stack; + assertContains("new Promise", stack); + throw new Error(); + } + function foo() { + promise = new Promise(bar); + } + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); +})(); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-1.js b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-1.js new file mode 100644 index 0000000000..d3bd0b8543 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-1.js @@ -0,0 +1,19 @@ +// 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 foo(p) { return p.catch(x => x); } + +const a = Promise.resolve(1); + +foo(a); +foo(a); +%OptimizeFunctionOnNextCall(foo); +foo(a); + +let custom_then_called = false; +a.__proto__.then = function() { custom_then_called = true; } +foo(a); +assertTrue(custom_then_called); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-2.js b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-2.js new file mode 100644 index 0000000000..0d3f34db28 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-custom-then-2.js @@ -0,0 +1,19 @@ +// 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 foo(p) { return p.catch(x => x); } + +const a = Promise.resolve(1); + +foo(a); +foo(a); +%OptimizeFunctionOnNextCall(foo); +foo(a); + +let custom_then_called = false; +a.then = function() { custom_then_called = true; } +foo(a); +assertTrue(custom_then_called); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-catch-subclass.js b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-subclass.js new file mode 100644 index 0000000000..5aadaada81 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-catch-subclass.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 + +let custom_then_called = false; + +function foo(p) { + custom_then_called = false; + p.catch(x => x); + return custom_then_called; +} + +class MyPromise extends Promise { + then(onFulfilled, onRejected) { + custom_then_called = true; + return super.then(onFulfilled, onRejected); + } +} + +const a = MyPromise.resolve(1); + +assertTrue(foo(a)); +assertTrue(foo(a)); +%OptimizeFunctionOnNextCall(foo); +assertTrue(foo(a)); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-catch.js b/deps/v8/test/mjsunit/compiler/promise-prototype-catch.js new file mode 100644 index 0000000000..eae343fd2e --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-catch.js @@ -0,0 +1,29 @@ +// 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() { + function foo(p) { return p.catch(); } + foo(Promise.resolve(1)); + foo(Promise.resolve(1)); + %OptimizeFunctionOnNextCall(foo); + foo(Promise.resolve(1)); +})(); + +(function() { + function foo(p) { return p.catch(foo); } + foo(Promise.resolve(1)); + foo(Promise.resolve(1)); + %OptimizeFunctionOnNextCall(foo); + foo(Promise.resolve(1)); +})(); + +(function() { + function foo(p) { return p.catch(foo, undefined); } + foo(Promise.resolve(1)); + foo(Promise.resolve(1)); + %OptimizeFunctionOnNextCall(foo); + foo(Promise.resolve(1)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-1.js b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-1.js new file mode 100644 index 0000000000..a6987d446f --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-1.js @@ -0,0 +1,19 @@ +// 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 foo(p) { return p.finally(x => x); } + +const a = Promise.resolve(1); + +foo(a); +foo(a); +%OptimizeFunctionOnNextCall(foo); +foo(a); + +let custom_then_called = false; +a.__proto__.then = function() { custom_then_called = true; } +foo(a); +assertTrue(custom_then_called); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-2.js b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-2.js new file mode 100644 index 0000000000..5bad54a61d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-custom-then-2.js @@ -0,0 +1,19 @@ +// 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 foo(p) { return p.finally(x => x); } + +const a = Promise.resolve(1); + +foo(a); +foo(a); +%OptimizeFunctionOnNextCall(foo); +foo(a); + +let custom_then_called = false; +a.then = function() { custom_then_called = true; } +foo(a); +assertTrue(custom_then_called); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-finally-subclass.js b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-subclass.js new file mode 100644 index 0000000000..ff5657f6cb --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-finally-subclass.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 + +let custom_then_called = false; + +function foo(p) { + custom_then_called = false; + p.finally(x => x); + return custom_then_called; +} + +class MyPromise extends Promise { + then(onFulfilled, onRejected) { + custom_then_called = true; + return super.then(onFulfilled, onRejected); + } +} + +const a = MyPromise.resolve(1); + +assertTrue(foo(a)); +assertTrue(foo(a)); +%OptimizeFunctionOnNextCall(foo); +assertTrue(foo(a)); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-finally.js b/deps/v8/test/mjsunit/compiler/promise-prototype-finally.js new file mode 100644 index 0000000000..6060f7b857 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-finally.js @@ -0,0 +1,41 @@ +// 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() { + const p = Promise.resolve(1); + function foo(p) { return p.finally(); } + foo(p); + foo(p); + %OptimizeFunctionOnNextCall(foo); + foo(p); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p) { return p.finally(x => x); } + foo(p); + foo(p); + %OptimizeFunctionOnNextCall(foo); + foo(p); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p, f) { return p.finally(f); } + foo(p, x => x); + foo(p, x => x); + %OptimizeFunctionOnNextCall(foo); + foo(p, x => x); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p, f) { return p.finally(f).finally(f); } + foo(p, x => x); + foo(p, x => x); + %OptimizeFunctionOnNextCall(foo); + foo(p, x => x); +})(); diff --git a/deps/v8/test/mjsunit/compiler/promise-prototype-then.js b/deps/v8/test/mjsunit/compiler/promise-prototype-then.js new file mode 100644 index 0000000000..caf77708b6 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-prototype-then.js @@ -0,0 +1,50 @@ +// 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() { + const p = Promise.resolve(1); + function foo(p) { return p.then(); } + foo(p); + foo(p); + %OptimizeFunctionOnNextCall(foo); + foo(p); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p) { return p.then(x => x); } + foo(p); + foo(p); + %OptimizeFunctionOnNextCall(foo); + foo(p); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p) { return p.then(x => x, y => y); } + foo(p); + foo(p); + %OptimizeFunctionOnNextCall(foo); + foo(p); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p, f) { return p.then(f, f); } + foo(p, x => x); + foo(p, x => x); + %OptimizeFunctionOnNextCall(foo); + foo(p, x => x); +})(); + +(function() { + const p = Promise.resolve(1); + function foo(p, f) { return p.then(f, f).then(f, f); } + foo(p, x => x); + foo(p, x => x); + %OptimizeFunctionOnNextCall(foo); + foo(p, x => x); +})(); diff --git a/deps/v8/test/mjsunit/compiler/promise-resolve.js b/deps/v8/test/mjsunit/compiler/promise-resolve.js new file mode 100644 index 0000000000..13cb0fa0a3 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/promise-resolve.js @@ -0,0 +1,119 @@ +// 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 assertFulfilledWith(expected, thenable) { + assertPromiseResult(thenable, v => assertEquals(expected, v)); +} + +(function() { + function foo() { return Promise.resolve(); } + assertFulfilledWith(undefined, foo()); + assertFulfilledWith(undefined, foo()); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(undefined, foo()); +})(); + +(function() { + function foo(x) { return Promise.resolve(x); } + assertFulfilledWith(3, foo(3)); + assertFulfilledWith(3, foo(3)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(3, foo(3)); +})(); + +(function() { + function foo(x, y) { return Promise.resolve(x, y); } + assertFulfilledWith(1, foo(1, 0)); + assertFulfilledWith(2, foo(2, 1)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(3, foo(3, 2)); +})(); + +(function() { + function foo(x) { return Promise.resolve({x}); } + assertFulfilledWith({x:1}, foo(1)); + assertFulfilledWith({x:2}, foo(2)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith({x:3}, foo(3)); +})(); + +(function() { + function foo(x) { return Promise.resolve(Promise.resolve(x)); } + assertFulfilledWith(null, foo(null)); + assertFulfilledWith('a', foo('a')); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(42, foo(42)); +})(); + +(function() { + const thenable = new class Thenable { + then(fulfill, reject) { + fulfill(1); + } + }; + function foo() { return Promise.resolve(thenable); } + assertFulfilledWith(1, foo()); + assertFulfilledWith(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(1, foo()); +})(); + +(function() { + const MyPromise = class MyPromise extends Promise {}; + + (function() { + function foo() { return MyPromise.resolve(); } + assertFulfilledWith(undefined, foo()); + assertFulfilledWith(undefined, foo()); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(undefined, foo()); + })(); + + (function() { + function foo(x) { return MyPromise.resolve(x); } + assertFulfilledWith(3, foo(3)); + assertFulfilledWith(3, foo(3)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(3, foo(3)); + })(); + + (function() { + function foo(x, y) { return MyPromise.resolve(x, y); } + assertFulfilledWith(1, foo(1, 0)); + assertFulfilledWith(2, foo(2, 1)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(3, foo(3, 2)); + })(); + + (function() { + function foo(x) { return MyPromise.resolve({x}); } + assertFulfilledWith({x:1}, foo(1)); + assertFulfilledWith({x:2}, foo(2)); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith({x:3}, foo(3)); + })(); + + (function() { + function foo(x) { return MyPromise.resolve(Promise.resolve(x)); } + assertFulfilledWith(null, foo(null)); + assertFulfilledWith('a', foo('a')); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(42, foo(42)); + })(); + + (function() { + const thenable = new class Thenable { + then(fulfill, reject) { + fulfill(1); + } + }; + function foo() { return MyPromise.resolve(thenable); } + assertFulfilledWith(1, foo()); + assertFulfilledWith(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertFulfilledWith(1, foo()); + })(); +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-803022.js b/deps/v8/test/mjsunit/compiler/regress-803022.js new file mode 100644 index 0000000000..30e13cf032 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-803022.js @@ -0,0 +1,16 @@ +// 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 foo() { + for (var a = 0; a < 2; a++) { + if (a === 1) %OptimizeOsr(); + while (0 && 1) { + for (var j = 1; j < 2; j++) { } + } + } +} + +foo(); diff --git a/deps/v8/test/mjsunit/compiler/regress-808472.js b/deps/v8/test/mjsunit/compiler/regress-808472.js new file mode 100644 index 0000000000..8c8bdf1d0d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-808472.js @@ -0,0 +1,12 @@ +// 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 opt() { + let opt, arr = [...[...[...[...new Uint8Array(0x10000)]]]]; + while (arr--) { + opt = ((typeof opt) === 'undefined') ? /a/ : arr; + } +} +opt(); +opt(); diff --git a/deps/v8/test/mjsunit/compiler/regress-815392.js b/deps/v8/test/mjsunit/compiler/regress-815392.js new file mode 100644 index 0000000000..367c5e824d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-815392.js @@ -0,0 +1,13 @@ +// 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. + +const __f_1 = eval(`(function __f_1() { + class Derived extends Object { + constructor() { + ${"this.a=1;".repeat(0x3fffe-8)} + } + } + return Derived; +})`); +assertThrows(() => new (__f_1())()); diff --git a/deps/v8/test/mjsunit/compiler/regress-817225.js b/deps/v8/test/mjsunit/compiler/regress-817225.js new file mode 100644 index 0000000000..22f0375605 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-817225.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 + +function inlined(abort, n, a, b) { + if (abort) return; + var x = a ? true : "" + a; + if (!a) { + var y = n + y + 10; + if(!b) { + x = y; + } + if (x) { + x = false; + } + } + return x + 1; +} +inlined(); +function optimized(abort, a, b) { + return inlined(abort, "abc", a, b); +} +optimized(true); +%OptimizeFunctionOnNextCall(optimized); +optimized(); diff --git a/deps/v8/test/mjsunit/constant-folding-2.js b/deps/v8/test/mjsunit/constant-folding-2.js index 7586261c92..654dd23439 100644 --- a/deps/v8/test/mjsunit/constant-folding-2.js +++ b/deps/v8/test/mjsunit/constant-folding-2.js @@ -28,22 +28,28 @@ // Flags: --allow-natives-syntax --nostress-opt --opt -function test(f) { +function test(f, iterations) { f(); f(); - %OptimizeFunctionOnNextCall(f); - f(); + // Some of the tests need to learn until they stabilize. + let n = iterations ? iterations : 1; + for (let i = 0; i < n; i++) { + %OptimizeFunctionOnNextCall(f); + f(); + } + // Assert that the function finally stabilized. + assertOptimized(f); } test(function add() { assertEquals(2, 1 + 1); assertEquals(2.5, 1.25 + 1.25); - assertEquals("Infinity", String(Infinity + Infinity)); - assertEquals("Infinity", String(Infinity + 3)); - assertEquals("NaN", String(Infinity + (-Infinity))); - assertEquals("NaN", String(NaN + 2)); - assertEquals("-Infinity", String(1 / (-0.0 + (-0.0)))); - assertEquals("Infinity", String(1 / (-0.0 + 0.0))); + assertSame(Infinity, Infinity + Infinity); + assertSame(Infinity, Infinity + 3); + assertSame(NaN, Infinity + (-Infinity)); + assertSame(NaN, NaN + 2); + assertSame(-Infinity, 1 / (-0.0 + (-0.0))); + assertSame(Infinity, 1 / (-0.0 + 0.0)); }); test(function inc() { @@ -52,9 +58,9 @@ test(function inc() { var c = -Infinity; var d = NaN; assertEquals(2, ++a); - assertEquals("Infinity", String(++b)); - assertEquals("-Infinity", String(++c)); - assertEquals("NaN", String(++d)); + assertSame(Infinity, ++b); + assertSame(-Infinity, ++c); + assertSame(NaN, ++d); }); test(function dec() { @@ -63,155 +69,155 @@ test(function dec() { var c = -Infinity; var d = NaN; assertEquals(0, --a); - assertEquals("Infinity", String(--b)); - assertEquals("-Infinity", String(--c)); - assertEquals("NaN", String(--d)); + assertSame(Infinity, --b); + assertSame(-Infinity, --c); + assertSame(NaN, --d); }); test(function sub() { assertEquals(0, 1 - 1); assertEquals(0.5, 1.5 - 1); - assertEquals("Infinity", String(Infinity - (-Infinity))); - assertEquals("Infinity", String(Infinity - 3)); - assertEquals("NaN", String(Infinity - Infinity)); - assertEquals("NaN", String(NaN - 2)); - assertEquals("-Infinity", String(1 / (-0.0 - 0.0))); - assertEquals("Infinity", String(1 / (0.0 - 0.0))); + assertSame(Infinity, Infinity - (-Infinity)); + assertSame(Infinity, Infinity - 3); + assertSame(NaN, Infinity - Infinity); + assertSame(NaN, NaN - 2); + assertSame(-Infinity, 1 / (-0.0 - 0.0)); + assertSame(Infinity, 1 / (0.0 - 0.0)); }); test(function mul() { assertEquals(1, 1 * 1); assertEquals(2.25, 1.5 * 1.5); - assertEquals("Infinity", String(Infinity * Infinity)); - assertEquals("-Infinity", String(Infinity * (-Infinity))); - assertEquals("Infinity", String(Infinity * 3)); - assertEquals("-Infinity", String(Infinity * (-3))); - assertEquals("NaN", String(NaN * 3)); - assertEquals("-Infinity", String(1 / (-0.0 * 0.0))); - assertEquals("Infinity", String(1 / (0.0 * 0.0))); + assertSame(Infinity, Infinity * Infinity); + assertSame(-Infinity, Infinity * (-Infinity)); + assertSame(Infinity, Infinity * 3); + assertSame(-Infinity, Infinity * (-3)); + assertSame(NaN, NaN * 3); + assertSame(-Infinity, 1 / (-0.0 * 0.0)); + assertSame(Infinity, 1 / (0.0 * 0.0)); }); test(function div() { assertEquals(1, 1 / 1); assertEquals(1.5, 2.25 / 1.5); - assertEquals("NaN", String(Infinity / Infinity)); - assertEquals("Infinity", String(Infinity / 3)); - assertEquals("-Infinity", String(Infinity / (-3))); - assertEquals("NaN", String(NaN / 3)); - assertEquals("-Infinity", String(1 / (-0.0))); - assertEquals("Infinity", String(Infinity/0.0)); + assertSame(NaN, Infinity / Infinity); + assertSame(Infinity, Infinity / 3); + assertSame(-Infinity, Infinity / (-3)); + assertSame(NaN, NaN / 3); + assertSame(-Infinity, 1 / (-0.0)); + assertSame(Infinity, Infinity/0.0); }); test(function mathMin() { assertEquals(1, Math.min(1, 10)); assertEquals(1.5, Math.min(1.5, 2.5)); assertEquals(0, Math.min(Infinity, 0)); - assertEquals("Infinity", String(Math.min(Infinity, Infinity))); - assertEquals("-Infinity", String(Math.min(Infinity, -Infinity))); - assertEquals("NaN", String(Math.min(NaN, 1))); - assertEquals("Infinity", String(1 / Math.min(0.0, 0.0))); - assertEquals("-Infinity", String(1 / Math.min(-0.0, -0.0))); - assertEquals("-Infinity", String(1 / Math.min(0.0, -0.0))); + assertSame(Infinity, Math.min(Infinity, Infinity)); + assertSame(-Infinity, Math.min(Infinity, -Infinity)); + assertSame(NaN, Math.min(NaN, 1)); + assertSame(Infinity, 1 / Math.min(0.0, 0.0)); + assertSame(-Infinity, 1 / Math.min(-0.0, -0.0)); + assertSame(-Infinity, 1 / Math.min(0.0, -0.0)); }); test(function mathMax() { assertEquals(10, Math.max(1, 10)); assertEquals(2.5, Math.max(1.5, 2.5)); assertEquals(Infinity, Math.max(Infinity, 0)); - assertEquals("-Infinity", String(Math.max(-Infinity, -Infinity))); - assertEquals("Infinity", String(Math.max(Infinity, -Infinity))); - assertEquals("NaN", String(Math.max(NaN, 1))); - assertEquals("Infinity", String(1 / Math.max(0.0, 0.0))); - assertEquals("-Infinity", String(1 / Math.max(-0.0, -0.0))); - assertEquals("Infinity", String(1 / Math.max(0.0, -0.0))); + assertSame(-Infinity, Math.max(-Infinity, -Infinity)); + assertSame(Infinity, Math.max(Infinity, -Infinity)); + assertSame(NaN, Math.max(NaN, 1)); + assertSame(Infinity, 1 / Math.max(0.0, 0.0)); + assertSame(-Infinity, 1 / Math.max(-0.0, -0.0)); + assertSame(Infinity, 1 / Math.max(0.0, -0.0)); }); test(function mathExp() { assertEquals(1.0, Math.exp(0.0)); assertTrue(2.7 < Math.exp(1) && Math.exp(1) < 2.8); - assertEquals("Infinity", String(Math.exp(Infinity))); + assertSame(Infinity, Math.exp(Infinity)); assertEquals("0", String(Math.exp(-Infinity))); - assertEquals("NaN", String(Math.exp(NaN))); + assertSame(NaN, Math.exp(NaN)); }); test(function mathLog() { assertEquals(0.0, Math.log(1.0)); assertTrue(1 < Math.log(3) && Math.log(3) < 1.5); - assertEquals("Infinity", String(Math.log(Infinity))); - assertEquals("NaN", String(Math.log(-Infinity))); - assertEquals("NaN", String(Math.exp(NaN))); + assertSame(Infinity, Math.log(Infinity)); + assertSame(NaN, Math.log(-Infinity)); + assertSame(NaN, Math.exp(NaN)); }); test(function mathSqrt() { assertEquals(1.0, Math.sqrt(1.0)); - assertEquals("NaN", String(Math.sqrt(-1.0))); - assertEquals("Infinity", String(Math.sqrt(Infinity))); - assertEquals("NaN", String(Math.sqrt(-Infinity))); - assertEquals("NaN", String(Math.sqrt(NaN))); + assertSame(NaN, Math.sqrt(-1.0)); + assertSame(Infinity, Math.sqrt(Infinity)); + assertSame(NaN, Math.sqrt(-Infinity)); + assertSame(NaN, Math.sqrt(NaN)); }); test(function mathPowHalf() { assertEquals(1.0, Math.pow(1.0, 0.5)); - assertEquals("NaN", String(Math.sqrt(-1.0))); - assertEquals("Infinity", String(Math.pow(Infinity, 0.5))); - assertEquals("NaN", String(Math.sqrt(-Infinity, 0.5))); + assertSame(NaN, Math.sqrt(-1.0)); + assertSame(Infinity, Math.pow(Infinity, 0.5)); + assertSame(NaN, Math.sqrt(-Infinity, 0.5)); assertEquals(0, Math.pow(Infinity, -0.5)); - assertEquals("NaN", String(Math.sqrt(-Infinity, -0.5))); - assertEquals("NaN", String(Math.sqrt(NaN, 0.5))); + assertSame(NaN, Math.sqrt(-Infinity, -0.5)); + assertSame(NaN, Math.sqrt(NaN, 0.5)); }); test(function mathAbs() { assertEquals(1.5, Math.abs(1.5)); assertEquals(1.5, Math.abs(-1.5)); - assertEquals("Infinity", String(Math.abs(Infinity))); - assertEquals("Infinity", String(Math.abs(-Infinity))); - assertEquals("NaN", String(Math.abs(NaN))); + assertSame(Infinity, Math.abs(Infinity)); + assertSame(Infinity, Math.abs(-Infinity)); + assertSame(NaN, Math.abs(NaN)); }); test(function mathRound() { assertEquals(2, Math.round(1.5)); assertEquals(-1, Math.round(-1.5)); - assertEquals("Infinity", String(Math.round(Infinity))); - assertEquals("-Infinity", String(Math.round(-Infinity))); - assertEquals("Infinity", String(1 / Math.round(0.0))); - assertEquals("-Infinity", String(1 / Math.round(-0.0))); - assertEquals("NaN", String(Math.round(NaN))); + assertSame(Infinity, Math.round(Infinity)); + assertSame(-Infinity, Math.round(-Infinity)); + assertSame(Infinity, 1 / Math.round(0.0)); + assertSame(-Infinity, 1 / Math.round(-0.0)); + assertSame(NaN, Math.round(NaN)); assertEquals(Math.pow(2, 52) + 1, Math.round(Math.pow(2, 52) + 1)); }); test(function mathFround() { assertTrue(isNaN(Math.fround(NaN))); - assertEquals("Infinity", String(1/Math.fround(0))); - assertEquals("-Infinity", String(1/Math.fround(-0))); - assertEquals("Infinity", String(Math.fround(Infinity))); - assertEquals("-Infinity", String(Math.fround(-Infinity))); - assertEquals("Infinity", String(Math.fround(1E200))); - assertEquals("-Infinity", String(Math.fround(-1E200))); + assertSame(Infinity, 1/Math.fround(0)); + assertSame(-Infinity, 1/Math.fround(-0)); + assertSame(Infinity, Math.fround(Infinity)); + assertSame(-Infinity, Math.fround(-Infinity)); + assertSame(Infinity, Math.fround(1E200)); + assertSame(-Infinity, Math.fround(-1E200)); assertEquals(3.1415927410125732, Math.fround(Math.PI)); }); test(function mathFloor() { assertEquals(1, Math.floor(1.5)); assertEquals(-2, Math.floor(-1.5)); - assertEquals("Infinity", String(Math.floor(Infinity))); - assertEquals("-Infinity", String(Math.floor(-Infinity))); - assertEquals("Infinity", String(1 / Math.floor(0.0))); - assertEquals("-Infinity", String(1 / Math.floor(-0.0))); - assertEquals("NaN", String(Math.floor(NaN))); + assertSame(Infinity, Math.floor(Infinity)); + assertSame(-Infinity, Math.floor(-Infinity)); + assertSame(Infinity, 1 / Math.floor(0.0)); + assertSame(-Infinity, 1 / Math.floor(-0.0)); + assertSame(NaN, Math.floor(NaN)); assertEquals(Math.pow(2, 52) + 1, Math.floor(Math.pow(2, 52) + 1)); }); test(function mathPow() { assertEquals(2.25, Math.pow(1.5, 2)); assertTrue(1.8 < Math.pow(1.5, 1.5) && Math.pow(1.5, 1.5) < 1.9); - assertEquals("Infinity", String(Math.pow(Infinity, 0.5))); - assertEquals("Infinity", String(Math.pow(-Infinity, 0.5))); + assertSame(Infinity, Math.pow(Infinity, 0.5)); + assertSame(Infinity, Math.pow(-Infinity, 0.5)); assertEquals(0, Math.pow(Infinity, -0.5)); assertEquals(0, Math.pow(Infinity, -0.5)); - assertEquals("Infinity", String(Math.pow(Infinity, Infinity))); + assertSame(Infinity, Math.pow(Infinity, Infinity)); assertEquals(0, Math.pow(Infinity, -Infinity)); - assertEquals("NaN", String(Math.pow(Infinity, NaN))); - assertEquals("NaN", String(Math.pow(NaN, 2))); + assertSame(NaN, Math.pow(Infinity, NaN)); + assertSame(NaN, Math.pow(NaN, 2)); }); test(function stringAdd() { @@ -226,24 +232,48 @@ test(function stringLength() { assertEquals(-5, { length: -5 }.length); }); -test(function stringCharCodeAt() { - assertEquals(99, "abc".charCodeAt(2)); - assertEquals("NaN", String("abc".charCodeAt(-1))); - assertEquals("NaN", String("abc".charCodeAt(4))); - assertEquals(98, "abc".charCodeAt(1.1)); - assertEquals("NaN", String("abc".charCodeAt(4.1))); - assertEquals("NaN", String("abc".charCodeAt(1 + 4294967295))); -}); - test(function stringCharAt() { assertEquals("c", "abc".charAt(2)); assertEquals("", "abc".charAt(-1)); assertEquals("", "abc".charAt(4)); assertEquals("b", "abc".charAt(1.1)); assertEquals("", "abc".charAt(4.1)); - assertEquals("", String("abc".charAt(1 + 4294967295))); -}); + assertEquals("", "abc".charAt(Infinity)); + assertEquals("", "abc".charAt(-Infinity)); + assertEquals("a", "abc".charAt(-0)); + assertEquals("a", "abc".charAt(+0)); + assertEquals("", "".charAt()); + assertEquals("", "abc".charAt(1 + 4294967295)); +}, 10); + +test(function stringCharCodeAt() { + assertSame(99, "abc".charCodeAt(2)); + assertSame(NaN, "abc".charCodeAt(-1)); + assertSame(NaN, "abc".charCodeAt(4)); + assertSame(98, "abc".charCodeAt(1.1)); + assertSame(NaN, "abc".charCodeAt(4.1)); + assertSame(NaN, "abc".charCodeAt(Infinity)); + assertSame(NaN, "abc".charCodeAt(-Infinity)); + assertSame(97, "abc".charCodeAt(-0)); + assertSame(97, "abc".charCodeAt(+0)); + assertSame(NaN, "".charCodeAt()); + assertSame(NaN, "abc".charCodeAt(1 + 4294967295)); +}, 10); +test(function stringCodePointAt() { + assertSame(65533, "äϠ�𝌆".codePointAt(2)); + assertSame(119558, "äϠ�𝌆".codePointAt(3)); + assertSame(undefined, "äϠ�".codePointAt(-1)); + assertSame(undefined, "äϠ�".codePointAt(4)); + assertSame(992, "äϠ�".codePointAt(1.1)); + assertSame(undefined, "äϠ�".codePointAt(4.1)); + assertSame(undefined, "äϠ�".codePointAt(Infinity)); + assertSame(undefined, "äϠ�".codePointAt(-Infinity)); + assertSame(228, "äϠ�".codePointAt(-0)); + assertSame(97, "aϠ�".codePointAt(+0)); + assertSame(undefined, "".codePointAt()); + assertSame(undefined, "äϠ�".codePointAt(1 + 4294967295)); +}, 10); test(function int32Mod() { assertEquals(-0, -2147483648 % (-1)); diff --git a/deps/v8/test/mjsunit/d8/d8-worker-sharedarraybuffer.js b/deps/v8/test/mjsunit/d8/d8-worker-sharedarraybuffer.js index 09586c3a11..0a15413ea3 100644 --- a/deps/v8/test/mjsunit/d8/d8-worker-sharedarraybuffer.js +++ b/deps/v8/test/mjsunit/d8/d8-worker-sharedarraybuffer.js @@ -28,17 +28,17 @@ // Flags: --harmony-sharedarraybuffer if (this.Worker) { - (function TestTransfer() { + (function TestClone() { var workerScript = `onmessage = function(m) { var sab = m; var ta = new Uint32Array(sab); if (sab.byteLength !== 16) { - throw new Error('SharedArrayBuffer transfer byteLength'); + throw new Error('SharedArrayBuffer clone byteLength'); } for (var i = 0; i < 4; ++i) { if (ta[i] !== i) { - throw new Error('SharedArrayBuffer transfer value ' + i); + throw new Error('SharedArrayBuffer clone value ' + i); } } // Atomically update ta[0] @@ -53,7 +53,7 @@ if (this.Worker) { ta[i] = i; } - // Transfer SharedArrayBuffer + // Clone SharedArrayBuffer w.postMessage(sab); assertEquals(16, sab.byteLength); // ArrayBuffer should not be neutered. @@ -68,7 +68,7 @@ if (this.Worker) { assertEquals(16, sab.byteLength); // Still not neutered. })(); - (function TestTransferMulti() { + (function TestCloneMulti() { var workerScript = `onmessage = function(msg) { var sab = msg.sab; diff --git a/deps/v8/test/mjsunit/default-nospec.js b/deps/v8/test/mjsunit/default-nospec.js new file mode 100644 index 0000000000..0e3b6c1f55 --- /dev/null +++ b/deps/v8/test/mjsunit/default-nospec.js @@ -0,0 +1,84 @@ +// 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 --no-always-opt + +(()=> { + function f(a, b, c) { + return String.prototype.indexOf.call(a, b, c); + } + f("abc", "de", 1); + f("abc", "de", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", "de", {}); + %OptimizeFunctionOnNextCall(f); + f("abc", "de", {}); + assertOptimized(f); +})(); + +(()=> { + function f(a, b, c) { + return String.prototype.indexOf.apply(a, [b, c]); + } + f("abc", "de", 1); + f("abc", "de", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}, 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}, 1); + assertOptimized(f); +})(); + +(()=> { + function f(a, b, c) { + return Reflect.apply(String.prototype.indexOf, a, [b, c]); + } + f("abc", "de", 1); + f("abc", "de", 1); + %OptimizeFunctionOnNextCall(f); + f({}, "de", 1); + %OptimizeFunctionOnNextCall(f); + f({}, "de", 1); + assertOptimized(f); +})(); + +(()=> { + function f(a, b) { + return String.fromCharCode.call(a, b); + } + f("abc", 1); + f("abc", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}); + %OptimizeFunctionOnNextCall(f); + f({}, {}); + assertOptimized(f); +})(); + +(()=> { + function f(a, b) { + return String.fromCharCode.apply(undefined, [b, {}]); + } + f("abc", 1); + f("abc", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}); + %OptimizeFunctionOnNextCall(f); + f("abc", {}); + assertOptimized(f); +})(); + + +(()=> { + function f(a, b) { + return Reflect.apply(String.fromCharCode, a, [b, {}]); + } + f("abc", 1); + f("abc", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}); + %OptimizeFunctionOnNextCall(f); + f("abc", {}); + assertOptimized(f); +})(); diff --git a/deps/v8/test/mjsunit/deserialize-script-id.js b/deps/v8/test/mjsunit/deserialize-script-id.js deleted file mode 100644 index 5dca9f353a..0000000000 --- a/deps/v8/test/mjsunit/deserialize-script-id.js +++ /dev/null @@ -1,17 +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 --cache=code -// Test that script ids are unique and we found the correct ones. - -var Debug = %GetDebugContext().Debug; -Debug.setListener(function(){}); - -var scripts = %DebugGetLoadedScripts(); -scripts.sort(function(a, b) { return a.id - b.id; }); -scripts.reduce(function(prev, cur) { - assertTrue(prev === undefined || prev.id != cur.id); -}); - -Debug.setListener(null); 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); diff --git a/deps/v8/test/mjsunit/es8/object-entries.js b/deps/v8/test/mjsunit/es8/object-entries.js index 5c7e74e378..1c6358648b 100644 --- a/deps/v8/test/mjsunit/es8/object-entries.js +++ b/deps/v8/test/mjsunit/es8/object-entries.js @@ -19,7 +19,7 @@ function TestMeta() { TestMeta(); -function TestBasic() { +function TestBasic(withWarmup) { var x = 16; var O = { d: 1, @@ -33,22 +33,29 @@ function TestBasic() { O.a = 2; O.b = 4; Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN }); - assertEquals([ + if (withWarmup) { + for (const key in O) {} + } + O.c = 6; + const resultEntries = [ ["0", 123], ["256", "ducks"], ["1000", 456], ["d", 1], - ["c", 3], + ["c", 6], ["0x100", "quack"], ["a", 2], ["b", 4] - ], Object.entries(O)); + ]; + assertEquals(resultEntries, Object.entries(O)); + assertEquals(resultEntries, Object.entries(O)); assertEquals(Object.entries(O), Object.keys(O).map(key => [key, O[key]])); assertTrue(Array.isArray(Object.entries({}))); assertEquals(0, Object.entries({}).length); } TestBasic(); +TestBasic(true); function TestToObject() { @@ -59,7 +66,7 @@ function TestToObject() { TestToObject(); -function TestOrder() { +function TestOrder(withWarmup) { var O = { a: 1, [Symbol.iterator]: null @@ -88,6 +95,11 @@ function TestOrder() { } }); + if (withWarmup) { + for (const key in P) {} + } + log = []; + assertEquals([["456", 123], ["a", 1]], Object.entries(P)); assertEquals([ "[[OwnPropertyKeys]]", @@ -99,9 +111,10 @@ function TestOrder() { ], log); } TestOrder(); +TestOrder(true); -function TestOrderWithDuplicates() { +function TestOrderWithDuplicates(withWarmup) { var O = { a: 1, [Symbol.iterator]: null @@ -130,6 +143,11 @@ function TestOrderWithDuplicates() { } }); + if (withWarmup) { + for (const key in P) {} + } + log = []; + assertEquals([ ["a", 1], ["a", 1], @@ -151,9 +169,20 @@ function TestOrderWithDuplicates() { ], log); } TestOrderWithDuplicates(); +TestOrderWithDuplicates(true); +function TestDescriptorProperty() { + function f() {}; + const o = {}; + o.a = f; -function TestPropertyFilter() { + for (const key in o) {}; + const entries = Object.entries(o); + assertEquals([['a', f]], entries); +} +TestDescriptorProperty(); + +function TestPropertyFilter(withWarmup) { var object = { prop3: 30 }; object[2] = 40; object["prop4"] = 50; @@ -164,6 +193,10 @@ function TestPropertyFilter() { var sym = Symbol("prop8"); object[sym] = 90; + if (withWarmup) { + for (const key in object) {} + } + values = Object.entries(object); assertEquals(5, values.length); assertEquals([ @@ -175,11 +208,15 @@ function TestPropertyFilter() { ], values); } TestPropertyFilter(); +TestPropertyFilter(true); -function TestWithProxy() { +function TestWithProxy(withWarmup) { var obj1 = {prop1:10}; var proxy1 = new Proxy(obj1, { }); + if (withWarmup) { + for (const key in proxy1) {} + } assertEquals([ [ "prop1", 10 ] ], Object.entries(proxy1)); var obj2 = {}; @@ -191,6 +228,9 @@ function TestWithProxy() { return Reflect.getOwnPropertyDescriptor(target, name); } }); + if (withWarmup) { + for (const key in proxy2) {} + } assertEquals([ [ "prop2", 20 ], [ "prop3", 30 ] ], Object.entries(proxy2)); var obj3 = {}; @@ -206,12 +246,16 @@ function TestWithProxy() { return [ "prop0", "prop1", Symbol("prop2"), Symbol("prop5") ]; } }); + if (withWarmup) { + for (const key in proxy3) {} + } assertEquals([ [ "prop0", 0 ], [ "prop1", 5 ] ], Object.entries(proxy3)); } TestWithProxy(); +TestWithProxy(true); -function TestMutateDuringEnumeration() { +function TestMutateDuringEnumeration(withWarmup) { var aDeletesB = { get a() { delete this.b; @@ -219,6 +263,9 @@ function TestMutateDuringEnumeration() { }, b: 2 }; + if (withWarmup) { + for (const key in aDeletesB) {} + } assertEquals([ [ "a", 1 ] ], Object.entries(aDeletesB)); var aRemovesB = { @@ -228,9 +275,15 @@ function TestMutateDuringEnumeration() { }, b: 2 }; + if (withWarmup) { + for (const key in aRemovesB) {} + } assertEquals([ [ "a", 1 ] ], Object.entries(aRemovesB)); var aAddsB = { get a() { this.b = 2; return 1; } }; + if (withWarmup) { + for (const key in aAddsB) {} + } assertEquals([ [ "a", 1 ] ], Object.entries(aAddsB)); var aMakesBEnumerable = {}; @@ -243,12 +296,16 @@ function TestMutateDuringEnumeration() { }); Object.defineProperty(aMakesBEnumerable, "b", { value: 2, configurable:true, enumerable: false }); + if (withWarmup) { + for (const key in aMakesBEnumerable) {} + } assertEquals([ [ "a", 1 ], [ "b", 2 ] ], Object.entries(aMakesBEnumerable)); } TestMutateDuringEnumeration(); +TestMutateDuringEnumeration(true); -(function TestElementKinds() { +function TestElementKinds(withWarmup) { var O1 = { name: "1" }, O2 = { name: "2" }, O3 = { name: "3" }; var PI = 3.141592653589793; var E = 2.718281828459045; @@ -303,13 +360,22 @@ TestMutateDuringEnumeration(); }), [["0", "s"], ["1", "t"], ["2", "r"], ["9999", "Y"]] ], }; + if (withWarmup) { + for (const key in element_kinds) {} + } for (let [kind, [object, expected]] of Object.entries(element_kinds)) { + if (withWarmup) { + for (const key in object) {} + } let result1 = Object.entries(object); %HeapObjectVerify(object); %HeapObjectVerify(result1); assertEquals(expected, result1, `fast Object.entries() with ${kind}`); let proxy = new Proxy(object, {}); + if (withWarmup) { + for (const key in proxy) {} + } let result2 = Object.entries(proxy); %HeapObjectVerify(result2); assertEquals(result1, result2, `slow Object.entries() with ${kind}`); @@ -331,9 +397,15 @@ TestMutateDuringEnumeration(); for (let [kind, [object, expected]] of Object.entries(element_kinds)) { if (kind == "FAST_STRING_WRAPPER_ELEMENTS") break; object.__defineGetter__(1, makeFastElements); + if (withWarmup) { + for (const key in object) {} + } let result1 = Object.entries(object).toString(); %HeapObjectVerify(object); %HeapObjectVerify(result1); } -})(); +} + +TestElementKinds(); +TestElementKinds(true); diff --git a/deps/v8/test/mjsunit/es9/regexp-lookbehind.js b/deps/v8/test/mjsunit/es9/regexp-lookbehind.js index 54c975cfdf..c3aae317a9 100644 --- a/deps/v8/test/mjsunit/es9/regexp-lookbehind.js +++ b/deps/v8/test/mjsunit/es9/regexp-lookbehind.js @@ -162,3 +162,10 @@ assertEquals(["cacb", "a", ""], /(?<=a(.\2)b(\1)).{4}/.exec("aabcacbc")); assertEquals(["b", "ac", "ac"], /(?<=a(\2)b(..\1))b/.exec("aacbacb")); assertEquals(["x", "aa"], /(?<=(?:\1b)(aa))./.exec("aabaax")); assertEquals(["x", "aa"], /(?<=(?:\1|b)(aa))./.exec("aaaax")); + +// Restricted syntax in Annex B 1.4. +assertThrows("/(?<=.)*/u", SyntaxError); +assertThrows("/(?<=.){1,2}/u", SyntaxError); +assertThrows("/(?<=.)*/", SyntaxError); +assertThrows("/(?<=.)?/", SyntaxError); +assertThrows("/(?<=.)+/", SyntaxError); diff --git a/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js b/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js index a7b0d1bda4..2d6be098a2 100644 --- a/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js +++ b/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js @@ -717,8 +717,8 @@ if (testFailed) { next_: 0, get next() { log.push("get syncIterable.next"); - let i = this.next_++; return (...args) => { + let i = this.next_++; log.push("call syncIterable.next(" + args.join(", ") + ")"); return results[i]; } @@ -748,14 +748,12 @@ if (testFailed) { "get nextValue#1.then", "call nextValue#1.then", "got value value1", - "get syncIterable.next", "call syncIterable.next()", "get iterResult #2.done", "get iterResult #2.value", "get nextValue#2.then", "call nextValue#2.then", "got value value2", - "get syncIterable.next", "call syncIterable.next()", "get iterResult #3.done", "get iterResult #3.value", diff --git a/deps/v8/test/mjsunit/harmony/async-generators-basic.js b/deps/v8/test/mjsunit/harmony/async-generators-basic.js index d7af1836b8..12240e6114 100644 --- a/deps/v8/test/mjsunit/harmony/async-generators-basic.js +++ b/deps/v8/test/mjsunit/harmony/async-generators-basic.js @@ -153,7 +153,7 @@ async function* asyncGeneratorForToString() {} assertEquals("async function* asyncGeneratorForToString() {}", asyncGeneratorForToString.toString()); -assertEquals("async function* () {}", async function*() {}.toString()); +assertEquals("async function*() {}", async function*() {}.toString()); assertEquals("async function* namedAsyncGeneratorForToString() {}", async function* namedAsyncGeneratorForToString() {}.toString()); @@ -164,9 +164,9 @@ assertEquals("async *method() { }", assertEquals("async *method() { }", (new (class { async *method() { } })).method.toString()); -assertEquals("async function* anonymous() {\n\n}", +assertEquals("async function* anonymous(\n) {\n\n}", AsyncGeneratorFunction().toString()); -assertEquals("async function* anonymous() {\n\n}", +assertEquals("async function* anonymous(\n) {\n\n}", (new AsyncGeneratorFunction()).toString()); // ---------------------------------------------------------------------------- diff --git a/deps/v8/test/mjsunit/harmony/bigint/add.js b/deps/v8/test/mjsunit/harmony/bigint/add.js index b57846e7f1..5e986b3726 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/add.js +++ b/deps/v8/test/mjsunit/harmony/bigint/add.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "a2102214b151421124f462d37f843", - b: "90f3fa0f2fb9b1481b1a4737586ad6bdf71cb2ae51e06fdcb00fb779163e94ae4237", - r: "90f3fa0f2fb9b1481b1a4737586ad6bdf71cb2b872e29127c523d88b6584c1e63a7a" + a: -0xc4043e2c4cc49e4d6870103ce7c2ff2d512bf4b1b67553ba410db514ee0af8888ad6cfn, + b: 0x2aae86de73ff479133a657a40d26e8dcf192019c7421836615ec34978bad93n, + r: -0xc4043e2c2216176ef470c8abb41ca78944050bd4c4e3521dccec31aed81ec3f0ff293cn }, { - a: "35ca28bdd383c1b9ffdb851cc7f385ad370eef3d", - b: "-ca2d4dd677f23e005f44ec121303c3c304940eb2fd15e9e88772a3c5ba8515", - r: "-ca2d4dd677f23e005f44ebdc48db05ef80d254b32190cd2093ecf68eab95d8" + a: -0xee0933b25c8c0ef09fa385ffa1d3ca76855b560e186d27fa9f6ce105cb8517a4aecd5n, + b: -0x2ffc3a7babad313ede574774cb55cd40ab3b2n, + r: -0xee0933b25c8c0ef09fa385ffa1d3ca76b5579089c41a59397dc4287a96dae4e55a087n }, { - a: "-8abb4b6ca534b584fad2f5898dd22ae6", - b: "0", - r: "-8abb4b6ca534b584fad2f5898dd22ae6" + a: -0xdbb3e8fac212affdeda8959829838af77e43172n, + b: 0x2315999da3ac2ab89d2076cbe6e2e03082352e92c274680117ce7012dn, + r: 0x2315999da3ac2ab89c44c2e2ec20cd80844785fd2a4ae47620502cfbbn }, { - a: "b3", - b: "4180a0a", - r: "4180abd" + a: -0x5ad9780b309c24919defb1b331ebba4en, + b: 0xbe8dd806b3da0f79e7f6ad2fb566536cc78c1471c236891ce0n, + r: 0xbe8dd806b3da0f79e79bd3b7aa35b74835ee24c00f049d6292n }, { - a: "-8de89", - b: "c329fbab24d762a9453f90b134fcf5da9777aa1fdb26b74f27583a92a43f0f2c450", - r: "c329fbab24d762a9453f90b134fcf5da9777aa1fdb26b74f27583a92a43f0e9e5c7" + a: -0xade45eac6aaaf2c8097d7a3efecba4e80dd7aac4f692cfe841d113e68096c0218d521an, + b: -0x73c4119b366e22edd0797b5883a13e3bfc4124a559903ce785e0c833a8306b41cfn, + r: -0xade4d2707c4629362c6b4ab87a2428894c13a7061b3829787eb899c748ca6851f893e9n }, { - a: "-49af5f350d64c75047dfb107550dae478c983dd520e86c9807b1f5", - b: "60a62691669b8c323a29db2eb9cb75ba5811", - r: "-49af5f350d64c750477f0ae0c3a712bb5a5e13f9f22ea1224d59e4" + a: -0x6e9ab93d5cff3b3f31a55aa2f43fc321bff6978189e00fa4e64cn, + b: 0xec1caec29eb55312a313e50e20178873a350f1f89cbc971n, + r: -0x6e9aaa7b92131153dc743071b5eee120476f5d4c7ac085d91cdbn }, { - a: "80bf614aaa1140792099375f7fac9c7046303a8d13086755d505795f38761", - b: "-949dc945", - r: "80bf614aaa1140792099375f7fac9c7046303a8d13086755d50570155be1c" + a: -0x9a61c05bd53b74b731b8f8687e64d1ed1340404b5137ce39n, + b: -0x1e6793ea0fa51b2354b48n, + r: -0x9a61c05bd53b74b731b8f8687e66b86651e13a9d036d1981n }, { - a: "4241d736e6a40", - b: "-78e88f5eaeae4ff8b", - r: "-78e84d1cd7776954b" + a: -0x7c5a08517038f7dn, + b: 0x1d89f2n, + r: -0x7c5a08516e6058bn }, { - a: "-8033927bf52210827b99e712fb220631503adfaa4e0045c872b9b", - b: "-2f", - r: "-8033927bf52210827b99e712fb220631503adfaa4e0045c872bca" + a: -0xc4fd1b5aae2cfdc7b3ea6a74b7926a9a1ca3513bd08341e0c770080ban, + b: 0x76c79770202f9d9c6d2e244n, + r: -0xc4fd1b5aae2cfdc7b3ea6a74b7926a9a1c2c89a4606312432b02d9e76n }, { - a: "-3ad8b67efe9", - b: "-35586bf43788fd8e313da33c62d9a5", - r: "-35586bf43788fd8e314150c7cac98e" + a: 0xda114ddab6bfed910cc05c64f72961107beb98c3271n, + b: 0x98c52c393c6660663248fcbaa300b8n, + r: 0xda114ddab6bff71d5f83f02b5d2fc4350bb742f3329n }, { - a: "-a43d8c9af54e8ea545e1af4674613932650c833669c7adc9273b77", - b: "-6a4", - r: "-a43d8c9af54e8ea545e1af4674613932650c833669c7adc927421b" + a: -0x46311d926dfd26f0850ea3497fcd0d95a5dabab0361f219a601dc3dbe35d0n, + b: -0xf340af7b84e4eced2ca613e1ef4bb6aec4b8f01bc3n, + r: -0x46311d926dfd26f0851dd75477855be474ad8511743e1655cb0a0f6ae5193n }, { - a: "26c178e22dd42280a59b", - b: "fba77d85ba082981ce4a1ca21ac8b805b389297dc", - r: "fba77d85ba082981ce4a1f0e3256dae2f5b133d77" + a: 0xb2b4d9c0c73258a8092n, + b: 0xf4d1c3d2861cc0bfaea456c03b0f548a32effc1c3e1593935a6b0n, + r: 0xf4d1c3d2861cc0bfaea456c03b0f548a33a2b0f5fedcc5ec02742n }, { - a: "-c9bc2ac82920efc63fa48f63fae105ec432672b50269fad72ee8b44a1", - b: "8967d49deeff878f40fa1bf408400b8085820d47b", - r: "-c9bc2ac82920efc5b63cbac60be17e5d022c56c0fa29ef56a966a7026" + a: -0x56604879bdaaff7409cd59cfbafe73a74c284bfaeb991b6e11171bc08cf68bean, + b: 0xf4016a6e94c0f256af54fca00d6c909a620c6ea950c73cade3724174c12888n, + r: -0x556c470f4f163e81b31e04d31af10716b1c63f8c424854316333a97f18356362n }, { - a: "815a18c9a2d8c6e5f3fffa958430851c4ea3", - b: "59d451c6efad276d3cc393907dda0eca463488958f397bb09", - r: "59d451c6efad2f82de502dbe0a486e0a45dde0d8978b409ac" + a: -0x7a238c856c50aee41d1a2a1446a77f1567n, + b: 0x58n, + r: -0x7a238c856c50aee41d1a2a1446a77f150fn }, { - a: "8cfc360e8d215045cb5c289a50e5c7fa9da34c0b9d9be9597e6e476efdb121", - b: "-482747619f0edd06", - r: "8cfc360e8d215045cb5c289a50e5c7fa9da34c0b9d9be9115726e5cfeed41b" + a: 0xcdaf8c242e5da7265cc715871c3n, + b: -0x63604dd2b8df176c627ce3b018b2e74448746123d5578e66e9c0n, + r: -0x63604dd2b8df176c627ce3b00bd7ee82058e86b16f8b1d0e77fdn }, { - a: "346337dbb9bbfc08cb815434c50315d32d", - b: "-ac569f54f5ea8852463c7542e876a9953", - r: "299dcde66a5d5383a71d8ce0967bab39da" + a: 0xfa254e9c8d182d2bd90d8ff2b25d4e9819900b62b9ef60f3744ddc55cd362den, + b: -0x1fef80ff5d53dd0adaa75e8f0d16429851de115822n, + r: 0xfa254e9c8d182d2bd90d8df3ba4d58c2dbbf5db84406702210245737ec20abcn }, { - a: "8bb7c3e56", - b: "-c334d52ed6eb903256253e01fc0c5118fe9bc", - r: "-c334d52ed6eb903256253e01fc0bc5613ab66" + a: 0x3e85cn, + b: 0x687c558b2c1308c1a133d647ff7en, + r: 0x687c558b2c1308c1a133d64be7dan }, { - a: "b1f444a7a95e6d1d293ff0182e3dd5e945234484a5b47516b5b42627ed54fa8cf1221e", - b: "-93b77e906778b7e0a85c07e08babe730edd93ed37adef19da9e76de2add3", - r: "b1f444a7a8cab59e98d877604d9579e16497989d74c69bd7e23947364fab131f0e744b" + a: 0x9011db3dd56dbf2ef06154cbd48a67f6038483cff59f49011e57n, + b: 0xc033be10adcb6a7a5a697a7ef95ac3680611ff7ef690231314d338an, + r: 0xc03cbf2e61a8c1564d58809446180c0e857237c7338f7d07a4e51e1n }, { - a: "9a156524b9", - b: "-bce28d1561fc0153b836c6e0969d2674fcb960331cdb55df24e34e4b65136fcb59", - r: "-bce28d1561fc0153b836c6e0969d2674fcb960331cdb55df24e34e4acafe0aa6a0" + a: -0xefac02ab40df0f00a1b97a4n, + b: 0xc3b5e53656cd891e179ec3fb8a8d192f9bab5cfd76c014400n, + r: 0xc3b5e53656cd891e179ec3fb899d6d2cf06a7dee761e5ac5cn }, { - a: "5eaf418fbccefb4f53abc413c02cee60eb3880b615c615c2005b3d11c8ee4aaf3b4ded8", - b: "-eb8aa4a72cf44f06208", - r: "5eaf418fbccefb4f53abc413c02cee60eb3880b615c615c2005a518724471dbaec47cd0" + a: -0x7f9d48b408a5bb3827bc0149ecd538a2b2a7d4e1e0a4e9c36ee05f8be3a5b3n, + b: 0xd83d8cb2fb784703498cf0d61ff097ca42635664058cb85ea39f5931c37a1n, + r: -0x72196fe8d8ee36c7f323323c8ad62f260e819f7ba04c1e3d84a669f8c76e12n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a + b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a + d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: +"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/and.js b/deps/v8/test/mjsunit/harmony/bigint/and.js index e5c3b145d6..7a68f8b3dc 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/and.js +++ b/deps/v8/test/mjsunit/harmony/bigint/and.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "-193b47d0d9a8688b329e80de92195f311825", - b: "-2fabed9434bff933e23ea21af0f21a43", - r: "-193b6ffbfdbc7cbffbbfe2feb21bfff31a67" + a: 0x9252b94f220ded0c18706998886397699c5a25527575dn, + b: -0x286817ba2e8fd8n, + r: 0x9252b94f220ded0c1870699888639769185a045015008n }, { - a: "35979ec99b7ff03f81817ebc9ddd50025d1ccf41565b502f0fc85ec54f630", - b: "be96016cc031653c9b1eceb1dd", - r: "8c9401648000603c810c44b010" + a: 0x15a28152354fe421bbe4649d4d22d536ac34f9ba962n, + b: 0x8n, + r: 0n }, { - a: "-f594f8199c11594681a9c38fd985a03d8c79ce6c8d342809924c89b385af43116ec3a21", - b: "-53e7b9738caaecc58fde1b5a4aa9f782f28a04e2bb29d207ccd5d45", - r: "-f594f8199c115946d3effbffddafecfd8fffdf7ecfbdff8bf2ce8df3bfafd317eed7f65" + a: 0xd09791bf7ae6703fae8d654104f54fcd957bbf028540b8e7c0f859fdcc1b7abd617en, + b: 0x24b473d03n, + r: 0x24a052102n }, { - a: "dd7245d3ca5b360296082e6ca91915179b257f36e45e6e44cf892db875fdcfb19522b3", - b: "-dcc83137df3bb234e1144390f6c5bc0772a07f2a4540865554d20ebd37be", - r: "dd7245d3ca0336028000044c891801140b013a02e00c4e00c5882d3820a90db1000002" + a: 0x2f73fbd05e9f7f70beba3dc7cd883732149a3d02a422f90f336n, + b: 0x4490583f8n, + r: 0x9008330n }, { - a: "-28", - b: "eaec4017147fd9741ff3b98f1b6f71d8f3d6869c18b39c6237a6b2d4d2fc3c81e9", - r: "eaec4017147fd9741ff3b98f1b6f71d8f3d6869c18b39c6237a6b2d4d2fc3c81c8" + a: 0xd6ea27844b3d356774e73de10d393ab9cadb81848e3b4a34d1f7440d3n, + b: 0x1639eeee731f3ba09234b5e15ec92f8bfb5cea28a0e89c59ed1c45b5f04n, + r: 0x10ea26000b39200234a5214009290ab948ca008088184824104504000n }, { - a: "-223909fc585f36f995d6f72dd9f169df1fad8", - b: "b13e919ce59c18c7c0517eecdb2519155cc", - r: "80360184a0880042000052240a040000508" + a: -0x131f5e2c196269fd140c8727a9a02170e0dddb6aec109a89bcn, + b: 0x401ec4eae8b756f2b222f6f565fb6acecce3c524e9b453n, + r: 0x12c488800242f230005655448b0a0204810124613440n }, { - a: "-fcb4ac9fdc7ee85d03585f944a79b28efffb461e17df2d", - b: "13cd27fb49c92d53c567688ab6b9", - r: "38023b100492100042160882091" + a: -0x5bcba128bf7b949780a4bd02782a63ae79f646a33b8672f3f692ab98n, + b: -0xa81dd8ff624072fce3a00eb0bd5700e5666c3beb7d59701c42489n, + r: -0x5bcba1fdbfffb497afeebf02fb2bf7fe7ff666e3bfb7f7f7f7d6afa0n }, { - a: "-1a16ca8c3725cec0c8a61ce81", - b: "-dbf3e", - r: "-1a16ca8c3725cec0c8a6dffbe" + a: 0xc997546528786548270061bcn, + b: 0x75023f046c04f9095f64d3b8c75ab21950an, + r: 0x499014640838044023000108n }, { - a: "-834db45b67472062091e", - b: "5aff66623af6b6cd042a361d5a22aea03152b764a056c71", - r: "5aff66623af6b6cd042a361d5a228a2030408304a056460" + a: 0x5ad0abd6e43ef787248af2607fb29b9c3f7a1e7b106269ff3bn, + b: -0xd483c8630392db4b620e0f6n, + r: 0x5ad0abd6e43ef787248af2607fb29380394a06520040491f0an }, { - a: "1a8c37cff2e02f5272bc61d60b8301e443c38172446f75d75e01c41f60", - b: "e15d12bee18edaca77ad15ff0a567e132bb1b046623858", - r: "215012bc61860a8201a401c30052440321911000401840" + a: -0x9ed448bdb4794e4c0485db9ebe6cad0b0n, + b: -0x549a70753c9afn, + r: -0x9ed448bdb4794e4c0485df9efe7dbd9b0n }, { - a: "-f463", - b: "bb02038e2ff03fa", - r: "bb02038e2ff0398" + a: -0x3a3fe42647633612082372714484767efc9673ce964b76f9f53a63d5n, + b: 0x99615e5edd0506cbb5512fb56ee2dd1238bn, + r: 0x986116189800068881100b0000608c1000bn }, { - a: "3178f92d2eeee1aebc33f085aa96c9046f1133ad6afbd666664ab79625639e001", - b: "124d8bd8ea20d8e510ba30d9", - r: "20d02406020586010382001" + a: -0xac1b8238c08f5n, + b: -0xb9439dfbbc70e12b3a1fc7ccbfebeacd9bb321d83d3an, + r: -0xb9439dfbbc70e12b3a1fc7ccbfebeacfdbbb23dc3dfen }, { - a: "fc7aaaa7a52f3604e1e700f01ea6f266912f583bffa78aee08939401056cde", - b: "-50e3611d6ada075f432319f10c8192f1de56ead628972", - r: "fc7aaaa7a52f3604e0e100e008025202010d4820ef2782c00012900005648e" + a: 0x120580503n, + b: 0x90e13d34618496af407fabefabdd23892f488n, + r: 0x20100400n }, { - a: "7dea10c67bdf023c00d94643e9f2d38295635b0b2b55a0e40818", - b: "8defe4741785c6c2d2ecaf7752a903ed", - r: "443e0701380844252082b5500a00008" + a: 0xaa51cn, + b: 0x2122a9c43b2531d5n, + r: 0x2114n }, { - a: "6f837e0ec2d00abb60051299bfd36b58c803f6445f91bb8dded858c6c1c476142", - b: "-26746eda5ca5095ab8f315c88b201cfa2affbbb700fc3bba8626b5bfd0a", - r: "6f837e08829000a3400400010cc22350c80304440000088d02c04040c14040042" + a: 0xaf43eb353c1547dc6ad79768e9a6n, + b: 0x55c80f89d8fe82dbf69eca557dd0479b6a449db77e38b2241ec81aa7d4042766dd3e63n, + r: 0x28022014081007d4000706482822n }, { - a: "ab69c286138358dea4308b60f12f212fcd1e0", - b: "-c8735b6ce5513cc661fdae7941055028a2ea768dc13b9c83a79b9bf84e62cdf", - r: "aa29c2041181501e84200840602401218d120" + a: 0xbd38b2d88212ceea6fbe3890769e46236n, + b: 0xeb22e568873e9bfdb5d2ddbc03n, + r: 0x88202468863a83890540c42002n }, { - a: "6c9ec2e7cdb2c1fb630a8e16323138db939c2a21e3576b777d", - b: "-51cf93f77a711c00", - r: "6c9ec2e7cdb2c1fb630a8e16323138db938c202000050a6400" + a: 0x24cd8c9634eddf319c57b54dffb49ce4974528f03b2c732d052ad496n, + b: -0x4079cfn, + r: 0x24cd8c9634eddf319c57b54dffb49ce4974528f03b2c732d052a8410n }, { - a: "edee34cd0c29ad27fed12e77a42aedbf8b53161716c90d516394b9038a2f125c95", - b: "-18a515e3705a582d82f14bd42075b3b", - r: "edee34cd0c29ad27fed12e77a42aedbf8b52140600c8085061049003022d100485" + a: -0x61f263476a1212fce55cf7d437f4364b73a1815a641n, + b: -0x19226cb79772cca166043a29d1f0fe1df5n, + r: -0x61f263476b9236fffd7fffde37f477ebffbf8ffbff5n }, { - a: "466fee7dabecbaea71c19892f045d7d196a80c6f", - b: "-5c93c7afd552be", - r: "466fee7dabecbaea71c19892f001441010280c42" + a: -0x44309b08a65bc7dc1e53d598d82ccdaa852941d7c851d907a6acn, + b: 0xdd93dc17d38658ee30453d5f27en, + r: 0x5d1304178102408230402d05054n }, { - a: "-657c587f67a70177797befb96f116c2843", - b: "-c3b8e2", - r: "-657c587f67a70177797befb96f11efb8e4" + a: 0x1e3eea4668e7a6c3bfa87d3f7a419bd18an, + b: -0x592d83940f884f9n, + r: 0x1e3eea4668e7a6c3bfa86d274201035102n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a & b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a & d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: &"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/as-int-n.js b/deps/v8/test/mjsunit/harmony/bigint/as-int-n.js index faa7dba866..51b5073d24 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/as-int-n.js +++ b/deps/v8/test/mjsunit/harmony/bigint/as-int-n.js @@ -284,9 +284,7 @@ assertEquals(4294967296n, BigInt.asUintN(2**32, 4294967296n)); assertEquals(4294967297n, BigInt.asUintN(2**32, 4294967297n)); }{ - assertEquals( - BigInt.parseInt("0x7234567812345678"), - BigInt.asUintN(63, BigInt.parseInt("0xf234567812345678"))); + assertEquals(0x7234567812345678n, BigInt.asUintN(63, 0xf234567812345678n)); }{ assertThrows(() => BigInt.asUintN(2n, 12n), TypeError); assertThrows(() => BigInt.asUintN(-1, 0n), RangeError); diff --git a/deps/v8/test/mjsunit/harmony/bigint/basics.js b/deps/v8/test/mjsunit/harmony/bigint/basics.js index 398d670ca8..99a9403db0 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/basics.js +++ b/deps/v8/test/mjsunit/harmony/bigint/basics.js @@ -197,6 +197,28 @@ const six = BigInt(6); // Multi-digit BigInts. // Test parseInt/toString round trip on a list of randomly generated // string representations of numbers in various bases. + + // Userland polyfill while we wait for BigInt.fromString (see: + // https://mathiasbynens.github.io/proposal-number-fromstring/ ). + // This intentionally only implements what the tests below need. + function ParseBigInt(str, radix) { + const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; + var result = 0n; + var base = BigInt(radix); + var index = 0; + var negative = false; + if (str[0] === "-") { + negative = true; + index++; + } + for (; index < str.length; index++) { + var digit = alphabet.indexOf(str[index]); + assertTrue(digit >= 0 && digit < radix); + result = result * base + BigInt(digit); + } + if (negative) result = -result; + return result; + } var positive = [0, 0, // Skip base 0 and 1. "1100110001100010110011110110010010001011100111100101111000111101100001000", "1001200022210010220101120212021002011002201122200002211102120120021011020", @@ -273,28 +295,12 @@ const six = BigInt(6); ]; for (var base = 2; base <= 36; base++) { var input = positive[base]; - assertEquals(input, BigInt.parseInt(input, base).toString(base)); + assertEquals(input, ParseBigInt(input, base).toString(base)); input = negative[base]; - assertEquals(input, BigInt.parseInt(input, base).toString(base)); + assertEquals(input, ParseBigInt(input, base).toString(base)); } } -// .parseInt -{ - assertEquals("hellobigint", BigInt.parseInt("hellobigint", 32).toString(32)); - assertEquals("abc", BigInt.parseInt("101010111100", 2).toString(16)); - // Detect "0x" prefix. - assertEquals("f00dcafe", BigInt.parseInt("0xf00dcafe").toString(16)); - // Default base is 10, trailing junk is skipped. - assertEquals("abc", BigInt.parseInt("2748junk").toString(16)); - // Objects are converted to string. - let obj = {toString: () => "0x12345"}; - assertEquals("12345", BigInt.parseInt(obj).toString(16)); - // Empty and invalid strings throw. - assertThrows("BigInt.parseInt('')", SyntaxError); - assertThrows("BigInt.parseInt('nope', 2)", SyntaxError); -} - // .valueOf { assertEquals(Object(zero).valueOf(), another_zero); diff --git a/deps/v8/test/mjsunit/harmony/bigint/comparisons.js b/deps/v8/test/mjsunit/harmony/bigint/comparisons.js index 513ff37d00..38150c74bf 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/comparisons.js +++ b/deps/v8/test/mjsunit/harmony/bigint/comparisons.js @@ -429,8 +429,8 @@ const six = BigInt(6); assertFalse(%Equal("-0x1", minus_one)); const unsafe = "9007199254740993"; // 2**53 + 1 - assertTrue(%GreaterThan(BigInt.parseInt(unsafe), unsafe)); - assertTrue(%LessThan(unsafe, BigInt.parseInt(unsafe))); + assertTrue(%GreaterThan(eval(unsafe + "n"), unsafe)); + assertTrue(%LessThan(unsafe, eval(unsafe + "n"))); assertThrows(() => %LessThan(six, Symbol(6)), TypeError); assertThrows(() => %LessThan(Symbol(6), six), TypeError); @@ -508,10 +508,10 @@ const six = BigInt(6); assertFalse("-0x1" <= minus_one); const unsafe = "9007199254740993"; // 2**53 + 1 - assertFalse(BigInt.parseInt(unsafe) < unsafe); - assertFalse(BigInt.parseInt(unsafe) <= unsafe); - assertTrue(unsafe < BigInt.parseInt(unsafe)); - assertTrue(unsafe <= BigInt.parseInt(unsafe)); + assertFalse(eval(unsafe + "n") < unsafe); + assertFalse(eval(unsafe + "n") <= unsafe); + assertTrue(unsafe < eval(unsafe + "n")); + assertTrue(unsafe <= eval(unsafe + "n")); assertThrows(() => six < Symbol(6), TypeError); assertThrows(() => six <= Symbol(6), TypeError); diff --git a/deps/v8/test/mjsunit/harmony/bigint/dataview.js b/deps/v8/test/mjsunit/harmony/bigint/dataview.js new file mode 100644 index 0000000000..c34a42ac1d --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/bigint/dataview.js @@ -0,0 +1,78 @@ +// 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-bigint + +var buffer = new ArrayBuffer(64); +var dataview = new DataView(buffer, 8, 24); +var bytes = new Uint8Array(buffer); + +var b1 = 0xff1234567890abcdefn; +var b1_64 = BigInt.asUintN(64, b1); + +dataview.setBigInt64(8, b1); +assertEquals(0x12, bytes[16]); +assertEquals(0x34, bytes[17]); +assertEquals(0x56, bytes[18]); +assertEquals(0x78, bytes[19]); +assertEquals(0x90, bytes[20]); +assertEquals(0xab, bytes[21]); +assertEquals(0xcd, bytes[22]); +assertEquals(0xef, bytes[23]); +assertEquals(b1_64, dataview.getBigInt64(8)); + +dataview.setBigInt64(8, b1, true); // Little-endian. +assertEquals(0xef, bytes[16]); +assertEquals(0xcd, bytes[17]); +assertEquals(0xab, bytes[18]); +assertEquals(0x90, bytes[19]); +assertEquals(0x78, bytes[20]); +assertEquals(0x56, bytes[21]); +assertEquals(0x34, bytes[22]); +assertEquals(0x12, bytes[23]); +assertEquals(b1_64, dataview.getBigInt64(8, true)); + +dataview.setBigUint64(8, b1); +assertEquals(0x12, bytes[16]); +assertEquals(0x34, bytes[17]); +assertEquals(0x56, bytes[18]); +assertEquals(0x78, bytes[19]); +assertEquals(0x90, bytes[20]); +assertEquals(0xab, bytes[21]); +assertEquals(0xcd, bytes[22]); +assertEquals(0xef, bytes[23]); +assertEquals(b1_64, dataview.getBigUint64(8)); + +dataview.setBigUint64(8, b1, true); // Little-endian. +assertEquals(0xef, bytes[16]); +assertEquals(0xcd, bytes[17]); +assertEquals(0xab, bytes[18]); +assertEquals(0x90, bytes[19]); +assertEquals(0x78, bytes[20]); +assertEquals(0x56, bytes[21]); +assertEquals(0x34, bytes[22]); +assertEquals(0x12, bytes[23]); +assertEquals(b1_64, dataview.getBigUint64(8, true)); + +var b2 = -0x76543210fedcba98n; +dataview.setBigInt64(8, b2, true); +assertEquals(0x68, bytes[16]); +assertEquals(0x45, bytes[17]); +assertEquals(0x23, bytes[18]); +assertEquals(0x01, bytes[19]); +assertEquals(0xef, bytes[20]); +assertEquals(0xcd, bytes[21]); +assertEquals(0xab, bytes[22]); +assertEquals(0x89, bytes[23]); +assertEquals(b2, dataview.getBigInt64(8, true)); +assertEquals(0x89abcdef01234568n, dataview.getBigUint64(8, true)); + +assertThrows(() => dataview.setBigInt64(0, 1), TypeError); +assertThrows(() => dataview.setBigUint64(0, 1), TypeError); +assertThrows(() => dataview.setInt32(0, 1n), TypeError); +assertThrows(() => dataview.setUint32(0, 1n), TypeError); + +// None of the stores wrote out of bounds. +for (var i = 0; i < 16; i++) assertEquals(0, bytes[i]); +for (var i = 24; i < 64; i++) assertEquals(0, bytes[i]); diff --git a/deps/v8/test/mjsunit/harmony/bigint/dec.js b/deps/v8/test/mjsunit/harmony/bigint/dec.js index 5e1f40b2dd..ddb0431cba 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/dec.js +++ b/deps/v8/test/mjsunit/harmony/bigint/dec.js @@ -7,74 +7,73 @@ // Flags: --harmony-bigint var data = [{ - a: "-609648ccf253976b12f6b6c8e20790c17ef6b89ea9f536267783607cf465b1ca", - r: "-609648ccf253976b12f6b6c8e20790c17ef6b89ea9f536267783607cf465b1cb" + a: 0x26ffcdbd233a53e7ca4612f2b02e1f2c1d885c3177e7n, + r: 0x26ffcdbd233a53e7ca4612f2b02e1f2c1d885c3177e6n }, { - a: "-6e4c39cdd2c666e32cf2fd3c53a20eeb725e7578af97d42", - r: "-6e4c39cdd2c666e32cf2fd3c53a20eeb725e7578af97d43" + a: 0xf2a29a35193377a223ef0d6d98db95eeb24a4165f288fd2b4an, + r: 0xf2a29a35193377a223ef0d6d98db95eeb24a4165f288fd2b49n }, { - a: "34c93e1c", - r: "34c93e1b" + a: 0x454d22e29e6104n, + r: 0x454d22e29e6103n }, { - a: "-db3032", - r: "-db3033" + a: -0xb00874640d30e6fce6bf79508378ed17e44dacb48a4200bce536cec462b3c2n, + r: -0xb00874640d30e6fce6bf79508378ed17e44dacb48a4200bce536cec462b3c3n }, { - a: "8e658ffacbefbdec5", - r: "8e658ffacbefbdec4" + a: 0x4c151a24d765249c2bab4a1915b24b80ae437417c5n, + r: 0x4c151a24d765249c2bab4a1915b24b80ae437417c4n }, { - a: "-d321033ec94d6a75f", - r: "-d321033ec94d6a760" + a: -0xcbd476b1f9ca08ff820941n, + r: -0xcbd476b1f9ca08ff820942n }, { - a: "-286017f718d6118b581ec4357e456ce6d12c01aed9a32ff0cc048d", - r: "-286017f718d6118b581ec4357e456ce6d12c01aed9a32ff0cc048e" + a: -0xe848e5830fa1035322b39c2cdd031109ca8n, + r: -0xe848e5830fa1035322b39c2cdd031109ca9n }, { - a: "c0", - r: "bf" + a: -0x4d58c5e190f0ebac5bb36ca4d214069f69726c63a5n, + r: -0x4d58c5e190f0ebac5bb36ca4d214069f69726c63a6n }, { - a: "9f9577e008a6f46f7709f71362176ebe23d19eb9e58a41de6f2631b18f2ca", - r: "9f9577e008a6f46f7709f71362176ebe23d19eb9e58a41de6f2631b18f2c9" + a: 0x9b396n, + r: 0x9b395n }, { - a: "-9d4294590df0aa8ea46a5c2a3d186a6afcc00c6ebb072752", - r: "-9d4294590df0aa8ea46a5c2a3d186a6afcc00c6ebb072753" + a: 0x593921fe8b9d4906cn, + r: 0x593921fe8b9d4906bn }, { - a: "-4bc2aed1641151db908c0eb21aa46d8b406803dc0f71d66671322d59babf10c2", - r: "-4bc2aed1641151db908c0eb21aa46d8b406803dc0f71d66671322d59babf10c3" + a: -0xe127928c7cecd6e9ca94d98e858f9c76a0fccac62203aac7710cef1f9e352n, + r: -0xe127928c7cecd6e9ca94d98e858f9c76a0fccac62203aac7710cef1f9e353n }, { - a: "-1dfb3929632fbba39f60cabdc27", - r: "-1dfb3929632fbba39f60cabdc28" + a: 0xeb14cd952d06eb6fc613016f73b7339cbdd010n, + r: 0xeb14cd952d06eb6fc613016f73b7339cbdd00fn }, { - a: "c0d409943c093aec43ba99a33ef2bb54574ecdc7cccf6547ab44eafb27", - r: "c0d409943c093aec43ba99a33ef2bb54574ecdc7cccf6547ab44eafb26" + a: -0xfdeab6a3dbd603137f680413fecc9e1c80n, + r: -0xfdeab6a3dbd603137f680413fecc9e1c81n }, { - a: "3d148dcffe94f859c80b38c4", - r: "3d148dcffe94f859c80b38c3" + a: -0x7e9abbdfad170df2129dae8e15088a02b9ba99276a351a05n, + r: -0x7e9abbdfad170df2129dae8e15088a02b9ba99276a351a06n }, { - a: "0", - r: "-1" + a: 0x7b98f57n, + r: 0x7b98f56n }, { - a: "d659f6507e0ac2e653bdb7c3fb38c1514dd33619a9a0c87fcb69b22", - r: "d659f6507e0ac2e653bdb7c3fb38c1514dd33619a9a0c87fcb69b21" + a: -0x919751deb470faa60d7c5c995c8bed72f9542d710fbbf1341n, + r: -0x919751deb470faa60d7c5c995c8bed72f9542d710fbbf1342n }, { - a: "14efe", - r: "14efd" + a: -0xc5541d89b118a88afdd187228440427c8a24f9d9bn, + r: -0xc5541d89b118a88afdd187228440427c8a24f9d9cn }, { - a: "-f2df301948cd17ff391a6589a67551c00679687ba5", - r: "-f2df301948cd17ff391a6589a67551c00679687ba6" + a: -0xe6c88a170595fn, + r: -0xe6c88a1705960n }, { - a: "-e", - r: "-f" + a: -0xa1ffbfa388c332804dc4dc973n, + r: -0xa1ffbfa388c332804dc4dc974n }, { - a: "-a09cf77fea7af1767695c978af13fdb62f4f040b6fb803625fb124cc99139cddadd", - r: "-a09cf77fea7af1767695c978af13fdb62f4f040b6fb803625fb124cc99139cddade" + a: 0x67b768ce0c415127a77402861d1901dd7f60a8624ebea6ecafe03adc3cen, + r: 0x67b768ce0c415127a77402861d1901dd7f60a8624ebea6ecafe03adc3cdn }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var r = --a; - if (d.r !== r.toString(16)) { - print("Input: " + a.toString(16)); + var r = --d.a; + if (d.r !== r) { + print("Input: " + d.a.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); error_count++; diff --git a/deps/v8/test/mjsunit/harmony/bigint/div.js b/deps/v8/test/mjsunit/harmony/bigint/div.js index 771a0c7fda..1eeea1184f 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/div.js +++ b/deps/v8/test/mjsunit/harmony/bigint/div.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "c0bb18527ab19a800932cc14c553c69688372809dde38f095fdb99478a7eba", - b: "8137ebc482f361a3e43fb80fe2ba509caa3f0acc62be0d2", - r: "17dd3b8ecbdd71a4" + a: -0x1e0f357314bac34227333c0c2086430dae88cb538f161174888591n, + b: 0x390n, + r: -0x8700f00dd65d4009ab90c5d3a887e9c8ad110a72ca7e0f84a40n }, { - a: "10c5163e874c786fcfcb48bbb0ccf8d6c66f480b76332194", - b: "4e462b2", - r: "36d8ca96869a7226d456bff9b5ed3effdcaaf6f83" + a: 0x9b7a0098fd2d495b4b2c76ff5888ae2a0359cfec6b029e6f3ee9b014802n, + b: 0xbn, + r: 0xe225d252e49ef6563ecc4fff0c69b782ed99e89db2ec895bfe6b2ea974n }, { - a: "-677f8c8668fcc826129f2724a5b88a6225dd19959810b5254afbc0", - b: "-2bf8ff1c49636", - r: "25a8bd406d721554f45ad37cc691d58821ad163f3a" + a: 0x6821a6dad136b9f64096337b45d6d947cf0f0b55501e33e66fbc4ef9776n, + b: 0xan, + r: 0xa69c3e2ae8578ff06756b8c53c8af53fb1b1abbbb363863d7f93b18f25n }, { - a: "e80276ba7d416f4f7e5f8917529eb204cc7ed08413261e73aa23f169eb46e7162", - b: "-c884f07a", - r: "-12834073e7cbc44804a99cb2778fb82b098645946d5e4f5e6c47c49267" + a: 0xf42f96f0c7f5a9c656a66122a9bcc57aa386bdb9a834e4174d45795ae408dae14e085cn, + b: -0x5e0d81a1107ef9a38b4f24b4n, + r: -0x298a4d479eac8c186fd61939024b420080b6ae6500c70c1n }, { - a: "-f9a51f64ce995e0a1c7f8369a573dae2533bc3df801edbb79235d41502e1ce", - b: "-f33bf", - r: "106bf522569501704f9700d6bfcd203a606e63725e339e92ff931f568f" + a: 0xbaf7baed984dda3c20f23201f366257c601f7fbcaf51d8b738a68fd92b4n, + b: 0xd24a1eafcn, + r: 0xe39bd4d870d72880e6ad88ec17bcca6bd0eaacfbbd28ba7458n }, { - a: "-6c9ae08dfa5b11c29ae30e53c108d915e0e87f1a8ca82f42d23a53b08895", - b: "-43fd79afe1ae6a4994ee7dfc2c89453d6b6", - r: "198ecd667e8cca17c2839b38fe" + a: -0xa658d0683d450bfec3de3fe4253f4348dd8e9a5b1002f6c24ff0en, + b: -0xeffb9a6fa690e0be59aba488b7a7c5a85a65a018242n, + r: 0xb1730d7206n }, { - a: "-d20a2f7074ecbc776b64c2e04ff007e194b8cdd106b2be2e78d752f2d16e9", - b: "43eb8ae7d7f9be6d77e3be696ffef", - r: "-317ab1a09014950e1c53b9e3e8f44873c" + a: 0x5a65f7b2dace4550099f4009192caa513468ef4da7e2fd81n, + b: 0xf144f8bfad42d9beaf7b82a46561n, + r: 0x5feae36e8e4932adcb21n }, { - a: "-999e0f75f2f652d403840cea3536b1a522433a331dace7c39d7990b993908fdd6", - b: "cea1de74020232c6c4bedca49d63f140c", - r: "-be51ac62c073e7d7cb9e43fc12436bfe" + a: -0x87271b0cbb63eba5e3d70f6af1aa6ec60c0a7884fb8d657b03en, + b: -0xb67f8c18099ce8fa0c0f4ce2852b5590f7a8037d326b0n, + r: 0xbd9602n }, { - a: "1b49ac0c323436294f1471a3f00feb197b9b42549c3", - b: "5a7e30888a22fbbcecfe2a0b2e5eca30", - r: "4d321e8fe1c" + a: 0xd4bc42a434dba1427d387f0858aaf39c6281ffc0f10b8b0996cb3bfn, + b: -0x4198d1fec9b48e38d42f2e295abc39c2a6866527efn, + r: -0x33e39b6878d955n }, { - a: "-689adf0d332ed26c63f8f361d5cb66056321b683ce87c60567df7305396f20d6ab8", - b: "82f3b92f5bb57811fdb66f519", - r: "-cc7e64b9ef239ac4c31b6ae3687aa181bda7657222" + a: 0x6a6f0c97d974dfd20337ca611dbdc96433964a206d54n, + b: 0x16c7c6f9e0e4e24d521e463fecb394e2936f3104590n, + r: 0x4an }, { - a: "-6fecb457f9e05c15b7fe038494c25053938d4747a01577cf2dc939a21e", - b: "b7cb6ce62c1d7483d0b675109f5782a1ad19", - r: "-9be52d2e94716bb441dbcd" + a: -0xd09af7515272d81a64307afaed8854c8e2996d8e01d4864n, + b: 0x7521dfcbdf4cfbbf8d3859bf67618c91dc6915718303dbn, + r: -0x1cn }, { - a: "f96f8276f314d37657ce7774bc539198ee84fcec8a53cbb3d36ad81040b715", - b: "-891c9a0dd99b02", - r: "-1d1b803e3484173c0d2e8add5042117eaa27c853c222f5fdd" + a: 0xf0da5f24832a2b651aac5dff62b22475212c26e123ff78c34560f35e9bcn, + b: -0xf9n, + r: -0xf79fbd51bf65f518c82563b974e4632b505ebe13adbfb6c297859a98cn }, { - a: "-d2c9a9068d57f2ebc9ad432b48b4135f2a911519d4b791", - b: "-a34d124b5b4825d314683098d0", - r: "14a715b96671307438926" + a: 0x76f4f5b5de8a263514554d62273e51f40342d5df692ae17625ead5b5fen, + b: -0xa5e697c57fb65858604e0a060737e7d9d1en, + r: -0xb78fb2167de210959e57cd3n }, { - a: "-59593d55f61c1c739601e15624fe2e61592fe6abf1ecb238c9f8e1a7bded9c1bd1c", - b: "f067a5a155fc894b0f7f0a939f1772c4d135a", - r: "-5f250867331e7eff64dafcd58e9922" + a: -0xa714d4d9d747fa5258f80f3887f4dda8a11423050046282n, + b: -0xaa3b218ab92e21920a707487fdbn, + r: 0xfb437487ba8580181ca3n }, { - a: "2c0a3172494623013ba14d01433ad38167f365765b1c0ca610", - b: "ffe8", - r: "2c0e52ca0c37483000215020c64d6ac36a455bf6fa4382" + a: -0x165f3c659ac4157cb3af081b3fc42c0c788e2df501596c2b8n, + b: -0xfaa86d6eca3n, + r: 0x16d94bce4865cf842d17a399d8b4467f3f369fn }, { - a: "-a9cde7cdfe56eb8bd6777543ae714fadac2d97a394d8e9e8", - b: "104b0d7135d3d2", - r: "-a6bfb9031e60b5bc4b20e814cabfd80bd27" + a: 0x268d93a21aab44c52f961b1c97c002f427eb8b11e0707e3879c3a348f8e2b1c40c122n, + b: 0x70ccda2e2bba53b124c877bb4edbdbd387742cfe59d9bn, + r: 0x577effaeb2338647e38edb43n }, { - a: "6216ceed0d221476bfba7701f8297af56a4e66d003f8165b", - b: "bfcaaf8676ad6a", - r: "82ed6efc83669b0bc476bdd717dcfb6f10" + a: 0x3a13493c9e8d3d986a2a56c0aa811be408e1560f30ae155n, + b: -0x62a1a35fd7e184be45a1d0ba67888f0d982afb7a90an, + r: -0x96bcn }, { - a: "-707752a899efbe8989d205293535a404a6afb39cf21ce1274", - b: "-3a24848be1024a6ea901f", - r: "1ef2f2a8c0ad85ff4e6e6afdd3966" + a: -0x2a3f3f90ea280bf64e7e460f004ea4fb2553637cb7c844f349f045ffdbn, + b: -0xf2af2581bddfd9bfc1158c86211c4f4b169c0b1n, + r: 0x2c90ab8577b8d0ee86en }, { - a: "-e662fb8c46f979ff3b3f576fffd5c51cf70071ab61168b2eafee4708af", - b: "964c4dd019b9a543df0cd1830a90428ec84ec04f8165283", - r: "-18869d87ce54" + a: 0x8fd5f992d4d767c8a360ad32142fa9e9d87bc0036d1d6bb7aa7471dd7f38bn, + b: 0xe70n, + r: 0x9f6709805e05fd8b3c433e470387f06391b6948459e4c2bc072747e2a0n }, { - a: "b4403dee3a192009a5aae85c74efdb52b66dee1be6befa66f708ca9bf6b7", - b: "-36db9f9f6e", - r: "-34928ce65c2b71a6b6ce351838d4263d91ff2bceecec7a91441" + a: 0x52c0e08ba0a22a00498058dfeeaab2b21909e81e30c48652699n, + b: 0x1d516c96827an, + r: 0x2d2967f58654a5d30934348b225bf2b6e2a3123dn }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a / b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a / d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: /"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/inc.js b/deps/v8/test/mjsunit/harmony/bigint/inc.js index 64865a2b32..4ead89e1bf 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/inc.js +++ b/deps/v8/test/mjsunit/harmony/bigint/inc.js @@ -7,74 +7,73 @@ // Flags: --harmony-bigint var data = [{ - a: "-989c298c6fc3", - r: "-989c298c6fc2" + a: 0xb3df90n, + r: 0xb3df91n }, { - a: "bff2c86c449a56", - r: "bff2c86c449a57" + a: 0xaacd53fc9545eb394304a3c69caba730230a6527730an, + r: 0xaacd53fc9545eb394304a3c69caba730230a6527730bn }, { - a: "-6fb15264369b63e3b92d6f74458140d4b62a56ecbfca000492b6b8a0c56c651ebaecdd1", - r: "-6fb15264369b63e3b92d6f74458140d4b62a56ecbfca000492b6b8a0c56c651ebaecdd0" + a: 0x32efa4ba1c29098be7df8fa0f3c74a183612ecn, + r: 0x32efa4ba1c29098be7df8fa0f3c74a183612edn }, { - a: "e161f6284b91fa2646dc0f162c575bb8a0d0f5bfee26748b7181413567", - r: "e161f6284b91fa2646dc0f162c575bb8a0d0f5bfee26748b7181413568" + a: -0xcabed06f63ad50406b96187208cf9ec6faf46413ce83e280c31ben, + r: -0xcabed06f63ad50406b96187208cf9ec6faf46413ce83e280c31bdn }, { - a: "-4d073653cc812", - r: "-4d073653cc811" + a: -0x8a40ce58f753466f4008faa0814e76d9b594908df0e42cf6ad4a781e60ce2n, + r: -0x8a40ce58f753466f4008faa0814e76d9b594908df0e42cf6ad4a781e60ce1n }, { - a: "-ce31549364717dea9d1bf30baed642f", - r: "-ce31549364717dea9d1bf30baed642e" + a: -0x848c8fc23bc93801n, + r: -0x848c8fc23bc93800n }, { - a: "2ae123a62361f1de2cc5ca9cfd9658f47d", - r: "2ae123a62361f1de2cc5ca9cfd9658f47e" + a: -0x13a8316c5af3f3b06aab6642e717a7bdn, + r: -0x13a8316c5af3f3b06aab6642e717a7bcn }, { - a: "-4820298153b7bbd86337ad72e0d1ac7448de99bc6ce4c43c2", - r: "-4820298153b7bbd86337ad72e0d1ac7448de99bc6ce4c43c1" + a: -0x5f5e517cf7efe577cd689c36d1beb3d9df4cfdc3fcb55ed9e9d8fan, + r: -0x5f5e517cf7efe577cd689c36d1beb3d9df4cfdc3fcb55ed9e9d8f9n }, { - a: "2e", - r: "2f" + a: 0n, + r: 0x1n }, { - a: "-8f3b598ac2ab8a78a2d3e1f7ab1124b05a830aa1261bf57d8de2a", - r: "-8f3b598ac2ab8a78a2d3e1f7ab1124b05a830aa1261bf57d8de29" + a: 0x107d5ec8048c4d715e213ec74f9f04006d3f2d90dd95d17c3e82f7a4ccn, + r: 0x107d5ec8048c4d715e213ec74f9f04006d3f2d90dd95d17c3e82f7a4cdn }, { - a: "-5c070fdee0d3f4a9adc63", - r: "-5c070fdee0d3f4a9adc62" + a: 0xb8e09fc6037a75bbfn, + r: 0xb8e09fc6037a75bc0n }, { - a: "-3700cd6a6d1e68de1", - r: "-3700cd6a6d1e68de0" + a: 0x515d1b999660074184n, + r: 0x515d1b999660074185n }, { - a: "56c68c", - r: "56c68d" + a: 0xe12def67dc33628638612b8137d0fa425ea2dn, + r: 0xe12def67dc33628638612b8137d0fa425ea2en }, { - a: "-1ab894376fcf0dab9c", - r: "-1ab894376fcf0dab9b" + a: 0x96a9n, + r: 0x96aan }, { - a: "-937dcf37c57588e55260c3eea20318", - r: "-937dcf37c57588e55260c3eea20317" + a: -0x9df122a299a5e65b275028n, + r: -0x9df122a299a5e65b275027n }, { - a: "-f8ee63b438580a8915baf84edcfd0688247905e593e153644a88761bab0", - r: "-f8ee63b438580a8915baf84edcfd0688247905e593e153644a88761baaf" + a: 0x20dd05bfb5ed6ebfb05da9a7488800b8895fbfe6d709eecb6071cda73e13n, + r: 0x20dd05bfb5ed6ebfb05da9a7488800b8895fbfe6d709eecb6071cda73e14n }, { - a: "-c63d4353ddf575bf02", - r: "-c63d4353ddf575bf01" + a: 0xb38294d2e5523534c56dd6ef38ba744b29e3a3bb6f863f1aeaen, + r: 0xb38294d2e5523534c56dd6ef38ba744b29e3a3bb6f863f1aeafn }, { - a: "-bef439cc990a8b1d69b80fa7b3c703ba2", - r: "-bef439cc990a8b1d69b80fa7b3c703ba1" + a: -0x6b58de4ba9b2699ea6777dc1adc0b2486n, + r: -0x6b58de4ba9b2699ea6777dc1adc0b2485n }, { - a: "6007edbd20b0ba90d86cf80e871e898c8907bb37", - r: "6007edbd20b0ba90d86cf80e871e898c8907bb38" + a: 0xf40028a48894df5d81131046477a22e55cbead5n, + r: 0xf40028a48894df5d81131046477a22e55cbead6n }, { - a: "-692b36b5e874a448415678ac2b4d0a61c75bdc1674ae14d753cad7d46846", - r: "-692b36b5e874a448415678ac2b4d0a61c75bdc1674ae14d753cad7d46845" + a: -0x44cbe6c7f5e7e879d3cb2eaffc4af0a43affc094218031a1f123746549dd7b8cdcbdn, + r: -0x44cbe6c7f5e7e879d3cb2eaffc4af0a43affc094218031a1f123746549dd7b8cdcbcn }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var r = ++a; - if (d.r !== r.toString(16)) { - print("Input: " + a.toString(16)); + var r = ++d.a; + if (d.r !== r) { + print("Input: " + d.a.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); error_count++; diff --git a/deps/v8/test/mjsunit/harmony/bigint/mod.js b/deps/v8/test/mjsunit/harmony/bigint/mod.js index c310e2d3b4..c8cc7fa4fd 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/mod.js +++ b/deps/v8/test/mjsunit/harmony/bigint/mod.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "-67c2a5ba4221c048b64ecca6dd979391c44296b8b87ce97584ebab03be18", - b: "-bebdbd9b278d05704416fd87d09aece9b69f98843", - r: "-8794ba5d9204eb8adfb5e44c11a65fe5af057e6a4" + a: 0xaed3c714bb42a73d708bcf1dc9a9deebadc913ef42bac6a6178a60n, + b: -0xf3d6bd1c059b79n, + r: 0x2a4f893c8ece3n }, { - a: "-843cfbe576106b8e7c0aabec2cde402e7f76a711dbbf6ae79d6d932e22cf", - b: "553d800ffcf69f80026", - r: "-272250d344908c21525" + a: -0x8a6d8cb8e32aba50e08fd50aecbda6821e1863bf9a2n, + b: 0xe19ab8530bce542ec6b4c848fc383a2b688f07976dd523dabn, + r: -0x8a6d8cb8e32aba50e08fd50aecbda6821e1863bf9a2n }, { - a: "-b5fc9e8e21fbad798bcd3571ab169dd5e2059d1a9aa4d1bf44fe18da725b", - b: "-da5d287414fbb2b4b", - r: "-2610eb2277e01a758" + a: 0x7cd19a308b217ddd9dcda69ebe37767f09a483cb87060314aeade6f6c619d27c3n, + b: 0xae30b5c754e0an, + r: 0x619154797565dn }, { - a: "a9c92d42b53a6fbf0824f5b7bd9ed1cab1f9419d7ec2b50f192abfa6d620d53", - b: "9de30592e1fe27d26afe06bbb4781c77ef58418", - r: "9a67af5868a619a48883aed4c0d0a876e2ce143" + a: -0xaa90d777e849974d7ebebd2ed76dce635e36713e9e0c97cen, + b: 0xcc2bc7239bf83ecafc74b25750981df258n, + r: -0xa32d47bc250c5a41d147a862099778685en }, { - a: "ffa271b138163a779c89f17aa720490854520120b1307ef", - b: "ab27ef49f3a00085981a5bc1c13530aec35e29c", - r: "4c49a63b98d2dd7a33a843f98ba82b54909e337" + a: 0x7386178fe1159c4ca3c4e5caa6eda4413926047efd22007931c22ab54bn, + b: 0xc05100caa704bca144n, + r: 0x55ead7f83d4a795753n }, { - a: "d43f739464bcc8643dfaa807cbbe1157189e33368dd19b800db3682bb0dcb73", - b: "bf66b1dc93054920039f9b3eba688d9", - r: "bb2f3000959d66b3962d755d141c3ac" + a: -0xa48867cf46692351a59bc89c0ddc9a6d2cd9f72578c0bab72d8389n, + b: 0x77c2eec6cc0bef33dd4756b223c35a0f2b528f8648a7n, + r: -0x184a6eed8fcd32399c59605c7255b5614b388be24b44n }, { - a: "111ae5ba62ec37fd157ef531195363c5c8ace4427ff58811746af94ab8", - b: "58112d0d88f3c8722d1e28942e8949c433c4619b451", - r: "283276aa2b6316ca2146b1e6bcc8aa8de4b5446847a" + a: 0xac7681c26f78191107c9cde47f984fc7ffb7bffd0a055fc14n, + b: -0xe2d91d1a0e1edc3f806a24c36f7ca0a8a9b44b66c9n, + r: 0xdf0b3460335089fca0b1da676b3d1e9caf15afd3den }, { - a: "-4609a1c7d563bbdb49fd01e05031395e6e06b78407e440", - b: "-75ee71f85344163bae2ba0e438", - r: "-68b517938971cb261babea1cf8" + a: -0x3035011f4adba0c032ddc2fc884ff7663b45cb3baebec0fn, + b: 0xcc27f9a21470911a61aae50ae118ebcf85ea4dn, + r: -0xc5ea1db5af95ccdce2844b13b82659be1ac2adn }, { - a: "292cd2c5eb3e80942066c5af8bfdaf8d1d091f61f3005d226318", - b: "5", - r: "3" + a: -0x2dbe79c42b1e8db7aea4ca9cfaf1350528b096e23f69ea322cn, + b: -0x82f7e4f2ee432485n, + r: -0x824bddbaf61ce383n }, { - a: "-a9f8c03f06200b54959a2ced325090be25417f0bf1274d", - b: "13eb3a0c772fc98e537883a3ef72e1ee37b249ee17c0510", - r: "-a9f8c03f06200b54959a2ced325090be25417f0bf1274d" + a: 0xc5c7fbeb60fdb9f8e8347ebf9fe303e3223394b2db93ce2n, + b: 0xcd988b4cb278a39fd3ae58c16616855f01fab0fb0n, + r: 0xc3b5157e680c8ca66df1bd640c6ad1601bd612b02n }, { - a: "c4ddadae9abee150068fe6536c6b2fe229070410da61a09abe1a7270b", - b: "5f4d55e3345e37fe8887f3ca5e", - r: "42eea65dd545aacdcd250b505b" + a: 0x73dd1e27450edb450fe4bd70494a8ad85a8ad9691bc40bf500a1n, + b: 0xc8fb467f71be8a6b965d21857ecfdn, + r: 0x646e6d9fa1e2eb2933b2e5a837d37n }, { - a: "-7a73d61e639dacedd207dfe1edc630b1dfda9078489a7f0cf79dcdfcbf3992efc13861f", - b: "-c0f2b9045bb3865d89cc0c9920c3ccfae382c250", - r: "-6bdc3d5943d7a35e4ecbc5c8deb335ca2c3bbc0f" + a: -0xecb217583ec4240399bfa34560b45f1fd08efd0ebb56b2dn, + b: 0xeba34abn, + r: -0xc2d347bn }, { - a: "-a9ac4a2e055f22c8ba7956ffca5457a71412eb74d3a180555bb25ce5096e23d6c619", - b: "-f3c", - r: "-a5d" + a: 0x29c8a9854802b9317b90683eb82609b3aa695598807fea0482a56567n, + b: -0xabe5e55b228f8n, + r: 0x52303615b525fn }, { - a: "-b16cfd7fbbf820afc77be1590fd9802ecd12059238b98bb96d9d215af4808", - b: "2c288a9de167", - r: "-2b3901c1b8d1" + a: 0x7b532ee90b3945dbed20180632f46c90d0edb558e39456103f50e5a74ff1dn, + b: 0x17n, + r: 0x6n }, { - a: "-df12dd3e56dc3c3dd769ad964f8356a5860177f1b4a3b95acc75", - b: "4ec6f5474b18", - r: "-17bf0980582d" + a: -0x6f1dbf8dedea796a2423fad9688d71340963da3a4f005f13e9cd4aa03b96c864552cn, + b: -0x408a4f36ec4a1b74642fb0a4559en, + r: -0x33c06c53e6e47ca87f36447f1b0n }, { - a: "1d197bf4aa09a02760cb004e9edf25e6591ae14d92b6cbf1349ea1c040d66", - b: "-23ebacc5f380e5649a1234c3ed050472569cbcd056", - r: "20e5e588b4861be3ec7b4005a6a50566e60a3a4364" + a: -0xe77508ff49bc76c78678676ca1edc82eb167f3b07d3208d89d26582ef74d60n, + b: -0xf005fb1a8b29035c72980abe4a0715c90n, + r: -0x159e8c7616079663b4e12765a05cc6d40n }, { - a: "fab19b7e774bf33bb42a7af90d8dc75cbc927e3225003610c05b117c25c90944d", - b: "-3b433469282a54d46cac", - r: "10eda9e98b721b4a2505" + a: 0x626749ef019017f53b2c686f26594e6d3c5f247cf0ed7024cca277n, + b: 0x5bd931ea8c6939115ad69f6ce3c6bbc300320n, + r: 0x3a4b041c36d0a45ef932745eab473943b1a97n }, { - a: "5b19514660782d3a2429d7791659868abb9d8fc96077247", - b: "-59188be60", - r: "2340c3607" + a: -0x960dde134b881d3366d659c7d8c3eb6346f50c08c6f78en, + b: -0xc9e7fa60f6ce1997012f5a6164138447fa248754985905dc6n, + r: -0x960dde134b881d3366d659c7d8c3eb6346f50c08c6f78en }, { - a: "-2884ed1401b5e976be7dc1faf7bffb632c808649fa75ab458cc66ef4e75", - b: "bf", - r: "-40" + a: 0x702dc0033e09e9e58ec3fc96f861587ad13cea1ed7b7eb301n, + b: 0x71f0c97687b4f3318be2fe54b90273n, + r: 0x4e1859254ac1d42f7c812decef00a3n }, { - a: "-4c9cdf26be1797e54480ab20797e35d04941c11ff78b040c00099422cec", - b: "ee20f34835529f4a73", - r: "-e24db40426d47f968b" + a: 0x39376649769a0abb26133deee934330ef21a2f90ea89476569630021af6023235n, + b: -0x4aaaec4085f65ccc9d547beb122160afcbb3n, + r: 0x3027d5ebb37c5aa438f11dfcafa3b003b91bn }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a % b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a % d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: %"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/mul.js b/deps/v8/test/mjsunit/harmony/bigint/mul.js index 83a6700768..c6a9ae6148 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/mul.js +++ b/deps/v8/test/mjsunit/harmony/bigint/mul.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "-be5e349bf5ad48e7a5d", - b: "a47a19a48667620a82973579739e08c64651b3ede2c578ff975e", - r: "-7a4f25aa8725368922062fc91a110352a660657ffb3a489126ded10ccd29d929120c926" + a: 0x2bf1f236c2df29f7c99be052dfe1b69ae158d777fea487af889f6259f472c0n, + b: -0xae0090dfn, + r: -0x1dde8b7f987479d7b308e2b8a122703d417f921fd4ab04fcac81439ace4f445c7bf540n }, { - a: "912d5d85aec5ec6caf90514f0ec005f711caac82960c0ee911ef30f145107ae236783e6", - b: "0", - r: "0" + a: -0x71cd629b6682b5b1c50f9436ded88468bcn, + b: -0xb24ce1d11726048158fb42c02e9361973193n, + r: 0x4f42fbebca0bc1746d114996d9c9cceb4065c347da31dc0efa88db41f1f724aef81ff4n }, { - a: "-87c17f6930bdef7e7c7ae7dab8be3baa2e7d67", - b: "285af6503c42d077a0d59558deb170bad", - r: "-1566788db7747e33ddb6540190617b57856e5f3924447f9f400f34a9aa75aa7d20f2b9b" + a: 0xef7c15fb2256338bd0650fa51c28551108ccb9828850f1b415d0c8f1a47fc0e2f86n, + b: 0xc17n, + r: 0xb4f552dbf2c20292f5475d025276b9c70f16316c91e0a9a2833bf2d616bc484f808d0an }, { - a: "-3d0fd72abc5fb82d5cf45679812b71", - b: "-3c537c742e17c5fac136e33f5e7edf256ef52b6df", - r: "e63a0402966391e13e600371183f223379b66912ee706a2b369668b3e33e9a15992d6f" + a: 0xcc8a5a56c623d9f9be2103bc237976f26n, + b: 0x13a02fec7cfd49c5a081c06bbbaac5c70dc3an, + r: 0xfae417740ef1963ad78aa4252159d986593845690f4f5fe759f6d913d79810473d69cn }, { - a: "dfd77cf4b0d071df2487c9b77959ee027380a159b0", - b: "-56300fb05cba28d5150892ff66e77", - r: "-4b5c6a1976d3a318cb9f93e154dc362da4e740fa31d82baefead60c355bfea99eaa50d0" + a: -0x519n, + b: 0x7de5551df3ec2619a89139153663a79f8bdb47047423c8070d7cfddc26d43af8ee9n, + r: -0x281c60ee5b06ece38cc4c4bfd2242017c4ff0cd05b40a66abf3c22a1741efe09ef81c1n }, { - a: "-bea52261387bb2aaf8c61b5ee7bbf85b3bbbedfe60773ed9873cbceba078d3fecbb", - b: "-2ad7", - r: "1fe73453d2eabb331a676ede8eb9759c8c6bffe09c76947578e08b0152379841d867f0d" + a: 0x6fb9ba0d0n, + b: -0x86b45ffb80fbf2b61abc14b28855780f83e187fd6ae26e09d28d6f05260e1n, + r: -0x3ac9efdd4e930fcbf654819060b858f182f7768db6bc72deb8d734d2ea10fa02b656d0n }, { - a: "5b5a3a047d8f7e1519d6d92d3241c0f32c4d789", - b: "-4bd3e8c09b0ba71bc25416877a4c7135", - r: "-1b0f0d6ba20fe60049c4a172e8b1fb9824c1e85e21f1ebe08556b7074d8d4f4ac90185d" + a: -0xde2e7a0883a63d69d2120108f92943e4a34b63e8468c12b38a0519a6498n, + b: -0xb1857781fefn, + r: 0x9a11f83db6da31f78a2415d3891f79a0f6aafc69553fb458a2bc3ae2e2f65cb09251e8n }, { - a: "1b2c8263d4bac8cc825657f81fca6196799aff00fa960d5c04", - b: "-6b140fca30c8037b18d88", - r: "-b5dbba6fba700592408e2ebbba2d4c6557d61d1201e24314f690e77c0b59c68d8b1620" + a: -0x2c90284ebdb5237ba7c9562f596ef9a21254a3n, + b: -0xb55feab8b45cc1bcdcfc5585c9114de0n, + r: 0x1f929eda8d33ec2ded8d76382a4cb731f805d28e827521a27154b6618a6f87ed5215a0n }, { - a: "dd74f1f92ab5b9e0b447b7fe9076f7", - b: "-9dbb0acb24e6336fe4f37f8e942d1d5c22dfe4f34", - r: "-88728628dd4ed79514e720448e4f9ad422ba6ca62cd61bf779cfb3cb12afb5bbe20632c" + a: 0x11ffe68d26ca29eac43b64n, + b: -0xe3311b278fec1fb3f8f59acfd9147c773197fc54c66b25bdn, + r: -0xff95d530fd53e61744d86d09f9ab5401b1efb2133af5c47ffeca31aca22a4da414cd4n }, { - a: "-e97d2712832aa20a", - b: "-cb98c0fa9b4b35fc7a4ebed6d3d106bb758c244eb756c75587300ad", - r: "b9b1904d502a19d20cc7bd8e05670f667db817bb9104ef8acc747f3df6541eede4d80c2" + a: 0xbda74de44eeb2995a4185325014863n, + b: 0xf99164c7248a0372d72d82cbf65fdb345c84bca6n, + r: 0xb8e3712f119fefa47168950100b33aa1ec4e61a970d0eec2d2dd4b925cc4dfd709a432n }, { - a: "828ca2d8981f347f4bec14ba", - b: "-8ce5b6b1c329477a0a728ed81331af1f03e3eaa1ccb2cb3", - r: "-47da0e06c179e58b3e5d8abc4a2b274ede3a7d73c0b5fcb3690f0b544ed6c0b7120760e" + a: 0x47fc0bb6d761e12a1f7cf2a14f4cc777486b22516ca339641fn, + b: -0xd2fa2494ae242494f307n, + r: -0x3b531808ad9095f9f904dba47ef4a0aef54f736cc2836accb7b1b70f07ee862e8729d9n }, { - a: "aade382f2483a571e12cb1796bd124e21c6014261cef5d733a1b35fb01db7232c5b", - b: "-d34a", - r: "-8d068c8b18b90f6aaf82ed3260f68bdb06bf64613cdda736fc33395b7d16688edb9d34e" + a: 0x91d09f35203fcf69974d347ab718912cn, + b: 0xfc2d9a00611e4e1767b67db898b951e5d2bbb9n, + r: 0x8fa3561bff2cc00a780a71e5b16d6092296514d401c88fc54e04a91062775cb4e40cccn }, { - a: "34188043594e64ac10b37923ad29b4b536a4098ce76c9133155820b7843de95af", - b: "106952", - r: "356f6c0aa4a1a0d27dd2e8867420eddcd9fb5614450d6bb85cba0071e03e4563a0b90e" + a: 0x5a5b1ede360dafcac08c92f4b809e401502df5ab8569303a2n, + b: -0xb64d963b1ac4eb46ddd65n, + r: -0x40582a6083cd0feb5b33ac138feaf9250b5084e561807e56a8415c810a1bf9861d48ean }, { - a: "96b2a125fc041fe36aebe7dfd02a4f56b90", - b: "-a9f9c57a732002abf0764868f297442f61d1", - r: "-640ef4605c38f6643d60526833e7a3b7b71a72b7042434abc0ca600e7f79b3aa98e6090" + a: 0xf68275dc25d6af7dde130n, + b: 0xfe330b766e44f479e342e3315812e977d4d5e39bffe42111dn, + r: 0xf4c697f78dc7c9b3207b50cf2cf3035aa065e96c37c0be3345f71f34096f057e76b270n }, { - a: "-ae8327a77a340d2c90c93bb0ebe02d7a77d7c2a4e8d21a21d0", - b: "268a49068f2769f949d95", - r: "-1a45bc5e1b636b28bf716dfeaf0599cd932270796233adf7d58b8d72d06ac580c323e10" + a: 0x77009ed053f71n, + b: -0x647aecfc2af4079a586fbba99070c3f51d5465d9a4fd8c12cdab10854n, + r: -0x2eb5627edb1072a65a1db2d243d0bf2eeb5c3ff6ad61ec1063e9ee40b783bd06d55914n }, { - a: "-a0adcb953540a4f25fc97a40a2c9285bfba7e70e4ffc", - b: "fff2302a069e8f69d00e529a81b", - r: "-a0a5204f09eeb3ecd9fe2c6de34d0e0ed70c6d1589d95fd83de33d921a3152dfe5bcf94" + a: 0xccfa15bb6125b01bece5a919ab5e9128e784d63e50b5990ba8047a7effn, + b: 0x1a366ac48cdan, + r: 0x14fcf8728aa3dc5ef26b077dfc012d592c3a0cdfc3331942f921f037eea5af9eff9926n }, { - a: "-83771467194c5b612539be7228f366a8", - b: "9412ce8f98510486287bc15c35883fff04d126e", - r: "-4c0a803e9a079742969e01dbb7990566b2f5ac9658653c967b5d295f6a996ba1655ec30" + a: 0x4fc54a59f2n, + b: -0x93bbcbd684987407c4ec4a3cbdc7c4821c33ca20ca8449b0055905e9a8ffn, + r: -0x2e08ce533fdc7bb8a3a2280cfb116c85837b74606ed25f8daad623baa4ac7de758680en }, { - a: "12c3327d3d7ed4b3180cc301f98d351804451be431137fa48aa67627db867a2cd", - b: "-ee0af6", - r: "-11724697fa94a9caafbee6e7b778ecae17ed7ebba5575296b1fc4995a12fe5c9a8872fe" + a: -0xcf21626f318089a85738f7e9cdcf0a477f4d880ce58679n, + b: -0xc7ca8704a49fdb8f9567c68cn, + r: 0xa1a6d11a77d8e1b723bfa0242407a454274145c31bb6ede29bb0e3883b08951b36202cn }, { - a: "-5", - b: "-a00c8e774e3d4a6fc2fa384382720700e49e3e4b882bb5c4c0dbe4cdcd92126731128b", - r: "3203ec8548732742ecee319518c3a230477173779a8da8cd7c44b780503da5c03f55cb7" + a: 0x20c3cb19e51d4e2ac2c89f26e052bef8n, + b: -0xab2a148297108425ebd2fd17d897f647e0792fn, + r: -0x15e82b69a0eaed04cd140c6aed3b1f5bc0fc5de7ceddcb2d77615767b19dd82c744788n }, { - a: "a0a4dc9610ada50dfa633ad910a02aa20c85", - b: "-4d7aa1dc1cc1d1767b4e25a839e7c177652", - r: "-309e8a7c10fbc6b50f6ad012099765a35395b9d51112d50e0a8f3ac076942a9e5a0509a" + a: -0xcc4f48f45d8165569348fb995370n, + b: 0x140cc111df0a06e32335478ded744eb3a737a53409n, + r: -0x10005f808c07a1d91faac090aad06804b491919a9d2ed58f6caa52448ad97bd486aef0n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a * b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a * d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: *"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/neg.js b/deps/v8/test/mjsunit/harmony/bigint/neg.js index 8cec9cc21b..2fedf297a5 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/neg.js +++ b/deps/v8/test/mjsunit/harmony/bigint/neg.js @@ -7,74 +7,73 @@ // Flags: --harmony-bigint var data = [{ - a: "58ad59aa3aa9d04d4c12493966e204ef0500d5f92ecb31", - r: "-58ad59aa3aa9d04d4c12493966e204ef0500d5f92ecb31" + a: 0xcn, + r: -0xcn }, { - a: "6dbd19e4b781a8f113ae95738dda4b70ba027755052126c198d20ade97869ff", - r: "-6dbd19e4b781a8f113ae95738dda4b70ba027755052126c198d20ade97869ff" + a: -0x5a3d0f6cdb7987a2d262838c05359f786a484d052529n, + r: 0x5a3d0f6cdb7987a2d262838c05359f786a484d052529n }, { - a: "d02befb1c96364a984664f85", - r: "-d02befb1c96364a984664f85" + a: -0x98d8c6cbfd67b6b652b7a4670478f6706e06a3n, + r: 0x98d8c6cbfd67b6b652b7a4670478f6706e06a3n }, { - a: "86", - r: "-86" + a: -0xe66ac692ff012bd0f4ca38804628f71ff411aede09c59597n, + r: 0xe66ac692ff012bd0f4ca38804628f71ff411aede09c59597n }, { - a: "0", - r: "0" + a: -0x97e1e0c13c0c0c420aca92268ea802047c30570335de0000dn, + r: 0x97e1e0c13c0c0c420aca92268ea802047c30570335de0000dn }, { - a: "-f8da", - r: "f8da" + a: 0x6b2eddc3b212913abed4f5c84e3eee64d6463224dff8n, + r: -0x6b2eddc3b212913abed4f5c84e3eee64d6463224dff8n }, { - a: "2b0f358b54a82fbaddc5a6e61a5d", - r: "-2b0f358b54a82fbaddc5a6e61a5d" + a: -0xfcd42a712dd928deb51ab2d151fa6bee0f4dd2fa6n, + r: 0xfcd42a712dd928deb51ab2d151fa6bee0f4dd2fa6n }, { - a: "-3d32065b9bbb36ee521ff82da", - r: "3d32065b9bbb36ee521ff82da" + a: -0x75ba8e0e92a05ff552f2dc3afb39a4dn, + r: 0x75ba8e0e92a05ff552f2dc3afb39a4dn }, { - a: "ca3da934e8081c457933c90", - r: "-ca3da934e8081c457933c90" + a: 0x4570376e541836fab5190e08an, + r: -0x4570376e541836fab5190e08an }, { - a: "-e4d2bbdf90affad1d2a", - r: "e4d2bbdf90affad1d2a" + a: 0x15aca33cfb06n, + r: -0x15aca33cfb06n }, { - a: "-290845e8f55d467e3", - r: "290845e8f55d467e3" + a: 0x7ec0027910c44b791bf193c6f25487a9435n, + r: -0x7ec0027910c44b791bf193c6f25487a9435n }, { - a: "-771c77d2dd2227c30cf44f1bf3230", - r: "771c77d2dd2227c30cf44f1bf3230" + a: -0x31f0d92f358618e6b29a2899bd988533838d33839fb37n, + r: 0x31f0d92f358618e6b29a2899bd988533838d33839fb37n }, { - a: "-77aa11", - r: "77aa11" + a: 0xb4f84118d797244c982f1n, + r: -0xb4f84118d797244c982f1n }, { - a: "d220c8af9c97516bf5ec295585f711e020480d08ac11689726a285930", - r: "-d220c8af9c97516bf5ec295585f711e020480d08ac11689726a285930" + a: 0x626n, + r: -0x626n }, { - a: "53841e699f994e1a43f7f848f34d418792191de15b78e1a852c430b2f8af6e7", - r: "-53841e699f994e1a43f7f848f34d418792191de15b78e1a852c430b2f8af6e7" + a: 0x9f35c8968457d07608699df5894c0542f35b73b0b5ce8423aan, + r: -0x9f35c8968457d07608699df5894c0542f35b73b0b5ce8423aan }, { - a: "7c30187b8901bd748adc4bc243", - r: "-7c30187b8901bd748adc4bc243" + a: -0xb5be1f7937895adc457f051d1f4bc74d556b432dn, + r: 0xb5be1f7937895adc457f051d1f4bc74d556b432dn }, { - a: "-e07ac5649eb741a023b0f9928d5982032f6766a479c7fbf26", - r: "e07ac5649eb741a023b0f9928d5982032f6766a479c7fbf26" + a: 0xcacb413b3cab5a5f5086511728d1afbaa82ca41e69805daf47503e2n, + r: -0xcacb413b3cab5a5f5086511728d1afbaa82ca41e69805daf47503e2n }, { - a: "5ab3237bb32234bcaf8", - r: "-5ab3237bb32234bcaf8" + a: -0x77ef7cbb15cee20a519a1n, + r: 0x77ef7cbb15cee20a519a1n }, { - a: "7df7", - r: "-7df7" + a: -0x71ac9bfe7f5f70038c7fn, + r: 0x71ac9bfe7f5f70038c7fn }, { - a: "-518b7b", - r: "518b7b" + a: -0x500a02b8fd66ee1067022c02c7241acdc42b947bfb933aa95a8d6n, + r: 0x500a02b8fd66ee1067022c02c7241acdc42b947bfb933aa95a8d6n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var r = -a; - if (d.r !== r.toString(16)) { - print("Input: " + a.toString(16)); + var r = -d.a; + if (d.r !== r) { + print("Input: " + d.a.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); error_count++; diff --git a/deps/v8/test/mjsunit/harmony/bigint/not.js b/deps/v8/test/mjsunit/harmony/bigint/not.js index 7ceaa01e63..6b4b2eb713 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/not.js +++ b/deps/v8/test/mjsunit/harmony/bigint/not.js @@ -7,74 +7,73 @@ // Flags: --harmony-bigint var data = [{ - a: "3d02c87edc77722299f6559ecca038911f864a4e78c20af80f4a6d9", - r: "-3d02c87edc77722299f6559ecca038911f864a4e78c20af80f4a6da" + a: 0x9f0305cd75e4n, + r: -0x9f0305cd75e5n }, { - a: "ac01894aeaf77255ede209897561ec1e3c7e916b9", - r: "-ac01894aeaf77255ede209897561ec1e3c7e916ba" + a: -0xe8e9c8312f553c9n, + r: 0xe8e9c8312f553c8n }, { - a: "-7aaab657ab197f26eb6b98fe4c2c79b199a8156129ca04", - r: "7aaab657ab197f26eb6b98fe4c2c79b199a8156129ca03" + a: -0x1a29f0783a66534da3c024ad1cc854073f886888fen, + r: 0x1a29f0783a66534da3c024ad1cc854073f886888fdn }, { - a: "9718579cc52befdaff1ec035b5ed03cec5c1d1678c28712cf0c9bec2c807897b74f0", - r: "-9718579cc52befdaff1ec035b5ed03cec5c1d1678c28712cf0c9bec2c807897b74f1" + a: -0xfc2cc19496c1ced95be832ca5246d41c526b9fa28b88bcd39813aa336n, + r: 0xfc2cc19496c1ced95be832ca5246d41c526b9fa28b88bcd39813aa335n }, { - a: "e614366bc4e67509843254c52e13da5380b00a35aa1d233e70821f7d649ad1957db", - r: "-e614366bc4e67509843254c52e13da5380b00a35aa1d233e70821f7d649ad1957dc" + a: 0x13ebn, + r: -0x13ecn }, { - a: "fb815f78e6952b500226c", - r: "-fb815f78e6952b500226d" + a: 0x4c12d642b2a132f0c927ec7504b530fb45d5e249163ffdc59feb3de31881n, + r: -0x4c12d642b2a132f0c927ec7504b530fb45d5e249163ffdc59feb3de31882n }, { - a: "94404df802649cff2ea6c0996f55ec60c14f00ab29b287092389951f6227c4ec7", - r: "-94404df802649cff2ea6c0996f55ec60c14f00ab29b287092389951f6227c4ec8" + a: 0x49637a624cb8782002e3e0874ad76215e188cee948c7ce7b0f66e1d0n, + r: -0x49637a624cb8782002e3e0874ad76215e188cee948c7ce7b0f66e1d1n }, { - a: "-74b42cd7bccd", - r: "74b42cd7bccc" + a: -0x81cbae84e6753b885ada46c0bf72368c083fed622fn, + r: 0x81cbae84e6753b885ada46c0bf72368c083fed622en }, { - a: "da", - r: "-db" + a: -0xcdf793acfdd08b6n, + r: 0xcdf793acfdd08b5n }, { - a: "3a9ade198", - r: "-3a9ade199" + a: 0x88n, + r: -0x89n }, { - a: "56e766d24fd18c2241f244dedc426c0b1ae59e7ed4f06def0a75e0a5c8651e2ce87928", - r: "-56e766d24fd18c2241f244dedc426c0b1ae59e7ed4f06def0a75e0a5c8651e2ce87929" + a: -0x1fn, + r: 0x1en }, { - a: "cc430c91347b22ecb1a6f1a2ceea168ffa4a9b80065bd1ec5d", - r: "-cc430c91347b22ecb1a6f1a2ceea168ffa4a9b80065bd1ec5e" + a: 0x5c3278e76266b9e93d63eb4f2aa53716220aa1n, + r: -0x5c3278e76266b9e93d63eb4f2aa53716220aa2n }, { - a: "32e4b7f82d8c037d0f562296e21b1e58a", - r: "-32e4b7f82d8c037d0f562296e21b1e58b" + a: -0x9f4fe05n, + r: 0x9f4fe04n }, { - a: "-526d3f1a904561f0cde1f0a2a4", - r: "526d3f1a904561f0cde1f0a2a3" + a: 0xdn, + r: -0xen }, { - a: "3de5a9635a40539831c9665577e5eedbf680755e2065a0caa346759e17225", - r: "-3de5a9635a40539831c9665577e5eedbf680755e2065a0caa346759e17226" + a: -0x74a9d63d02bd1393b311211e35c8b2d11e2367ffffb812683365f02d98n, + r: 0x74a9d63d02bd1393b311211e35c8b2d11e2367ffffb812683365f02d97n }, { - a: "-d912828b8d6419900", - r: "d912828b8d64198ff" + a: 0x8a2831ae3e1b6b21a7b3d7ee921a0c0edf29b272d654f647169a5a6141d3aaf41439n, + r: -0x8a2831ae3e1b6b21a7b3d7ee921a0c0edf29b272d654f647169a5a6141d3aaf4143an }, { - a: "-17968ddf93", - r: "17968ddf92" + a: 0xa2ef28270a7e668e190bc303537f5a8ba3f0d59bcn, + r: -0xa2ef28270a7e668e190bc303537f5a8ba3f0d59bdn }, { - a: "-c2bfd766e34923d549bbaedb4d9b7bb35a61908e6144462a", - r: "c2bfd766e34923d549bbaedb4d9b7bb35a61908e61444629" + a: -0x4f8bd11ee4ef38682a0c94en, + r: 0x4f8bd11ee4ef38682a0c94dn }, { - a: "af426ec83aaafc84a94930e51a2899696a3d", - r: "-af426ec83aaafc84a94930e51a2899696a3e" + a: 0x5436d0721d1282755068add3b5ab5424cb455fad50811a9afff0be5n, + r: -0x5436d0721d1282755068add3b5ab5424cb455fad50811a9afff0be6n }, { - a: "-283de5b9379a45f065d3b8662ac38faa6492bc0eea6b7e3b51591a5cc27669e", - r: "283de5b9379a45f065d3b8662ac38faa6492bc0eea6b7e3b51591a5cc27669d" + a: 0x5db6907c92529f517d24a6ff7303de42cb9059ae2adc0c22n, + r: -0x5db6907c92529f517d24a6ff7303de42cb9059ae2adc0c23n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var r = ~a; - if (d.r !== r.toString(16)) { - print("Input: " + a.toString(16)); + var r = ~d.a; + if (d.r !== r) { + print("Input: " + d.a.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); error_count++; diff --git a/deps/v8/test/mjsunit/harmony/bigint/or.js b/deps/v8/test/mjsunit/harmony/bigint/or.js index 4ee32657d4..c378e141cd 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/or.js +++ b/deps/v8/test/mjsunit/harmony/bigint/or.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "a66", - b: "d0671cd6e4ebd7baf6e48b2529348cfa89fc9513ba30ef3f99aee07f267df163cf8", - r: "d0671cd6e4ebd7baf6e48b2529348cfa89fc9513ba30ef3f99aee07f267df163efe" + a: 0x77a87n, + b: 0xde08e7433fb9584911b8cb4bc7eed802299b4489fc635974d063847da4e8b461df5dn, + r: 0xde08e7433fb9584911b8cb4bc7eed802299b4489fc635974d063847da4e8b467ffdfn }, { - a: "a9950e5fc429f0f93d5fa8f306f4e5da88a8c9f9", - b: "d1fc1ac3db7ff5547462800923e616727120f74f0a6cb7bf1886dd4f4ac", - r: "d1fc1ac3db7ff554746a9959e7fe56ff7fb3f7ff8f7cffff5daedfcfdfd" + a: -0x1d3ff6f353f2d035ed7b4b8e5e4ae1c8d162n, + b: -0xcf829b11c2f996f388b22cd03aeb75ec434f3be8fde6466n, + r: -0x192f308302c00024a55a4004520a81c84062n }, { - a: "5e277a64b6515ad69ed8935ae8dcdb6dc66f98fcbb462b10bea0db15ad6010d", - b: "7df3", - r: "5e277a64b6515ad69ed8935ae8dcdb6dc66f98fcbb462b10bea0db15ad67dff" + a: 0x6dbbc93af9a9c222187dn, + b: -0xfaa906348dc49859c34bc7c6n, + r: -0xfaa9020404c400500149c781n }, { - a: "3b8368196588e684403965902763d66aa", - b: "-edf58c5ab418f49cf9fdb7f3b1c416a03c1dfbe90ba7ea6373c", - r: "-edf58c5ab418f49cf9c43493a0801600381dc2880b808821112" + a: 0xf8n, + b: 0x4388532n, + r: 0x43885fan }, { - a: "-5587f5e86137f8ea4d7259acdd0b77a26ea069385501c9985df6a5fcd3c", - b: "9878871628ea5cb66", - r: "-5587f5e86137f8ea4d7259acdd0b77a26ea069385501811849d605a041a" + a: -0x3ee35e1823b91414618f05995e11594920539921e9440n, + b: -0x58c5811ee19db01b7d9824c49682af55956119cfbc9868287ef138da08ee3n, + r: -0x3c80040002800414010101891c1048082051180008423n }, { - a: "-dc65679b1ea7c86c10890e6d6be3bd069b4c7", - b: "83ea9", - r: "-dc65679b1ea7c86c10890e6d6be3bd0618047" + a: -0xa2a70c5da9a7e98f242e82d518n, + b: 0n, + r: -0xa2a70c5da9a7e98f242e82d518n }, { - a: "-755f422bfb614b7ed2c8e05cd1e0e0a", - b: "-d3185fac5454a495d7b149e67df4436339e060d924d", - r: "-24154221496049744240204040c0209" + a: 0x7868475f450ff2b15a03eccb4d26ce8711383f615cn, + b: 0x1c62774e1db239cb461c4190b54de4d872f9484cf82ed1258cc14580cf29f608n, + r: 0x1c62774e1db239cb461c41f8fd4fffdd7ffbf95efbeedb6daecfc791ff3ff75cn }, { - a: "-1dfdf84b41ddd069053", - b: "f9b2bc80b580311773e9a5d57e8f24ace46bd2a0fce24404db684efa8692638b5d604e6", - r: "-1105784900548009011" + a: 0x865d033028551a71f6f9f8d7b36cf9819n, + b: -0x68e30391d9831a4ea3e65b2e433f55ba398n, + r: -0x68610290c9830a4482000206000c1102387n }, { - a: "18d1b78380aa9016029417c2ebe77a", - b: "-b63b35e6711dcbf00dc02cd936", - r: "-3835446109c9600800041806" + a: -0x817a0dacbafbaf40ef819fc62a8efc4b4960n, + b: -0x5af313e32a5386e29cb5d2b34d54f04da389f33d52444f177671e41n, + r: -0x12a04840a008a008f019504008074430841n }, { - a: "-9981f", - b: "-5d876576146a2d5dc8d52d26ea3304287af0922685f8e1a46875e80f24a470", - r: "-800f" + a: -0xef8c9475210c0a31aa12c34db6e7737609c75b78a54cn, + b: -0xba91b4ec3a5390db84febaeaddb8209155413e2e02fb0n, + r: -0xa9080441210808300a02820d9282011400034260250cn }, { - a: "-20f8052991bc5a8f2631c9e4b34aa9073a69913185a539d719", - b: "a59fdaa025b42", - r: "-20f8052991bc5a8f2631c9e4b34aa9073a6991200005398419" + a: -0xf4e707078d14001959f4n, + b: 0n, + r: -0xf4e707078d14001959f4n }, { - a: "-d02620570", - b: "-3b14d75fb9d9b95d13f884a82c9f16", - r: "-400200506" + a: 0x601f0n, + b: 0x246fbfn, + r: 0x266fffn }, { - a: "-8", - b: "-4", - r: "-4" + a: -0x9ccd3d1b6d4bcde8643ad641d395980bn, + b: -0x379e57728185fd098383a23c7f56dn, + r: -0x13901650808484018100003859009n }, { - a: "e0e8ab319d1f051560e1155ae5789dd4d9b638e07e5a57c3432e6cb9239d", - b: "85c9cd1f09436dc45ac783f31a21a1ff4e11ceca00cc164", - r: "e0e8ab319d1f0d5dfcf1f5def7fcddfcf9bf39e27e5ff7e35feeecbde3fd" + a: 0xcc4b3ba719bd1b37f254f36a72ee375ad22abn, + b: -0xb0c220750f2dad9de91ffb8a7bbf8ffefen, + r: -0x4000640e0c8098a0095880188a02dc55n }, { - a: "8131173cb5597e2ae560cae6d0907f004792b1b1c7", - b: "-2ac290724a7c86", - r: "-c290604a4c01" + a: 0xa230c33b718cd563f9c1577f4f8da160851902341ba1a6e6bdcbec413d98a18n, + b: 0xc2f4e2db2df59ccc34690479ebe64df967n, + r: 0xa230c33b718cd563f9c1577f4f8dad6fcf3db2ff5bede7e6bdcffeff7ddfb7fn }, { - a: "bdb24fd4d78b01d77e41d95f2c3eedeb2bf919", - b: "-97f6ccbd94d64ada501e0f288568", - r: "-14f60881940600d2401204000467" + a: -0x5fbac9a8f47n, + b: 0xf1bfe6f97e8f516685372b06ea89659c3df4ab3f6779e5c0b41e1b570fn, + r: -0x54ba0808841n }, { - a: "-d5ad86f9a4808394f6e7dcd2a67bd3e6a9", - b: "1a80309934942e4e55fbf2ba4d1d2f8cc4697338097e2c1b7ce013da8a79965974286", - r: "-408c066804000010f6c25450261a40a429" + a: -0x7fd2d4a4c60ba795e2fcn, + b: 0x33dcea557cc5156dacb9ad7b252598172f92d8cf7d38e69f0a0n, + r: -0xd02d02000082194025cn }, { - a: "c7a0086120a1613a28456", - b: "b8", - r: "c7a0086120a1613a284fe" + a: -0x3833089d7cf4e0181247572037a90cc2506342a2191137345e3a0e10n, + b: 0xededf5c7e54cd86afc6d838205c8a78cac7a0e410792a21cf3e4e38dd8ca2dd80n, + r: -0x283208103824c01802450720300908c2004142200111072052180210n }, { - a: "c8480c", - b: "0", - r: "c8480c" + a: -0x188818a47abbfe64357ccd1a33fb5cb875f86n, + b: -0x14faf1811ee737d048c025f7a1fe156f7e90d23a699d040609e631836500df2e30cdn, + r: -0x108808202299d040201c411832500cb061085n }, { - a: "ec8913fc89aa7a47672bc0f5269e8629cabf2dba88836cb3a9", - b: "-52594e7", - r: "-4010447" + a: 0xf60c0260022920bdbd1c837778657936956c15b4cb1n, + b: 0xa10df3b397c24n, + r: 0xf60c0260022920bdbd1c8377786579b79dffb7b7cb5n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a | b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a | d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: |"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/sar.js b/deps/v8/test/mjsunit/harmony/bigint/sar.js index 7feb8aebcd..f66115dcb6 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/sar.js +++ b/deps/v8/test/mjsunit/harmony/bigint/sar.js @@ -7,100 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "-4efa0d1f8a127", - b: "-66", - r: "-13be8347e2849c0000000000000000000000000" + a: 0x211a34fn, + b: 0xa6n, + r: 0n }, { - a: "-100000001", - b: "20", - r: "-2" + a: 0xa0d0aff5d2783ad192f37423n, + b: 0x7n, + r: 0x141a15feba4f075a325e6e8n }, { - a: "853cd87b0bd5c046aecbf4b3d", - b: "-96", - r: "214f361ec2f57011abb2fd2cf40000000000000000000000000000000000000" + a: -0x68ba010a12ed551fc17c67f63331eea3n, + b: 0xae5n, + r: -0x1n }, { - a: "-4bc82dba903fedec0a079f7ae4fa6bd6befa", - b: "0", - r: "-4bc82dba903fedec0a079f7ae4fa6bd6befa" + a: 0xb64dc8009n, + b: 0xf1n, + r: 0n }, { - a: "43969b4db0d921d9f0ca68f74e4e4b9073732a7955a5b4571", - b: "-91", - r: "872d369b61b243b3e194d1ee9c9c9720e6e654f2ab4b68ae2000000000000000000000000000000000000" + a: -0x364cdec628e438712e4f8cb7an, + b: 0x48cn, + r: -0x1n }, { - a: "495f57", - b: "-a5", - r: "92beae00000000000000000000000000000000000000000" + a: -0xb417099aba80a783f52790b779b38c2e6fbdf5f490d7b02a59e81032een, + b: 0x6a3n, + r: -0x1n }, { - a: "-22109b99d3025aaef5c3fbd27420a72", - b: "45d", - r: "-1" + a: 0x9d2b41n, + b: 0n, + r: 0x9d2b41n }, { - a: "b3f6b156f4afcf259efd3cd1", - b: "c7", - r: "0" + a: -0x4a070c83b02ba86434228a50cbaf50ddf38n, + b: -0x63n, + r: -0x25038641d815d4321a11452865d7a86ef9c0000000000000000000000000n }, { - a: "137aeeadc8d1395042e80393cc1b6a1c7b6e526ab1b6fc2f2859fd70e0c29df2802", - b: "f49", - r: "0" + a: 0x3e76514036ccb958c98f60n, + b: -0x76n, + r: 0xf9d94500db32e563263d8000000000000000000000000000000n }, { - a: "70f51026476e43bd7e911d37a4553701", - b: "33", - r: "e1ea204c8edc877afd2" + a: -0x51fe20d47ba564bc09337d5c8d284deb5006549bad2629230198f34n, + b: -0xfn, + r: -0x28ff106a3dd2b25e0499beae469426f5a8032a4dd693149180cc79a0000n }, { - a: "-3f935a89481c85d666498cf64fdc2a57028f7b295621dc665c0442229563", - b: "-2", - r: "-fe4d6a2520721759992633d93f70a95c0a3deca5588771997011088a558c" + a: 0x49adce1d09dadc5a0635f24d066d3a29e37b9be6059b88d0239d6ca6d92267a372n, + b: -0x6n, + r: 0x126b73874276b716818d7c93419b4e8a78dee6f98166e23408e75b29b64899e8dc80n }, { - a: "-c3", - b: "-87", - r: "-618000000000000000000000000000000000" + a: 0xca19971406fb07cn, + b: -0x17n, + r: 0x650ccb8a037d83e000000n }, { - a: "aae225520f630c0dfbb815f121836612d75a1f65a301461cd05ad0a741496", - b: "-4", - r: "aae225520f630c0dfbb815f121836612d75a1f65a301461cd05ad0a7414960" + a: 0xd8de8f631313b1f98f77d265ee48014f82eb20n, + b: 0xen, + r: 0x3637a3d8c4c4ec7e63ddf4997b920053e0bn }, { - a: "a5348f9af939041cc6ed386c060619a42f30c4aa8", - b: "95", - r: "529a" + a: -0x550d3470c8ad9b8f22ed01a4b1d3f648n, + b: -0x4dn, + r: -0xaa1a68e1915b371e45da034963a7ec900000000000000000000n }, { - a: "-4c27fc7e3892a6a5b517", - b: "-6c", - r: "-4c27fc7e3892a6a5b517000000000000000000000000000" + a: -0xa7eadcd4a1b8037081952f0a9199n, + b: -0xcfn, + r: -0x53f56e6a50dc01b840ca978548cc8000000000000000000000000000000000000000000000000000n }, { - a: "98efd35f2239f7efde9aef42ad0acd835e68ad868a2cd8fac260f1c7496e3fd2ada76", - b: "0", - r: "98efd35f2239f7efde9aef42ad0acd835e68ad868a2cd8fac260f1c7496e3fd2ada76" + a: -0x65b3933c9e1eb5f953f6cc55cn, + b: 0xa6cn, + r: -0x1n }, { - a: "-92f0264c863bdf66d4c83e8bf812123d759b4", - b: "-96", - r: "-24bc0993218ef7d9b5320fa2fe04848f5d66d00000000000000000000000000000000000000" + a: -0x92cea858475460661a2831a28434bde95e5132e1dcaeb161ec89bd9555f41n, + b: -0xbn, + r: -0x4967542c23aa30330d1418d1421a5ef4af289970ee5758b0f644decaaafa0800n }, { - a: "ec6341ff2b0e9cf8721e2eb4ec9c9", - b: "74", - r: "0" + a: -0x1d838ade17fe571916a26314b6a8b42e9b6e2b74238de734d6f5575df7n, + b: -0x7n, + r: -0xec1c56f0bff2b8c8b51318a5b545a174db715ba11c6f39a6b7aabaefb80n }, { - a: "-32de8dced947fa55cd0b91332a81f70", - b: "-5b", - r: "-196f46e76ca3fd2ae685c8999540fb800000000000000000000000" + a: 0xdd5bf8581e32875d44e26ef10c45bdff68d209015933586dc37211n, + b: -0xa9n, + r: 0x1bab7f0b03c650eba89c4dde2188b7bfed1a41202b266b0db86e422000000000000000000000000000000000000000000n }, { - a: "-3ef43bf8610f6533526ba734e85eafa04cd50a3", - b: "-25", - r: "-7de877f0c21eca66a4d74e69d0bd5f4099aa146000000000" -}, { - a: "-9979591a367a32ae0039c54fd0f3d9e0ccc80be52b7e517fc94d9f3587dc54d933bb", - b: "0", - r: "-9979591a367a32ae0039c54fd0f3d9e0ccc80be52b7e517fc94d9f3587dc54d933bb" + a: -0xa92d3014dcn, + b: -0x4cn, + r: -0xa92d3014dc0000000000000000000n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a >> b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a >> d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: >>"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/shl.js b/deps/v8/test/mjsunit/harmony/bigint/shl.js index 1b0f309f88..bedd785b54 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/shl.js +++ b/deps/v8/test/mjsunit/harmony/bigint/shl.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "-9a6d035348727045f6abf7d59056d30e9ce885e87f5f8438347bfcda0a1f9b", - b: "-2", - r: "-269b40d4d21c9c117daafdf56415b4c3a73a217a1fd7e10e0d1eff368287e7" + a: -0xe813d76adc0a177778c0c232c595e8572b783210f4a7009d7c1787n, + b: 0x9en, + r: -0x3a04f5dab70285ddde30308cb1657a15cade0c843d29c0275f05e1c000000000000000000000000000000000000000n }, { - a: "615f9676062ea7a1b89396ce4208712f279475490829", - b: "ff", - r: "30afcb3b031753d0dc49cb672104389793ca3aa484148000000000000000000000000000000000000000000000000000000000000000" + a: -0xded00dff14554cn, + b: 0xd9n, + r: -0x1bda01bfe28aa98000000000000000000000000000000000000000000000000000000n }, { - a: "-9b6131d8b806543fce32b4c2ca2038ffa956929848a61b5eb7f", - b: "-e7", - r: "-1" + a: -0x50c2df089209be37998c8f6e30c4c95a61e77a9241n, + b: 0x46n, + r: -0x1430b7c224826f8de66323db8c3132569879dea490400000000000000000n }, { - a: "-331d9e", - b: "0", - r: "-331d9e" + a: 0x668086293eab52b52b879f00375d0f513f1ff9a93df788e38527en, + b: -0x3n, + r: 0xcd010c527d56a56a570f3e006eba1ea27e3ff3527bef11c70a4fn }, { - a: "cb79696d3a6f5d5d034e9d2", - b: "-d33", - r: "0" + a: 0n, + b: -0x1n, + r: 0n }, { - a: "ca99", - b: "10", - r: "ca990000" + a: 0x26bd28fb3e06bb0ddan, + b: -0xcn, + r: 0x26bd28fb3e06bb0n }, { - a: "6f97833d5", - b: "0", - r: "6f97833d5" + a: -0xa04dca5c74bdb1dbf2f0n, + b: -0x3fn, + r: -0x1409cn }, { - a: "67d36e7948d18af35f0823c0d58ba47ca0846cdfaa7a7407f09d44747275532681b343", - b: "f", - r: "33e9b73ca468c579af8411e06ac5d23e5042366fd53d3a03f84ea23a393aa99340d9a18000" + a: -0xd6b46ec3ead311e2e45ca4ae8aa9cf5acf4c2d6c61de06e9e36n, + b: -0xan, + r: -0x35ad1bb0fab4c478b917292ba2aa73d6b3d30b5b187781ba8n }, { - a: "f4896", - b: "-7", - r: "1e91" + a: -0x1f1922aen, + b: -0xbfn, + r: -0x1n }, { - a: "996ce2a9e0f7d65e0523204c9c469bfd14821efe571ac59cdc01", - b: "1d", - r: "132d9c553c1efacbc0a464099388d37fa29043dfcae358b39b8020000000" + a: 0x47n, + b: -0x2n, + r: 0x11n }, { - a: "-f8f", - b: "f1", - r: "-1f1e000000000000000000000000000000000000000000000000000000000000" + a: -0xf64n, + b: 0x7en, + r: -0x3d900000000000000000000000000000000n }, { - a: "-b685bbcd953ba9c5973ae523dc81d7b35e0cf2b9b51026d4ba1ac21bd5c3c18f9c13", - b: "0", - r: "-b685bbcd953ba9c5973ae523dc81d7b35e0cf2b9b51026d4ba1ac21bd5c3c18f9c13" + a: -0x78dn, + b: -0x85en, + r: -0x1n }, { - a: "e2295b362b7048fb163d1272178ed441517fc689e5ec5ea40f29", - b: "-30", - r: "e2295b362b7048fb163d1272178ed441517fc689" + a: -0xa03bc462b00e4113a2472eb73dn, + b: 0n, + r: -0xa03bc462b00e4113a2472eb73dn }, { - a: "-b322e816b014448f44e60b418582390d2a3ad95", - b: "0", - r: "-b322e816b014448f44e60b418582390d2a3ad95" + a: 0x3816aa0f01396f4abe0ee7164e211ce60ce590b615d86f6e6363c0bdd513d8a0n, + b: 0x4n, + r: 0x3816aa0f01396f4abe0ee7164e211ce60ce590b615d86f6e6363c0bdd513d8a00n }, { - a: "4c135e4d7", - b: "0", - r: "4c135e4d7" + a: -0xaf8711d29fdecd42a255f14aafe13b9404cced5df0af8b86080af7682cben, + b: 0x1n, + r: -0x15f0e23a53fbd9a8544abe2955fc277280999dabbe15f170c1015eed0597cn }, { - a: "-d5b694", - b: "f1", - r: "-1ab6d28000000000000000000000000000000000000000000000000000000000000" + a: 0x218b11dfn, + b: 0n, + r: 0x218b11dfn }, { - a: "-7994be7", - b: "-d", - r: "-3ccb" + a: 0x263fcb4707e6fd4a21b1f646ddd90a5e78d781c272621dcaf861d6250d7be675e067n, + b: -0x868n, + r: 0n }, { - a: "a6443add555ea15af90092e8", - b: "42", - r: "29910eb75557a856be4024ba00000000000000000" + a: 0x8312b459b585847682en, + b: 0x4en, + r: 0x20c4ad166d61611da0b80000000000000000000n }, { - a: "9385ed", - b: "e5", - r: "1270bda000000000000000000000000000000000000000000000000000000000" + a: 0xb45d42e0595a4b104b0b9a177ffdc52b401b61659fe163e720621aef8c8e6191ba7an, + b: 0x3n, + r: 0x5a2ea1702cad25882585cd0bbffee295a00db0b2cff0b1f390310d77c64730c8dd3d0n }, { - a: "-531", - b: "7d", - r: "-a620000000000000000000000000000000" + a: -0x42d2c4n, + b: 0xfdn, + r: -0x85a588000000000000000000000000000000000000000000000000000000000000000n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a << b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a << d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: <<"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/sub.js b/deps/v8/test/mjsunit/harmony/bigint/sub.js index f0af2ca930..a1ff9b4bb3 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/sub.js +++ b/deps/v8/test/mjsunit/harmony/bigint/sub.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "e5e5071838eb1314", - b: "3b7f55dce703a25ea14fdea6186156f775dec5d29f6edb3a014", - r: "-3b7f55dce703a25ea14fdea6186156f775d067822deb4c88d00" + a: 0xc4fd438551d58edn, + b: 0x91b42ee55a50d974an, + r: -0x90ef31a1d4ff03e5dn }, { - a: "-f", - b: "22d6805c7201a8ad4b9e6c2a7e8b5ab3bac", - r: "-22d6805c7201a8ad4b9e6c2a7e8b5ab3bbb" + a: -0x86b766ec276e390087458ce093b07b2574732d5f3f5125n, + b: 0x4b1fe0dd23316de1b38b343d4112fbd7e8c8d081de5dbabda7357fd9e868466693den, + r: -0x4b1fe0dd23316de1b38b34c3f879e7ff5701d10923ea9b5157b0a54e5b95a5a5e503n }, { - a: "-22", - b: "-11a0adfaedd5adb92297af1c3794ef5461dd8bc146db3", - r: "11a0adfaedd5adb92297af1c3794ef5461dd8bc146d91" + a: 0x63e1eac0d5470c8f802ec390b6415c43ed16d28d6dn, + b: -0xbe26927b2f6ae85b5d3062d869d22da005805d23142a236955127b6ca688c07fn, + r: 0xbe26927b2f6ae85b5d30633c4bbcee754c8ceca342edb41f966ebf59bd5b4decn }, { - a: "-d20c39d0", - b: "-46faa9d3eabcbd8b6d07adc2d0ff289d2", - r: "46faa9d3eabcbd8b6d07adc2c3de65002" + a: -0x873cf988993d97e5180fn, + b: -0xd791aa365f881a7f05f21f73ef390c0b37408dd0a908801682464178426an, + r: 0xd791aa365f881a7f05f21f73ef390c0b37408dd021cb868de908a9932a5bn }, { - a: "-e5b56109a11", - b: "211e1dcdf52f020ab0f16e18cc4e46027d05bfa3155b88973e630ae9a75bf2c7fbad269", - r: "-211e1dcdf52f020ab0f16e18cc4e46027d05bfa3155b88973e630ae9a75cd87d5cb6c7a" + a: -0xcb273d5b123eff101c62f016ae2896223b93b9114e40d1fn, + b: 0x2169f8c954623f8381bf12fd0927e1a645f5b3c6c00e58105c297ba40446208dn, + r: -0x2169f8c954623f838e7186d2ba4bd19747bbe2c82af0e1727fe2b735192a2dacn }, { - a: "-b682aa", - b: "-5fa59a6a80d39c0c885c030e9c8c84ec7", - r: "5fa59a6a80d39c0c885c030e9c811cc1d" + a: -0xe965bf745fffcf22n, + b: 0x7c3b92f8a030cbfca7cc5f2fd454459c79a3ac2201524468fbn, + r: -0x7c3b92f8a030cbfca7cc5f2fd454459c7a8d11e175b244381dn }, { - a: "-c1325b8ab9fea966f093bbfbc2e611b0e5bf0b13ce047c7133056d4eea", - b: "f97d5c4014c5cc87923c344a", - r: "-c1325b8ab9fea966f093bbfbc2e611b0e6b888700e19423dba97a98334" + a: 0n, + b: 0x6975a8ededffd265f472e660e18n, + r: -0x6975a8ededffd265f472e660e18n }, { - a: "-1872900ab729911a3c021db53672eda07a9ad623", - b: "152d13997090c43551edfc89d4c7ea5e9ffee4a114085858892e67e82edea6384aaaba7", - r: "-152d13997090c43551edfc89d4c7ea602727e54c86a169fc4950433b960d803ff4581ca" + a: -0x236bda1a3a9635190f26c3739b7342f33a27cd2568n, + b: 0x1a7e6n, + r: -0x236bda1a3a9635190f26c3739b7342f33a27cecd4en }, { - a: "5440388fc10de9", - b: "-4b", - r: "5440388fc10e34" + a: 0xb682b9c88f0b6d7b5e9a4f77dd0d7885d62cd162783b2e55b30b954e10caf3n, + b: 0x2c6574161d9aff7bbebd95e561fbd5d70d893e8c9772bcc697cddn, + r: 0xb682b9c88c451639fcc09f8021219f27800d140507629a6ce9946981a74e16n }, { - a: "-198dc54795a81722f70acc9cc20505492172c7819ba168e57d", - b: "-48f3b40bf850f771d44e423eb266846801d9e4e920c", - r: "-198dc543066cd66371fb557f7d20e15dfb0a81017e031a5371" + a: 0xdd6aa5240c4n, + b: 0xb9c7bef20c0cc0f814cce3c40d43e4c26en, + r: -0xb9c7bef20c0cc0f814cce3b636999281aan }, { - a: "c78082429b3163ce243c778", - b: "-97afe29", - r: "c78082429b3163cebbec5a1" + a: 0x35cd14329d5f81dbn, + b: 0x25997b1f3500f9b27f2ceean, + r: -0x25997b1bd82fb688a934d0fn }, { - a: "-50df", - b: "-d5352ec9c1b0e62b97ea1363ce8b72", - r: "d5352ec9c1b0e62b97ea1363ce3a93" + a: -0x55ec15d7ed316df3fc7bcfcce0f0a6d7034113bad6d74bae88d4aab03032n, + b: 0x9d09b8869aab44d6690fad48c8dffd0e18cc21fb26c2a80ac08fd4f42296f46d37cddn, + r: -0x9d09b886a00a0633e7e2c42808a7ba0ae6db2c6896f6b9466dfd49af0b243f183ad0fn }, { - a: "-5c9777f93d64636ff8bcda39125625aa58a49e9a4f29ece2b7afa5d", - b: "894bb7aa90b8687e6290c3218a4258dac9400d556caafe02cf8c312c053f2fc73", - r: "-894bb7aa9114fff65bce2784fa3b15b50252637b1703a2a169db5b18e7f6df6d0" + a: 0n, + b: -0xfbf3b308a6066d497e1cn, + r: 0xfbf3b308a6066d497e1cn }, { - a: "-e15c51f0627e460c477", - b: "-dfd13bac43ebe2f8e77f5b31314843", - r: "dfd13bac43ddcd33c879334cd083cc" + a: 0x6acfc1e4b681be9582cd28453387ed2c29f5eb4cd6d78aaac67n, + b: -0x4f5997n, + r: 0x6acfc1e4b681be9582cd28453387ed2c29f5eb4cd6d78fa05fen }, { - a: "0", - b: "adbd3e4b06b92771ae25eb52fca5fc86391303ebf7962", - r: "-adbd3e4b06b92771ae25eb52fca5fc86391303ebf7962" + a: -0xc93eb5cae0c90eb77e702ccb44eea6180829d0b360872n, + b: 0xdn, + r: -0xc93eb5cae0c90eb77e702ccb44eea6180829d0b36087fn }, { - a: "960a8aa627a1c48721f4e0", - b: "-9e8742ae61615481cdd12f0728f0b61", - r: "9e8742ae6ac1fd2c304b4b4f9b10041" + a: -0x324ef140a16c5c20a9a189a720136f4836ea98056n, + b: 0x49471582a658bf5524128e130b3378d29331baa8eb8n, + r: -0x49796473e6fa2bb144bc2f9cb2538c41db68a540f0en }, { - a: "-abf5cf9ff3c15b0645009", - b: "-e805773176aaa712d144e172db033c64aeaddf3380b2", - r: "e805773176aaa712d144e1681ba6426572982ecf30a9" + a: 0x6f15ac8490de4e308286fdde1142ad0052c2cn, + b: 0x9ca6c715de18d7f64a751452e967b5807eec951777245ce5fe3n, + r: -0x9ca6c715de18d78734c88fc20b1984fdf7eeb70634775c933b7n }, { - a: "349ebb89b13a7149ec1a4e067574c3825f90ec4e4413948b808c6a", - b: "-44cdc0e3efa11513525f68163033a59d7b0610070", - r: "349ebb89b13a7596c8288d0086c5f8a856124f517e6d6c3be18cda" + a: -0xc303adn, + b: 0x5ec0a706a54978a59b10007942e563957ad22e708678fbfdb02862b2c3n, + r: -0x5ec0a706a54978a59b10007942e563957ad22e708678fbfdb02925b670n }, { - a: "a86c53e8c49b20cff057882c4345c40f5c34a8cb8", - b: "-76453703c781511b52e663", - r: "a86c53e8c49b20cff05eec7fb3823c246de9d731b" + a: -0xdb736b5f3979c24f70aafa5f17711d725d552a9778e1n, + b: 0x70b56a0773498a45b796cf79ea18211614cn, + r: -0xdb736b5f408518efe7df930372ea8a69fbf6aca8da2dn }, { - a: "-2647d3c", - b: "776e5b3a57bd5196be1b9c99ae899d949cb2b94310c53be8910db71b", - r: "-776e5b3a57bd5196be1b9c99ae899d949cb2b94310c53be893723457" + a: 0xe91b9a797168c6b7440f946n, + b: -0x2588c1301521dd9646a2e22e3aca462ca95e76069be2f7b95d8bb81ccn, + r: 0x2588c1301521dd9646a2e22e3aca462caa4791a11554608014cfc7b12n }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a - b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a - d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: -"); diff --git a/deps/v8/test/mjsunit/harmony/bigint/typedarray.js b/deps/v8/test/mjsunit/harmony/bigint/typedarray.js new file mode 100644 index 0000000000..29713b8a20 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/bigint/typedarray.js @@ -0,0 +1,240 @@ +// 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-bigint --allow-natives-syntax + +var intarray = new BigInt64Array(8); +var uintarray = new BigUint64Array(8); + +function test(f) { + f(); + f(); // Make sure we test ICs. + f(); + %OptimizeFunctionOnNextCall(f); + f(); +} + +function test_both(f) { + test(() => f(BigInt64Array)); + test(() => f(BigUint64Array)); +} + +test(function basic_assignment() { + const x = 0x1234567890abcdefn; + intarray[0] = x; + assertEquals(x, intarray[0]); + uintarray[0] = x; + assertEquals(x, uintarray[0]); + const y = -0x76543210fedcba98n; + intarray[0] = y; + assertEquals(y, intarray[0]); +}); + +test(function construct() { + var a = new BigInt64Array([1n, -2n, {valueOf: () => 3n}]); + assertArrayEquals([1n, -2n, 3n], a); + assertThrows(() => new BigInt64Array([4, 5]), TypeError); + var b = new BigUint64Array([6n, -7n]); + assertArrayEquals([6n, 0xfffffffffffffff9n], b); + var c = new BigUint64Array(new BigInt64Array([8n, -9n])); + assertArrayEquals([8n, 0xfffffffffffffff7n], c); + var d = new BigInt64Array(new BigUint64Array([10n, 0xfffffffffffffff5n])); + assertArrayEquals([10n, -11n], d); + assertThrows(() => new BigInt64Array(new Int32Array([12, 13])), TypeError); + assertThrows(() => new Int32Array(new BigInt64Array([14n, -15n])), TypeError); +}); + +test_both(function copyWithin(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + a.copyWithin(0, 1, 3); + assertArrayEquals([2n, 3n, 3n], a); +}); + +test_both(function entries(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var it = a.entries(); + assertEquals([0, 1n], it.next().value); + assertEquals([1, 2n], it.next().value); + assertEquals([2, 3n], it.next().value); + assertTrue(it.next().done); +}); + +test_both(function every(BigArray) { + var a = BigArray.of(2n, 3n, 4n); + var seen = []; + assertTrue(a.every((x) => {seen.push(x); return x > 1n})); + assertEquals([2n, 3n, 4n], seen); +}); + +test_both(function fill(BigArray) { + var a = BigArray.of(1n, 2n, 3n, 4n); + a.fill(7n, 1, 3); + assertArrayEquals([1n, 7n, 7n, 4n], a); + assertThrows(() => (new BigArray(3).fill(1)), TypeError); +}); + +test_both(function filter(BigArray) { + var a = BigArray.of(1n, 3n, 4n, 2n); + var b = a.filter((x) => x > 2n); + assertArrayEquals([3n, 4n], b); +}); + +test_both(function find(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals(2n, a.find((x) => x === 2n)); + assertEquals(undefined, a.find((x) => x === 2)); +}); + +test_both(function findIndex(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals(1, a.findIndex((x) => x === 2n)); + assertEquals(-1, a.findIndex((x) => x === 2)); +}); + +test_both(function forEach(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var seen = []; + a.forEach((x) => seen.push(x)); + assertEquals([1n, 2n, 3n], seen); +}); + +test_both(function from(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var b = BigArray.from(a); + assertArrayEquals([1n, 2n, 3n], b); + assertThrows(() => BigArray.from([4, 5]), TypeError); + var c = BigArray.from([6, 7], BigInt); + assertArrayEquals([6n, 7n], c); + assertThrows(() => Int32Array.from([4n, 5n]), TypeError); + assertThrows(() => Int32Array.from([4, 5], BigInt), TypeError); +}); + +test(function from_mixed() { + var contents = [1n, 2n, 3n]; + var a = new BigInt64Array(contents); + var b = BigUint64Array.from(a); + assertArrayEquals(contents, b); + var c = BigInt64Array.from(b); + assertArrayEquals(contents, c); +}); + +test_both(function includes(BigArray) { + var a = BigArray.of(0n, 1n, 2n); + assertTrue(a.includes(1n)); + assertFalse(a.includes(undefined)); + assertFalse(a.includes(1)); + assertFalse(a.includes(0x1234567890abcdef123n)); // More than 64 bits. +}); + +test_both(function indexOf(BigArray) { + var a = BigArray.of(0n, 1n, 2n); + assertEquals(1, a.indexOf(1n)); + assertEquals(-1, a.indexOf(undefined)); + assertEquals(-1, a.indexOf(1)); + assertEquals(-1, a.indexOf(0x1234567890abcdef123n)); // More than 64 bits. +}); + +test_both(function join(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals("1-2-3", a.join("-")); +}); + +test_both(function keys(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var it = a.keys(); + assertEquals(0, it.next().value); + assertEquals(1, it.next().value); + assertEquals(2, it.next().value); + assertTrue(it.next().done); +}); + +test_both(function lastIndexOf(BigArray) { + var a = BigArray.of(0n, 1n, 2n); + assertEquals(1, a.lastIndexOf(1n)); + assertEquals(-1, a.lastIndexOf(undefined)); + assertEquals(-1, a.lastIndexOf(1)); + assertEquals(-1, a.lastIndexOf(0x1234567890abcdef123n)); // > 64 bits. +}); + +test_both(function map(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var b = a.map((x) => 2n * x); + assertEquals(BigArray, b.constructor); + assertArrayEquals([2n, 4n, 6n], b); +}); + +test_both(function of(BigArray) { + var a = BigArray.of(true, 2n, {valueOf: () => 3n}, "4"); + assertArrayEquals([1n, 2n, 3n, 4n], a); + assertThrows(() => BigArray.of(1), TypeError) + assertThrows(() => BigArray.of(undefined), TypeError) +}); + +test_both(function reduce(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals(6n, a.reduce((sum, x) => sum + x, 0n)); +}); + +test_both(function reduceRight(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals(6n, a.reduce((sum, x) => sum + x, 0n)); +}); + +test_both(function reverse(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + a.reverse(); + assertArrayEquals([3n, 2n, 1n], a); +}); + +test_both(function set(BigArray) { + var a = new BigArray(7); + a.set(BigArray.of(1n, 2n, 3n), 2); + assertArrayEquals([0n, 0n, 1n, 2n, 3n, 0n, 0n], a); + a.set([4n, 5n, 6n], 1); + assertArrayEquals([0n, 4n, 5n, 6n, 3n, 0n, 0n], a); + assertThrows(() => a.set([7, 8, 9], 3), TypeError); + assertThrows(() => a.set(Int32Array.of(10, 11), 2), TypeError); + + var Other = BigArray == BigInt64Array ? BigUint64Array : BigInt64Array; + a.set(Other.of(12n, 13n), 4); + assertArrayEquals([0n, 4n, 5n, 6n, 12n, 13n, 0n], a); +}); + +test_both(function slice(BigArray) { + var a = BigArray.of(1n, 2n, 3n, 4n); + var b = a.slice(1, 3); + assertArrayEquals([2n, 3n], b); +}); + +test_both(function some(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertTrue(a.some((x) => x === 2n)); +}); + +test_both(function sort(BigArray) { + var a = BigArray.of(7n, 2n, 5n, 3n); + a.sort(); + assertArrayEquals([2n, 3n, 5n, 7n], a); +}); + +test_both(function subarray(BigArray) { + var a = BigArray.of(1n, 2n, 3n, 4n); + var b = a.subarray(1, 3); + assertEquals(BigArray, b.constructor); + assertArrayEquals([2n, 3n], b); +}); + +test_both(function toString(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + assertEquals("1,2,3", a.toString()); +}); + +test_both(function values(BigArray) { + var a = BigArray.of(1n, 2n, 3n); + var it = a.values(); + assertEquals(1n, it.next().value); + assertEquals(2n, it.next().value); + assertEquals(3n, it.next().value); + assertTrue(it.next().done); +}); diff --git a/deps/v8/test/mjsunit/harmony/bigint/xor.js b/deps/v8/test/mjsunit/harmony/bigint/xor.js index d8c9012971..a934825bd9 100644 --- a/deps/v8/test/mjsunit/harmony/bigint/xor.js +++ b/deps/v8/test/mjsunit/harmony/bigint/xor.js @@ -7,96 +7,94 @@ // Flags: --harmony-bigint var data = [{ - a: "abde23cae3113c95ec7f444c7277658", - b: "-65e40fb1", - r: "-abde23cae3113c95ec7f444a2c379e9" + a: -0x46505bec40d461c595b5e4be178b7d00n, + b: -0x9170e5437d4e3ec7c0971e2c6d3bbbd2929ff108ea4ee64f7a91aa367fn, + r: 0x9170e5437d4e3ec7c0971e2c6d7deb897edf25692fdb53abc486214a81n }, { - a: "2d0bbdc05059c78b7e9f43689b2f7a9afaefd679212c2a9b990", - b: "29fcdb109b54650f9762b494916bc1cf14853430697febe7acf4327983ce0c6c4c183", - r: "29fcdb109b54650f974fbf29513b98089ffbab7301e4c49d360eddaffaef2046d7813" + a: -0x49171f24aa9660f7f854148018a8b03256200508n, + b: 0x75c2103e4e8e52d0311n, + r: -0x49171f24aa9660f7f85413dc39ab54dab30d0617n }, { - a: "b958dc77068d01811e031d6320df5e53823697be94f7654340b", - b: "-c1f5ca609a658e24fc33fec10a84b18fb745cb7c6", - r: "-b958dc77064cf44b7e9978ed04236dad433c130f1b4020883cf" + a: -0x3cde31210d299e4f6734f76c4f2df3056fn, + b: -0x402b7fe66d16877867f43n, + r: 0x3cde31210d299a4dd0ca91bd275a757a2cn }, { - a: "cf7319e3fe16912370c830906f88b", - b: "98d972f3c", - r: "cf7319e3fe16912370c8a8491d7b7" + a: 0x727n, + b: 0xe1c82371da63bdb801273077095be8977ff9f14aa619829bf4b418n, + r: 0xe1c82371da63bdb801273077095be8977ff9f14aa619829bf4b33fn }, { - a: "aea6d9e7cec74bca19", - b: "5abbcd0c5aa1f96fef9db32b3618de782db64b8f6b4", - r: "5abbcd0c5aa1f96fef9db32b3cf2b3e6515a3f33cad" + a: 0x7c2b1e0918a85bf5faea9077b7dn, + b: -0xed714ba58fd54b19n, + r: -0x7c2b1e0918a68ce140b26d23066n }, { - a: "-b522a022e90fa094f3b729a7a0a914349f5e1fd778829d7576ad36711", - b: "-aa00d2fd6a7636", - r: "b522a022e90fa094f3b729a7a0a914349f5e1fd778883d78597b91125" + a: 0x1dded5fd695f4babcan, + b: 0x7e1cb4346c68e84f8fbdd3501daead2ce99a90e56038n, + r: 0x7e1cb4346c68e84f8fbdd3501db373f914f3cfaecbf2n }, { - a: "9c2bc822ec4a590eb8a77ee630009713090", - b: "30b13459c1434", - r: "9c2bc822ec4a590eb8a77ed68134ced24a4" + a: 0xec7d9595de759652a3bb96c80edca63790c32ce7f6cf0ef0n, + b: -0x67f0feef424f56d6ae6856a20901199de53ebn, + r: -0xec7d9595de73e95d4d4fb23d63b640b2fae3bcf66f115d1bn }, { - a: "-f14873e1f6121d584d5541073c7ce162873e156b72fb3c943ffd5f212c0d6", - b: "f449f0a292048546924d2973626f5441c045d4adbfd00d301791f0db965f", - r: "-fe0cecebdf32550c247193900a5a14269b3a4821a9063c473e84402c9568b" + a: 0x69ab204291f752866c3d49fdf1d656298f43e896cea3ef31a04n, + b: -0x5f5b2fd130e33ed76fa22de5ac70bdf96dee80a09e3107e1c93a135ea80b7e3640cdn, + r: -0x5f5b2fd130e33ed769389fe1856fc8d10b2d543f412c628351ce2dd7c4e140c55ac9n }, { - a: "83d5552fba4213d8dd1ed9bc6c2", - b: "4f7ccc10ba9b6880b862f8d5e1c9", - r: "47419942413f49bd35b3154e270b" + a: -0xd396d40076en, + b: 0x3158623c80393n, + r: -0x318bf4e8804ffn }, { - a: "9fdb44741177921c8338b70fc7fa362295bfc92f6275fa16492", - b: "93676e5ef972", - r: "9fdb44741177921c8338b70fc7fa362295bfc92654031ff9de0" + a: 0x8c1dbfbd68007d171986777446303896a1ee46n, + b: -0x75fd69710f5bea1cece9d59ec4bca29712b49dcf5ee5cc3299d7fb4fb024f10ae955fn, + r: -0x75fd69710f5bea1cece9d59ec4bca29fd36f6619dee21d4301b08c0bd3277860f7b19n }, { - a: "4355637ed", - b: "-7aeb3013cc5eb39d56eed8104407a3e68039944f7673a0c75bd3", - r: "-7aeb3013cc5eb39d56eed8104407a3e68039944f767795916c40" + a: -0x4c6e3ccbabdd6f58450ec3ec8adfb10831b70893cb996f0ac97a0ae2f3a943185d1n, + b: 0xeb136731a19867949d46886e62050c4b446767a076c73dn, + r: -0x4c6e3ccbabdd6f58450ecd5dbcacab11b7ce4147a31f892a99bebea485d344742een }, { - a: "7fdf50188f716c13feced67a1c33ecf422", - b: "-7106cd7b9", - r: "-7fdf50188f716c13feced67a1b2380239b" + a: 0xeaff60e10ebb4b8f2da6a517n, + b: -0x17af62a3e808af1be3d864132dfd7363bc95872580585d7a9904n, + r: -0x17af62a3e808af1be3d864132dfd999cdc74899ecbd770dc3c15n }, { - a: "368cf8d0f5790a03774b9a1e116f82281ebd9e18de7f54a7d91f50", - b: "8bc4e4f24ce2a7d037079552e6c7db2795f15c92a01f4e0d9", - r: "368cf06cbb362ecd5d36996e683aac44630fe747cbb67ea62dff89" + a: -0xd4424b4f09210108076d63bd621180f280df8f4480n, + b: -0x20953185dd2c534b3cb8da73ce55ab386d62fe8a793a1e74cdf3ad95f3cc2573b3n, + r: 0x20953185dd2c534b3cb8da731a17e0776443ff827e577dc9afe22d677313aa37cdn }, { - a: "-7466a596078a20cc4eca96953e3", - b: "-666328e5437b1475dcfe2f44f1c6a82af82ce7ee7cf229c8398836d2d834f9014", - r: "666328e5437b1475dcfe2f44f1c6a82af82ce79a1a57bfcfb3a8fa9c12a26c3f1" + a: 0x84317d7ec6df6dbfe9413cee812ff95c587f61c7b8de5828d445a69555cff26fba9n, + b: -0x853c667aed62685df5993748e5668802b7bf918f8c1222a5267c33f013ff1e10f1b909n, + r: -0x8534256d3a8e05ab2e67a35b2b8e9afd227a16799069af40a4f177aa7aaa42efd742a2n }, { - a: "ad284b70a22d96bdefba53f134c65a1e4958013bb9a31f091fde6fc89", - b: "-c89374df2", - r: "-ad284b70a22d96bdefba53f134c65a1e4958013bb9a31f09d74d1b179" + a: -0xe3b4bf724b172b23c5834ed6f70f984ab3b146070770cbc3b86779db7n, + b: -0x68166de3a03d9efce30cb36e242db000c850c0d4f454594e23a1a7cn, + r: 0xe3dca91fa8b716bd39604265992bb5fab37916c7d3849f9af644d87cdn }, { - a: "-47df52354db5", - b: "-aa7f61aba9ad859e803e964418af30", - r: "aa7f61aba9ad859e807949162de29b" + a: -0x5358b8efb260b40e37cb5b45eb4e7864n, + b: -0x3e617e3967a5b3554ebf24f1e51a253dfc20a76ef01f02442fn, + r: 0x3e617e3967a5b3554eec7c490aa84589f2176c35b5f44c3c4dn }, { - a: "-f03ea80f22a3dc03f036b13f85faf5fb1", - b: "86e9110772d369fdd52b45a8fb22cea26cb73e908408f8a3cdf637f0042c8efdc11", - r: "-86e9110772d369fdd52b45a8fb22cea26c4700388b2a5b7fce0601413ba974083a2" + a: -0x702359917a8aceedc381n, + b: -0x714f08d9c29e9fc0044982eb2469707896265n, + r: 0x714f08d9c29e9fc0034bb77233c1dc964a1e4n }, { - a: "3603d29c8", - b: "f4849ec3ec3c352b", - r: "f4849ec08c011ce3" + a: -0x455ac38dn, + b: -0x6152562bf5b6f785abec41e8625bccd3bf3067225733dan, + r: 0x6152562bf5b6f785abec41e8625bccd3bf3067670df055n }, { - a: "e6668ed8eae8b4bb7bdf522d44e9f1bcf66", - b: "361cab4f5be1", - r: "e6668ed8eae8b4bb7bdf522e25234549487" + a: 0x47n, + b: 0xa3d30490286ddf5d4f4256n, + r: 0xa3d30490286ddf5d4f4211n }, { - a: "-d0395d", - b: "-4a8ee89d006d22a124070241caf5f4343bdfd30d12", - r: "4a8ee89d006d22a124070241caf5f4343bdf03344d" + a: -0x530cc599859ccdbbb3c1dcb46248a4474c63323cc58a7891da79e0322b91c795ac57n, + b: 0x2d986083244cd488657c947a952ae15b23d90ebbc34daan, + r: -0x530cc599859ccdbbb3c1dc99fa28276300b7ba59b91e0204f098bb11f29f7c56e1fdn }]; var error_count = 0; for (var i = 0; i < data.length; i++) { var d = data[i]; - var a = BigInt.parseInt(d.a, 16); - var b = BigInt.parseInt(d.b, 16); - var r = a ^ b; - if (d.r !== r.toString(16)) { - print("Input A: " + a.toString(16)); - print("Input B: " + b.toString(16)); + var r = d.a ^ d.b; + if (d.r !== r) { + print("Input A: " + d.a.toString(16)); + print("Input B: " + d.b.toString(16)); print("Result: " + r.toString(16)); print("Expected: " + d.r); print("Op: ^"); diff --git a/deps/v8/test/mjsunit/harmony/function-sent.js b/deps/v8/test/mjsunit/harmony/function-sent.js deleted file mode 100644 index cd0ca957a8..0000000000 --- a/deps/v8/test/mjsunit/harmony/function-sent.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-function-sent - - -{ - function* g() { return function.sent } - assertEquals({value: 42, done: true}, g().next(42)); -} - - -{ - function* g() { - try { - yield function.sent; - } finally { - yield function.sent; - return function.sent; - } - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: 2, done: false}, x.next(2)); - assertEquals({value: 3, done: true}, x.next(3)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: 2, done: false}, x.throw(2)); - assertEquals({value: 3, done: true}, x.next(3)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: 2, done: false}, x.return(2)); - assertEquals({value: 3, done: true}, x.next(3)); - } -} - - -{ - function* inner() { - try { - yield function.sent; - } finally { - return 23; - } - } - - function* g() { - yield function.sent; - yield* inner(); - return function.sent; - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: undefined, done: false}, x.next(2)); - assertEquals({value: 3, done: true}, x.next(3)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: undefined, done: false}, x.next(2)); - assertEquals({value: 42, done: true}, x.throw(42)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, x.next(1)); - assertEquals({value: undefined, done: false}, x.next(2)); - assertEquals({value: 23, done: true}, x.return(42)); - } -} - - -assertThrows("function f() { return function.sent }", SyntaxError); -assertThrows("() => { return function.sent }", SyntaxError); -assertThrows("() => { function.sent }", SyntaxError); -assertThrows("() => function.sent", SyntaxError); -assertThrows("({*f() { function.sent }})", SyntaxError); -assertDoesNotThrow("({*f() { return function.sent }})"); diff --git a/deps/v8/test/mjsunit/harmony/function-tostring.js b/deps/v8/test/mjsunit/harmony/function-tostring.js index 949ac2282f..8fccf0dacd 100644 --- a/deps/v8/test/mjsunit/harmony/function-tostring.js +++ b/deps/v8/test/mjsunit/harmony/function-tostring.js @@ -122,3 +122,25 @@ testDynamicFunction("a, b", "return a"); testDynamicFunction("a,/*A*/b", "return a"); testDynamicFunction("/*A*/a,b", "return a"); testDynamicFunction("a,b", "return a/*A*/"); + +// Proxies of functions should not throw, but return a NativeFunction. +assertEquals("function () { [native code] }", + new Proxy(function () { hidden }, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(() => { hidden }, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(class {}, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(function() { hidden }.bind({}), {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(function*() { hidden }, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(async function() { hidden }, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy(async function*() { hidden }, {}).toString()); +assertEquals("function () { [native code] }", + new Proxy({ method() { hidden } }.method, {}).toString()); + +// Non-callable proxies still throw. +assertThrows(() => Function.prototype.toString.call(new Proxy({}, {})), + TypeError); diff --git a/deps/v8/test/mjsunit/harmony/private-fields-ic.js b/deps/v8/test/mjsunit/harmony/private-fields-ic.js new file mode 100644 index 0000000000..e7889b1e7b --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/private-fields-ic.js @@ -0,0 +1,294 @@ +// 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-private-fields + +{ + class X { + #x = 1; + getX(arg) { return arg.#x; } + setX(arg, val) { arg.#x = val; } + } + + let x1 = new X; + let y = new class {}; + + // IC: 0 -> Error + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + + assertThrows(() => x1.setX(y, 2), TypeError); + assertThrows(() => x1.setX(y, 3), TypeError); + assertThrows(() => x1.setX(y, 4), TypeError); + + // IC: 0 -> Monomorphic + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + + x1.setX(x1, 2); + x1.setX(x1, 3); + x1.setX(x1, 4); +} + +{ + class X { + #x = 1; + getX(arg) { return arg.#x; } + setX(arg, val) { arg.#x = val; } + } + + let x1 = new X; + // IC: 0 -> Monomorphic + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + + x1.setX(x1, 2); + x1.setX(x1, 3); + x1.setX(x1, 4); + + let y = new class {}; + // IC: Monomorphic -> Error + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + + assertThrows(() => x1.setX(y, 2), TypeError); + assertThrows(() => x1.setX(y, 3), TypeError); + assertThrows(() => x1.setX(y, 4), TypeError); + + let x3 = new X; + // IC: Monomorphic -> Monomorphic + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + + x1.setX(x3, 2); + x1.setX(x3, 3); + x1.setX(x3, 4); +} + + +{ + class X { + #x = 1; + getX(arg) { return arg.#x; } + setX(arg, val) { arg.#x = val; } + } + + let x1 = new X; + // IC: 0 -> Monomorphic + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + + x1.setX(x1, 2); + x1.setX(x1, 3); + x1.setX(x1, 4); + + class X2 extends X { + #x2 = 2; + } + + let x2 = new X2; + // IC: Monomorphic -> Polymorphic + assertEquals(1, x1.getX(x2)); + assertEquals(1, x1.getX(x2)); + assertEquals(1, x1.getX(x2)); + + x1.setX(x2, 2); + x1.setX(x2, 3); + x1.setX(x2, 4); + + let y = new class {}; + + // IC: Polymorphic -> Error + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + + assertThrows(() => x1.setX(y, 2), TypeError); + assertThrows(() => x1.setX(y, 3), TypeError); + assertThrows(() => x1.setX(y, 4), TypeError); + + class X3 extends X { + #x3 = 2; + } + + let x3 = new X3; + // IC: Polymorphic -> Polymorphic + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + + x1.setX(x3, 2); + x1.setX(x3, 3); + x1.setX(x3, 4); +} + +{ + class X { + #x = 1; + getX(arg) { return arg.#x; } + setX(arg, val) { arg.#x = val; } + } + + let x1 = new X; + // IC: 0 -> Monomorphic + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + assertEquals(1, x1.getX(x1)); + + x1.setX(x1, 2); + x1.setX(x1, 3); + x1.setX(x1, 4); + + class X2 extends X { + #x2 = 2; + } + + let x2 = new X2; + // IC: Monomorphic -> Polymorphic + assertEquals(1, x1.getX(x2)); + assertEquals(1, x1.getX(x2)); + assertEquals(1, x1.getX(x2)); + + x1.setX(x2, 2); + x1.setX(x2, 3); + x1.setX(x2, 4); + + class X3 extends X { + #x3 = 2; + } + + let x3 = new X3; + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + assertEquals(1, x1.getX(x3)); + + x1.setX(x3, 2); + x1.setX(x3, 3); + x1.setX(x3, 4); + + + class X4 extends X { + #x4 = 2; + } + + let x4 = new X4; + assertEquals(1, x1.getX(x4)); + assertEquals(1, x1.getX(x4)); + assertEquals(1, x1.getX(x4)); + + x1.setX(x4, 2); + x1.setX(x4, 3); + x1.setX(x4, 4); + + class X5 extends X { + #x5 = 2; + } + + let x5 = new X5; + // IC: Polymorphic -> Megamorphic + assertEquals(1, x1.getX(x5)); + assertEquals(1, x1.getX(x5)); + assertEquals(1, x1.getX(x5)); + + x1.setX(x5, 2); + x1.setX(x5, 3); + x1.setX(x5, 4); + + let y = new class {}; + + // IC: Megamorphic -> Error + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + assertThrows(() => x1.getX(y), TypeError); + + assertThrows(() => x1.setX(y, 2), TypeError); + assertThrows(() => x1.setX(y, 3), TypeError); + assertThrows(() => x1.setX(y, 4), TypeError); + + class X6 extends X { + #x6 = 2; + } + + let x6 = new X6; + // IC: Megamorphic -> Megamorphic + assertEquals(1, x1.getX(x6)); + assertEquals(1, x1.getX(x6)); + assertEquals(1, x1.getX(x6)); + + x1.setX(x6, 2); + x1.setX(x6, 3); + x1.setX(x6, 4); +} + +{ + class C { + #a = 1; + getA() { return this.#a; } + setA(v) { this.#a = v; } + } + + let p = new Proxy(new C, { + get(target, name) { + return target[name]; + }, + + set(target, name, val) { + target[name] = val; + } + }); + + assertThrows(() => p.getA(), TypeError); + assertThrows(() => p.getA(), TypeError); + assertThrows(() => p.getA(), TypeError); + + assertThrows(() => p.setA(2), TypeError); + assertThrows(() => p.setA(3), TypeError); + assertThrows(() => p.setA(4), TypeError); + + let x = new Proxy(new C, {}); + assertThrows(() => x.getA(), TypeError); + assertThrows(() => x.getA(), TypeError); + assertThrows(() => x.getA(), TypeError); + + assertThrows(() => x.setA(2), TypeError); + assertThrows(() => x.setA(3), TypeError); + assertThrows(() => x.setA(4), TypeError); +} + +{ + class A { + constructor(arg) { + return arg; + } + } + + class X extends A { + #x = 1; + + constructor(arg) { + super(arg); + } + + getX(arg) { return arg.#x; } + + setX(arg, val) { arg.#x = val; } + } + + let proxy = new Proxy({}, {}); + let x = new X(proxy); + + assertEquals(1, X.prototype.getX(proxy)); + assertEquals(1, X.prototype.getX(proxy)); + assertEquals(1, X.prototype.getX(proxy)); + + X.prototype.setX(proxy, 2); + X.prototype.setX(proxy, 3); + X.prototype.setX(proxy, 4); +} diff --git a/deps/v8/test/mjsunit/harmony/private-fields-special-object.js b/deps/v8/test/mjsunit/harmony/private-fields-special-object.js new file mode 100644 index 0000000000..309143d904 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/private-fields-special-object.js @@ -0,0 +1,49 @@ +// 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-private-fields --allow-natives-syntax + +async function f(assert) { + try { + module_namespace_obj = await import('modules-skip-1.js'); + } catch(e) { + %AbortJS(e); + } + + class A { + constructor(arg) { + return arg; + } + } + + class X extends A { + #x = 1; + + constructor(arg) { + super(arg); + } + + getX(arg) { + return arg.#x; + } + + setX(arg, val) { arg.#x = val; } + } + + let x = new X(module_namespace_obj); + + assert.equals(1, X.prototype.getX(module_namespace_obj)); + assert.equals(1, X.prototype.getX(module_namespace_obj)); + assert.equals(1, X.prototype.getX(module_namespace_obj)); + + X.prototype.setX(module_namespace_obj, 2); + X.prototype.setX(module_namespace_obj, 3); + X.prototype.setX(module_namespace_obj, 4); +} + +testAsync(assert => { + assert.plan(3); + + f(assert).catch(assert.unreachable); +}, "private-fields-special-object"); diff --git a/deps/v8/test/mjsunit/harmony/private-fields.js b/deps/v8/test/mjsunit/harmony/private-fields.js new file mode 100644 index 0000000000..5edf606407 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/private-fields.js @@ -0,0 +1,441 @@ +// 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-private-fields --allow-natives-syntax + + +"use strict"; + +// TODO(gsathya): Missing tests: +// (d) tests involving eval +{ + class C { + #a; + getA() { return this.#a; } + } + + assertEquals(undefined, C.a); + + let c = new C; + assertEquals(undefined, c.a); + assertEquals(undefined, c.getA()); +} + +{ + class C { + #a = 1; + getA() { return this.#a; } + } + + assertEquals(undefined, C.a); + + let c = new C; + assertEquals(undefined, c.a); + assertEquals(1, c.getA()); +} + +{ + class C { + #a = 1; + #b = this.#a; + getB() { return this.#b; } + } + + let c = new C; + assertEquals(1, c.getB()); +} + +{ + class C { + #a = 1; + getA() { return this.#a; } + constructor() { + assertEquals(1, this.#a); + this.#a = 5; + } + } + + let c = new C; + assertEquals(5, c.getA()); +} + +{ + class C { + #a = this; + #b = () => this; + getA() { return this.#a; } + getB() { return this.#b; } + } + + let c1 = new C; + assertSame(c1, c1.getA()); + assertSame(c1, c1.getB()()); + let c2 = new C; + assertSame(c1, c1.getB().call(c2)); +} + +{ + class C { + #a = this; + #b = function() { return this; }; + getA() { return this.#a; } + getB() { return this.#b; } + } + + let c1 = new C; + assertSame(c1, c1.getA()); + assertSame(c1, c1.getB().call(c1)); + let c2 = new C; + assertSame(c2, c1.getB().call(c2)); +} + + +{ + class C { + #a = function() { return 1 }; + getA() {return this.#a;} + } + + let c = new C; + assertEquals('#a', c.getA().name); +} + +{ + let d = function() { return new.target; } + class C { + #c = d; + getC() { return this.#c; } + } + + let c = new C; + assertEquals(undefined, c.getC()()); + assertSame(new d, new (c.getC())); +} + +{ + class C { + #b = new.target; + #c = () => new.target; + getB() { return this.#b; } + getC() { return this.#c; } + } + + let c = new C; + assertEquals(undefined, c.getB()); + assertEquals(undefined, c.getC()()); +} + +{ + class C { + #a = 1; + #b = () => this.#a; + getB() { return this.#b; } + } + + let c1 = new C; + assertSame(1, c1.getB()()); +} + +{ + class C { + #a = 1; + getA(instance) { return instance.#a; } + } + + class B { } + let c = new C; + assertEquals(undefined, c.a); + assertEquals(1, c.getA(c)); + + assertThrows(() => c.getA(new B), TypeError); +} + +{ + class A { + #a = 1; + getA() { return this.#a; } + } + + class B extends A {} + let b = new B; + assertEquals(1, b.getA()); +} + +{ + let prototypeLookup = false; + class A { + set a(val) { + prototypeLookup = true; + } + + get a() { return undefined; } + } + + class C extends A { + #a = 1; + getA() { return this.#a; } + } + + let c = new C; + assertEquals(1, c.getA()); + assertEquals(false, prototypeLookup); +} + +{ + class A { + constructor() { this.a = 1; } + } + + class B extends A { + #b = this.a; + getB() { return this.#b; } + } + + let b = new B; + assertEquals(1, b.getB()); +} + +{ + class A { + #a = 1; + getA() { return this.#a; } + } + + class B extends A { + #b = super.getA(); + getB() { return this.#b; } + } + + let b = new B; + assertEquals(1, b.getB()); +} + +{ + class A { + #a = 1; + getA() { return this.#a;} + } + + class B extends A { + #a = 2; + get_A() { return this.#a;} + } + + let a = new A; + let b = new B; + assertEquals(1, a.getA()); + assertEquals(1, b.getA()); + assertEquals(2, b.get_A()); +} + +{ + let foo = undefined; + class A { + #a = 1; + constructor() { + foo = this.#a; + } + } + + let a = new A; + assertEquals(1, foo); +} + +{ + let foo = undefined; + class A extends class {} { + #a = 1; + constructor() { + super(); + foo = this.#a; + } + } + + let a = new A; + assertEquals(1, foo); +} + +{ + function makeClass() { + return class { + #a; + setA(val) { this.#a = val; } + getA() { return this.#a; } + } + } + + let classA = makeClass(); + let a = new classA; + let classB = makeClass(); + let b = new classB; + + assertEquals(undefined, a.getA()); + assertEquals(undefined, b.getA()); + + a.setA(3); + assertEquals(3, a.getA()); + assertEquals(undefined, b.getA()); + + b.setA(5); + assertEquals(3, a.getA()); + assertEquals(5, b.getA()); + + assertThrows(() => a.getA.call(b), TypeError); + assertThrows(() => b.getA.call(a), TypeError); +} + +{ + let value = undefined; + + new class { + #a = 1; + getA() { return this.#a; } + + constructor() { + new class { + #a = 2; + constructor() { + value = this.#a; + } + } + } + } + + assertEquals(2, value); +} + +{ + class A { + #a = 1; + b = class { + getA() { return this.#a; } + get_A(val) { return val.#a; } + } + } + + let a = new A(); + let b = new a.b; + assertEquals(1, b.getA.call(a)); + assertEquals(1, b.get_A(a)); +} + +{ + class C { + b = this.#a; + #a = 1; + } + + assertThrows(() => new C, TypeError); +} + +{ + class C { + #b = this.#a; + #a = 1; + } + + assertThrows(() => new C, TypeError); +} + +{ + let symbol = Symbol(); + + class C { + #a = 1; + [symbol] = 1; + getA() { return this.#a; } + setA(val) { this.#a = val; } + } + + var p = new Proxy(new C, { + get: function(target, name) { + if (typeof(arg) === 'symbol') { + assertFalse(%SymbolIsPrivate(name)); + } + return target[name]; + } + }); + + assertThrows(() => p.getA(), TypeError); + assertThrows(() => p.setA(1), TypeError); + assertEquals(1, p[symbol]); +} + +{ + class C { + #b = Object.freeze(this); + #a = 1; + getA() { return this.#a; } + } + + let c = new C; + assertEquals(1, c.getA()); +} + +{ + class C { + #a = 1; + setA(another, val) { another.#a = val; } + getA(another) { return another.#a; } + } + + let c = new C; + assertThrows(() => c.setA({}, 2), TypeError); + c.setA(c, 3); + assertEquals(3, c.getA(c)); +} + +{ + class A { + constructor(arg) { + return arg; + } + } + + class C extends A { + #x = 1; + + constructor(arg) { + super(arg); + } + + getX(arg) { + return arg.#x; + } + } + + let leaker = new Proxy({}, {}); + let c = new C(leaker); + assertEquals(1, C.prototype.getX(leaker)); + assertSame(c, leaker); + + c = new C(); + assertThrows(() => new C(c), TypeError); + + new C(1); +} + +{ + class C { + #a = 1; + b; + getA() { return this.b().#a; } + } + + let c = new C(); + c.b = () => c; + assertEquals(1, c.getA()); +} + +{ + class C { + #a = 1; + b; + getA(arg) { return arg.b().#a; } + } + + let c = new C(); + c.b = () => c; + assertEquals(1, c.getA(c)); +} diff --git a/deps/v8/test/mjsunit/harmony/private.js b/deps/v8/test/mjsunit/harmony/private.js index 39376f3ea9..c4306c516c 100644 --- a/deps/v8/test/mjsunit/harmony/private.js +++ b/deps/v8/test/mjsunit/harmony/private.js @@ -57,8 +57,6 @@ function TestType() { assertEquals("symbol", typeof symbols[i]) assertTrue(typeof symbols[i] === "symbol") assertTrue(%SymbolIsPrivate(symbols[i])) - assertEquals(null, %_ClassOf(symbols[i])) - assertEquals("Symbol", %_ClassOf(Object(symbols[i]))) } } TestType() diff --git a/deps/v8/test/mjsunit/keyed-store-array-literal.js b/deps/v8/test/mjsunit/keyed-store-array-literal.js new file mode 100644 index 0000000000..6892a8fd18 --- /dev/null +++ b/deps/v8/test/mjsunit/keyed-store-array-literal.js @@ -0,0 +1,75 @@ +// 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 f1() { + const x = [,]; + x[1] = 42; + assertEquals([undefined, 42], x); +} + +f1(); +f1(); +%OptimizeFunctionOnNextCall(f1); +f1(); +f1(); + + +function f2() { + const x = [0]; + for (const y of [1, 2, 3, 4]) { + x[x.length] = y; + } + assertEquals([0, 1, 2, 3, 4], x); +} + +f2(); +f2(); +%OptimizeFunctionOnNextCall(f2); +f2(); +f2(); + + +function f3() { + const x = [0]; + for (const y of [1.1, {}]) { + x[x.length] = y; + } + assertEquals([0, 1.1, {}], x); +} + +f3(); +f3(); +%OptimizeFunctionOnNextCall(f3); +f3(); +f3(); + + +function f4(x) { + x[x.length] = x.length; +} + +let x1 = []; +f4(x1); +assertEquals([0], x1); +f4(x1); +assertEquals([0, 1], x1); +%OptimizeFunctionOnNextCall(f4); +f4(x1); +assertEquals([0, 1, 2], x1); +f4(x1); +assertEquals([0, 1, 2, 3], x1); + +let x2 = {length: 42}; +f4(x2); +assertEquals(42, x2[42]); +f4(x2); +assertEquals(42, x2[42]); +%OptimizeFunctionOnNextCall(f4); +f4(x2); +assertEquals(42, x2[42]); +f4(x2); +assertEquals(42, x2[42]); diff --git a/deps/v8/test/mjsunit/math-deopt.js b/deps/v8/test/mjsunit/math-deopt.js new file mode 100644 index 0000000000..b5fff7d149 --- /dev/null +++ b/deps/v8/test/mjsunit/math-deopt.js @@ -0,0 +1,70 @@ +// 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 --no-always-opt + +(()=> { + function f(a) { + return Math.abs(a); + } + f(1); + f(1); + %OptimizeFunctionOnNextCall(f); + f("100"); + %OptimizeFunctionOnNextCall(f); + f("100"); + assertOptimized(f); +})(); + +(()=> { + function f(a) { + return Math.min(1,a); + } + f(1); + f(1); + %OptimizeFunctionOnNextCall(f); + f("100"); + %OptimizeFunctionOnNextCall(f); + f("100"); + assertOptimized(f); +})(); + +(()=> { + function f(a) { + return Math.pow(a,10); + } + f(1); + f(1); + %OptimizeFunctionOnNextCall(f); + f("100"); + %OptimizeFunctionOnNextCall(f); + f("100"); + assertOptimized(f); +})(); + +(()=> { + function f(a) { + return Math.clz32(a); + } + f(1); + f(1); + %OptimizeFunctionOnNextCall(f); + f("100"); + %OptimizeFunctionOnNextCall(f); + f("100"); + assertOptimized(f); +})(); + +(()=> { + function f(a) { + return Math.imul(a, 10); + } + f(1); + f(1); + %OptimizeFunctionOnNextCall(f); + f("100"); + %OptimizeFunctionOnNextCall(f); + f("100"); + assertOptimized(f); +})(); diff --git a/deps/v8/test/mjsunit/mjsunit.gyp b/deps/v8/test/mjsunit/mjsunit.gyp deleted file mode 100644 index e0a7469248..0000000000 --- a/deps/v8/test/mjsunit/mjsunit.gyp +++ /dev/null @@ -1,26 +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. - -{ - 'conditions': [ - ['test_isolation_mode != "noop"', { - 'targets': [ - { - 'target_name': 'mjsunit_run', - 'type': 'none', - 'dependencies': [ - '../../src/d8.gyp:d8_run', - ], - 'includes': [ - '../../gypfiles/features.gypi', - '../../gypfiles/isolate.gypi', - ], - 'sources': [ - 'mjsunit.isolate', - ], - }, - ], - }], - ], -} diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 10cf527f30..e51f2a9910 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -55,6 +55,9 @@ MjsUnitAssertionError.prototype.toString = function () { // For known primitive values, please use assertEquals. var assertSame; +// Inverse of assertSame. +var assertNotSame; + // Expected and found values are identical primitive values or functions // or similarly structured objects (checking internal properties // of, e.g., Number and Date objects, the elements of arrays @@ -166,9 +169,6 @@ var isInterpreted; // Returns true if given function is optimized. var isOptimized; -// Returns true if given function is compiled by Crankshaft. -var isCrankshafted; - // Returns true if given function is compiled by TurboFan. var isTurboFanned; @@ -178,6 +178,8 @@ var testAsync; // Monkey-patchable all-purpose failure handler. var failWithMessage; +// Returns a pretty-printed string representation of the passed value. +var prettyPrinted; (function () { // Scope for utility functions. @@ -224,7 +226,7 @@ var failWithMessage; } - function PrettyPrint(value) { + prettyPrinted = function prettyPrinted(value) { switch (typeof value) { case "string": return JSON.stringify(value); @@ -247,11 +249,12 @@ var failWithMessage; case "String": case "Boolean": case "Date": - return objectClass + "(" + PrettyPrint(ValueOf(value)) + ")"; + return objectClass + "(" + prettyPrinted(ValueOf(value)) + ")"; case "RegExp": return RegExpPrototypeToString.call(value); case "Array": - var mapped = ArrayPrototypeMap.call(value, PrettyPrintArrayElement); + var mapped = ArrayPrototypeMap.call( + value, prettyPrintedArrayElement); var joined = ArrayPrototypeJoin.call(mapped, ","); return "[" + joined + "]"; case "Uint8Array": @@ -279,9 +282,9 @@ var failWithMessage; } - function PrettyPrintArrayElement(value, index, array) { + function prettyPrintedArrayElement(value, index, array) { if (value === undefined && !(index in array)) return ""; - return PrettyPrint(value); + return prettyPrinted(value); } @@ -296,7 +299,7 @@ var failWithMessage; message += " (" + name_opt + ")"; } - var foundText = PrettyPrint(found); + var foundText = prettyPrinted(found); if (expectedText.length <= 40 && foundText.length <= 40) { message += ": expected <" + expectedText + "> found <" + foundText + ">"; } else { @@ -372,19 +375,29 @@ var failWithMessage; } else if ((expected !== expected) && (found !== found)) { return; } - fail(PrettyPrint(expected), found, name_opt); + fail(prettyPrinted(expected), found, name_opt); }; + assertNotSame = function assertNotSame(expected, found, name_opt) { + // TODO(mstarzinger): We should think about using Harmony's egal operator + // or the function equivalent Object.is() here. + if (found !== expected) { + if (expected === 0 || (1 / expected) !== (1 / found)) return; + } else if (!((expected !== expected) && (found !== found))) { + return; + } + fail(prettyPrinted(expected), found, name_opt); + } assertEquals = function assertEquals(expected, found, name_opt) { if (!deepEquals(found, expected)) { - fail(PrettyPrint(expected), found, name_opt); + fail(prettyPrinted(expected), found, name_opt); } }; assertNotEquals = function assertNotEquals(expected, found, name_opt) { if (deepEquals(found, expected)) { - fail("not equals to " + PrettyPrint(expected), found, name_opt); + fail("not equals to " + prettyPrinted(expected), found, name_opt); } }; @@ -392,7 +405,7 @@ var failWithMessage; assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt) { if (Math.abs(expected - found) > delta) { - fail(PrettyPrint(expected) + " +- " + PrettyPrint(delta), found, name_opt); + fail(prettyPrinted(expected) + " +- " + prettyPrinted(delta), found, name_opt); } }; @@ -499,7 +512,7 @@ var failWithMessage; if (typeof actualConstructor === "function") { actualTypeName = actualConstructor.name || String(actualConstructor); } - failWithMessage("Object <" + PrettyPrint(obj) + "> is not an instance of <" + + failWithMessage("Object <" + prettyPrinted(obj) + "> is not an instance of <" + (type.name || type) + ">" + (actualTypeName ? " but of <" + actualTypeName + ">" : "")); } @@ -657,14 +670,6 @@ var failWithMessage; return (opt_status & V8OptimizationStatus.kOptimized) !== 0; } - isCrankshafted = function isCrankshafted(fun) { - var opt_status = OptimizationStatus(fun, ""); - assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, - "not a function"); - return (opt_status & V8OptimizationStatus.kOptimized) !== 0 && - (opt_status & V8OptimizationStatus.kTurboFanned) === 0; - } - isTurboFanned = function isTurboFanned(fun) { var opt_status = OptimizationStatus(fun, ""); assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, @@ -779,7 +784,7 @@ var failWithMessage; equals(expected, found, name_opt) { this.actualAsserts_++; if (!deepEquals(expected, found)) { - this.fail(PrettyPrint(expected), found, name_opt); + this.fail(prettyPrinted(expected), found, name_opt); } } diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index ebcdad1852..c3f6b22f89 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -87,7 +87,7 @@ 'array-constructor': [PASS, SLOW, ['arch == arm and simulator == True', SKIP]], # Very slow test - 'regress/regress-crbug-808192' : [PASS, NO_VARIANTS, ['arch == arm or arch == arm64 or arch == android_arm or arch == android_arm64 or arch == mipsel or arch == mips64el or arch == mips64 or arch == mips', SKIP]], + 'regress/regress-crbug-808192' : [PASS, SLOW, NO_VARIANTS, ['arch == arm or arch == arm64 or arch == android_arm or arch == android_arm64 or arch == mipsel or arch == mips64el or arch == mips64 or arch == mips or arch == s390 or arch == s390x or arch == ppc or arch == ppc64', SKIP]], # Very slow on ARM and MIPS, contains no architecture dependent code. 'unicode-case-overoptimization': [PASS, NO_VARIANTS, ['arch == arm or arch == arm64 or arch == android_arm or arch == android_arm64 or arch == mipsel or arch == mips64el or arch == mips64 or arch == mips', SKIP]], @@ -104,6 +104,7 @@ 'generated-transition-stub': [PASS, ['mode == debug', SKIP]], 'migrations': [SKIP], 'array-functions-prototype-misc': [PASS, SLOW, ['mode == debug', SKIP]], + 'compiler/regress-808472': [PASS, ['mode == debug', SKIP]], ############################################################################## # This test sets the umask on a per-process basis and hence cannot be @@ -159,7 +160,6 @@ 'regress/regress-605470': [PASS, SLOW], 'regress/regress-655573': [PASS, SLOW], 'regress/regress-1200351': [PASS, SLOW], - 'regress/regress-crbug-474297': [PASS, ['gc_stress == False', SKIP]], 'wasm/embenchen/*': [PASS, SLOW], 'wasm/unreachable-validation': [PASS, SLOW], @@ -242,6 +242,10 @@ 'unicode-test': [SKIP], 'whitespaces': [SKIP], + # Unsuitable for GC stress because coverage information is lost on GC. + 'code-coverage-ad-hoc': [SKIP], + 'code-coverage-precise': [SKIP], + # TODO(mstarzinger): Takes too long with TF. 'array-sort': [PASS, NO_VARIANTS], 'regress/regress-91008': [PASS, NO_VARIANTS], @@ -409,6 +413,7 @@ # Too slow. 'harmony/regexp-property-lu-ui': [SKIP], + 'regress/regress-165637': [SKIP], # Flaky with baseline? 'regress/regress-2185-2': [SKIP], @@ -633,16 +638,57 @@ 'shared-function-tier-up-turbo': [SKIP], # Fails deopt_fuzzer due to --deopt_every_n_times - 'es6/array-iterator-turbo': [SKIP] + 'es6/array-iterator-turbo': [SKIP], + + # BUG(v8:7466). + 'compiler/promise-constructor': [SKIP], }], # 'deopt_fuzzer == True' ############################################################################## -['gc_fuzzer == True', { +['gc_fuzzer', { 'regress/regress-336820': [SKIP], 'regress/regress-748069': [SKIP], 'regress/regress-778668': [SKIP], 'ignition/regress-672027': [PASS, ['tsan', SKIP]], -}], # 'gc_fuzzer == True' + 'string-replace-gc': [PASS, SLOW, ['mode == debug', SKIP]], + + # Unsuitable for GC fuzzing because coverage information is lost on GC. + 'code-coverage-ad-hoc': [SKIP], + 'code-coverage-precise': [SKIP], + + # Fails allocation on tsan. + 'es6/classes': [PASS, ['tsan', SKIP]], + + # Tests that fail some assertions due to checking internal state sensitive + # to GC. We mark PASS,FAIL to not skip those tests on the endurance fuzzer. + 'array-literal-feedback': [PASS, FAIL], + 'compiler/native-context-specialization-hole-check': [PASS, FAIL], + 'elements-transition-hoisting': [PASS, FAIL], + 'es6/collections-constructor-custom-iterator': [PASS, FAIL], + 'keyed-load-with-symbol-key': [PASS, FAIL], + 'regress/regress-3709': [PASS, FAIL], + 'regress/regress-trap-allocation-memento': [PASS, FAIL], + 'regress/regress-unlink-closures-on-deopt': [PASS, FAIL], + 'shared-function-tier-up-turbo': [PASS, FAIL], +}], # 'gc_fuzzer' + +############################################################################## +['endurance_fuzzer', { + # BUG(v8:7400). + 'wasm/lazy-compilation': [SKIP], + + # BUG(v8:7429). + 'regress/regress-599414-array-concat-fast-path': [SKIP], + + # Often crashes due to memory consumption. + 'regress/regress-655573': [SKIP], + + # TSAN allocation failures. + 'deep-recursion': [PASS, ['tsan', SKIP]], + 'regress/regress-430201b': [PASS, ['tsan', SKIP]], + 'regress/regress-crbug-493779': [PASS, ['tsan', SKIP]], + 'regress/wasm/regress-763439': [PASS, ['tsan', SKIP]], +}], # 'endurance_fuzzer' ############################################################################## ['predictable == True', { @@ -654,6 +700,8 @@ # BUG(v8:7166). 'd8/enable-tracing': [SKIP], + # Relies on async compilation which requires background tasks. + 'wasm/streaming-error-position': [SKIP], }], # 'predictable == True' ############################################################################## diff --git a/deps/v8/test/mjsunit/mjsunit_suppressions.js b/deps/v8/test/mjsunit/mjsunit_suppressions.js new file mode 100644 index 0000000000..1bd466993f --- /dev/null +++ b/deps/v8/test/mjsunit/mjsunit_suppressions.js @@ -0,0 +1,9 @@ +// 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. + + +// This turns all mjsunit asserts into no-ops used for fuzzing. +(function () { + failWithMessage = function () {} +})(); diff --git a/deps/v8/test/mjsunit/optimized-reduce.js b/deps/v8/test/mjsunit/optimized-reduce.js new file mode 100644 index 0000000000..efcb7ccd1c --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-reduce.js @@ -0,0 +1,49 @@ +// 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 --expose-gc --turbo-inline-array-builtins +// Flags: --opt --no-always-opt + +// Make sure we gracefully handle the case of an empty array in +// optimized code. +(function() { + var nothingThere = function(only_holes) { + var a = [1,2,,3]; // holey smi array. + if (only_holes) { + a = [,,,]; // also a holey smi array. + } + return a.reduce((r,v,i,o)=>r+v); + } + nothingThere(); + nothingThere(); + %OptimizeFunctionOnNextCall(nothingThere); + assertThrows(() => nothingThere(true)); +})(); + +// An error generated inside the callback includes reduce in it's +// stack trace. +(function() { + var re = /Array\.reduce/; + var alwaysThrows = function() { + var b = [,,,]; + var result = 0; + var callback = function(r,v,i,o) { + return r + v; + }; + b.reduce(callback); + } + try { + alwaysThrows(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } + try { alwaysThrows(); } catch (e) {} + try { alwaysThrows(); } catch (e) {} + %OptimizeFunctionOnNextCall(alwaysThrows); + try { + alwaysThrows(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } +})(); diff --git a/deps/v8/test/mjsunit/optimized-reduceright.js b/deps/v8/test/mjsunit/optimized-reduceright.js new file mode 100644 index 0000000000..2689a39de5 --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-reduceright.js @@ -0,0 +1,49 @@ +// 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 --expose-gc --turbo-inline-array-builtins +// Flags: --opt --no-always-opt + +// Make sure we gracefully handle the case of an empty array in +// optimized code. +(function() { + var nothingThere = function(only_holes) { + var a = [1,2,,3]; // holey smi array. + if (only_holes) { + a = [,,,]; // also a holey smi array. + } + return a.reduceRight((r,v,i,o)=>r+v); + } + nothingThere(); + nothingThere(); + %OptimizeFunctionOnNextCall(nothingThere); + assertThrows(() => nothingThere(true)); +})(); + +// An error generated inside the callback includes reduce in it's +// stack trace. +(function() { + var re = /Array\.reduceRight/; + var alwaysThrows = function() { + var b = [,,,]; + var result = 0; + var callback = function(r,v,i,o) { + return r + v; + }; + b.reduceRight(callback); + } + try { + alwaysThrows(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } + try { alwaysThrows(); } catch (e) {} + try { alwaysThrows(); } catch (e) {} + %OptimizeFunctionOnNextCall(alwaysThrows); + try { + alwaysThrows(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-2470.js b/deps/v8/test/mjsunit/regress/regress-2470.js index cba1b06c3e..708af54ca3 100644 --- a/deps/v8/test/mjsunit/regress/regress-2470.js +++ b/deps/v8/test/mjsunit/regress/regress-2470.js @@ -46,4 +46,4 @@ assertThrows('Function("a", "", "//", "//")', SyntaxError); // Some embedders rely on the string representation of the resulting // function in cases where no formal parameters are specified. var asString = Function("return 23").toString(); -assertSame("function anonymous() {\nreturn 23\n}", asString); +assertSame("function anonymous(\n) {\nreturn 23\n}", asString); diff --git a/deps/v8/test/mjsunit/regress/regress-5010.js b/deps/v8/test/mjsunit/regress/regress-5010.js deleted file mode 100644 index ecd4026dd8..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-5010.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax - -var bound = (function(){}).bind({}); -assertEquals("Function", %_ClassOf(bound)); -assertEquals("Function", %ClassOf(bound)); diff --git a/deps/v8/test/mjsunit/regress/regress-5691.js b/deps/v8/test/mjsunit/regress/regress-5691.js new file mode 100644 index 0000000000..6cda92ca79 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5691.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 + +var log = ""; +var result; +Promise.resolve() + .then(() => log += "|turn1") + .then(() => log += "|turn2") + .then(() => log += "|turn3") + .then(() => log += "|turn4") + .then(() => result = "|start|turn1|fast-resolve|turn2|turn3|slow-resolve|turn4\n"+log) + .catch(e => print("ERROR", e)); + +Promise.resolve(Promise.resolve()).then(() => log += "|fast-resolve"); +(class extends Promise {}).resolve(Promise.resolve()).then(() => log += "|slow-resolve"); + +log += "|start"; + %RunMicrotasks(); +assertEquals("|start|turn1|fast-resolve|turn2|turn3|slow-resolve|turn4\n\ +|start|turn1|fast-resolve|turn2|turn3|slow-resolve|turn4", result); diff --git a/deps/v8/test/mjsunit/regress/regress-6703.js b/deps/v8/test/mjsunit/regress/regress-6703.js new file mode 100644 index 0000000000..82bf21d55e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6703.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. + +assertTrue(/(\u039C)/i.test("\xB5")); +assertTrue(/(\u039C)+/i.test("\xB5")); +assertTrue(/(\u039C)/ui.test("\xB5")); +assertTrue(/(\u039C)+/ui.test("\xB5")); + +assertTrue(/(\u03BC)/i.test("\xB5")); +assertTrue(/(\u03BC)+/i.test("\xB5")); +assertTrue(/(\u03BC)/ui.test("\xB5")); +assertTrue(/(\u03BC)+/ui.test("\xB5")); + +assertTrue(/(\u03BC)/i.test("\u039C")); +assertTrue(/(\u03BC)+/i.test("\u039C")); +assertTrue(/(\u03BC)/ui.test("\u039C")); +assertTrue(/(\u03BC)+/ui.test("\u039C")); + +assertTrue(/(\u0178)/i.test("\xFF")); +assertTrue(/(\u0178)+/i.test("\xFF")); +assertTrue(/(\u0178)/ui.test("\xFF")); +assertTrue(/(\u0178)+/ui.test("\xFF")); diff --git a/deps/v8/test/mjsunit/regress/regress-7369.js b/deps/v8/test/mjsunit/regress/regress-7369.js new file mode 100644 index 0000000000..de715ef6dc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-7369.js @@ -0,0 +1,8 @@ +// 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. + +assertEquals(-Infinity, 1/parseInt(-0.9)); +assertEquals(-Infinity, 1/parseInt("-0.9")); +assertEquals(-Infinity, 1/parseInt(-0.09)); +assertEquals(-Infinity, 1/parseInt(-0.009)); diff --git a/deps/v8/test/mjsunit/regress/regress-800651.js b/deps/v8/test/mjsunit/regress/regress-800651.js new file mode 100644 index 0000000000..420cc7c294 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-800651.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 + +var list = []; +function log(item) { list.push(item); } +async function f() { + try { + let namespace = await import(/a/); + } catch(e) { + log(1); + } +} +f(); + +async function g() { + try { + let namespace = await import({ get toString() { return undefined; }}); + } catch(e) { + log(2); + } +} +g(); + %RunMicrotasks(); +assertEquals(list, [1,2]); diff --git a/deps/v8/test/mjsunit/regress/regress-803750.js b/deps/v8/test/mjsunit/regress/regress-803750.js new file mode 100644 index 0000000000..3541ff9a35 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-803750.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. + +// Verify that very large arrays can be constructed. +assertEquals(Array.isArray(Array.of.apply(Array, Array(65536))), true); +assertEquals(Array.isArray(Array.of.apply(null, Array(65536))), true); diff --git a/deps/v8/test/mjsunit/regress/regress-804096.js b/deps/v8/test/mjsunit/regress/regress-804096.js new file mode 100644 index 0000000000..43a2ef4754 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804096.js @@ -0,0 +1,12 @@ +// 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: --opt + +for (let i = 0; i < 5000; i++) { + try { + [].reduce(function() {}); + } catch (x) { + } +} diff --git a/deps/v8/test/mjsunit/regress/regress-804176.js b/deps/v8/test/mjsunit/regress/regress-804176.js new file mode 100644 index 0000000000..ab36c8ccbb --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804176.js @@ -0,0 +1,13 @@ +// 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. + +const set_entries = [{}]; +set_entries[Symbol.iterator] = function() {}; +assertThrows(() => new Set(set_entries), TypeError); +assertThrows(() => new WeakSet(set_entries), TypeError); + +const map_entries = [[{}, 1]]; +map_entries[Symbol.iterator] = function() {}; +assertThrows(() => new Set(map_entries), TypeError); +assertThrows(() => new WeakSet(map_entries), TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-804177.js b/deps/v8/test/mjsunit/regress/regress-804177.js new file mode 100644 index 0000000000..b100480599 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804177.js @@ -0,0 +1,38 @@ +// 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. + +// Tests that insertion at the beginning via unshift won't crash when using a +// constructor that creates an array larger than normal. (Also values inserted +// by original constructor past the end should not survive into the result of +// unshift). +(function testUnshift() { + a = [1]; + function f() { + return a; + } + b = Array.of.call(f); + b.unshift(2); + assertEquals(b, [2]); +})(); + +// Tests that insertion past the end won't expose values previously put into the +// backing store by using a constructor that creates an array larger than normal. +(function testInsertionPastEnd() { + a = [9,9,9,9]; + function f() { + return a; + } + b = Array.of.call(f,1,2); + b[4] = 1; + assertEquals(b, [1, 2, undefined, undefined, 1]); +})(); + +// Tests that using Array.of with a constructor returning an object with an +// unwriteable length throws a TypeError. +(function testFrozenArrayThrows() { + function f() { + return Object.freeze([1,2,3]); + } + assertThrows(function() { Array.of.call(f); }, TypeError); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-804188.js b/deps/v8/test/mjsunit/regress/regress-804188.js new file mode 100644 index 0000000000..72fe8ef651 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804188.js @@ -0,0 +1,14 @@ +// 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. + +Object.defineProperty(Array.prototype, Symbol.iterator, { + value: function* () {} +}); +const arrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +arrayIteratorProto.next = function() {}; + +assertThrows(() => new Map([[{}, 1], [{}, 2]]), TypeError); +assertThrows(() => new WeakMap([[{}, 1], [{}, 2]]), TypeError); +assertThrows(() => new Set([{}]), TypeError); +assertThrows(() => new WeakSet([{}]), TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-804288.js b/deps/v8/test/mjsunit/regress/regress-804288.js new file mode 100644 index 0000000000..6f7855d68c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804288.js @@ -0,0 +1,9 @@ +// 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. + +var arr = [{}]; +Object.setPrototypeOf(arr, {}); +var ta = new Uint8Array(arr); + +let kDeclNoLocals = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-804801.js b/deps/v8/test/mjsunit/regress/regress-804801.js new file mode 100644 index 0000000000..daec8dc92f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804801.js @@ -0,0 +1,34 @@ +// 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 f() { return 42; } +const bound_function = f.bind(); +const callable_proxy = new Proxy(function(){}.__proto__, {}); + +function testSet(ctor) { + new ctor([]); + new ctor([{},{}]); +} + +function testMap(ctor) { + new ctor([]); + new ctor([[{},{}],[{},{}]]); +} + +function testAllVariants(set_or_add_function) { + Set.prototype.add = set_or_add_function; + testSet(Set); + + WeakSet.prototype.add = set_or_add_function; + testSet(WeakSet); + + Map.prototype.set = set_or_add_function; + testMap(Map); + + WeakMap.prototype.set = set_or_add_function; + testMap(WeakMap); +} + +testAllVariants(bound_function); +testAllVariants(callable_proxy); diff --git a/deps/v8/test/mjsunit/regress/regress-804837.js b/deps/v8/test/mjsunit/regress/regress-804837.js new file mode 100644 index 0000000000..2e5e603a7f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-804837.js @@ -0,0 +1,14 @@ +// 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: --opt --allow-natives-syntax + +var __v_25662 = [, 1.8]; +function __f_6214(__v_25668) { + __v_25662.reduce(() => {1}); +} +__f_6214(); +__f_6214(); +%OptimizeFunctionOnNextCall(__f_6214); +__f_6214(); diff --git a/deps/v8/test/mjsunit/regress/regress-805729.js b/deps/v8/test/mjsunit/regress/regress-805729.js new file mode 100644 index 0000000000..0703aa2ad8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-805729.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. + +async function* asyncGenerator() {}; +let gen = asyncGenerator(); +gen.return({ get then() { delete this.then; gen.next(); } }); diff --git a/deps/v8/test/mjsunit/regress/regress-805768.js b/deps/v8/test/mjsunit/regress/regress-805768.js new file mode 100644 index 0000000000..e36106fdb3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-805768.js @@ -0,0 +1,19 @@ +// 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 foo() { + var a = ['']; + print(a[0]); + return a; +} + +function bar(a) { a[0] = "bazinga!"; } + +for (var i = 0; i < 5; i++) bar([]); + +%OptimizeFunctionOnNextCall(bar); +bar(foo()); +assertEquals([''], foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-812451.js b/deps/v8/test/mjsunit/regress/regress-812451.js new file mode 100644 index 0000000000..8ccad1d124 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-812451.js @@ -0,0 +1,14 @@ +// 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: --expose-gc + +var x = []; +function foo(x, p) { + x[p] = 5.3; +} +foo(x, 1); +foo(x, 2); +foo(x, -1); +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-814643.js b/deps/v8/test/mjsunit/regress/regress-814643.js new file mode 100644 index 0000000000..085c56fe84 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-814643.js @@ -0,0 +1,6 @@ +// 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. + +Number.prototype.__proto__ = String.prototype; +Uint8Array.from(1); diff --git a/deps/v8/test/mjsunit/regress/regress-816289.js b/deps/v8/test/mjsunit/regress/regress-816289.js new file mode 100644 index 0000000000..4a3a4b629d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-816289.js @@ -0,0 +1,6 @@ +// 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. + +delete String.prototype[Symbol.iterator]; +Int8Array.from("anything"); diff --git a/deps/v8/test/mjsunit/regress/regress-816317.js b/deps/v8/test/mjsunit/regress/regress-816317.js new file mode 100644 index 0000000000..304786e694 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-816317.js @@ -0,0 +1,12 @@ +// 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. + +let a = new Float64Array(15); +Object.defineProperty(a, "length", { + get: function () { + return 6; + } +}); +delete a.__proto__.__proto__[Symbol.iterator]; +Float64Array.from(a); diff --git a/deps/v8/test/mjsunit/regress/regress-821137.js b/deps/v8/test/mjsunit/regress/regress-821137.js new file mode 100644 index 0000000000..639b3b998a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-821137.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. + +// Tests that creating an iterator that shrinks the array populated by +// Array.from does not lead to out of bounds writes. +let oobArray = []; +let maxSize = 1028 * 8; +Array.from.call(function() { return oobArray }, {[Symbol.iterator] : _ => ( + { + counter : 0, + next() { + let result = this.counter++; + if (this.counter > maxSize) { + oobArray.length = 0; + return {done: true}; + } else { + return {value: result, done: false}; + } + } + } +) }); +assertEquals(oobArray.length, maxSize); + +// iterator reset the length to 0 just before returning done, so this will crash +// if the backing store was not resized correctly. +oobArray[oobArray.length - 1] = 0x41414141; diff --git a/deps/v8/test/mjsunit/regress/regress-995.js b/deps/v8/test/mjsunit/regress/regress-995.js index 3f99179104..cf680da1e7 100644 --- a/deps/v8/test/mjsunit/regress/regress-995.js +++ b/deps/v8/test/mjsunit/regress/regress-995.js @@ -39,14 +39,6 @@ function f(value) { } f(new String("bar")); -// HClassOf. -function g(value) { - if (%_ClassOf(value) === 'Date') { - if (%_ClassOf(value) === 'String') assertTrue(false); - } -} -g(new Date()); - // HIsNull. function h(value) { if (value == null) { diff --git a/deps/v8/test/mjsunit/regress/regress-charat-empty.js b/deps/v8/test/mjsunit/regress/regress-charat-empty.js new file mode 100644 index 0000000000..6548ad5b2f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-charat-empty.js @@ -0,0 +1,14 @@ +// 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: --opt --no-always-opt --allow-natives-syntax +(() => { + function f(s) { + return s.charAt(); + } + f(""); + f(""); + %OptimizeFunctionOnNextCall(f); + f(""); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-109362.js b/deps/v8/test/mjsunit/regress/regress-crbug-109362.js index 20285f614d..cf7cd4e5fa 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-109362.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-109362.js @@ -14,15 +14,16 @@ function test(expectation, f) { } /* -(function() { +(function( +) { 1 + reference_error //@ sourceURL=evaltest }) */ -test("2:5", new Function( +test("3:5", new Function( '1 + reference_error //@ sourceURL=evaltest')); /* (function(x -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) @@ -34,7 +35,7 @@ test("4:6", new Function( ,z// ,y -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) @@ -44,7 +45,7 @@ test("7:6", new Function( /* (function(x/\*,z// ,y*\/ -/\**\/) { +) { 1 + reference_error //@ sourceURL=evaltest }) */ diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-474297.js b/deps/v8/test/mjsunit/regress/regress-crbug-474297.js deleted file mode 100644 index ce240251bd..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-474297.js +++ /dev/null @@ -1,12 +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: --gc-interval=33 --expose-gc --allow-natives-syntax - -var Debug = %GetDebugContext().Debug; -Debug.setListener(function(){}); - -%DebugGetLoadedScripts(); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-507070.js b/deps/v8/test/mjsunit/regress/regress-crbug-507070.js deleted file mode 100644 index 0cb14b27e7..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-507070.js +++ /dev/null @@ -1,20 +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 --cache=code --no-debug-code - -try { } catch(e) { } -try { try { } catch (e) { } } catch(e) { } -try { - var Debug = %GetDebugContext().Debug; - Debug.setListener(function(){}); -} catch(e) { } -(function() { - Debug.setBreakPoint(function(){}, 0, 0); -})(); - -var a = 1; -a += a; -Debug.setListener(null); -assertEquals(2, a); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-663410.js b/deps/v8/test/mjsunit/regress/regress-crbug-663410.js index 5bef089f11..6d2a487715 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-663410.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-663410.js @@ -4,5 +4,5 @@ function alert(x) {}; assertThrows( - Function("a=`","`,xss=1){alert(xss)") + 'Function("a=`","`,xss=1){alert(xss)")' ); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-802333.js b/deps/v8/test/mjsunit/regress/regress-crbug-802333.js new file mode 100644 index 0000000000..35d762187b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-802333.js @@ -0,0 +1,26 @@ +// 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 deferred_func() { + class C { + method1() { + + } + } +} + +let bound = (a => a).bind(this, 0); + +function opt() { + deferred_func.prototype; // ReduceJSLoadNamed + + return bound(); +} + +assertEquals(0, opt()); +%OptimizeFunctionOnNextCall(opt); + +assertEquals(0, opt()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-805765.js b/deps/v8/test/mjsunit/regress/regress-crbug-805765.js new file mode 100644 index 0000000000..b630efb4c7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-805765.js @@ -0,0 +1,13 @@ +// 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. + +var code = "(function* gen() {" +for (var i = 0; i < 256; ++i) { + code += `var v_${i} = 0;` +} +code += `yield; })` + +var gen = eval(code); +var g = gen(); +g.next(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-806200.js b/deps/v8/test/mjsunit/regress/regress-crbug-806200.js new file mode 100644 index 0000000000..dbd66019a5 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-806200.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: --allow-natives-syntax + +assertThrows("%Foo(...spread)", SyntaxError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-808192.js b/deps/v8/test/mjsunit/regress/regress-crbug-808192.js index 3336c0043e..f57d5fc3a6 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-808192.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-808192.js @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(cbruni): enable always opt once v8:7438 -// Flags: --expose-gc --no-always-opt +// Flags: --expose-gc const f = eval(`(function f(i) { if (i == 0) { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-813450.js b/deps/v8/test/mjsunit/regress/regress-crbug-813450.js new file mode 100644 index 0000000000..b301012950 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-813450.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 + +var constructorArgs = new Array(0x10100); +var constructor = function() {}; +var target = new Proxy(constructor, { + construct: function() { + } +}); +var proxy = new Proxy(target, { + construct: function(newTarget, args) { + return Reflect.construct(constructor, []); + } +}); +var instance = new proxy(); +var instance2 = Reflect.construct(proxy, constructorArgs); +%HeapObjectVerify(target); +%HeapObjectVerify(proxy); +%HeapObjectVerify(instance); +%HeapObjectVerify(instance2); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-816961.js b/deps/v8/test/mjsunit/regress/regress-crbug-816961.js new file mode 100644 index 0000000000..c1637ad2c5 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-816961.js @@ -0,0 +1,18 @@ +// 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. + +assertThrows(function() { + var memory = new WebAssembly.Memory({initial: 64 * 1024 * 1024 / 0x10000}); + var array = new Uint8Array(memory.buffer); + Uint8Array.of.call(function() { return array }, + {valueOf() { memory.grow(1); } }); +}, TypeError); + +assertThrows(function() { + var memory = new WebAssembly.Memory({initial: 64 * 1024 * 1024 / 0x10000}); + var array = new Uint8Array(memory.buffer); + Uint8Array.from.call(function() { return array }, + [{valueOf() { memory.grow(1); } }], + x => x); +}, TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-822284.js b/deps/v8/test/mjsunit/regress/regress-crbug-822284.js new file mode 100644 index 0000000000..97a38259e3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-822284.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 foo(a) { + a = "" + Math.abs(a); + return a.charCodeAt(0); +} + +// Add '1' to the number to string table (as SeqString). +String.fromCharCode(49); + +// Turn the SeqString into a ThinString via forced internalization. +const o = {}; +o[(1).toString()] = 1; + +assertEquals(49, foo(1)); +assertEquals(49, foo(1)); +%OptimizeFunctionOnNextCall(foo); +assertEquals(49, foo(1)); diff --git a/deps/v8/test/mjsunit/regress/regress-stringAt-boundsCheck.js b/deps/v8/test/mjsunit/regress/regress-stringAt-boundsCheck.js new file mode 100644 index 0000000000..2e14aa027c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-stringAt-boundsCheck.js @@ -0,0 +1,18 @@ +// 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: --opt --allow-natives-syntax + +(() => { + function f(u) { + for (var j = 0; j < 20; ++j) { + print("" + u.codePointAt()); + } + } + + f("test"); + f("foo"); + %OptimizeFunctionOnNextCall(f); + f(""); +})(); diff --git a/deps/v8/test/mjsunit/regress/string-next-encoding.js b/deps/v8/test/mjsunit/regress/string-next-encoding.js new file mode 100644 index 0000000000..27b99a9c9e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/string-next-encoding.js @@ -0,0 +1,20 @@ +// 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: --opt --allow-natives-syntax + +function f() { + var s = "äϠ�𝌆"; + var i = s[Symbol.iterator](); + assertEquals("ä", i.next().value); + assertEquals("Ϡ", i.next().value); + assertEquals("�", i.next().value); + assertEquals("𝌆", i.next().value); + assertSame(undefined, i.next().value); +} + +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-7353.js b/deps/v8/test/mjsunit/regress/wasm/regress-7353.js new file mode 100644 index 0000000000..d41cbabf36 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-7353.js @@ -0,0 +1,29 @@ +// 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: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addMemory(16, 32); +builder.addFunction('grow', kSig_i_i).addBody([ + kExprGetLocal, 0, + kExprGrowMemory, 0, +]).exportFunc(); +builder.addFunction('main', kSig_i_i).addBody([ + ...wasmI32Const(0x41), + kExprSetLocal, 0, + // Enter loop, such that values are spilled to the stack. + kExprLoop, kWasmStmt, + kExprEnd, + // Reload value. This must be loaded as 32 bit value. + kExprGetLocal, 0, + kExprI32LoadMem, 0, 0, +]).exportFunc(); +const instance = builder.instantiate(); +// Execute grow, such that the stack contains garbage data afterwards. +instance.exports.grow(1); +instance.exports.main(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-7364.js b/deps/v8/test/mjsunit/regress/wasm/regress-7364.js new file mode 100644 index 0000000000..8e66295b70 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-7364.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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const exportingModuleBinary = (() => { + const builder = new WasmModuleBuilder(); + builder.addFunction('f', kSig_i_v).addBody([kExprI32Const, 42]).exportFunc(); + return builder.toBuffer(); +})(); + +const exportingModule = new WebAssembly.Module(exportingModuleBinary); +const exportingInstance = new WebAssembly.Instance(exportingModule); + +const reExportingModuleBinary = (() => { + const builder = new WasmModuleBuilder(); + const gIndex = builder.addImport('a', 'g', kSig_i_v); + builder.addExport('y', gIndex); + return builder.toBuffer(); +})(); + +const module = new WebAssembly.Module(reExportingModuleBinary); +const imports = { + a: {g: exportingInstance.exports.f}, +}; +const instance = new WebAssembly.Instance(module, imports); + +// Previously exported Wasm functions are re-exported with the same value +assertEquals(instance.exports.y, exportingInstance.exports.f); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-7366.js b/deps/v8/test/mjsunit/regress/wasm/regress-7366.js new file mode 100644 index 0000000000..41f758efb1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-7366.js @@ -0,0 +1,33 @@ +// 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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addFunction(undefined, kSig_i_iii).addBody([ + // Return the sum of all arguments. + kExprGetLocal, 0, kExprGetLocal, 1, kExprGetLocal, 2, kExprI32Add, kExprI32Add +]); +const sig = builder.addType(kSig_i_iii); +builder.addFunction(undefined, kSig_i_iii) + .addBody([ + ...wasmI32Const(1), // i32.const 0x1 + kExprSetLocal, 0, // set_local 0 + ...wasmI32Const(4), // i32.const 0x1 + kExprSetLocal, 1, // set_local 1 + ...wasmI32Const(16), // i32.const 0x1 + kExprSetLocal, 2, // set_local 2 + kExprLoop, kWasmStmt, // loop + kExprEnd, // end + kExprGetLocal, 0, // get_local 0 + kExprGetLocal, 1, // get_local 1 + kExprGetLocal, 2, // get_local 2 + kExprI32Const, 0, // i32.const 0 (func index) + kExprCallIndirect, sig, 0, // call indirect + ]) + .exportAs('main'); +builder.appendToTable([0]); +const instance = builder.instantiate(); +assertEquals(21, instance.exports.main()); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-7422.js b/deps/v8/test/mjsunit/regress/wasm/regress-7422.js new file mode 100644 index 0000000000..87896b4c35 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-7422.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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +sig = makeSig([kWasmI32, kWasmI32, kWasmI32, kWasmI32, kWasmI32], [kWasmI32]); +builder.addFunction(undefined, sig).addBody([kExprGetLocal, 4]); +builder.addMemory(16, 32); +builder.addFunction('main', sig) + .addBody([ + kExprI32Const, 0, kExprSetLocal, 0, + // Compute five arguments to the function call. + kExprI32Const, 0, kExprI32Const, 0, kExprI32Const, 0, kExprI32Const, 0, + kExprGetLocal, 4, kExprI32Const, 1, kExprI32Add, + // Now some intermediate computation to force the arguments to be spilled + // to the stack: + kExprGetLocal, 0, kExprI32Const, 1, kExprI32Add, kExprGetLocal, 1, + kExprGetLocal, 1, kExprI32Add, kExprI32Add, kExprDrop, + // Now call the function. + kExprCallFunction, 0 + ]) + .exportFunc(); +var instance = builder.instantiate(); +assertEquals(11, instance.exports.main(2, 4, 6, 8, 10)); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-7499.js b/deps/v8/test/mjsunit/regress/wasm/regress-7499.js new file mode 100644 index 0000000000..71f246decf --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-7499.js @@ -0,0 +1,19 @@ +// 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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addMemory(16, 32); +builder.addFunction(undefined, kSig_v_v).addBody([ + kExprI32Const, 0, // i32.const 0 + kExprI64LoadMem, 0, 0xff, 0xff, 0xff, 0xff, + 0x0f, // i64.load align=0 offset=0xffffffff + kExprDrop, // drop +]); +builder.addExport('main', 0); +const module = builder.instantiate(); +assertThrows( + () => module.exports.main(), WebAssembly.RuntimeError, /out of bounds/); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-801785.js b/deps/v8/test/mjsunit/regress/wasm/regress-801785.js new file mode 100644 index 0000000000..1870d7e8f1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-801785.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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +// Flags: --print-wasm-code + +const builder = new WasmModuleBuilder(); +builder.addMemory(8, 16); +builder.addFunction(undefined, kSig_i_i).addBody([ + // wasm to wasm call. + kExprGetLocal, 0, kExprCallFunction, 0x1 +]); +builder.addFunction(undefined, kSig_i_i).addBody([ + // load from <get_local 0> to create trap code. + kExprGetLocal, 0, kExprI32LoadMem, 0, + // unreachable to create a runtime call. + kExprUnreachable +]); +builder.instantiate(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-803427.js b/deps/v8/test/mjsunit/regress/wasm/regress-803427.js new file mode 100644 index 0000000000..833b140fd4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-803427.js @@ -0,0 +1,13 @@ +// 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: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +let module = new WebAssembly.Module(builder.toBuffer()); +var worker = new Worker('onmessage = function() {};'); +worker.postMessage(module) diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-803788.js b/deps/v8/test/mjsunit/regress/wasm/regress-803788.js new file mode 100644 index 0000000000..8edec7c464 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-803788.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: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +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 ]) +let module = new WebAssembly.Module(builder.toBuffer()); +let table = new WebAssembly.Table({ + element: "anyfunc", + initial: 10, +}); +let instance = new WebAssembly.Instance(module, { + q: { + base: 0, + table: table, + fun: () => (0) + } +}); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-808012.js b/deps/v8/test/mjsunit/regress/wasm/regress-808012.js new file mode 100644 index 0000000000..1b91f226a8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-808012.js @@ -0,0 +1,14 @@ +// 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: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addFunction('test', kSig_i_i).addBody([kExprUnreachable]); +let module = new WebAssembly.Module(builder.toBuffer()); +var worker = new Worker('onmessage = function() {};'); +worker.postMessage(module); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-810973.js b/deps/v8/test/mjsunit/regress/wasm/regress-810973.js new file mode 100644 index 0000000000..5a776884ee --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-810973.js @@ -0,0 +1,32 @@ +// 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. + + this.WScript = new Proxy({}, { + get() { + switch (name) { + } + } + }); +function MjsUnitAssertionError() { +}; +let __v_692 = `(function module() { "use asm";function foo(`; +const __v_693 = +3695; +for (let __v_695 = 0; __v_695 < __v_693; ++__v_695) { + __v_692 += `arg${__v_695},`; +} +try { + __v_692 += `arg${__v_693}){`; +} catch (e) {} +for (let __v_696 = 0; __v_696 <= __v_693; ++__v_696) { + __v_692 += `arg${__v_696}=+arg${__v_696};`; +} + __v_692 += "return 10;}function bar(){return foo("; +for (let __v_697 = 0; __v_697 < __v_693; ++__v_697) { + __v_692 += "0.0,"; +} + __v_692 += "1.0)|0;}"; + + __v_692 += "return bar})()()"; +const __v_694 = eval(__v_692); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-812005.js b/deps/v8/test/mjsunit/regress/wasm/regress-812005.js new file mode 100644 index 0000000000..979b769bbc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-812005.js @@ -0,0 +1,16 @@ +// 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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +const builder = new WasmModuleBuilder(); +builder.addFunction(undefined, kSig_d_v).addBody([ + ...wasmF64Const(0), // f64.const 0 + ...wasmF64Const(0), // f64.const 0 + ...wasmI32Const(0), // i32.const 0 + kExprBrIf, 0x00, // br_if depth=0 + kExprF64Add // f64.add +]); +builder.instantiate(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-816226.js b/deps/v8/test/mjsunit/regress/wasm/regress-816226.js new file mode 100644 index 0000000000..a9cb715570 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-816226.js @@ -0,0 +1,5 @@ +// 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. + +(new Int8Array((new WebAssembly.Memory({})).buffer)).buffer; diff --git a/deps/v8/test/mjsunit/regress/wasm/regress-819869.js b/deps/v8/test/mjsunit/regress/wasm/regress-819869.js new file mode 100644 index 0000000000..f2606fb610 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regress-819869.js @@ -0,0 +1,12 @@ +// 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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +builder.addFunction(undefined, kSig_i_i) + .addLocals({i32_count: 0xffffffff}) + .addBody([]); +assertThrows(() => builder.instantiate(), WebAssembly.CompileError); diff --git a/deps/v8/test/mjsunit/skipping-inner-functions.js b/deps/v8/test/mjsunit/skipping-inner-functions.js index e228b258c4..fba9a3e277 100644 --- a/deps/v8/test/mjsunit/skipping-inner-functions.js +++ b/deps/v8/test/mjsunit/skipping-inner-functions.js @@ -365,3 +365,15 @@ TestSkippableFunctionInForOfHeaderAndBody(); function lazy(p = (function() {}, class {}, function() {}, class { method1() { } })) { } lazy(); })(); + +(function TestOneByteTwoByteMismatch() { + // Regression test for + // https://bugs.chromium.org/p/v8/issues/detail?id=7428 + + let name = 'weird_string\u2653'.slice(0, 12); + let o = {}; + o[name] = null; + var x; + eval('x = function weird_string() { function skip() {} };'); + x(); +})(); diff --git a/deps/v8/test/mjsunit/string-charcodeat-external.js b/deps/v8/test/mjsunit/string-charcodeat-external.js new file mode 100644 index 0000000000..8b291dad33 --- /dev/null +++ b/deps/v8/test/mjsunit/string-charcodeat-external.js @@ -0,0 +1,17 @@ +// 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: --expose-externalize-string --expose-gc --allow-natives-syntax + +function foo(s) { + return s.charCodeAt(12); +} + +var extern = "internalized dummy"; +extern = "1234567890qiaipppiúöäöáœba"+"jalsdjasldjasdlasjdalsdjasldk"; +externalizeString(extern, true /* force two-byte */); +assertEquals(97, foo(extern)); +assertEquals(97, foo(extern)); +%OptimizeFunctionOnNextCall(foo); +assertEquals(97, foo(extern)); diff --git a/deps/v8/test/mjsunit/string-deopt.js b/deps/v8/test/mjsunit/string-deopt.js new file mode 100644 index 0000000000..15549186ea --- /dev/null +++ b/deps/v8/test/mjsunit/string-deopt.js @@ -0,0 +1,57 @@ +// 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 --no-always-opt + +(()=> { + function f(a, b, c) { + return a.indexOf(b, c); + } + f("abc", "de", 1); + f("abc", "de", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", "de", {}); + %OptimizeFunctionOnNextCall(f); + f("abc", "de", {}); + assertOptimized(f); +})(); + +(()=> { + function f(a, b, c) { + return a.indexOf(b, c); + } + f("abc", "de", 1); + f("abc", "de", 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}, 1); + %OptimizeFunctionOnNextCall(f); + f("abc", {}, 1); + assertOptimized(f); +})(); + +(()=> { + function f(a, b, c) { + return a.substring(b, c); + } + f("abcde", 1, 4); + f("abcde", 1, 4); + %OptimizeFunctionOnNextCall(f); + f("abcde", 1, {}); + %OptimizeFunctionOnNextCall(f); + f("abcde", 1, {}); + assertOptimized(f); +})(); + +(()=> { + function f(a, b, c) { + return a.substring(b, c); + } + f("abcde", 1, 4); + f("abcde", 1, 4); + %OptimizeFunctionOnNextCall(f); + f("abcde", {}, 4); + %OptimizeFunctionOnNextCall(f); + f("abcde", {}, 4); + assertOptimized(f); +})(); diff --git a/deps/v8/test/mjsunit/string-trim.js b/deps/v8/test/mjsunit/string-trim.js new file mode 100644 index 0000000000..201a34f1c9 --- /dev/null +++ b/deps/v8/test/mjsunit/string-trim.js @@ -0,0 +1,11 @@ +// 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-string-trimming + +assertEquals('trim', String.prototype.trim.name); +assertEquals('trimStart', String.prototype.trimStart.name); +assertEquals('trimStart', String.prototype.trimLeft.name); +assertEquals('trimEnd', String.prototype.trimEnd.name); +assertEquals('trimEnd', String.prototype.trimRight.name); diff --git a/deps/v8/test/mjsunit/testcfg.py b/deps/v8/test/mjsunit/testcfg.py index bc9d69ff33..d31a189ba2 100644 --- a/deps/v8/test/mjsunit/testcfg.py +++ b/deps/v8/test/mjsunit/testcfg.py @@ -25,11 +25,15 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from collections import OrderedDict +import itertools import os import re +from testrunner.local import statusfile from testrunner.local import testsuite from testrunner.objects import testcase +from testrunner.outproc import base as outproc FILES_PATTERN = re.compile(r"//\s+Files:(.*)") ENV_PATTERN = re.compile(r"//\s+Environment Variables:(.*)") @@ -37,9 +41,22 @@ SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) +# Flags known to misbehave when combining arbitrary mjsunit tests. Can also +# be compiled regular expressions. +COMBINE_TESTS_FLAGS_BLACKLIST = [ + '--check-handle-count', + '--enable-tracing', + re.compile('--experimental.*'), + '--expose-trigger-failure', + re.compile('--harmony.*'), + '--mock-arraybuffer-allocator', + '--print-ast', + re.compile('--trace.*'), + '--wasm-lazy-compilation', +] class TestSuite(testsuite.TestSuite): - def ListTests(self, context): + def ListTests(self): tests = [] for dirname, dirs, files in os.walk(self.root, followlinks=True): for dotted in [x for x in dirs if x.startswith('.')]: @@ -47,7 +64,9 @@ class TestSuite(testsuite.TestSuite): dirs.sort() files.sort() for filename in files: - if filename.endswith(".js") and filename != "mjsunit.js": + if (filename.endswith(".js") and + filename != "mjsunit.js" and + filename != "mjsunit_suppressions.js"): fullpath = os.path.join(dirname, filename) relpath = fullpath[len(self.root) + 1 : -3] testname = relpath.replace(os.path.sep, "/") @@ -55,9 +74,15 @@ class TestSuite(testsuite.TestSuite): tests.append(test) return tests + def _test_combiner_class(self): + return TestCombiner + def _test_class(self): return TestCase + def _suppressed_test_class(self): + return SuppressedTestCase + class TestCase(testcase.TestCase): def __init__(self, *args, **kwargs): @@ -111,12 +136,12 @@ class TestCase(testcase.TestCase): def _get_source_flags(self): return self._source_flags - def _get_files_params(self, ctx): + def _get_files_params(self): files = list(self._source_files) - if not ctx.no_harness: + if not self._test_config.no_harness: files += self._mjsunit_files files += self._files_suffix - if ctx.isolates: + if self._test_config.isolates: files += ['--isolate'] + files return files @@ -128,5 +153,157 @@ class TestCase(testcase.TestCase): return os.path.join(self.suite.root, self.path + self._get_suffix()) -def GetSuite(name, root): - return TestSuite(name, root) +class TestCombiner(testsuite.TestCombiner): + def get_group_key(self, test): + """Combine tests with the same set of flags. + Ignore: + 1. Some special cases where it's not obvious what to pass in the command. + 2. Tests with flags that can cause failure even inside try-catch wrapper. + 3. Tests that use async functions. Async functions can be scheduled after + exiting from try-catch wrapper and cause failure. + """ + if (len(test._files_suffix) > 1 or + test._env or + not test._mjsunit_files or + test._source_files): + return None + + source_flags = test._get_source_flags() + if ('--expose-trigger-failure' in source_flags or + '--throws' in source_flags): + return None + + source_code = test.get_source() + # Maybe we could just update the tests to await all async functions they + # call? + if 'async' in source_code: + return None + + # TODO(machenbach): Remove grouping if combining tests in a flag-independent + # way works well. + return 1 + + def _combined_test_class(self): + return CombinedTest + + +class CombinedTest(testcase.TestCase): + """Behaves like normal mjsunit tests except: + 1. Expected outcome is always PASS + 2. Instead of one file there is a try-catch wrapper with all combined tests + passed as arguments. + """ + def __init__(self, name, tests): + super(CombinedTest, self).__init__(tests[0].suite, '', name, + tests[0]._test_config) + self._tests = tests + + def _prepare_outcomes(self, force_update=True): + self._statusfile_outcomes = outproc.OUTCOMES_PASS_OR_TIMEOUT + self.expected_outcomes = outproc.OUTCOMES_PASS_OR_TIMEOUT + + def _get_shell_with_flags(self): + """In addition to standard set of shell flags it appends: + --disable-abortjs: %AbortJS can abort the test even inside + trycatch-wrapper, so we disable it. + --es-staging: We blacklist all harmony flags due to false positives, + but always pass the staging flag to cover the mature features. + --omit-quit: Calling quit() in JS would otherwise early terminate. + --quiet-load: suppress any stdout from load() function used by + trycatch-wrapper. + """ + shell = 'd8' + shell_flags = [ + '--test', + '--disable-abortjs', + '--es-staging', + '--omit-quit', + '--quiet-load', + ] + return shell, shell_flags + + def _get_cmd_params(self): + return ( + super(CombinedTest, self)._get_cmd_params() + + ['tools/testrunner/trycatch_loader.js', '--'] + + self._tests[0]._mjsunit_files + + ['--'] + + [t._files_suffix[0] for t in self._tests] + ) + + def _merge_flags(self, flags): + """Merges flags from a list of flags. + + Flag values not starting with '-' are merged with the preceeding flag, + e.g. --foo 1 will become --foo=1. All other flags remain the same. + + Returns: A generator of flags. + """ + if not flags: + return + # Iterate over flag pairs. ['-'] is a sentinel value for the last iteration. + for flag1, flag2 in itertools.izip(flags, flags[1:] + ['-']): + if not flag2.startswith('-'): + assert '=' not in flag1 + yield flag1 + '=' + flag2 + elif flag1.startswith('-'): + yield flag1 + + def _is_flag_blacklisted(self, flag): + for item in COMBINE_TESTS_FLAGS_BLACKLIST: + if isinstance(item, basestring): + if item == flag: + return True + elif item.match(flag): + return True + return False + + def _get_combined_flags(self, flags_gen): + """Combines all flags - dedupes, keeps order and filters some flags. + + Args: + flags_gen: Generator for flag lists. + Returns: A list of flags. + """ + merged_flags = self._merge_flags(list(itertools.chain(*flags_gen))) + unique_flags = OrderedDict((flag, True) for flag in merged_flags).keys() + return [ + flag for flag in unique_flags + if not self._is_flag_blacklisted(flag) + ] + + def _get_source_flags(self): + # Combine flags from all source files. + return self._get_combined_flags( + test._get_source_flags() for test in self._tests) + + def _get_statusfile_flags(self): + # Combine flags from all status file entries. + return self._get_combined_flags( + test._get_statusfile_flags() for test in self._tests) + + +class SuppressedTestCase(TestCase): + """The same as a standard mjsunit test case with all asserts as no-ops.""" + def __init__(self, *args, **kwargs): + super(SuppressedTestCase, self).__init__(*args, **kwargs) + self._mjsunit_files.append( + os.path.join(self.suite.root, "mjsunit_suppressions.js")) + + def _prepare_outcomes(self, *args, **kwargs): + super(SuppressedTestCase, self)._prepare_outcomes(*args, **kwargs) + # Skip tests expected to fail. We suppress all asserts anyways, but some + # tests are expected to fail with type errors or even dchecks, and we + # can't differentiate that. + if statusfile.FAIL in self._statusfile_outcomes: + self._statusfile_outcomes = [statusfile.SKIP] + + def _get_extra_flags(self, *args, **kwargs): + return ( + super(SuppressedTestCase, self)._get_extra_flags(*args, **kwargs) + + ['--disable-abortjs'] + ) + + +def GetSuite(*args, **kwargs): + return TestSuite(*args, **kwargs) diff --git a/deps/v8/test/mjsunit/wasm/OWNERS b/deps/v8/test/mjsunit/wasm/OWNERS index 5bd472f49d..d9195d8e54 100644 --- a/deps/v8/test/mjsunit/wasm/OWNERS +++ b/deps/v8/test/mjsunit/wasm/OWNERS @@ -2,6 +2,4 @@ ahaas@chromium.org bradnelson@chromium.org clemensh@chromium.org eholk@chromium.org -mtrofin@chromium.org -rossberg@chromium.org titzer@chromium.org diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js b/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js index a1af7a4393..1a89c3ef1a 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js @@ -200,23 +200,8 @@ var inputs = [ ]; var funcs = [ - f32_add, - f32_sub, - f32_mul, - f32_div, - f32_ceil, - f32_floor, -// TODO(bradnelson) f32_sqrt, -// TODO(bradnelson) f32_abs, -// TODO(bradnelson) f32_min is wrong for -0 -// TODO(bradnelson) f32_max is wrong for -0 - f32_eq, - f32_ne, - f32_lt, - f32_lteq, - f32_gt, - f32_gteq, - f32_neg, + f32_add, f32_sub, f32_mul, f32_div, f32_ceil, f32_floor, f32_sqrt, f32_abs, + f32_min, f32_max, f32_eq, f32_ne, f32_lt, f32_lteq, f32_gt, f32_gteq, f32_neg ]; (function () { diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js b/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js index c7b439fede..a07de98558 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js @@ -262,32 +262,10 @@ var inputs = [ ]; var funcs = [ - f64_add, - f64_sub, - f64_mul, - f64_div, - f64_eq, - f64_ne, - f64_lt, - f64_lteq, - f64_gt, - f64_gteq, - f64_ceil, - f64_floor, -// TODO(bradnelson) f64_sqrt, - f64_abs, - f64_neg, -// TODO(bradnelson) f64_min is wrong for -0 -// TODO(bradnelson) f64_max is wrong for -0 - f64_acos, - f64_asin, - f64_atan, - f64_cos, - f64_sin, - f64_tan, - f64_exp, - f64_log, - f64_atan2, + f64_add, f64_sub, f64_mul, f64_div, f64_eq, f64_ne, f64_lt, + f64_lteq, f64_gt, f64_gteq, f64_ceil, f64_floor, f64_sqrt, f64_abs, + f64_neg, f64_min, f64_max, f64_acos, f64_asin, f64_atan, f64_cos, + f64_sin, f64_tan, f64_exp, f64_log, f64_atan2, ]; (function () { diff --git a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js index 0ec3296b03..d254c9e620 100644 --- a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js +++ b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js @@ -98,6 +98,26 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertEquals(clone.constructor, compiled_module.constructor); })(); +(function SerializeWrappersWithSameSignature() { + let builder = new WasmModuleBuilder(); + builder.addFunction("main", kSig_i_v) + .addBody([kExprI32Const, 42]) + .exportFunc(); + builder.addFunction("main_same_signature", kSig_i_v) + .addBody([kExprI32Const, 23]) + .exportFunc(); + + var wire_bytes = builder.toBuffer(); + var compiled_module = new WebAssembly.Module(wire_bytes); + var serialized = %SerializeWasmModule(compiled_module); + var clone = %DeserializeWasmModule(serialized, wire_bytes); + + assertNotNull(clone); + assertFalse(clone == undefined); + assertFalse(clone == compiled_module); + assertEquals(clone.constructor, compiled_module.constructor); +})(); + (function SerializeAfterInstantiation() { let builder = new WasmModuleBuilder(); builder.addFunction("main", kSig_i_v) diff --git a/deps/v8/test/mjsunit/wasm/errors.js b/deps/v8/test/mjsunit/wasm/errors.js index a90236459f..0d4893c18a 100644 --- a/deps/v8/test/mjsunit/wasm/errors.js +++ b/deps/v8/test/mjsunit/wasm/errors.js @@ -160,15 +160,22 @@ function assertConversionError(bytes, imports, msg) { (function TestConversionError() { let b = builder(); - b.addImport("foo", "bar", kSig_v_l); - assertConversionError(b.addFunction("run", kSig_v_v).addBody([ - kExprI64Const, 0, kExprCallFunction, 0 - ]).exportFunc().end().toBuffer(), {foo:{bar: (l)=>{}}}, "invalid type"); - - b = builder() - assertConversionError(builder().addFunction("run", kSig_l_v).addBody([ - kExprI64Const, 0 - ]).exportFunc().end().toBuffer(), {}, "invalid type"); + b.addImport('foo', 'bar', kSig_v_l); + let buffer = b.addFunction('run', kSig_v_v) + .addBody([kExprI64Const, 0, kExprCallFunction, 0]) + .exportFunc() + .end() + .toBuffer(); + assertConversionError( + buffer, {foo: {bar: (l) => {}}}, kTrapMsgs[kTrapTypeError]); + + buffer = builder() + .addFunction('run', kSig_l_v) + .addBody([kExprI64Const, 0]) + .exportFunc() + .end() + .toBuffer(); + assertConversionError(buffer, {}, kTrapMsgs[kTrapTypeError]); })(); @@ -178,7 +185,7 @@ function assertConversionError(bytes, imports, msg) { builder.addImport("mod", "func", sig); builder.addFunction("main", sig) .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprCallFunction, 0]) - .exportAs("main") + .exportAs("main"); var main = builder.instantiate({ mod: { func: ()=>{%DebugTrace();} diff --git a/deps/v8/test/mjsunit/wasm/function-prototype.js b/deps/v8/test/mjsunit/wasm/function-prototype.js index d3356cec80..c2f1edd5c4 100644 --- a/deps/v8/test/mjsunit/wasm/function-prototype.js +++ b/deps/v8/test/mjsunit/wasm/function-prototype.js @@ -17,8 +17,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var func = builder.instantiate().exports.nine; // Check type and existence of prototype - assertEquals("function", typeof func.apply); - assertTrue(func.prototype != undefined); + assertEquals('function', typeof func); + assertEquals('function', typeof func.apply); + assertEquals('prototype' in func, false); assertEquals(String(f.index), func.name); assertEquals(undefined, func.displayName); diff --git a/deps/v8/test/mjsunit/wasm/import-table.js b/deps/v8/test/mjsunit/wasm/import-function.js index 2c89e45c3e..2c89e45c3e 100644 --- a/deps/v8/test/mjsunit/wasm/import-table.js +++ b/deps/v8/test/mjsunit/wasm/import-function.js diff --git a/deps/v8/test/mjsunit/wasm/indirect-tables.js b/deps/v8/test/mjsunit/wasm/indirect-tables.js index 88d1bb719a..9176ec4932 100644 --- a/deps/v8/test/mjsunit/wasm/indirect-tables.js +++ b/deps/v8/test/mjsunit/wasm/indirect-tables.js @@ -33,7 +33,7 @@ function AddFunctions(builder) { function js_div(a, b) { return (a / b) | 0; } (function ExportedTableTest() { - print("ExportedTableTest..."); + print(arguments.callee.name); let builder = new WasmModuleBuilder(); @@ -102,9 +102,9 @@ function js_div(a, b) { return (a / b) | 0; } })(); -(function ImportedTableTest() { +(function ImportedTableTest1() { let kTableSize = 10; - print("ImportedTableTest..."); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); let d = builder.addImport("q", "js_div", kSig_i_ii); @@ -172,9 +172,9 @@ function js_div(a, b) { return (a / b) | 0; } } })(); -(function ImportedTableTest() { +(function ImportedTableTest2() { let kTableSize = 10; - print("ManualTableTest..."); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); @@ -240,7 +240,7 @@ function js_div(a, b) { return (a / b) | 0; } (function CumulativeTest() { - print("CumulativeTest..."); + print(arguments.callee.name); let kTableSize = 10; let table = new WebAssembly.Table( @@ -251,7 +251,7 @@ function js_div(a, b) { return (a / b) | 0; } builder.addImportedTable("x", "table", kTableSize, kTableSize); let g = builder.addImportedGlobal("x", "base", kWasmI32); let sig_index = builder.addType(kSig_i_v); - builder.addFunction("g", sig_index) + let f = builder.addFunction("f", sig_index) .addBody([ kExprGetGlobal, g ]); @@ -260,7 +260,7 @@ function js_div(a, b) { return (a / b) | 0; } kExprGetLocal, 0, kExprCallIndirect, sig_index, kTableZero]) // -- .exportAs("main"); - builder.addFunctionTableInit(g, true, [g]); + builder.addFunctionTableInit(g, true, [f.index]); let module = new WebAssembly.Module(builder.toBuffer()); @@ -283,7 +283,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TwoWayTest() { - print("TwoWayTest..."); + print(arguments.callee.name); let kTableSize = 3; // Module {m1} defines the table and exports it. @@ -342,7 +342,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function MismatchedTableSize() { - print("MismatchedTableSize..."); + print(arguments.callee.name); let kTableSize = 5; for (var expsize = 1; expsize < 4; expsize++) { @@ -374,7 +374,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TableGrowBoundsCheck() { - print("TableGrowBoundsCheck"); + print(arguments.callee.name); var kMaxSize = 30, kInitSize = 5; let table = new WebAssembly.Table({element: "anyfunc", initial: kInitSize, maximum: kMaxSize}); @@ -398,7 +398,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function CumulativeGrowTest() { - print("CumulativeGrowTest..."); + print(arguments.callee.name); let table = new WebAssembly.Table({ element: "anyfunc", initial: 10, maximum: 30}); var builder = new WasmModuleBuilder(); @@ -460,7 +460,7 @@ function js_div(a, b) { return (a / b) | 0; } (function TestImportTooLarge() { - print("TestImportTooLarge..."); + print(arguments.callee.name); let builder = new WasmModuleBuilder(); builder.addImportedTable("t", "t", 1, 2); @@ -478,7 +478,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TableImportLargerThanCompiled() { - print("TableImportLargerThanCompiled..."); + print(arguments.callee.name); var kMaxSize = 30, kInitSize = 5; var builder = new WasmModuleBuilder(); builder.addImportedTable("x", "table", 1, 35); @@ -492,7 +492,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function ModulesShareTableAndGrow() { - print("ModulesShareTableAndGrow..."); + print(arguments.callee.name); let module1 = (() => { let builder = new WasmModuleBuilder(); builder.addImportedTable("x", "table", 1, 35); @@ -525,7 +525,7 @@ function js_div(a, b) { return (a / b) | 0; } (function MultipleElementSegments() { let kTableSize = 10; - print("MultipleElementSegments..."); + print(arguments.callee.name); let mul = (a, b) => a * b; let add = (a, b) => a + b; @@ -603,7 +603,8 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function IndirectCallIntoOtherInstance() { - print("IndirectCallIntoOtherInstance..."); + print(arguments.callee.name); + var mem_1 = new WebAssembly.Memory({initial: 1}); var mem_2 = new WebAssembly.Memory({initial: 1}); var view_1 = new Int32Array(mem_1.buffer); @@ -644,7 +645,7 @@ function js_div(a, b) { return (a / b) | 0; } (function ImportedFreestandingTable() { - print("ImportedFreestandingTable..."); + print(arguments.callee.name); function forceGc() { gc(); @@ -709,7 +710,8 @@ function js_div(a, b) { return (a / b) | 0; } // Remove this test when v8:7232 is addressed comprehensively. (function TablesAreImmutableInWasmCallstacks() { - print('TablesAreImmutableInWasmCallstacks...'); + print(arguments.callee.name); + let table = new WebAssembly.Table({initial:2, element:'anyfunc'}); let builder = new WasmModuleBuilder(); @@ -743,3 +745,93 @@ function js_div(a, b) { return (a / b) | 0; } table.set(0, null); assertEquals(null, table.get(0)); })(); + +(function ImportedWasmFunctionPutIntoTable() { + print(arguments.callee.name); + + let wasm_mul = (() => { + let builder = new WasmModuleBuilder(); + builder.addFunction("mul", kSig_i_ii) + .addBody( + [kExprGetLocal, 0, + kExprGetLocal, 1, + kExprI32Mul]) + .exportFunc(); + return builder.instantiate().exports.mul; + })(); + + let builder = new WasmModuleBuilder(); + + let j = builder.addImport("q", "js_div", kSig_i_ii); + let w = builder.addImport("q", "wasm_mul", kSig_i_ii); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableBounds(10, 10); + let g = builder.addImportedGlobal("q", "base", kWasmI32); + builder.addFunctionTableInit(g, true, [j, w]); + + let module = new WebAssembly.Module(builder.toBuffer()); + for (var i = 0; i < 5; i++) { + let instance = new WebAssembly.Instance(module, {q: {base: i, js_div: js_div, wasm_mul: wasm_mul}}); + let j = i + 1; + + assertThrows(() => {instance.exports.main(j, i-1)}); + assertEquals((33/j)|0, instance.exports.main(j, i+0)); + assertEquals((33*j)|0, instance.exports.main(j, i+1)); + assertThrows(() => {instance.exports.main(j, i+2)}); + } + +})(); + +(function ImportedWasmFunctionPutIntoImportedTable() { + print(arguments.callee.name); + + let kTableSize = 10; + + let wasm_mul = (() => { + let builder = new WasmModuleBuilder(); + builder.addFunction("mul", kSig_i_ii) + .addBody( + [kExprGetLocal, 0, + kExprGetLocal, 1, + kExprI32Mul]) + .exportFunc(); + return builder.instantiate().exports.mul; + })(); + + let table = new WebAssembly.Table({element: "anyfunc", + initial: kTableSize, + maximum: kTableSize}); + + let builder = new WasmModuleBuilder(); + + let j = builder.addImport("q", "js_div", kSig_i_ii); + let w = builder.addImport("q", "wasm_mul", kSig_i_ii); + builder.addImportedTable("q", "table", kTableSize, kTableSize); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 44, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + let g = builder.addImportedGlobal("q", "base", kWasmI32); + builder.addFunctionTableInit(g, true, [j, w]); + + let module = new WebAssembly.Module(builder.toBuffer()); + for (var i = 0; i < 5; i++) { + let instance = new WebAssembly.Instance(module, {q: {base: i, js_div: js_div, wasm_mul: wasm_mul, table: table}}); + let j = i + 1; + + assertEquals((44/j)|0, instance.exports.main(j, i+0)); + assertEquals((44*j)|0, instance.exports.main(j, i+1)); + assertThrows(() => {instance.exports.main(j, i+2)}); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/interpreter.js b/deps/v8/test/mjsunit/wasm/interpreter.js index f5697eb00f..a57498b9a8 100644 --- a/deps/v8/test/mjsunit/wasm/interpreter.js +++ b/deps/v8/test/mjsunit/wasm/interpreter.js @@ -296,7 +296,7 @@ function checkStack(stack, expected_lines) { } catch (e) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ - 'TypeError: invalid type', // - + 'TypeError: ' + kTrapMsgs[kTrapTypeError], // - ' at direct (wasm-function[1]:1)', // - ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - @@ -309,7 +309,7 @@ function checkStack(stack, expected_lines) { } catch (e) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ - 'TypeError: invalid type', // - + 'TypeError: ' + kTrapMsgs[kTrapTypeError], // - ' at indirect (wasm-function[2]:1)', // - ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - @@ -493,3 +493,30 @@ function checkStack(stack, expected_lines) { tab.set(0, instance1.exports.exp); instance2.exports.call2(); })(); + +(function testTableCall3() { + // See crbug.com/814562. + print(arguments.callee.name); + const builder0 = new WasmModuleBuilder(); + const sig_index = builder0.addType(kSig_i_v); + builder0.addFunction('main', kSig_i_i) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_index, kTableZero + ]) // -- + .exportAs('main'); + builder0.setFunctionTableBounds(3, 3); + builder0.addExportOfKind('table', kExternalTable); + const module0 = new WebAssembly.Module(builder0.toBuffer()); + const instance0 = new WebAssembly.Instance(module0); + + const builder1 = new WasmModuleBuilder(); + builder1.addFunction('main', kSig_i_v).addBody([kExprUnreachable]); + builder1.addImportedTable('z', 'table'); + builder1.addFunctionTableInit(0, false, [0], true); + const module1 = new WebAssembly.Module(builder1.toBuffer()); + const instance1 = + new WebAssembly.Instance(module1, {z: {table: instance0.exports.table}}); + assertThrows( + () => instance0.exports.main(0), WebAssembly.RuntimeError, 'unreachable'); +})(); diff --git a/deps/v8/test/mjsunit/wasm/liftoff.js b/deps/v8/test/mjsunit/wasm/liftoff.js index b65f83f9ec..c57cbfc090 100644 --- a/deps/v8/test/mjsunit/wasm/liftoff.js +++ b/deps/v8/test/mjsunit/wasm/liftoff.js @@ -7,6 +7,22 @@ load('test/mjsunit/wasm/wasm-constants.js'); load('test/mjsunit/wasm/wasm-module-builder.js'); +(function testLiftoffFlag() { + print(arguments.callee.name); + const builder = new WasmModuleBuilder(); + builder.addFunction('i32_add', kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add]) + .exportFunc(); + + const module = new WebAssembly.Module(builder.toBuffer()); + const instance = new WebAssembly.Instance(module); + const instance2 = new WebAssembly.Instance(module); + + assertEquals(%IsLiftoffFunction(instance.exports.i32_add), + %IsLiftoffFunction(instance2.exports.i32_add)); +})(); + + (function testLiftoffSync() { print(arguments.callee.name); const builder = new WasmModuleBuilder(); diff --git a/deps/v8/test/mjsunit/wasm/memory-size.js b/deps/v8/test/mjsunit/wasm/memory-size.js index 0c96efb798..f803df2e3d 100644 --- a/deps/v8/test/mjsunit/wasm/memory-size.js +++ b/deps/v8/test/mjsunit/wasm/memory-size.js @@ -7,8 +7,11 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); +var kV8MaxWasmMemoryPages = 32767; // ~ 2 GiB +var kSpecMaxWasmMemoryPages = 65536; // 4 GiB + (function testMemorySizeZero() { - print("testMemorySizeZero()"); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); builder.addMemory(0, 0, false); builder.addFunction("memory_size", kSig_i_v) @@ -19,7 +22,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); })(); (function testMemorySizeNonZero() { - print("testMemorySizeNonZero()"); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); var size = 11; builder.addMemory(size, size, false); @@ -29,3 +32,42 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var module = builder.instantiate(); assertEquals(size, module.exports.memory_size()); })(); + +(function testMemorySizeSpecMaxOk() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, kSpecMaxWasmMemoryPages, true); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(1, module.exports.memory_size()); +})(); + +(function testMemorySizeV8MaxPlus1Throws() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(kV8MaxWasmMemoryPages + 1, + kV8MaxWasmMemoryPages + 1, false); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + assertThrows(() => builder.instantiate()); +})(); + +(function testMemorySpecMaxOk() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, kSpecMaxWasmMemoryPages, false); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(1, module.exports.memory_size()); +})(); + +(function testMemoryInitialMaxPlus1Throws() { + print(arguments.callee.name); + assertThrows(() => new WebAssembly.Memory( + {initial: kV8WasmMaxMemoryPages + 1})); +})(); diff --git a/deps/v8/test/mjsunit/wasm/table-grow.js b/deps/v8/test/mjsunit/wasm/table-grow.js index a9a4ba298c..c78d272139 100644 --- a/deps/v8/test/mjsunit/wasm/table-grow.js +++ b/deps/v8/test/mjsunit/wasm/table-grow.js @@ -286,7 +286,7 @@ let id = (() => { // identity exported function assertInvalidFunction = function(s) { assertThrows( () => instances[i].exports.main(s), WebAssembly.RuntimeError, - /invalid function/); + kTrapMsgs[kTrapFuncInvalid]); } assertInvalidFunction(size); assertInvalidFunction(size + 1); diff --git a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js b/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js deleted file mode 100644 index e298468350..0000000000 --- a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-wasm --allow-natives-syntax - -load("test/mjsunit/wasm/wasm-constants.js"); -load("test/mjsunit/wasm/wasm-module-builder.js"); - -var expect_elison = 0; -var expect_no_elison = 1; -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, first_import and second_export have same signature, -// So that wrappers will be removed -(function TestWasmWrapperElision() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index = second_module.addType(kSig_i_i); - second_module - .addImport("import_module_2", "import_name_2", sig_index); - second_module - .addFunction("second_export", sig_index) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index = first_module.addType(kSig_i_i); - first_module - .addImport("import_module_1", "import_name_1", sig_index); - first_module - .addFunction("first_export", sig_index) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index) - .addBody([ - kExprI32Const, 1, - kExprGetLocal, 0, - kExprI32Add, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(2), 3); - assertEquals(the_export(-1), 0); - assertEquals(the_export(0), 1); - assertEquals(the_export(5.5), 6); - assertEquals(%CheckWasmWrapperElision(the_export, expect_elison), true); -})(); - -// Function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this test, first_import and second_export have the same signature, and -// therefore the wrappers will be removed. If the wrappers are not removed, then -// the test crashes because of the int64 parameter, which is not allowed in the -// wrappers. -(function TestWasmWrapperElisionInt64() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index1 = second_module.addType(kSig_i_i); - var sig_index_ll = second_module.addType(kSig_l_l); - second_module - .addImport("import_module_2", "import_name_2", sig_index1); - second_module - .addFunction("second_export", sig_index_ll) - .addBody([ - kExprGetLocal, 0, - kExprI32ConvertI64, - kExprCallFunction, 0, - kExprI64SConvertI32, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index = first_module.addType(kSig_i_v); - var sig_index_ll = first_module.addType(kSig_l_l); - first_module - .addImport("import_module_1", "import_name_1", sig_index_ll); - first_module - .addFunction("first_export", sig_index) - .addBody([ - kExprI64Const, 2, - kExprCallFunction, 2, - kExprI32ConvertI64, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_ll) - .addBody([ - kExprI64Const, 1, - kExprGetLocal, 0, - kExprI64Add, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(), 3); -})(); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has fewer params than first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionLessParams() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_1 = second_module.addType(kSig_i_i); - second_module - .addImport("import_module_2", "import_name_2", sig_index_1); - second_module - .addFunction("second_export", sig_index_1) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(4, 5), 4); - assertEquals(the_export(-1, 4), -1); - assertEquals(the_export(0, 2), 0); - assertEquals(the_export(9.9, 4.3), 9); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has more params than first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionMoreParams() { - var imported = function (a, b, c) { - return a+b+c; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_3 = second_module.addType(kSig_i_iii); - second_module - .addImport("import_module_2", "import_name_2", sig_index_3); - second_module - .addFunction("second_export", sig_index_3) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprGetLocal, 2, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(5, 6), 11); - assertEquals(the_export(-1, -4), -5); - assertEquals(the_export(0, 0), 0); - assertEquals(the_export(1.1, 2.7), 3); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has different params type with first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionTypeMismatch() { - var imported = function (a, b) { - return a+b; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_2 = second_module.addType(kSig_d_dd); - second_module - .addImport("import_module_2", "import_name_2", sig_index_2); - second_module - .addFunction("second_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(2.8, 9.1), 11); - assertEquals(the_export(-1.7, -2.5), -3); - assertEquals(the_export(0.0, 0.0), 0); - assertEquals(the_export(2, -2), 0); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - - -(function TestSimpleI64Ret() { - var builder = new WasmModuleBuilder(); - builder.addFunction("exp", kSig_l_v) - .addBody([ - kExprI64Const, 23 - ]) - .exportFunc(); - var exported = builder.instantiate().exports.exp; - - var builder = new WasmModuleBuilder(); - builder.addImport("imp", "func", kSig_l_v); - builder.addFunction("main", kSig_i_v) - .addBody([ - kExprCallFunction, 0, - kExprI32ConvertI64 - ]) - .exportFunc(); - - var instance = builder.instantiate({imp: {func: exported}}); - - assertEquals(23, instance.exports.main()); - -})(); diff --git a/deps/v8/test/mjsunit/wasm/wasm-constants.js b/deps/v8/test/mjsunit/wasm/wasm-constants.js index 4c86065b89..4a303c77ac 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-constants.js +++ b/deps/v8/test/mjsunit/wasm/wasm-constants.js @@ -114,7 +114,7 @@ let kSig_i_dd = makeSig([kWasmF64, kWasmF64], [kWasmI32]); let kSig_v_v = makeSig([], []); let kSig_i_v = makeSig([], [kWasmI32]); let kSig_l_v = makeSig([], [kWasmI64]); -let kSig_f_v = makeSig([], [kWasmF64]); +let kSig_f_v = makeSig([], [kWasmF32]); let kSig_d_v = makeSig([], [kWasmF64]); let kSig_v_i = makeSig([kWasmI32], []); let kSig_v_ii = makeSig([kWasmI32, kWasmI32], []); @@ -374,7 +374,7 @@ let kTrapRemByZero = 4; let kTrapFloatUnrepresentable = 5; let kTrapFuncInvalid = 6; let kTrapFuncSigMismatch = 7; -let kTrapInvalidIndex = 8; +let kTrapTypeError = 8; let kTrapMsgs = [ "unreachable", @@ -382,10 +382,10 @@ let kTrapMsgs = [ "divide by zero", "divide result unrepresentable", "remainder by zero", - "integer result unrepresentable", - "invalid function", + "float unrepresentable in integer range", + "invalid index into function table", "function signature mismatch", - "invalid index into function table" + "wasm function signature contains illegal type" ]; function assertTraps(trap, code) { |