diff options
Diffstat (limited to 'deps/v8/test/mjsunit/es6')
7 files changed, 202 insertions, 3 deletions
diff --git a/deps/v8/test/mjsunit/es6/array-iterator-detached.js b/deps/v8/test/mjsunit/es6/array-iterator-detached.js index f385039b4d..4e4f664373 100644 --- a/deps/v8/test/mjsunit/es6/array-iterator-detached.js +++ b/deps/v8/test/mjsunit/es6/array-iterator-detached.js @@ -17,7 +17,7 @@ function Baseline() { %NeverOptimizeFunction(Baseline); assertThrows(Baseline, TypeError, - "Cannot perform Array Iterator.prototype.next on a neutered ArrayBuffer"); + "Cannot perform Array Iterator.prototype.next on a detached ArrayBuffer"); function Turbo(count = 10000) { let array = Array(10000); @@ -45,4 +45,4 @@ Turbo(10); %OptimizeFunctionOnNextCall(Turbo); assertThrows(Turbo, TypeError, - "Cannot perform Array Iterator.prototype.next on a neutered ArrayBuffer"); + "Cannot perform Array Iterator.prototype.next on a detached ArrayBuffer"); diff --git a/deps/v8/test/mjsunit/es6/block-conflicts-sloppy.js b/deps/v8/test/mjsunit/es6/block-conflicts-sloppy.js index b2ebfce6c9..8d896b93a2 100644 --- a/deps/v8/test/mjsunit/es6/block-conflicts-sloppy.js +++ b/deps/v8/test/mjsunit/es6/block-conflicts-sloppy.js @@ -3,6 +3,8 @@ // found in the LICENSE file. // Test for conflicting variable bindings. +// Stress-testing this test is very slow and provides no useful coverage. +// Flags: --nostress-opt --noalways-opt function CheckException(e) { var string = e.toString(); diff --git a/deps/v8/test/mjsunit/es6/block-const-assign.js b/deps/v8/test/mjsunit/es6/block-const-assign.js index 541dc0d97b..5700d69d04 100644 --- a/deps/v8/test/mjsunit/es6/block-const-assign.js +++ b/deps/v8/test/mjsunit/es6/block-const-assign.js @@ -29,6 +29,9 @@ // when using an immutable binding in an assigment or with // prefix/postfix decrement/increment operators. +// Optimization stress is not useful for early syntax errors. +// Flags: --nostress-opt --noalways-opt + "use strict"; const decls = [ @@ -135,7 +138,8 @@ let usecontexts = [ function Test(program, error) { program = "'use strict'; " + program; try { - print(program, " // throw " + error.name); + // If you need to debug this test, enable the following line: + // print(program, " // throw " + error.name); eval(program); } catch (e) { assertInstanceof(e, error); diff --git a/deps/v8/test/mjsunit/es6/iterator-eager-deopt.js b/deps/v8/test/mjsunit/es6/iterator-eager-deopt.js new file mode 100644 index 0000000000..fe004c8c6d --- /dev/null +++ b/deps/v8/test/mjsunit/es6/iterator-eager-deopt.js @@ -0,0 +1,69 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The GetIterator bytecode is used to implement a part of the iterator +// protocol (https://tc39.es/ecma262/#sec-getiterator). Here, the +// bytecode performs multiple operations including some that have side-effects +// and may deoptimize eagerly or lazily. +// This test ensures the eager deoptimization is handled correctly. + +// Flags: --allow-natives-syntax --no-always-opt + +var getIteratorCount = 0; +var iteratorCount = 0; +var iteratorAfterEagerDeoptCount = 0; + +function foo(obj) { + // The following for-of loop uses the iterator protocol to iterate + // over the 'obj'. + // The GetIterator bytecode invovlves 3 steps: + // 1. method = GetMethod(obj, @@iterator) + // 2. iterator = Call(method, obj) + // 3. if(!IsJSReceiver(iterator)) throw SymbolIteratorInvalid. + for(var x of obj){} +} + +// This iterator gets inlined when the 'foo' function is JIT compiled for +// the first time. +var iterator = function() { + iteratorCount++; + return { + next: function() { + return { done: true }; + } + } +} + +var iteratorAfterEagerDeopt = function() { + iteratorAfterEagerDeoptCount++; + return { + next: function() { + return { done: true }; + } + } +} + +// Here, retrieval of function at @@iterator has side effect (increments the +// 'getIteratorCount'). Changing the value of 'iterator' in the JIT compiled +// 'foo' causes deoptimization after the count is incremented. Now the deopt +// cannot resume at the beginning of the bytecode because it would end up in +// incrementing the count again. +let y = { get [Symbol.iterator] () { + getIteratorCount++; + return iterator; + } + }; + +%PrepareFunctionForOptimization(foo); +foo(y); +foo(y); +%OptimizeFunctionOnNextCall(foo); + +// Change the value of 'iterator' to trigger eager deoptimization of 'foo'. +iterator = iteratorAfterEagerDeopt +foo(y); +assertUnoptimized(foo); +assertEquals(getIteratorCount, 3); +assertEquals(iteratorCount, 2); +assertEquals(iteratorAfterEagerDeoptCount, 1); diff --git a/deps/v8/test/mjsunit/es6/iterator-invalid-receiver-opt.js b/deps/v8/test/mjsunit/es6/iterator-invalid-receiver-opt.js new file mode 100644 index 0000000000..fac416b5b5 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/iterator-invalid-receiver-opt.js @@ -0,0 +1,51 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The GetIterator bytecode is used to implement a part of the iterator +// protocol (https://tc39.es/ecma262/#sec-getiterator). +// Here, call to the @@iterator property returns invalid JS receiver. +// This test ensures that the optimized version of the GetIterator bytecode +// incorporates exception handling mechanism without deoptimizing. + +// Flags: --allow-natives-syntax --opt + +var iteratorCount = 0; +var exceptionCount = 0; + +function foo(obj) { + // The following for-of loop uses the iterator protocol to iterate + // over the 'obj'. + // The GetIterator bytecode invovlves 3 steps: + // 1. method = GetMethod(obj, @@iterator) + // 2. iterator = Call(method, obj) + // 3. if(!IsJSReceiver(iterator)) throw SymbolIteratorInvalid. + try{ + for(let a of obj){ + assertUnreachable(); + } + } catch(e){ + exceptionCount++; + } +} + +// This iterator retuns '3' which is not a valid JSReceiver +var iterator = function() { + iteratorCount++; + return 3; +} + +let y = { + get [Symbol.iterator]() { + return iterator; + } +}; + +%PrepareFunctionForOptimization(foo); +foo(y); +foo(y); +%OptimizeFunctionOnNextCall(foo); +foo(y); +assertOptimized(foo); +assertEquals(iteratorCount, 3); +assertEquals(exceptionCount, 3); diff --git a/deps/v8/test/mjsunit/es6/iterator-lazy-deopt.js b/deps/v8/test/mjsunit/es6/iterator-lazy-deopt.js new file mode 100644 index 0000000000..f2b39a208d --- /dev/null +++ b/deps/v8/test/mjsunit/es6/iterator-lazy-deopt.js @@ -0,0 +1,71 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The GetIterator bytecode is used to implement a part of the iterator +// protocol (https://tc39.es/ecma262/#sec-getiterator). Here, the +// bytecode performs multiple operations including some that have side-effects +// and may deoptimize eagerly or lazily. +// This test ensures the lazy deoptimization is handled correctly. + +// Flags: --allow-natives-syntax --no-always-opt + +var triggerLazyDeopt = false +var iteratorCount = 0; +var iteratorAfterLazyDeoptCount = 0; +var getIteratorCount = 0; + +function foo(obj) { + // The following for-of loop uses the iterator protocol to iterate + // over the 'obj'. + // The GetIterator bytecode invovlves 3 steps: + // 1. method = GetMethod(obj, @@iterator) + // 2. iterator = Call(method, obj) + // 3. if(!IsJSReceiver(iterator)) throw SymbolIteratorInvalid. + for(var x of obj){} +} + +// This iterator gets inlined when the 'foo' function is JIT compiled for +// the first time. +var iterator = function() { + iteratorCount++; + return { + next: function() { + return { done: true }; + } + } +} + +iteratorAfterLazyDeopt = function() { + iteratorAfterLazyDeoptCount++; + return { + next: function() { + return { done: true }; + } + } +} +// Here, retrieval of function at @@iterator has side effect (increments the +// 'getIteratorCount').The lazy deoptimization is triggerred by setting the +// 'triggerLazyDeopt' to true after the count is incremented. Now the deopt +// cannot resume at the beginning of the bytecode because it would end up in +// incrementing the count again. +let y = { get [Symbol.iterator] () { + getIteratorCount++; + if(triggerLazyDeopt) { + %DeoptimizeFunction(foo); + iterator = iteratorAfterLazyDeopt + } + return iterator; + } + }; + +%PrepareFunctionForOptimization(foo); +foo(y); +foo(y); +%OptimizeFunctionOnNextCall(foo); +triggerLazyDeopt = true; +foo(y); +assertUnoptimized(foo); +assertEquals(getIteratorCount, 3); +assertEquals(iteratorCount, 2); +assertEquals(iteratorAfterLazyDeoptCount, 1); diff --git a/deps/v8/test/mjsunit/es6/large-classes-properties.js b/deps/v8/test/mjsunit/es6/large-classes-properties.js index fe3fb13b8f..c725d8376e 100644 --- a/deps/v8/test/mjsunit/es6/large-classes-properties.js +++ b/deps/v8/test/mjsunit/es6/large-classes-properties.js @@ -3,6 +3,8 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax +// This gets very slow with stress flags, and triggers optimization anyway: +// Flags: --nostress-opt --noalways-opt (function testLargeClassesProperties(){ // This is to test for dictionary mode when there more than |