diff options
Diffstat (limited to 'deps/v8/test/mjsunit')
376 files changed, 7068 insertions, 2510 deletions
diff --git a/deps/v8/test/mjsunit/allocation-site-info.js b/deps/v8/test/mjsunit/allocation-site-info.js index c7184af6f2..075678bdbb 100644 --- a/deps/v8/test/mjsunit/allocation-site-info.js +++ b/deps/v8/test/mjsunit/allocation-site-info.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --opt --no-always-opt +// Flags: --opt --no-always-opt --no-stress-fullcodegen var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -45,14 +45,14 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; } function isHoley(obj) { - if (%HasFastHoleyElements(obj)) return true; + if (%HasHoleyElements(obj)) return true; return false; } @@ -81,7 +81,7 @@ assertNotHoley(obj); assertKind(elements_kind.fast_smi_only, obj); obj = new Array(0); -assertNotHoley(obj); +assertHoley(obj); assertKind(elements_kind.fast_smi_only, obj); obj = new Array(2); @@ -271,7 +271,7 @@ assertKind(elements_kind.fast, obj); return a; } - for (i = 0; i < 2; i++) { + for (var i = 0; i < 2; i++) { a = foo(i); b = foo(i); b[5] = 1; // boilerplate goes holey @@ -279,7 +279,7 @@ assertKind(elements_kind.fast, obj); a[0] = 3.5; // boilerplate goes holey double assertKind(elements_kind.fast_double, a); assertNotHoley(a); - c = foo(i); + var c = foo(i); assertKind(elements_kind.fast_double, c); assertHoley(c); } @@ -422,8 +422,10 @@ gc(); obj = get_object_literal(); assertKind(elements_kind.fast_smi_only, obj.array); + // Force double transition. obj.array[1] = 3.5; assertKind(elements_kind.fast_double, obj.array); + // Transition information should be fed back to the inner literal. obj = get_object_literal(); assertKind(elements_kind.fast_double, obj.array); @@ -496,3 +498,71 @@ gc(); var b = make(); assertKind(elements_kind.fast_double, b); })(); + +(function TestBoilerplateMapDeprecation() { + function literal() { + return { a: 1, b: 2 }; + } + literal(); + literal(); + let instance = literal(); + assertKind(elements_kind.fast_smi_only, [instance.a, instance.b]); + // Create literal instances with double insteand of smi values. + for (let i = 0; i < 1000; i++) { + instance = literal(); + instance.a = 1.2; + assertKind(elements_kind.fast_double, [instance.a, instance.b]); + } + + // After deprecating the original boilerplate map we should get heap numbers + // back for the original unmodified literal as well. + for (let i =0; i < 100; i++) { + instance = literal(); + assertKind(elements_kind.fast_double, [instance.a, instance.b]); + } +})(); + +(function TestInnerBoilerplateMapDeprecation() { + // Create a literal where the inner literals cause a map deprecation of the + // previous inner literal. + function literal() { + return [ + {xA2A:false, a: 1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1, b: 2, c: 3, d: 4.1}, + + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1}, + {xA2A:false, a: 1.1, b: 2, c: 3, d: 4.1} + ]; + }; + let instance = literal(); + + // Make sure all sub-literals are migrated properly. + for (let i = 0; i < instance.length; i++) { + let sub_literal = instance[i]; + assertKind(elements_kind.fast_double, [sub_literal.a]); + assertKind(elements_kind.fast_smi_only, [sub_literal.b]); + assertKind(elements_kind.fast_smi_only, [sub_literal.c]); + assertKind(elements_kind.fast_double, [sub_literal.d]); + } + + instance = literal(); + instance = literal(); + instance = literal(); + for (let i = 0; i < instance.length; i++) { + let sub_literal = instance[i]; + assertKind(elements_kind.fast_double, [sub_literal.a]); + assertKind(elements_kind.fast_smi_only, [sub_literal.b]); + assertKind(elements_kind.fast_smi_only, [sub_literal.c]); + assertKind(elements_kind.fast_double, [sub_literal.d]); + } +})(); diff --git a/deps/v8/test/mjsunit/apply.js b/deps/v8/test/mjsunit/apply.js index 7ce6acccba..c52a23f91f 100644 --- a/deps/v8/test/mjsunit/apply.js +++ b/deps/v8/test/mjsunit/apply.js @@ -141,6 +141,28 @@ for (var j = 1; j < 0x400000; j <<= 1) { } } +// Check packed double arrays +var arr = [0.0]; +for (var i = 1; i < 4; i++) { + arr.push(i * 0.1); +} +assertEquals(0.0, Math.min.apply(Math, arr)); +assertEquals(0.30000000000000004, Math.max.apply(Math, arr)); + +// Check holey double arrays +var arr = Array(4); +for (var i = 0; i < 4; i++) { + arr[i] = i * 0.1; +} +assertEquals(0.0, Math.min.apply(Math, arr)); +assertEquals(0.30000000000000004, Math.max.apply(Math, arr)); + +// Check that holes are set properly +arr[5] = 0.5; +assertEquals(NaN, Math.min.apply(Math, arr)); +assertEquals(NaN, Math.max.apply(Math, arr)); + + var primes = new Array(0); function isPrime(possible_prime) { diff --git a/deps/v8/test/mjsunit/arguments-deopt.js b/deps/v8/test/mjsunit/arguments-deopt.js index edc6aa44c5..20e5f69152 100644 --- a/deps/v8/test/mjsunit/arguments-deopt.js +++ b/deps/v8/test/mjsunit/arguments-deopt.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax (function MaterializeStrictArguments() { "use strict" diff --git a/deps/v8/test/mjsunit/arguments.js b/deps/v8/test/mjsunit/arguments.js index 8c6186e1b9..caaac5a4d3 100644 --- a/deps/v8/test/mjsunit/arguments.js +++ b/deps/v8/test/mjsunit/arguments.js @@ -352,3 +352,17 @@ assertEquals(117, arg_set(0xFFFFFFFF)); args2.length = "aa" assertTrue(%HaveSameMap(args1, args2)); })(); + + +(function testArgumentsVerification() { + (function f2(a,a) { + %HeapObjectVerify(arguments); + })(1,2); + + function f7(a,a,a,a,a,a,a) { + %HeapObjectVerify(arguments); + }; + f7(1,2,3,4,5,6); + f7(1,2,3,4,5,6,7); + f7(1,2,3,4,5,6,7,8); +})(); diff --git a/deps/v8/test/mjsunit/array-construct-transition.js b/deps/v8/test/mjsunit/array-construct-transition.js index 3847f9405a..234fa4b93b 100644 --- a/deps/v8/test/mjsunit/array-construct-transition.js +++ b/deps/v8/test/mjsunit/array-construct-transition.js @@ -28,8 +28,8 @@ // Flags: --allow-natives-syntax var a = new Array(0, 1, 2); -assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasSmiElements(a)); var b = new Array(0.5, 1.2, 2.3); -assertTrue(%HasFastDoubleElements(b)); +assertTrue(%HasDoubleElements(b)); var c = new Array(0.5, 1.2, new Object()); -assertTrue(%HasFastObjectElements(c)); +assertTrue(%HasObjectElements(c)); diff --git a/deps/v8/test/mjsunit/array-constructor-feedback.js b/deps/v8/test/mjsunit/array-constructor-feedback.js index d5715f6d2d..12016b430a 100644 --- a/deps/v8/test/mjsunit/array-constructor-feedback.js +++ b/deps/v8/test/mjsunit/array-constructor-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --no-always-opt --opt +// Flags: --no-always-opt --opt --no-stress-fullcodegen // Test element kind of objects. @@ -47,14 +47,14 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; } function isHoley(obj) { - if (%HasFastHoleyElements(obj)) return true; + if (%HasHoleyElements(obj)) return true; return false; } @@ -180,7 +180,7 @@ function assertKind(expected, obj, name_opt) { %OptimizeFunctionOnNextCall(bar); a = bar(0); assertOptimized(bar); - assertFalse(isHoley(a)); + assertTrue(isHoley(a)); a = bar(1); // ouch! assertOptimized(bar); assertTrue(isHoley(a)); @@ -188,9 +188,7 @@ function assertKind(expected, obj, name_opt) { assertTrue(isHoley(a)); a = bar(0); assertOptimized(bar); - // Crankshafted functions don't use mementos, so feedback still - // indicates a packed array is desired. - assertFalse(isHoley(a)); + assertTrue(isHoley(a)); })(); // Test: Make sure that crankshaft continues with feedback for large arrays. diff --git a/deps/v8/test/mjsunit/array-feedback.js b/deps/v8/test/mjsunit/array-feedback.js index 01856c57d0..223c50391f 100644 --- a/deps/v8/test/mjsunit/array-feedback.js +++ b/deps/v8/test/mjsunit/array-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --opt --no-always-opt +// Flags: --opt --no-always-opt --no-stress-fullcodegen var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -45,14 +45,14 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; } function isHoley(obj) { - if (%HasFastHoleyElements(obj)) return true; + if (%HasHoleyElements(obj)) return true; return false; } @@ -84,7 +84,7 @@ function assertKind(expected, obj, name_opt) { create1(0); create1(0); a = create1(0); - assertFalse(isHoley(a)); + assertTrue(isHoley(a)); assertKind(elements_kind.fast_smi_only, a); a[0] = "hello"; b = create1(10); diff --git a/deps/v8/test/mjsunit/array-indexing-receiver.js b/deps/v8/test/mjsunit/array-indexing-receiver.js index 5d1dbf3e56..ea8d02b218 100644 --- a/deps/v8/test/mjsunit/array-indexing-receiver.js +++ b/deps/v8/test/mjsunit/array-indexing-receiver.js @@ -10,15 +10,15 @@ var kIterCount = 1; var kTests = { Array: { - FAST_ELEMENTS() { + PACKED_ELEMENTS() { var r = /foo/; var s = new String("bar"); var p = new Proxy({}, {}); var o = {}; var array = [r, s, p]; - assertTrue(%HasFastObjectElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasObjectElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(p), 2); @@ -26,14 +26,14 @@ var kTests = { } }, - FAST_HOLEY_ELEMENTS() { + HOLEY_ELEMENTS() { var r = /foo/; var p = new Proxy({}, {}); var o = {}; var array = [r, , p]; - assertTrue(%HasFastObjectElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasObjectElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(p), 2); @@ -41,10 +41,10 @@ var kTests = { } }, - FAST_SMI_ELEMENTS() { + PACKED_SMI_ELEMENTS() { var array = [0, 88, 9999, 1, -5, 7]; - assertTrue(%HasFastSmiElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasSmiElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(9999), 2); @@ -55,10 +55,10 @@ var kTests = { } }, - FAST_HOLEY_SMI_ELEMENTS() { + HOLEY_SMI_ELEMENTS() { var array = [49, , , 72, , , 67, -48]; - assertTrue(%HasFastSmiElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasSmiElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(72), 3); @@ -70,11 +70,11 @@ var kTests = { } }, - FAST_DOUBLE_ELEMENTS() { + PACKED_DOUBLE_ELEMENTS() { var array = [7.00000001, -13000.89412, 73451.4124, 5824.48, 6.0000495, 48.3488, 44.0, 76.35, NaN, 78.4]; - assertTrue(%HasFastDoubleElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasDoubleElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(7.00000001), 0); @@ -87,11 +87,11 @@ var kTests = { } }, - FAST_HOLEY_DOUBLE_ELEMENTS() { + HOLEY_DOUBLE_ELEMENTS() { var array = [7.00000001, -13000.89412, , 5824.48, , 48.3488, , NaN, , 78.4]; - assertTrue(%HasFastDoubleElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasDoubleElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertEquals(array.indexOf(7.00000001), 0); @@ -123,16 +123,16 @@ var kTests = { }, Object: { - FAST_ELEMENTS() { + PACKED_ELEMENTS() { var r = /foo/; var s = new String("bar"); var p = new Proxy({}, {}); var o = {}; var object = { 0: r, 1: s, 2: p, length: 3 }; - assertTrue(%HasFastObjectElements(object)); - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertFalse(%HasFastHoleyElements(object)); + assertTrue(%HasObjectElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, p), 2); @@ -140,14 +140,14 @@ var kTests = { } }, - FAST_HOLEY_ELEMENTS() { + HOLEY_ELEMENTS() { var r = /foo/; var p = new Proxy({}, {}); var o = {}; var object = { 0: r, 2: p, length: 3 }; - assertTrue(%HasFastObjectElements(object)); - assertTrue(%HasFastHoleyElements(object)); + assertTrue(%HasObjectElements(object)); + assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, p), 2); @@ -155,11 +155,11 @@ var kTests = { } }, - FAST_SMI_ELEMENTS() { + PACKED_SMI_ELEMENTS() { var object = { 0: 0, 1: 88, 2: 9999, 3: 1, 4: -5, 5: 7, length: 6 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastSmiElements(object)); - // assertFalse(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasSmiElements(object)); + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, 9999), 2); @@ -170,11 +170,11 @@ var kTests = { } }, - FAST_HOLEY_SMI_ELEMENTS() { + HOLEY_SMI_ELEMENTS() { var object = { 0: 49, 3: 72, 6: 67, 7: -48, length: 8 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastSmiElements(object)); - // assertTrue(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasSmiElements(object)); + // assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, 72), 3); @@ -186,13 +186,13 @@ var kTests = { } }, - FAST_DOUBLE_ELEMENTS() { + PACKED_DOUBLE_ELEMENTS() { var object = { 0: 7.00000001, 1: -13000.89412, 2: 73451.4124, 3: 5824.48, 4: 6.0000495, 5: 48.3488, 6: 44.0, 7: 76.35, 8: NaN, 9: 78.4, length: 10 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastDoubleElements(object)); - // assertFalse(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasDoubleElements(object)); + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, 7.00000001), 0); @@ -205,12 +205,12 @@ var kTests = { } }, - FAST_HOLEY_DOUBLE_ELEMENTS() { + HOLEY_DOUBLE_ELEMENTS() { var object = { 0: 7.00000001, 1: -13000.89412, 3: 5824.48, 5: 48.3488, 7: NaN, 9: 78.4, length: 10 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastDoubleElements(object)); - // assertTrue(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasDoubleElements(object)); + // assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertEquals(Array.prototype.indexOf.call(object, 7.00000001), 0); diff --git a/deps/v8/test/mjsunit/array-isarray.js b/deps/v8/test/mjsunit/array-isarray.js index 6b0d88543e..3ab8f8faff 100644 --- a/deps/v8/test/mjsunit/array-isarray.js +++ b/deps/v8/test/mjsunit/array-isarray.js @@ -6,9 +6,21 @@ assertTrue(Array.isArray([])); assertFalse(Array.isArray({})); assertFalse(Array.isArray(null)); +assertFalse(Array.isArray(0)); +assertFalse(Array.isArray(0.1)); +assertFalse(Array.isArray("")); +assertFalse(Array.isArray(undefined)); assertTrue(Array.isArray(new Proxy([], {}))); assertFalse(Array.isArray(new Proxy({}, {}))); assertTrue(Array.isArray(new Proxy(new Proxy([], {}), {}))); assertFalse(Array.isArray(new Proxy(new Proxy({}, {}), {}))); + +(function TestIsArrayStackOverflow() { + var proxy = new Proxy([], {}); + for(var i=0; i<200*1024; i++) { + proxy = new Proxy(proxy, {}); + } + assertThrows(()=>Array.isArray(proxy), RangeError); +})(); diff --git a/deps/v8/test/mjsunit/array-length.js b/deps/v8/test/mjsunit/array-length.js index ea2a6725b7..0fec92de00 100644 --- a/deps/v8/test/mjsunit/array-length.js +++ b/deps/v8/test/mjsunit/array-length.js @@ -43,6 +43,15 @@ assertEquals('undefined', typeof a[2]); assertEquals('undefined', typeof a[3]); +for(var i = 0; i < 10; i++) { + var array = new Array(i).fill(42); + array.push(42); + array.length = i; + array.length = i+1; + assertEquals('undefined' , typeof array[i]); +} + + var a = new Array(); a[0] = 0; a[1000] = 1000; diff --git a/deps/v8/test/mjsunit/array-literal-feedback.js b/deps/v8/test/mjsunit/array-literal-feedback.js index f3e39ddf4e..b03752a5f8 100644 --- a/deps/v8/test/mjsunit/array-literal-feedback.js +++ b/deps/v8/test/mjsunit/array-literal-feedback.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --opt --no-always-opt +// Flags: --opt --no-always-opt --no-stress-fullcodegen var elements_kind = { fast_smi_only : 'fast smi only elements', @@ -45,14 +45,14 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; } function isHoley(obj) { - if (%HasFastHoleyElements(obj)) return true; + if (%HasHoleyElements(obj)) return true; return false; } @@ -69,10 +69,10 @@ get_literal(3); // It's important to store a from before we crankshaft get_literal, because // mementos won't be created from crankshafted code at all. a = get_literal(3); - %OptimizeFunctionOnNextCall(get_literal); +%OptimizeFunctionOnNextCall(get_literal); get_literal(3); assertOptimized(get_literal); -assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasSmiElements(a)); // a has a memento so the transition caused by the store will affect the // boilerplate. a[0] = 3.5; @@ -80,15 +80,15 @@ a[0] = 3.5; // We should have transitioned the boilerplate array to double, and // crankshafted code should de-opt on the unexpected elements kind b = get_literal(3); -assertTrue(%HasFastDoubleElements(b)); +assertTrue(%HasDoubleElements(b)); assertEquals([1, 2, 3], b); assertUnoptimized(get_literal); // Optimize again get_literal(3); - %OptimizeFunctionOnNextCall(get_literal); +%OptimizeFunctionOnNextCall(get_literal); b = get_literal(3); -assertTrue(%HasFastDoubleElements(b)); +assertTrue(%HasDoubleElements(b)); assertOptimized(get_literal); diff --git a/deps/v8/test/mjsunit/array-literal-transitions.js b/deps/v8/test/mjsunit/array-literal-transitions.js index 2db6fd35c5..0ea985b2fc 100644 --- a/deps/v8/test/mjsunit/array-literal-transitions.js +++ b/deps/v8/test/mjsunit/array-literal-transitions.js @@ -26,55 +26,55 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc --ignition-osr --no-always-opt -// Flags: --opt +// Flags: --opt --no-stress-fullcodegen // IC and Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. function array_literal_test() { var a0 = [1, 2, 3]; - assertTrue(%HasFastSmiElements(a0)); + assertTrue(%HasSmiElements(a0)); var a1 = [get(1), get(2), get(3)]; - assertTrue(%HasFastSmiElements(a1)); + assertTrue(%HasSmiElements(a1)); var b0 = [1, 2, get("three")]; - assertTrue(%HasFastObjectElements(b0)); + assertTrue(%HasObjectElements(b0)); var b1 = [get(1), get(2), get("three")]; - assertTrue(%HasFastObjectElements(b1)); + assertTrue(%HasObjectElements(b1)); var c0 = [1, 2, get(3.5)]; - assertTrue(%HasFastDoubleElements(c0)); + assertTrue(%HasDoubleElements(c0)); assertEquals(3.5, c0[2]); assertEquals(2, c0[1]); assertEquals(1, c0[0]); var c1 = [1, 2, 3.5]; - assertTrue(%HasFastDoubleElements(c1)); + assertTrue(%HasDoubleElements(c1)); assertEquals(3.5, c1[2]); assertEquals(2, c1[1]); assertEquals(1, c1[0]); var c2 = [get(1), get(2), get(3.5)]; - assertTrue(%HasFastDoubleElements(c2)); + assertTrue(%HasDoubleElements(c2)); assertEquals(3.5, c2[2]); assertEquals(2, c2[1]); assertEquals(1, c2[0]); var object = new Object(); var d0 = [1, 2, object]; - assertTrue(%HasFastObjectElements(d0)); + assertTrue(%HasObjectElements(d0)); assertEquals(object, d0[2]); assertEquals(2, d0[1]); assertEquals(1, d0[0]); var e0 = [1, 2, 3.5]; - assertTrue(%HasFastDoubleElements(e0)); + assertTrue(%HasDoubleElements(e0)); assertEquals(3.5, e0[2]); assertEquals(2, e0[1]); assertEquals(1, e0[0]); var f0 = [1, 2, [1, 2]]; - assertTrue(%HasFastObjectElements(f0)); + assertTrue(%HasObjectElements(f0)); assertEquals([1,2], f0[2]); assertEquals(2, f0[1]); assertEquals(1, f0[0]); @@ -101,9 +101,9 @@ function test_large_literal() { large = [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ]; assertFalse(%HasDictionaryElements(large)); - assertFalse(%HasFastSmiElements(large)); - assertFalse(%HasFastDoubleElements(large)); - assertTrue(%HasFastObjectElements(large)); + assertFalse(%HasSmiElements(large)); + assertFalse(%HasDoubleElements(large)); + assertTrue(%HasObjectElements(large)); assertEquals(large, [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, new Object(), new Object(), new Object(), new Object()]); diff --git a/deps/v8/test/mjsunit/array-natives-elements.js b/deps/v8/test/mjsunit/array-natives-elements.js index 9898faac23..8ab2148b91 100644 --- a/deps/v8/test/mjsunit/array-natives-elements.js +++ b/deps/v8/test/mjsunit/array-natives-elements.js @@ -44,83 +44,83 @@ var __sequence = 0; function array_natives_test() { // Ensure small array literals start in specific element kind mode. - assertTrue(%HasFastSmiElements([])); - assertTrue(%HasFastSmiElements([1])); - assertTrue(%HasFastSmiElements([1,2])); - assertTrue(%HasFastDoubleElements([1.1])); - assertTrue(%HasFastDoubleElements([1.1,2])); + assertTrue(%HasSmiElements([])); + assertTrue(%HasSmiElements([1])); + assertTrue(%HasSmiElements([1,2])); + assertTrue(%HasDoubleElements([1.1])); + assertTrue(%HasDoubleElements([1.1,2])); // Push var a0 = make_array("[1, 2, 3]"); - assertTrue(%HasFastSmiElements(a0)); + assertTrue(%HasSmiElements(a0)); assertEquals(4, a0.push(4)); - assertTrue(%HasFastSmiElements(a0)); + assertTrue(%HasSmiElements(a0)); assertEquals(5, a0.push(1.3)); - assertTrue(%HasFastDoubleElements(a0)); + assertTrue(%HasDoubleElements(a0)); assertEquals(6, a0.push(1.5)); - assertTrue(%HasFastDoubleElements(a0)); + assertTrue(%HasDoubleElements(a0)); assertEquals(7, a0.push({})); - assertTrue(%HasFastObjectElements(a0)); + assertTrue(%HasObjectElements(a0)); assertEquals(8, a0.push({})); - assertTrue(%HasFastObjectElements(a0)); + assertTrue(%HasObjectElements(a0)); assertEquals([1,2,3,4,1.3,1.5,{},{}], a0); // Concat var a1; a1 = [1,2,3].concat([]); - //assertTrue(%HasFastSmiElements(a1)); + //assertTrue(%HasSmiElements(a1)); assertEquals([1,2,3], a1); a1 = [1,2,3].concat([4,5,6]); - assertTrue(%HasFastSmiElements(a1)); + assertTrue(%HasSmiElements(a1)); assertEquals([1,2,3,4,5,6], a1); a1 = [1,2,3].concat([4,5,6], [7,8,9]); - assertTrue(%HasFastSmiElements(a1)); + assertTrue(%HasSmiElements(a1)); assertEquals([1,2,3,4,5,6,7,8,9], a1); a1 = [1.1,2,3].concat([]); - assertTrue(%HasFastDoubleElements(a1)); + assertTrue(%HasDoubleElements(a1)); assertEquals([1.1,2,3], a1); a1 = [1,2,3].concat([1.1, 2]); - assertTrue(%HasFastDoubleElements(a1)); + assertTrue(%HasDoubleElements(a1)); assertEquals([1,2,3,1.1,2], a1); a1 = [1.1,2,3].concat([1, 2]); - assertTrue(%HasFastDoubleElements(a1)); + assertTrue(%HasDoubleElements(a1)); assertEquals([1.1,2,3,1,2], a1); a1 = [1.1,2,3].concat([1.2, 2]); - assertTrue(%HasFastDoubleElements(a1)); + assertTrue(%HasDoubleElements(a1)); assertEquals([1.1,2,3,1.2,2], a1); a1 = [1,2,3].concat([{}]); - assertTrue(%HasFastObjectElements(a1)); + assertTrue(%HasObjectElements(a1)); assertEquals([1,2,3,{}], a1); a1 = [1.1,2,3].concat([{}]); - assertTrue(%HasFastObjectElements(a1)); + assertTrue(%HasObjectElements(a1)); assertEquals([1.1,2,3,{}], a1); a1 = [{}].concat([1,2,3]); - assertTrue(%HasFastObjectElements(a1)); + assertTrue(%HasObjectElements(a1)); assertEquals([{},1,2,3], a1); a1 = [{}].concat([1.1,2,3]); - assertTrue(%HasFastObjectElements(a1)); + assertTrue(%HasObjectElements(a1)); assertEquals([{},1.1,2,3], a1); // Slice var a2 = [1,2,3]; - assertTrue(%HasFastSmiElements(a2.slice())); - assertTrue(%HasFastSmiElements(a2.slice(1))); - assertTrue(%HasFastSmiElements(a2.slice(1, 2))); + assertTrue(%HasSmiElements(a2.slice())); + assertTrue(%HasSmiElements(a2.slice(1))); + assertTrue(%HasSmiElements(a2.slice(1, 2))); assertEquals([1,2,3], a2.slice()); assertEquals([2,3], a2.slice(1)); assertEquals([2], a2.slice(1,2)); a2 = [1.1,2,3]; - assertTrue(%HasFastDoubleElements(a2.slice())); - assertTrue(%HasFastDoubleElements(a2.slice(1))); - assertTrue(%HasFastDoubleElements(a2.slice(1, 2))); + assertTrue(%HasDoubleElements(a2.slice())); + assertTrue(%HasDoubleElements(a2.slice(1))); + assertTrue(%HasDoubleElements(a2.slice(1, 2))); assertEquals([1.1,2,3], a2.slice()); assertEquals([2,3], a2.slice(1)); assertEquals([2], a2.slice(1,2)); a2 = [{},2,3]; - assertTrue(%HasFastObjectElements(a2.slice())); - assertTrue(%HasFastObjectElements(a2.slice(1))); - assertTrue(%HasFastObjectElements(a2.slice(1, 2))); + assertTrue(%HasObjectElements(a2.slice())); + assertTrue(%HasObjectElements(a2.slice(1))); + assertTrue(%HasObjectElements(a2.slice(1, 2))); assertEquals([{},2,3], a2.slice()); assertEquals([2,3], a2.slice(1)); assertEquals([2], a2.slice(1,2)); @@ -129,124 +129,124 @@ function array_natives_test() { var a3 = [1,2,3]; var a3r; a3r = a3.splice(0, 0); - assertTrue(%HasFastSmiElements(a3r)); - assertTrue(%HasFastSmiElements(a3)); + assertTrue(%HasSmiElements(a3r)); + assertTrue(%HasSmiElements(a3)); assertEquals([], a3r); assertEquals([1, 2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 1); - assertTrue(%HasFastSmiElements(a3r)); - assertTrue(%HasFastSmiElements(a3)); + assertTrue(%HasSmiElements(a3r)); + assertTrue(%HasSmiElements(a3)); assertEquals([1], a3r); assertEquals([2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 0, 2); - assertTrue(%HasFastSmiElements(a3r)); - assertTrue(%HasFastSmiElements(a3)); + assertTrue(%HasSmiElements(a3r)); + assertTrue(%HasSmiElements(a3)); assertEquals([], a3r); assertEquals([2, 1, 2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 1, 2); - assertTrue(%HasFastSmiElements(a3r)); - assertTrue(%HasFastSmiElements(a3)); + assertTrue(%HasSmiElements(a3r)); + assertTrue(%HasSmiElements(a3)); assertEquals([1], a3r); assertEquals([2, 2, 3], a3); a3 = [1.1,2,3]; a3r = a3.splice(0, 0); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([], a3r); assertEquals([1.1, 2, 3], a3); a3 = [1.1, 2, 3]; a3r = a3.splice(0, 1); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([1.1], a3r); assertEquals([2, 3], a3); a3 = [1.1, 2, 3]; a3r = a3.splice(0, 0, 2); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([], a3r); assertEquals([2, 1.1, 2, 3], a3); a3 = [1.1, 2, 3]; - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3)); a3r = a3.splice(0, 1, 2); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([1.1], a3r); assertEquals([2, 2, 3], a3); a3 = [1.1,2,3]; a3r = a3.splice(0, 0, 2.1); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([], a3r); assertEquals([2.1, 1.1, 2, 3], a3); a3 = [1.1,2,3]; a3r = a3.splice(0, 1, 2.2); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([1.1], a3r); assertEquals([2.2, 2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 0, 2.1); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([], a3r); assertEquals([2.1, 1, 2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 1, 2.2); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([1], a3r); assertEquals([2.2, 2, 3], a3); a3 = [{},2,3]; a3r = a3.splice(0, 0); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([], a3r); assertEquals([{}, 2, 3], a3); a3 = [1,2,{}]; a3r = a3.splice(0, 1); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([1], a3r); assertEquals([2, {}], a3); a3 = [1,2,3]; a3r = a3.splice(0, 0, {}); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([], a3r); assertEquals([{}, 1, 2, 3], a3); a3 = [1,2,3]; a3r = a3.splice(0, 1, {}); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([1], a3r); assertEquals([{}, 2, 3], a3); a3 = [1.1,2,3]; a3r = a3.splice(0, 0, {}); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([], a3r); assertEquals([{}, 1.1, 2, 3], a3); a3 = [1.1,2,3]; a3r = a3.splice(0, 1, {}); - assertTrue(%HasFastObjectElements(a3r)); - assertTrue(%HasFastObjectElements(a3)); + assertTrue(%HasObjectElements(a3r)); + assertTrue(%HasObjectElements(a3)); assertEquals([1.1], a3r); assertEquals([{}, 2, 3], a3); a3 = [1.1, 2.2, 3.3]; a3r = a3.splice(2, 1); - assertTrue(%HasFastDoubleElements(a3r)); - assertTrue(%HasFastDoubleElements(a3)); + assertTrue(%HasDoubleElements(a3r)); + assertTrue(%HasDoubleElements(a3)); assertEquals([3.3], a3r); - //assertTrue(%HasFastDoubleElements(a3r)); + //assertTrue(%HasDoubleElements(a3r)); assertEquals([1.1, 2.2], a3); - //assertTrue(%HasFastDoubleElements(a3r)); + //assertTrue(%HasDoubleElements(a3r)); a3r = a3.splice(1, 1, 4.4, 5.5); - //assertTrue(%HasFastDoubleElements(a3r)); - //assertTrue(%HasFastDoubleElements(a3)); + //assertTrue(%HasDoubleElements(a3r)); + //assertTrue(%HasDoubleElements(a3)); assertEquals([2.2], a3r); assertEquals([1.1, 4.4, 5.5], a3); @@ -254,50 +254,50 @@ function array_natives_test() { var a4 = [1,2,3]; assertEquals(3, a4.pop()); assertEquals([1,2], a4); - //assertTrue(%HasFastSmiElements(a4)); + //assertTrue(%HasSmiElements(a4)); a4 = [1.1,2,3]; assertEquals(3, a4.pop()); assertEquals([1.1,2], a4); - //assertTrue(%HasFastDoubleElements(a4)); + //assertTrue(%HasDoubleElements(a4)); a4 = [{},2,3]; assertEquals(3, a4.pop()); assertEquals([{},2], a4); - //assertTrue(%HasFastObjectElements(a4)); + //assertTrue(%HasObjectElements(a4)); // Shift var a4 = [1,2,3]; assertEquals(1, a4.shift()); assertEquals([2,3], a4); - //assertTrue(%HasFastSmiElements(a4)); + //assertTrue(%HasSmiElements(a4)); a4 = [1.1,2,3]; assertEquals(1.1, a4.shift()); assertEquals([2,3], a4); - //assertTrue(%HasFastDoubleElements(a4)); + //assertTrue(%HasDoubleElements(a4)); a4 = [{},2,3]; assertEquals({}, a4.shift()); assertEquals([2,3], a4); - //assertTrue(%HasFastObjectElements(a4)); + //assertTrue(%HasObjectElements(a4)); // Unshift var a4 = [1,2,3]; assertEquals(4, a4.unshift(1)); - assertTrue(%HasFastSmiElements(a4)); + assertTrue(%HasSmiElements(a4)); assertEquals([1,1,2,3], a4); a4 = [1,2,3]; assertEquals(4, a4.unshift(1.1)); - assertTrue(%HasFastDoubleElements(a4)); + assertTrue(%HasDoubleElements(a4)); assertEquals([1.1,1,2,3], a4); a4 = [1.1,2,3]; assertEquals(4, a4.unshift(1)); - assertTrue(%HasFastDoubleElements(a4)); + assertTrue(%HasDoubleElements(a4)); assertEquals([1,1.1,2,3], a4); a4 = [{},2,3]; assertEquals(4, a4.unshift(1)); - assertTrue(%HasFastObjectElements(a4)); + assertTrue(%HasObjectElements(a4)); assertEquals([1,{},2,3], a4); a4 = [{},2,3]; assertEquals(4, a4.unshift(1.1)); - assertTrue(%HasFastObjectElements(a4)); + assertTrue(%HasObjectElements(a4)); assertEquals([1.1,{},2,3], a4); } diff --git a/deps/v8/test/mjsunit/array-push5.js b/deps/v8/test/mjsunit/array-push5.js index 9961ff98c3..772f8576ec 100644 --- a/deps/v8/test/mjsunit/array-push5.js +++ b/deps/v8/test/mjsunit/array-push5.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen var v = 0; diff --git a/deps/v8/test/mjsunit/array-push9.js b/deps/v8/test/mjsunit/array-push9.js index d80cee89ea..f1427f2c9f 100644 --- a/deps/v8/test/mjsunit/array-push9.js +++ b/deps/v8/test/mjsunit/array-push9.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --deopt-every-n-times=5 --nodead-code-elimination +// Flags: --allow-natives-syntax --deopt-every-n-times=5 var array = []; diff --git a/deps/v8/test/mjsunit/array-store-and-grow.js b/deps/v8/test/mjsunit/array-store-and-grow.js index ee831ad061..f1b9a3b38a 100644 --- a/deps/v8/test/mjsunit/array-store-and-grow.js +++ b/deps/v8/test/mjsunit/array-store-and-grow.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen // Verifies that the KeyedStoreIC correctly handles out-of-bounds stores // to an array that grow it by a single element. Test functions are diff --git a/deps/v8/test/mjsunit/asm/global-imports.js b/deps/v8/test/mjsunit/asm/global-imports.js index 60c0930fa8..5214d3a2a1 100644 --- a/deps/v8/test/mjsunit/asm/global-imports.js +++ b/deps/v8/test/mjsunit/asm/global-imports.js @@ -72,3 +72,9 @@ Run("var x = foreign.x", "x(dbl) | 0", { x:p }, 17, true); Run("var x = foreign.x", "(x = fround, x(dbl)) | 0", { x:p }, 4, false); Run("var x = stdlib.Math.E", "(x = 3.1415, 1) | 0", {}, 1, false); Run("var x = stdlib.Math.imul", "(x = fround, 1) | 0", {}, 1, false); + +// Imports missing or causing side-effects during lookup. +Run("var x = +foreign.x", "+x", { no_x_present:0 }, NaN, true); +Run("var x = +foreign.x", "+x", { get x() { return 23 } }, 23, false); +Run("var x = +foreign.x", "+x", new Proxy({ x:42 }, {}), 42, false); +Run("var x = +foreign.x", "+x", { x : { valueOf : () => 65 } }, 65, false); diff --git a/deps/v8/test/mjsunit/asm/regress-674089.js b/deps/v8/test/mjsunit/asm/regress-674089.js index 03464285f3..e87f8451f5 100644 --- a/deps/v8/test/mjsunit/asm/regress-674089.js +++ b/deps/v8/test/mjsunit/asm/regress-674089.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --validate-asm --ignition --lazy-inner-functions +// Flags: --validate-asm --no-stress-fullcodegen --lazy-inner-functions function outer() { "use asm"; diff --git a/deps/v8/test/mjsunit/asm/regress-719866.js b/deps/v8/test/mjsunit/asm/regress-719866.js new file mode 100644 index 0000000000..da9719e970 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/regress-719866.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function Module(stdlib) { + "use asm"; + function f(a,b,c) { + a = +a; + b = +b; + c = +c; + var r = 0.0; + r = a / b * c; + return +r; + } + return { f:f } +} +var m = Module(this); +assertEquals(16, m.f(32, 4, 2)); diff --git a/deps/v8/test/mjsunit/asm/regress-740325.js b/deps/v8/test/mjsunit/asm/regress-740325.js new file mode 100644 index 0000000000..9377aaeea0 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/regress-740325.js @@ -0,0 +1,71 @@ +// 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-gc + +assertTrue = function assertTrue() { } +assertFalse = function assertFalse() { } + +__v_3 = []; +__v_2 = []; +__v_0 = 0; +__v_2.__defineGetter__(0, function() { + if (__v_0++ > 2) return; + gc(); + __v_3.concat(__v_2); +}); +__v_2[0]; + + +function __f_2() { +} + +(function __f_1() { + print("1..."); + function __f_5(stdlib, imports) { + "use asm"; + var __f_2 = imports.__f_2; + function __f_3(a) { + a = a | 0; + } + return { __f_3:__f_3 }; + } + var __v_2 = __f_5(this, { __f_2:__f_2 }); +; +})(); + +(function __f_10() { + print("2..."); + function __f_5() { + "use asm"; + function __f_3(a) { + } + } + var __v_2 = __f_5(); + assertFalse(); +})(); + +(function __f_11() { + print("3..."); + let m = (function __f_6() { + function __f_5() { + "use asm"; + function __f_3() { + } + return { __f_3:__f_3 }; + } + var __v_2 = __f_5( { __f_2:__f_2 }); + }); + for (var i = 0; i < 30; i++) { + print(" i = " + i); + var x = m(); + for (var j = 0; j < 200; j++) { + try { + __f_5; + } catch (e) { + } + } + x; + } +})(); diff --git a/deps/v8/test/mjsunit/bounds-checks-elimination.js b/deps/v8/test/mjsunit/bounds-checks-elimination.js index 4ea7f17e52..622e791fa5 100644 --- a/deps/v8/test/mjsunit/bounds-checks-elimination.js +++ b/deps/v8/test/mjsunit/bounds-checks-elimination.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --array-bounds-checks-elimination +// Flags: --allow-natives-syntax var a = [] for (var i = 0; i < 9; i++) a[i] = i + 1; diff --git a/deps/v8/test/mjsunit/code-coverage-block.js b/deps/v8/test/mjsunit/code-coverage-block.js new file mode 100644 index 0000000000..d55578156d --- /dev/null +++ b/deps/v8/test/mjsunit/code-coverage-block.js @@ -0,0 +1,541 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --no-always-opt --ignition --block-coverage --harmony-async-iteration +// Flags: --no-stress-fullcodegen + +// Test precise code coverage. + +function GetCoverage(source) { + for (var script of %DebugCollectCoverage()) { + if (script.script.source == source) return script; + } + return undefined; +} + +function TestCoverage(name, source, expectation) { + source = source.trim(); + eval(source); + %CollectGarbage("collect dead objects"); + var covfefe = GetCoverage(source); + var stringified_result = JSON.stringify(covfefe); + var stringified_expectation = JSON.stringify(expectation); + if (stringified_result != stringified_expectation) { + print(stringified_result.replace(/[}],[{]/g, "},\n {")); + } + assertEquals(stringified_expectation, stringified_result, name + " failed"); +} + +function nop() {} + +%DebugToggleBlockCoverage(true); + +TestCoverage( +"call an IIFE", +` +(function f() {})(); +`, +[{"start":0,"end":20,"count":1},{"start":1,"end":16,"count":1}] +); + +TestCoverage( +"call locally allocated function", +`let f = () => 1; f();`, +[{"start":0,"end":21,"count":1},{"start":8,"end":15,"count":1}] +); + +TestCoverage( +"if statements", +` +function g() {} // 0000 +function f(x) { // 0050 + if (x == 42) { // 0100 + if (x == 43) g(); else g(); // 0150 + } // 0200 + if (x == 42) { g(); } else { g(); } // 0250 + if (x == 42) g(); else g(); // 0300 + if (false) g(); else g(); // 0350 + if (false) g(); // 0400 + if (true) g(); else g(); // 0450 + if (true) g(); // 0500 +} // 0550 +f(42); // 0600 +f(43); // 0650 +`, +[{"start":0,"end":699,"count":1}, + {"start":0,"end":15,"count":11}, + {"start":50,"end":551,"count":2}, + {"start":115,"end":203,"count":1}, + {"start":167,"end":171,"count":0}, + {"start":265,"end":273,"count":1}, + {"start":279,"end":287,"count":1}, + {"start":315,"end":319,"count":1}, + {"start":325,"end":329,"count":1}, + {"start":363,"end":367,"count":0}, + {"start":413,"end":417,"count":0}, + {"start":472,"end":476,"count":0}] + +); + +TestCoverage( +"if statement (early return)", +` +!function() { // 0000 + if (true) { // 0050 + nop(); // 0100 + return; // 0150 + nop(); // 0200 + } // 0250 + nop(); // 0300 +}() // 0350 +`, +[{"start":0,"end":399,"count":1}, + {"start":1,"end":351,"count":1}, + {"start":161,"end":351,"count":0}] +); + +TestCoverage( +"if statement (no semi-colon)", +` +!function() { // 0000 + if (true) nop() // 0050 + if (true) nop(); else nop() // 0100 + nop(); // 0150 +}() // 0200 +`, +[{"start":0,"end":249,"count":1}, + {"start":1,"end":201,"count":1}, + {"start":124,"end":129,"count":0}] +); + +TestCoverage( +"for statements", +` +function g() {} // 0000 +!function() { // 0050 + for (var i = 0; i < 12; i++) g(); // 0100 + for (var i = 0; i < 12; i++) { // 0150 + g(); // 0200 + } // 0250 + for (var i = 0; false; i++) g(); // 0300 + for (var i = 0; true; i++) break; // 0350 + for (var i = 0; i < 12; i++) { // 0400 + if (i % 3 == 0) g(); else g(); // 0450 + } // 0500 +}(); // 0550 +`, +[{"start":0,"end":599,"count":1}, + {"start":0,"end":15,"count":36}, + {"start":51,"end":551,"count":1}, + {"start":131,"end":135,"count":12}, + {"start":181,"end":253,"count":12}, + {"start":330,"end":334,"count":0}, + {"start":431,"end":503,"count":12}, + {"start":470,"end":474,"count":4}, + {"start":480,"end":484,"count":8}] +); + +TestCoverage( +"for statements pt. 2", +` +function g() {} // 0000 +!function() { // 0050 + let j = 0; // 0100 + for (let i = 0; i < 12; i++) g(); // 0150 + for (const i = 0; j < 12; j++) g(); // 0200 + for (j = 0; j < 12; j++) g(); // 0250 + for (;;) break; // 0300 +}(); // 0350 +`, +[{"start":0,"end":399,"count":1}, + {"start":0,"end":15,"count":36}, + {"start":51,"end":351,"count":1}, + {"start":181,"end":185,"count":12}, + {"start":233,"end":237,"count":12}, + {"start":277,"end":281,"count":12}] +); + +TestCoverage( +"for statements (no semicolon)", +` +function g() {} // 0000 +!function() { // 0050 + for (let i = 0; i < 12; i++) g() // 0100 + for (let i = 0; i < 12; i++) break // 0150 + for (let i = 0; i < 12; i++) break; g() // 0200 +}(); // 0250 +`, +[{"start":0,"end":299,"count":1}, + {"start":0,"end":15,"count":13}, + {"start":51,"end":251,"count":1}, + {"start":131,"end":134,"count":12}] +); + +TestCoverage( +"for statement (early return)", +` +!function() { // 0000 + for (var i = 0; i < 10; i++) { // 0050 + nop(); // 0100 + continue; // 0150 + nop(); // 0200 + } // 0250 + nop(); // 0300 + for (;;) { // 0350 + nop(); // 0400 + break; // 0450 + nop(); // 0500 + } // 0550 + nop(); // 0600 + for (;;) { // 0650 + nop(); // 0700 + return; // 0750 + nop(); // 0800 + } // 0850 + nop(); // 0900 +}() // 0950 +`, +[{"start":0,"end":999,"count":1}, + {"start":1,"end":951,"count":1}, + {"start":81,"end":253,"count":10}, + {"start":163,"end":253,"count":0}, + {"start":460,"end":553,"count":0}, + {"start":761,"end":951,"count":0}] +); + +TestCoverage( +"for-of and for-in statements", +` +!function() { // 0000 + var i; // 0050 + for (i of [0,1,2,3]) { nop(); } // 0100 + for (let j of [0,1,2,3]) { nop(); } // 0150 + for (i in [0,1,2,3]) { nop(); } // 0200 + for (let j in [0,1,2,3]) { nop(); } // 0250 + var xs = [{a:0, b:1}, {a:1,b:0}]; // 0300 + for (var {a: x, b: y} of xs) { nop(); } // 0350 +}(); // 0400 +`, +[{"start":0,"end":449,"count":1}, + {"start":1,"end":401,"count":1}, + {"start":123,"end":133,"count":4}, + {"start":177,"end":187,"count":4}, + {"start":223,"end":233,"count":4}, + {"start":277,"end":287,"count":4}, + {"start":381,"end":391,"count":2}] +); + +TestCoverage( +"for-await-of statements", +` +!async function() { // 0000 + for await (var x of [0,1,2,3]) { // 0050 + nop(); // 0100 + } // 0150 +}(); // 0200 +%RunMicrotasks(); // 0250 +`, +[{"start":0,"end":299,"count":1}, + {"start":1,"end":201,"count":6}, // TODO(jgruber): Invocation count is off. + {"start":83,"end":153,"count":4}, + {"start":153,"end":201,"count":1}] +); + +TestCoverage( +"while and do-while statements", +` +function g() {} // 0000 +!function() { // 0050 + var i; // 0100 + i = 0; while (i < 12) i++; // 0150 + i = 0; while (i < 12) { g(); i++; } // 0200 + i = 0; while (false) g(); // 0250 + i = 0; while (true) break; // 0300 + // 0350 + i = 0; do i++; while (i < 12); // 0400 + i = 0; do { g(); i++; } // 0450 + while (i < 12); // 0500 + i = 0; do { g(); } while (false); // 0550 + i = 0; do { break; } while (true); // 0600 +}(); // 0650 +`, +[{"start":0,"end":699,"count":1}, + {"start":0,"end":15,"count":25}, + {"start":51,"end":651,"count":1}, + {"start":174,"end":178,"count":12}, + {"start":224,"end":237,"count":12}, + {"start":273,"end":277,"count":0}, + {"start":412,"end":416,"count":12}, + {"start":462,"end":475,"count":12}, + {"start":620,"end":622,"count":0}] +); + +TestCoverage( +"while statement (early return)", +` +!function() { // 0000 + let i = 0; // 0050 + while (i < 10) { // 0100 + i++; // 0150 + continue; // 0200 + nop(); // 0250 + } // 0300 + nop(); // 0350 + while (true) { // 0400 + nop(); // 0450 + break; // 0500 + nop(); // 0550 + } // 0600 + nop(); // 0650 + while (true) { // 0700 + nop(); // 0750 + return; // 0800 + nop(); // 0850 + } // 0900 + nop(); // 0950 +}() // 1000 +`, +[{"start":0,"end":1049,"count":1}, + {"start":1,"end":1001,"count":1}, + {"start":117,"end":303,"count":10}, + {"start":213,"end":303,"count":0}, + {"start":510,"end":603,"count":0}, + {"start":811,"end":1001,"count":0}] +); + +TestCoverage( +"do-while statement (early return)", +` +!function() { // 0000 + let i = 0; // 0050 + do { // 0100 + i++; // 0150 + continue; // 0200 + nop(); // 0250 + } while (i < 10); // 0300 + nop(); // 0350 + do { // 0400 + nop(); // 0450 + break; // 0500 + nop(); // 0550 + } while (true); // 0600 + nop(); // 0650 + do { // 0700 + nop(); // 0750 + return; // 0800 + nop(); // 0850 + } while (true); // 0900 + nop(); // 0950 +}() // 1000 +`, +[{"start":0,"end":1049,"count":1}, + {"start":1,"end":1001,"count":1}, + {"start":105,"end":303,"count":10}, + {"start":213,"end":303,"count":0}, + {"start":510,"end":603,"count":0}, + {"start":811,"end":1001,"count":0}] +); + +TestCoverage( +"return statements", +` +!function() { nop(); return; nop(); }(); // 0000 +!function() { nop(); return 42; // 0050 + nop(); }(); // 0100 +`, +[{"start":0,"end":149,"count":1}, + {"start":1,"end":37,"count":1}, + {"start":28,"end":37,"count":0}, + {"start":51,"end":122,"count":1}, + {"start":81,"end":122,"count":0}] +); + +TestCoverage( +"try/catch/finally statements", +` +!function() { // 0000 + try { nop(); } catch (e) { nop(); } // 0050 + try { nop(); } finally { nop(); } // 0100 + try { // 0150 + try { throw 42; } catch (e) { nop(); }// 0200 + } catch (e) { nop(); } // 0250 + try { // 0300 + try { throw 42; } finally { nop(); } // 0350 + } catch (e) { nop(); } // 0400 + try { // 0450 + throw 42; // 0500 + } catch (e) { // 0550 + nop(); // 0600 + } finally { // 0650 + nop(); // 0700 + } // 0750 +}(); // 0800 +`, +[{"start":0,"end":849,"count":1}, + {"start":1,"end":801,"count":1}, + {"start":77,"end":87,"count":0}, + {"start":219,"end":232,"count":0}, + {"start":264,"end":274,"count":0}, + {"start":369,"end":380,"count":0}, + {"start":403,"end":414,"count":0}, // TODO(jgruber): Include `catch` in range. + {"start":513,"end":564,"count":0}] +); + +TestCoverage( +"early return in blocks", +` +!function() { // 0000 + try { throw 42; } catch (e) { return; } // 0050 + nop(); // 0100 +}(); // 0150 +!function() { // 0200 + try { nop(); } finally { return; } // 0250 + nop(); // 0300 +}(); // 0350 +!function() { // 0400 + { // 0450 + let x = 42; // 0500 + return () => x; // 0550 + } // 0600 + nop(); // 0650 +}(); // 0700 +!function() { // 0750 + try { throw 42; } catch (e) { // 0800 + return; // 0850 + nop(); // 0900 + } // 0950 + nop(); // 1000 +}(); // 1050 +`, +[{"start":0,"end":1099,"count":1}, + {"start":1,"end":151,"count":1}, + {"start":67,"end":80,"count":0}, + {"start":89,"end":151,"count":0}, + {"start":201,"end":351,"count":1}, + {"start":284,"end":351,"count":0}, + {"start":401,"end":701,"count":1}, + {"start":569,"end":701,"count":0}, + {"start":561,"end":568,"count":0}, // TODO(jgruber): Sorting. + {"start":751,"end":1051,"count":1}, + {"start":817,"end":830,"count":0}, + {"start":861,"end":1051,"count":0}] + +); + +TestCoverage( +"switch statements", +` +!function() { // 0000 + var x = 42; // 0050 + switch (x) { // 0100 + case 41: nop(); break; // 0150 + case 42: nop(); break; // 0200 + default: nop(); break; // 0250 + } // 0300 +}(); // 0350 +`, +[{"start":0,"end":399,"count":1}, + {"start":1,"end":351,"count":1}, + {"start":154,"end":204,"count":0}, + {"start":226,"end":303,"count":0}] +); + +TestCoverage( +"labeled break statements", +` +!function() { // 0000 + var x = 42; // 0050 + l0: switch (x) { // 0100 + case 41: return; // 0150 + case 42: // 0200 + switch (x) { case 42: break l0; } // 0250 + break; // 0300 + } // 0350 + l1: for (;;) { // 0400 + for (;;) break l1; // 0450 + } // 0500 + l2: while (true) { // 0550 + while (true) break l2; // 0600 + } // 0650 + l3: do { // 0700 + do { break l3; } while (true); // 0750 + } while (true); // 0800 + l4: { break l4; } // 0850 + l5: for (;;) for (;;) break l5; // 0900 +}(); // 0950 +`, +[{"start":0,"end":999,"count":1}, + {"start":1,"end":951,"count":1}, + {"start":152,"end":202,"count":0}, + {"start":285,"end":353,"count":0}, + {"start":472,"end":503,"count":0}, + {"start":626,"end":653,"count":0}, + {"start":768,"end":803,"count":0}, + {"start":867,"end":869,"count":0}] +); + +TestCoverage( +"labeled continue statements", +` +!function() { // 0000 + l0: for (var i0 = 0; i0 < 2; i0++) { // 0050 + for (;;) continue l0; // 0100 + } // 0150 + var i1 = 0; // 0200 + l1: while (i1 < 2) { // 0250 + i1++; // 0300 + while (true) continue l1; // 0350 + } // 0400 + var i2 = 0; // 0450 + l2: do { // 0500 + i2++; // 0550 + do { continue l2; } while (true); // 0600 + } while (i2 < 2); // 0650 +}(); // 0700 +`, +[{"start":0,"end":749,"count":1}, + {"start":1,"end":701,"count":1}, + {"start":87,"end":153,"count":2}, + {"start":125,"end":153,"count":0}, + {"start":271,"end":403,"count":2}, + {"start":379,"end":403,"count":0}, + {"start":509,"end":653,"count":2}, + {"start":621,"end":653,"count":0}] +); + +TestCoverage( +"conditional expressions", +` +var TRUE = true; // 0000 +var FALSE = false; // 0050 +!function() { // 0100 + TRUE ? nop() : nop(); // 0150 + true ? nop() : nop(); // 0200 + false ? nop() : nop(); // 0250 + FALSE ? TRUE ? nop() // 0300 + : nop() // 0350 + : nop(); // 0400 + TRUE ? FALSE ? nop() // 0450 + : nop() // 0500 + : nop(); // 0550 + TRUE ? nop() : FALSE ? nop() // 0600 + : nop(); // 0650 + FALSE ? nop() : TRUE ? nop() // 0700 + : nop(); // 0750 +}(); // 0800 +`, +[{"start":0,"end":849,"count":1}, + {"start":101,"end":801,"count":1}, + {"start":167,"end":172,"count":0}, + {"start":217,"end":222,"count":0}, + {"start":260,"end":265,"count":0}, + {"start":310,"end":372,"count":0}, + {"start":467,"end":472,"count":0}, + {"start":559,"end":564,"count":0}, + {"start":617,"end":680,"count":0}, + {"start":710,"end":715,"count":0}, + {"start":775,"end":780,"count":0}] +); + +%DebugToggleBlockCoverage(false); diff --git a/deps/v8/test/mjsunit/code-coverage-precise.js b/deps/v8/test/mjsunit/code-coverage-precise.js index 03015f9202..2d4fa04ab9 100644 --- a/deps/v8/test/mjsunit/code-coverage-precise.js +++ b/deps/v8/test/mjsunit/code-coverage-precise.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --no-always-opt +// Flags: --allow-natives-syntax --no-always-opt --no-stress-fullcodegen // Test precise code coverage. diff --git a/deps/v8/test/mjsunit/compiler/alloc-object-huge.js b/deps/v8/test/mjsunit/compiler/alloc-object-huge.js index b0a981d6c2..7fd32eaa30 100644 --- a/deps/v8/test/mjsunit/compiler/alloc-object-huge.js +++ b/deps/v8/test/mjsunit/compiler/alloc-object-huge.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --inline-construct +// Flags: --allow-natives-syntax // Flags: --max-inlined-source-size=999999 --max-inlined-nodes=999999 // Flags: --max-inlined-nodes-cumulative=999999 diff --git a/deps/v8/test/mjsunit/compiler/alloc-object.js b/deps/v8/test/mjsunit/compiler/alloc-object.js index 5876134342..8d19816536 100644 --- a/deps/v8/test/mjsunit/compiler/alloc-object.js +++ b/deps/v8/test/mjsunit/compiler/alloc-object.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --inline-construct +// Flags: --allow-natives-syntax // Test that inlined object allocation works for different layouts of // objects (e.g. in object properties, slack tracking in progress or diff --git a/deps/v8/test/mjsunit/compiler/array-constructor.js b/deps/v8/test/mjsunit/compiler/array-constructor.js index 583817b7d8..eef242714b 100644 --- a/deps/v8/test/mjsunit/compiler/array-constructor.js +++ b/deps/v8/test/mjsunit/compiler/array-constructor.js @@ -87,3 +87,14 @@ %OptimizeFunctionOnNextCall(foo); assertEquals([1, 2, 3], foo(1, 2, 3)); })(); + +// Test Array construct inside try-catch block. +(() => { + function foo(x) { try { return new Array(x) } catch (e) { return e } } + + assertEquals([], foo(0)); + assertEquals([], foo(0)); + %OptimizeFunctionOnNextCall(foo); + assertEquals([], foo(0)); + assertInstanceof(foo(-1), RangeError); +})(); diff --git a/deps/v8/test/mjsunit/compiler/deopt-accessors5.js b/deps/v8/test/mjsunit/compiler/deopt-accessors5.js index 1b23c532dc..bf71585e25 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-accessors5.js +++ b/deps/v8/test/mjsunit/compiler/deopt-accessors5.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/compiler/deopt-accessors6.js b/deps/v8/test/mjsunit/compiler/deopt-accessors6.js index 16fb4ddf64..784123ae6c 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-accessors6.js +++ b/deps/v8/test/mjsunit/compiler/deopt-accessors6.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js b/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js index 8fa8af5a9b..28af2eebca 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js +++ b/deps/v8/test/mjsunit/compiler/deopt-inlined-from-call.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen var global = this; diff --git a/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js index 2c6473d15f..6f19d45bb8 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js +++ b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js @@ -9,6 +9,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); @@ -33,6 +34,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); @@ -57,6 +59,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); @@ -81,6 +84,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); @@ -105,6 +109,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); @@ -129,6 +134,7 @@ foo(1.1, 0.1); foo(0.1, 1.1); + foo(true, false); %OptimizeFunctionOnNextCall(foo); foo(undefined, 1.1); assertOptimized(foo); diff --git a/deps/v8/test/mjsunit/compiler/division-by-constant.js b/deps/v8/test/mjsunit/compiler/division-by-constant.js index d3f3ac37f4..212bdb24b9 100644 --- a/deps/v8/test/mjsunit/compiler/division-by-constant.js +++ b/deps/v8/test/mjsunit/compiler/division-by-constant.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --no-use-inlining +// Flags: --allow-natives-syntax // ----------------------------------------------------------------------------- diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-11.js b/deps/v8/test/mjsunit/compiler/escape-analysis-11.js index f33cf2d991..e922fc15c8 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-11.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-11.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape function g() { ({}).a += ''; @@ -15,5 +15,5 @@ function f() { f(); f(); -% OptimizeFunctionOnNextCall(f); +%OptimizeFunctionOnNextCall(f); f(); diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-12.js b/deps/v8/test/mjsunit/compiler/escape-analysis-12.js index 20d5f2a1b0..16029a0ad3 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-12.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-12.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape var x = {}; x = {}; @@ -13,5 +13,5 @@ function f() { } f(); f(); -% OptimizeFunctionOnNextCall(f); +%OptimizeFunctionOnNextCall(f); f(); diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-13.js b/deps/v8/test/mjsunit/compiler/escape-analysis-13.js index b1334f1f27..fca4da618e 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-13.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-13.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape --turbo-experimental +// Flags: --allow-natives-syntax --turbo-escape --turbo-experimental function f() { var x = {}; @@ -13,5 +13,5 @@ function f() { } f(); f(); -% OptimizeFunctionOnNextCall(f); +%OptimizeFunctionOnNextCall(f); f(); diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-15.js b/deps/v8/test/mjsunit/compiler/escape-analysis-15.js index 4ebd0f7887..4f9a40ad5c 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-15.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-15.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape --turbo-experimental --no-turbo-load-elimination +// Flags: --allow-natives-syntax --turbo-escape --turbo-experimental --no-turbo-load-elimination function f(i) { var o1 = {a: 1, b: 2}; diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-arguments.js b/deps/v8/test/mjsunit/compiler/escape-analysis-arguments.js index bdab182fed..f520167e19 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-arguments.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-arguments.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --use-escape-analysis --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Simple test of capture diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-framestate-use-at-branchpoint.js b/deps/v8/test/mjsunit/compiler/escape-analysis-framestate-use-at-branchpoint.js index d7ed61b6eb..c86674e52e 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-framestate-use-at-branchpoint.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-framestate-use-at-branchpoint.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape function foo() { var o = {x:0}; diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-materialize.js b/deps/v8/test/mjsunit/compiler/escape-analysis-materialize.js index e72797d823..6ad3a53218 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-materialize.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-materialize.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape (function TestMaterializeArray() { function f() { diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js b/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js index 1c7cae76c9..e6cc9f1ed2 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis-representation.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --use-escape-analysis +// Flags: --allow-natives-syntax // This tests that captured objects materialized through the deoptimizer // have field descriptors with a representation matching the values that diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis.js b/deps/v8/test/mjsunit/compiler/escape-analysis.js index b12e7bfca0..111ed634fd 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --use-escape-analysis --expose-gc +// Flags: --allow-natives-syntax --expose-gc // Test stores on a join path. diff --git a/deps/v8/test/mjsunit/compiler/function-apply.js b/deps/v8/test/mjsunit/compiler/function-apply.js new file mode 100644 index 0000000000..f9440dede1 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/function-apply.js @@ -0,0 +1,136 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test Function.prototype.apply with null/undefined argumentsList +(function() { + "use strict"; + function bar() { return this; } + function foo() { return bar.apply(this, null); } + + assertEquals(42, foo.call(42)); + assertEquals(42, foo.call(42)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(42, foo.call(42)); +})(); +(function() { + "use strict"; + function bar() { return this; } + function foo() { return bar.apply(this, undefined); } + + assertEquals(42, foo.call(42)); + assertEquals(42, foo.call(42)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(42, foo.call(42)); +})(); + +// Test Function.prototype.apply within try/catch. +(function() { + "use strict"; + function foo(bar) { + try { + return Function.prototype.apply.call(bar, bar, arguments); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); +(function() { + "use strict"; + function foo(bar) { + try { + return Function.prototype.apply.call(bar, bar, bar); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); + +// Test Function.prototype.apply with wrong number of arguments. +(function() { + "use strict"; + function bar() { return this; } + function foo() { return bar.apply(); } + + assertEquals(undefined, foo()); + assertEquals(undefined, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(undefined, foo()); +})(); +(function() { + "use strict"; + function bar() { return this; } + function foo() { return bar.apply(this); } + + assertEquals(42, foo.call(42)); + assertEquals(42, foo.call(42)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(42, foo.call(42)); +})(); +(function() { + "use strict"; + function bar() { return this; } + function foo() { return bar.apply(this, arguments, this); } + + assertEquals(42, foo.call(42)); + assertEquals(42, foo.call(42)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(42, foo.call(42)); +})(); + +// Test proper order of callable check and array-like iteration +// in Function.prototype.apply. +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Function.prototype.apply.call(undefined, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Function.prototype.apply.call(null, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Function.prototype.apply.call(null, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); diff --git a/deps/v8/test/mjsunit/compiler/function-bind.js b/deps/v8/test/mjsunit/compiler/function-bind.js new file mode 100644 index 0000000000..11337b4bf9 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/function-bind.js @@ -0,0 +1,77 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + "use strict"; + function bar() { return this; } + + function foo(x) { + return bar.bind(x); + } + + assertEquals(0, foo(0)()); + assertEquals(1, foo(1)()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("", foo("")()); +})(); + +(function() { + "use strict"; + function bar(x) { return x; } + + function foo(x) { + return bar.bind(undefined, x); + } + + assertEquals(0, foo(0)()); + assertEquals(1, foo(1)()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("", foo("")()); +})(); + +(function() { + function bar(x) { return x; } + + function foo(x) { + return bar.bind(undefined, x); + } + + assertEquals(0, foo(0)()); + assertEquals(1, foo(1)()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("", foo("")()); +})(); + +(function() { + "use strict"; + function bar(x, y) { return x + y; } + + function foo(x, y) { + return bar.bind(undefined, x, y); + } + + assertEquals(0, foo(0, 0)()); + assertEquals(2, foo(1, 1)()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("ab", foo("a", "b")()); + assertEquals(0, foo(0, 1).length); + assertEquals("bound bar", foo(1, 2).name) +})(); + +(function() { + function bar(x, y) { return x + y; } + + function foo(x, y) { + return bar.bind(undefined, x, y); + } + + assertEquals(0, foo(0, 0)()); + assertEquals(2, foo(1, 1)()); + %OptimizeFunctionOnNextCall(foo); + assertEquals("ab", foo("a", "b")()); + assertEquals(0, foo(0, 1).length); + assertEquals("bound bar", foo(1, 2).name) +})(); diff --git a/deps/v8/test/mjsunit/compiler/inline-accessors1.js b/deps/v8/test/mjsunit/compiler/inline-accessors1.js new file mode 100644 index 0000000000..daa01ec022 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/inline-accessors1.js @@ -0,0 +1,77 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + class O { + get x() { + return 1; + } + } + var o = new O; + + function foo(o) { + try { + return o.x; + } catch (e) { + return 0; + } + } + + assertEquals(1, foo(o)); + assertEquals(1, foo(o)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo(o)); +})(); + +(function() { + class O { + get x() { + %DeoptimizeFunction(foo); + return 1; + } + } + var o = new O; + + function foo(o) { + try { + return o.x; + } catch (e) { + return 0; + } + } + + assertEquals(1, foo(o)); + assertEquals(1, foo(o)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo(o)); +})(); + +(function() { + function bar(x) { + throw x; + } + + class O { + get x() { + %DeoptimizeFunction(foo); + return bar("x"); + } + } + var o = new O; + + function foo(o) { + try { + return o.x; + } catch (e) { + return 0; + } + } + + assertEquals(0, foo(o)); + assertEquals(0, foo(o)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo(o)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/inline-accessors.js b/deps/v8/test/mjsunit/compiler/inline-accessors2.js index b3985bf9dc..b3985bf9dc 100644 --- a/deps/v8/test/mjsunit/compiler/inline-accessors.js +++ b/deps/v8/test/mjsunit/compiler/inline-accessors2.js diff --git a/deps/v8/test/mjsunit/compiler/inline-construct.js b/deps/v8/test/mjsunit/compiler/inline-construct.js index aea1bb4848..111c0f32ad 100644 --- a/deps/v8/test/mjsunit/compiler/inline-construct.js +++ b/deps/v8/test/mjsunit/compiler/inline-construct.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --inline-construct +// Flags: --allow-natives-syntax // Test inlining of constructor calls. diff --git a/deps/v8/test/mjsunit/compiler/inline-exception-1.js b/deps/v8/test/mjsunit/compiler/inline-exception-1.js index ac259afad7..8da6845c3b 100644 --- a/deps/v8/test/mjsunit/compiler/inline-exception-1.js +++ b/deps/v8/test/mjsunit/compiler/inline-exception-1.js @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --no-always-opt +// Flags: --allow-natives-syntax --no-always-opt // This test file was generated by tools/gen-inlining-tests.py . diff --git a/deps/v8/test/mjsunit/compiler/inline-exception-2.js b/deps/v8/test/mjsunit/compiler/inline-exception-2.js index 89523cc6b2..6dbc7a478b 100644 --- a/deps/v8/test/mjsunit/compiler/inline-exception-2.js +++ b/deps/v8/test/mjsunit/compiler/inline-exception-2.js @@ -4,7 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --no-always-opt +// Flags: --allow-natives-syntax --no-always-opt // This test file was generated by tools/gen-inlining-tests.py . diff --git a/deps/v8/test/mjsunit/compiler/minus-zero.js b/deps/v8/test/mjsunit/compiler/minus-zero.js index ac66350051..23639dfcc3 100644 --- a/deps/v8/test/mjsunit/compiler/minus-zero.js +++ b/deps/v8/test/mjsunit/compiler/minus-zero.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --no-fold-constants +// Flags: --allow-natives-syntax function add(x, y) { return x + y; diff --git a/deps/v8/test/mjsunit/regress/regress-2653.js b/deps/v8/test/mjsunit/compiler/native-context-specialization-hole-check.js index 8864df7553..18e383bfb0 100644 --- a/deps/v8/test/mjsunit/regress/regress-2653.js +++ b/deps/v8/test/mjsunit/compiler/native-context-specialization-hole-check.js @@ -1,4 +1,4 @@ -// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright 2010 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -25,23 +25,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --deopt-every-n-garbage-collections=1 +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen -function foo(a, b) { - var l = a.length; - var array = new Array(l); - for (var k = 0; k < l; k++) { - array[k] = 120; - } - var result = new Array(l); - for (var i = 0; i < l; i++) { - result[i] = array[i]; - } - return result; +function f() { + Array.prototype[10] = 2; + var arr = new Array(); + arr[500] = 20; + arr[10] = arr[50]; } -a = "xxxxxxxxxxxxxxxxxxxxxxxxx"; -while (a.length < 100000) a = a + a; -foo(a, []); -%OptimizeFunctionOnNextCall(foo) -foo(a, []); +function g() { + f(); +} +g(); +g(); +%OptimizeFunctionOnNextCall(g); +g(); +assertTrue(%GetDeoptCount(g) > 0); diff --git a/deps/v8/test/mjsunit/compiler/native-context-specialization-string-concat.js b/deps/v8/test/mjsunit/compiler/native-context-specialization-string-concat.js new file mode 100644 index 0000000000..3b931c3a71 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/native-context-specialization-string-concat.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var foo = 'foo'; +var bar = 'bar'; + +var a; +var b; +var c; +var d; + +function baz() { return 'baz'; } + +function test(arg) { + // All operands are constant folded by native context + // specialization / inlining. + a = '"' + foo + '-' + bar + '"'; + b = '"' + foo + '-' + baz() + '"'; + + // Reduce down to a JSAdd of folded constant + arg. + c = foo + bar + arg; + + // Reduces to a StringConcat with three operands. + d = '"' + foo + arg + bar + '"'; +} + +test('boo'); +%OptimizeFunctionOnNextCall(test); +test('baa'); + +assertEquals('"foo-bar"', a); +assertEquals('"foo-baz"', b); +assertEquals('foobarbaa', c); +assertEquals('"foobaabar"', d); diff --git a/deps/v8/test/mjsunit/compiler/object-isprototypeof.js b/deps/v8/test/mjsunit/compiler/object-isprototypeof.js new file mode 100644 index 0000000000..284a4387d6 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/object-isprototypeof.js @@ -0,0 +1,153 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test corner cases with null/undefined receivers. +(function() { + function foo(x, y) { return Object.prototype.isPrototypeOf.call(x, y); } + + assertThrows(() => foo(null, {})); + assertThrows(() => foo(undefined, {})); + assertThrows(() => foo(null, [])); + assertThrows(() => foo(undefined, [])); + assertFalse(foo(null, 0)); + assertFalse(foo(undefined, 0)); + assertFalse(foo(null, "")); + assertFalse(foo(undefined, "")); + assertFalse(foo(null, null)); + assertFalse(foo(undefined, null)); + assertFalse(foo(null, undefined)); + assertFalse(foo(undefined, undefined)); + %OptimizeFunctionOnNextCall(foo); + assertThrows(() => foo(null, {})); + assertThrows(() => foo(undefined, {})); + assertThrows(() => foo(null, [])); + assertThrows(() => foo(undefined, [])); + assertFalse(foo(null, 0)); + assertFalse(foo(undefined, 0)); + assertFalse(foo(null, "")); + assertFalse(foo(undefined, "")); + assertFalse(foo(null, null)); + assertFalse(foo(undefined, null)); + assertFalse(foo(null, undefined)); + assertFalse(foo(undefined, undefined)); +})(); + +// Test general constructor prototype case. +(function() { + function A() {} + A.prototype = {}; + var a = new A; + + function foo(x) { return A.prototype.isPrototypeOf(x); } + + assertFalse(foo(0)); + assertFalse(foo("")); + assertFalse(foo(null)); + assertFalse(foo(undefined)); + assertFalse(foo({})); + assertFalse(foo([])); + assertTrue(foo(a)); + assertTrue(foo(new A)); + assertTrue(foo({__proto__: a})); + assertTrue(foo({__proto__: A.prototype})); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo(0)); + assertFalse(foo("")); + assertFalse(foo(null)); + assertFalse(foo(undefined)); + assertFalse(foo({})); + assertFalse(foo([])); + assertTrue(foo(a)); + assertTrue(foo(new A)); + assertTrue(foo({__proto__: a})); + assertTrue(foo({__proto__: A.prototype})); +})(); + +// Test known primitive values. +(function() { + function A() {} + A.prototype = {}; + var a = new A; + + function foo() { return A.prototype.isPrototypeOf(0); } + + assertFalse(foo()); + assertFalse(foo()); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo()); +})(); +(function() { + function A() {} + A.prototype = {}; + var a = new A; + + function foo() { return A.prototype.isPrototypeOf(null); } + + assertFalse(foo()); + assertFalse(foo()); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo()); +})(); +(function() { + function A() {} + A.prototype = {}; + var a = new A; + + function foo() { return A.prototype.isPrototypeOf(undefined); } + + assertFalse(foo()); + assertFalse(foo()); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo()); +})(); + +// Test constant-folded prototype chain checks. +(function() { + function A() {} + A.prototype = {}; + var a = new A; + + function foo() { return A.prototype.isPrototypeOf(a); } + + assertTrue(foo()); + assertTrue(foo()); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo()); +})(); +(function() { + function A() {} + var a = new A; + A.prototype = {}; + + function foo() { return A.prototype.isPrototypeOf(a); } + + assertFalse(foo()); + assertFalse(foo()); + %OptimizeFunctionOnNextCall(foo); + assertFalse(foo()); +})(); + +// Test Array prototype chain checks. +(function() { + var a = []; + + function foo() { return Array.prototype.isPrototypeOf(a); } + + assertTrue(foo()); + assertTrue(foo()); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo()); +})(); +(function() { + var a = []; + + function foo() { return Object.prototype.isPrototypeOf(a); } + + assertTrue(foo()); + assertTrue(foo()); + %OptimizeFunctionOnNextCall(foo); + assertTrue(foo()); +})(); diff --git a/deps/v8/test/mjsunit/compiler/optimized-with.js b/deps/v8/test/mjsunit/compiler/optimized-with.js new file mode 100644 index 0000000000..9bc8713722 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/optimized-with.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test with-statements inside a try-catch block. +(() => { + function f(object) { + try { + with (object) { return x } + } catch(e) { + return e + } + } + assertEquals(23, f({ x:23 })); + assertEquals(42, f({ x:42 })); + assertInstanceof(f(null), TypeError); + assertInstanceof(f(undefined), TypeError); + %OptimizeFunctionOnNextCall(f); + assertInstanceof(f(null), TypeError); + assertInstanceof(f(undefined), TypeError); +})(); diff --git a/deps/v8/test/mjsunit/compiler/reflect-apply.js b/deps/v8/test/mjsunit/compiler/reflect-apply.js new file mode 100644 index 0000000000..fb8f201a72 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/reflect-apply.js @@ -0,0 +1,114 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test Reflect.apply with wrong number of arguments. +(function() { + "use strict"; + function bar() { return this; } + function foo() { return Reflect.apply(bar); } + + assertThrows(foo); + assertThrows(foo); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo); +})(); +(function() { + "use strict"; + function bar() { return this; } + function foo() { return Reflect.apply(bar, this); } + + assertThrows(foo); + assertThrows(foo); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo); +})(); +(function() { + "use strict"; + function bar() { return this; } + function foo() { return Reflect.apply(bar, this, arguments, this); } + + assertEquals(42, foo.call(42)); + assertEquals(42, foo.call(42)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(42, foo.call(42)); +})(); + +// Test Reflect.apply within try/catch. +(function() { + "use strict"; + function foo(bar) { + try { + return Reflect.apply(bar, bar, arguments); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); +(function() { + "use strict"; + function foo(bar) { + try { + return Reflect.apply(bar, bar, bar); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); + +// Test proper order of callable check and array-like iteration +// in Reflect.apply. +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.apply(undefined, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.apply(null, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.apply(null, this, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); diff --git a/deps/v8/test/mjsunit/compiler/reflect-construct.js b/deps/v8/test/mjsunit/compiler/reflect-construct.js new file mode 100644 index 0000000000..fb70ff4412 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/reflect-construct.js @@ -0,0 +1,130 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test Reflect.construct with wrong number of arguments. +(function() { + "use strict"; + function A() {} + function foo() { return Reflect.construct(A); } + + assertThrows(foo); + assertThrows(foo); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo); +})(); +(function() { + "use strict"; + function A(x) { this.x = x; } + function foo() { return Reflect.construct(A, arguments); } + + assertInstanceof(foo(), A); + assertInstanceof(foo(), A); + assertEquals(1, foo(1).x); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo(1).x); +})(); +(function() { + "use strict"; + function A(x) { this.x = x; } + function foo() { return Reflect.construct(A, arguments, A, A); } + + assertInstanceof(foo(), A); + assertInstanceof(foo(), A); + assertEquals(1, foo(1).x); + %OptimizeFunctionOnNextCall(foo); + assertInstanceof(foo(), A); + assertEquals(1, foo(1).x); +})(); + +// Test Reflect.construct within try/catch. +(function() { + "use strict"; + function foo(bar) { + try { + return Reflect.construct(bar, arguments, bar); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); +(function() { + "use strict"; + function foo(bar) { + try { + return Reflect.construct(bar, bar, bar); + } catch (e) { + return 1; + } + } + + assertEquals(1, foo()); + assertEquals(1, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(1, foo()); +})(); + +// Test proper order of constructor check(s) and array-like iteration. +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.construct(undefined, dummy, undefined); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.construct(undefined, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); +(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.construct(null, dummy, null); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})();(function() { + var dummy_length_counter = 0; + var dummy = { get length() { ++dummy_length_counter; return 0; } }; + + function foo() { + return Reflect.construct(null, dummy); + } + + assertThrows(foo, TypeError); + assertThrows(foo, TypeError); + %OptimizeFunctionOnNextCall(foo); + assertThrows(foo, TypeError); + assertEquals(0, dummy_length_counter); +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-1.js b/deps/v8/test/mjsunit/compiler/regress-4389-1.js index c58ce2da40..adb37165db 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-1.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-1.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.fround(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-2.js b/deps/v8/test/mjsunit/compiler/regress-4389-2.js index 3b720a5a95..edfcf7a8f5 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-2.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-2.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.sqrt(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-3.js b/deps/v8/test/mjsunit/compiler/regress-4389-3.js index 9aa72d1ac9..f4dbc48670 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-3.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-3.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.floor(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-4.js b/deps/v8/test/mjsunit/compiler/regress-4389-4.js index e824973fac..2b9b1493eb 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-4.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-4.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.round(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-5.js b/deps/v8/test/mjsunit/compiler/regress-4389-5.js index 64797bc76c..e72a3c38ea 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-5.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-5.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.abs(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4389-6.js b/deps/v8/test/mjsunit/compiler/regress-4389-6.js index fe065707f4..72a8856525 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4389-6.js +++ b/deps/v8/test/mjsunit/compiler/regress-4389-6.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax function foo(x) { Math.log(x); } foo(1); diff --git a/deps/v8/test/mjsunit/compiler/regress-4413-1.js b/deps/v8/test/mjsunit/compiler/regress-4413-1.js index 6f5371127d..569823530f 100644 --- a/deps/v8/test/mjsunit/compiler/regress-4413-1.js +++ b/deps/v8/test/mjsunit/compiler/regress-4413-1.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo-asm +// Flags: --allow-natives-syntax var foo = (function(stdlib) { "use asm"; diff --git a/deps/v8/test/mjsunit/compiler/regress-445732.js b/deps/v8/test/mjsunit/compiler/regress-445732.js index 199a29a5f8..725e1282d6 100644 --- a/deps/v8/test/mjsunit/compiler/regress-445732.js +++ b/deps/v8/test/mjsunit/compiler/regress-445732.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo-asm +// Flags: --allow-natives-syntax "use asm"; diff --git a/deps/v8/test/mjsunit/compiler/regress-628773.js b/deps/v8/test/mjsunit/compiler/regress-628773.js index 3c315b3828..cb1fa6fd64 100644 --- a/deps/v8/test/mjsunit/compiler/regress-628773.js +++ b/deps/v8/test/mjsunit/compiler/regress-628773.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-tailcalls - "use strict"; function foo() { diff --git a/deps/v8/test/mjsunit/compiler/regress-713367.js b/deps/v8/test/mjsunit/compiler/regress-713367.js index 9cca5a8325..1bf0a04493 100644 --- a/deps/v8/test/mjsunit/compiler/regress-713367.js +++ b/deps/v8/test/mjsunit/compiler/regress-713367.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape var mp = Object.getPrototypeOf(0); diff --git a/deps/v8/test/mjsunit/compiler/regress-725743.js b/deps/v8/test/mjsunit/compiler/regress-725743.js new file mode 100644 index 0000000000..95904bc632 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-725743.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --no-turbo --cache=code --no-lazy + +function f() { + var n = a.length; + for (var i = 0; i < n; i++) { + } + for (var i = 0; i < n; i++) { + } +} +var a = "xxxxxxxxxxxxxxxxxxxxxxxxx"; +while (a.length < 100000) a = a + a; +f(); diff --git a/deps/v8/test/mjsunit/es6/generator-let-asi.js b/deps/v8/test/mjsunit/compiler/regress-729369.js index c806783aa6..3294564715 100644 --- a/deps/v8/test/mjsunit/es6/generator-let-asi.js +++ b/deps/v8/test/mjsunit/compiler/regress-729369.js @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -var let = 0; -function* generator() { - let - yield 0; +// Flags: --allow-natives-syntax + +function* f() { + x.__defineGetter__(); + var x = 0; + for (let y of iterable) { + yield y; + } } -let it = generator(); -let {value, done} = it.next(); -assertEquals(0, value); -assertEquals(false, done); +f(); diff --git a/deps/v8/test/mjsunit/compiler/regress-731495.js b/deps/v8/test/mjsunit/compiler/regress-731495.js new file mode 100644 index 0000000000..7e0d850efb --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-731495.js @@ -0,0 +1,15 @@ +// 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 + +function foo() { + global = ""; + global = global + "bar"; + return global; +}; + +assertEquals(foo(), "bar"); +%OptimizeFunctionOnNextCall(foo); +assertEquals(foo(), "bar"); diff --git a/deps/v8/test/mjsunit/compiler/regress-733181.js b/deps/v8/test/mjsunit/compiler/regress-733181.js new file mode 100644 index 0000000000..0a76ab70ea --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-733181.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function l(s) { + return ("xxxxxxxxxxxxxxxxxxxxxxx" + s).toLowerCase(); +} + +l("abcd"); +l("abcd"); +%OptimizeFunctionOnNextCall(l); +l("abcd"); + +function u(s) { + return ("xxxxxxxxxxxxxxxxxxxxxxx" + s).toUpperCase(); +} + +u("abcd"); +u("abcd"); +%OptimizeFunctionOnNextCall(u); +u("abcd"); diff --git a/deps/v8/test/mjsunit/compiler/regress-736567.js b/deps/v8/test/mjsunit/compiler/regress-736567.js new file mode 100644 index 0000000000..84c6dce1ff --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-736567.js @@ -0,0 +1,20 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f(b, x) { + var o = b ? { a : 1 } : undefined; + return o.a + !(x & 1); +} + +f(1); + +function g() { + f(0, "s"); +} + +assertThrows(g); +%OptimizeFunctionOnNextCall(g); +assertThrows(g); diff --git a/deps/v8/test/mjsunit/compiler/regress-739902.js b/deps/v8/test/mjsunit/compiler/regress-739902.js new file mode 100644 index 0000000000..8f94995840 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-739902.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + function f(x) { + return String.fromCharCode(x >>> 24); + }; + + var e = 0x41000001; + + f(e); + %OptimizeFunctionOnNextCall(f); + assertEquals("A", f(e)); +})(); + +(function() { + function f(x) { + return (x >>> 24) & 0xffff; + }; + + f(1); + %OptimizeFunctionOnNextCall(f); + assertEquals(0, f(1)); + assertEquals(100, f((100 << 24) + 42)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-compare-negate.js b/deps/v8/test/mjsunit/compiler/regress-compare-negate.js index 5591af1b32..e18d6a0f0e 100644 --- a/deps/v8/test/mjsunit/compiler/regress-compare-negate.js +++ b/deps/v8/test/mjsunit/compiler/regress-compare-negate.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --opt +// Flags: --allow-natives-syntax --opt function CompareNegate(a,b) { a = a|0; diff --git a/deps/v8/test/mjsunit/compiler/regress-escape-analysis-indirect.js b/deps/v8/test/mjsunit/compiler/regress-escape-analysis-indirect.js index 6d79a93133..01f3e13466 100644 --- a/deps/v8/test/mjsunit/compiler/regress-escape-analysis-indirect.js +++ b/deps/v8/test/mjsunit/compiler/regress-escape-analysis-indirect.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape function f(apply) { var value = 23; diff --git a/deps/v8/test/mjsunit/compiler/rest-parameters.js b/deps/v8/test/mjsunit/compiler/rest-parameters.js index b960a23aaf..45b8cb34df 100644 --- a/deps/v8/test/mjsunit/compiler/rest-parameters.js +++ b/deps/v8/test/mjsunit/compiler/rest-parameters.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax (function Rest0Params() { diff --git a/deps/v8/test/mjsunit/compiler/spread-call.js b/deps/v8/test/mjsunit/compiler/spread-call.js new file mode 100644 index 0000000000..1b7ae6f301 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/spread-call.js @@ -0,0 +1,80 @@ +// 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 + +function tests() { + "use strict" + function countArgs() { return arguments.length; } + + // Array params + assertEquals(3, countArgs(...[1, 2, 3])); // Smi + assertEquals(4, countArgs(...[1, 2, , 3])); // HoleySmi + assertEquals(3, countArgs(...[1.1, 2, 3])); // Double + assertEquals(4, countArgs(...[1.1, 2, , 3])); // HoleyDouble + assertEquals(3, countArgs(...[{valueOf: () => 0}, 1.1, '2'])); // Object + assertEquals( + 4, countArgs(...[{valueOf: () => 0}, 1.1, , '2'])); // HoleyObject + + // Smi param + assertThrows(() => countArgs(...1), TypeError); + + // Object param + assertThrows(() => countArgs(...{0: 0}), TypeError); + + // Strict arguments + assertEquals(0, countArgs(...arguments)); +} + +tests(); +tests(); +%OptimizeFunctionOnNextCall(tests); +tests(); + +function testRest(...args) { + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...args)); + assertEquals(4, countArgs(1, ...args)); + assertEquals(5, countArgs(1, 2, ...args)); +} +testRest(1, 2, 3); +testRest(1, 2, 3); +%OptimizeFunctionOnNextCall(testRest); +testRest(1, 2, 3); + +function testRestAndArgs(a, b, ...args) { + function countArgs() { return arguments.length; } + assertEquals(1, countArgs(...args)); + assertEquals(2, countArgs(b, ...args)); + assertEquals(3, countArgs(a, b, ...args)); + assertEquals(4, countArgs(1, a, b, ...args)); + assertEquals(5, countArgs(1, 2, a, b, ...args)); +} +testRestAndArgs(1, 2, 3); +testRestAndArgs(1, 2, 3); +%OptimizeFunctionOnNextCall(testRestAndArgs); +testRestAndArgs(1, 2, 3); + +function testArgumentsStrict() { + "use strict" + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...arguments)); + assertEquals(4, countArgs(1, ...arguments)); + assertEquals(5, countArgs(1, 2, ...arguments)); +} +testArgumentsStrict(1, 2, 3); +testArgumentsStrict(1, 2, 3); +%OptimizeFunctionOnNextCall(testArgumentsStrict); +testArgumentsStrict(1, 2, 3); + +function testArgumentsSloppy() { + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...arguments)); + assertEquals(4, countArgs(1, ...arguments)); + assertEquals(5, countArgs(1, 2, ...arguments)); +} +testArgumentsSloppy(1, 2, 3); +testArgumentsSloppy(1, 2, 3); +%OptimizeFunctionOnNextCall(testArgumentsSloppy); +testArgumentsSloppy(1, 2, 3); diff --git a/deps/v8/test/mjsunit/compiler/string-concat-try-catch.js b/deps/v8/test/mjsunit/compiler/string-concat-try-catch.js new file mode 100644 index 0000000000..dfd6edbb27 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/string-concat-try-catch.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var a = "a".repeat(268435440); + +(function() { + function foo(a) { + try { + return "longer than ConsString:kMinLength" + a + "0123456789012"; + } catch (e) { + return e; + } + } + + foo("a"); + foo("a"); + // Optimize with string length protector check. + %OptimizeFunctionOnNextCall(foo); + foo("a"); + assertInstanceof(foo(a), RangeError); + // Optimize without string length protector check. + %OptimizeFunctionOnNextCall(foo); + foo("a"); + assertInstanceof(foo(a), RangeError); +})(); diff --git a/deps/v8/test/mjsunit/compiler/string-concat-yield.js b/deps/v8/test/mjsunit/compiler/string-concat-yield.js new file mode 100644 index 0000000000..d6611d2d36 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/string-concat-yield.js @@ -0,0 +1,15 @@ +// 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 + +function* foo() { + var f = `foo${ yield 'yielded' }bar`; + return f; +} + +%OptimizeFunctionOnNextCall(foo); +var gen = foo(); +assertEquals('yielded', gen.next('unused').value); +assertEquals('foobazbar', gen.next('baz').value); diff --git a/deps/v8/test/mjsunit/constant-fold-control-instructions.js b/deps/v8/test/mjsunit/constant-fold-control-instructions.js index 5a240a3942..be3cdfdd91 100644 --- a/deps/v8/test/mjsunit/constant-fold-control-instructions.js +++ b/deps/v8/test/mjsunit/constant-fold-control-instructions.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --fold-constants +// Flags: --allow-natives-syntax function test() { assertEquals("string", typeof ""); diff --git a/deps/v8/test/mjsunit/constant-folding-2.js b/deps/v8/test/mjsunit/constant-folding-2.js index e2d334b2f2..da9e5d5469 100644 --- a/deps/v8/test/mjsunit/constant-folding-2.js +++ b/deps/v8/test/mjsunit/constant-folding-2.js @@ -26,7 +26,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --nodead-code-elimination --fold-constants // Flags: --allow-natives-syntax --nostress-opt --opt function test(f) { diff --git a/deps/v8/test/mjsunit/date.js b/deps/v8/test/mjsunit/date.js index b7d78bbec7..fc5bcc54b5 100644 --- a/deps/v8/test/mjsunit/date.js +++ b/deps/v8/test/mjsunit/date.js @@ -314,6 +314,15 @@ for (var i = 0; i < 24; i++) { } } +// Test padding with 0 rather than spaces +assertEquals('Wed, 01 Jan 0020 00:00:00 GMT', new Date('0020-01-01T00:00:00Z').toUTCString()); +let dateRegExp = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2} [0-9]{4}$/ +match = dateRegExp.exec(new Date('0020-01-01T00:00:00Z').toDateString()); +assertNotNull(match); +let stringRegExp = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT[+-][0-9]{4}( \(.+\))?$/ +match = stringRegExp.exec(new Date('0020-01-01T00:00:00Z').toString()); +assertNotNull(match); + assertThrows('Date.prototype.setTime.call("", 1);', TypeError); assertThrows('Date.prototype.setYear.call("", 1);', TypeError); assertThrows('Date.prototype.setHours.call("", 1, 2, 3, 4);', TypeError); diff --git a/deps/v8/test/mjsunit/deopt-recursive-eager-once.js b/deps/v8/test/mjsunit/deopt-recursive-eager-once.js index ba88b01b1a..3443f52611 100644 --- a/deps/v8/test/mjsunit/deopt-recursive-eager-once.js +++ b/deps/v8/test/mjsunit/deopt-recursive-eager-once.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --turbo --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen function foo(i, deopt = false) { if (i == 0) { diff --git a/deps/v8/test/mjsunit/deopt-recursive-lazy-once.js b/deps/v8/test/mjsunit/deopt-recursive-lazy-once.js index f0eec59a4b..38a5851091 100644 --- a/deps/v8/test/mjsunit/deopt-recursive-lazy-once.js +++ b/deps/v8/test/mjsunit/deopt-recursive-lazy-once.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --turbo --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen function foo(i, deopt = false) { if (i == 0) { diff --git a/deps/v8/test/mjsunit/deopt-recursive-soft-once.js b/deps/v8/test/mjsunit/deopt-recursive-soft-once.js index 9338ff553b..d3c9b8c550 100644 --- a/deps/v8/test/mjsunit/deopt-recursive-soft-once.js +++ b/deps/v8/test/mjsunit/deopt-recursive-soft-once.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --turbo --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen function foo(i, deopt = false, deoptobj = null) { diff --git a/deps/v8/test/mjsunit/deopt-unlinked.js b/deps/v8/test/mjsunit/deopt-unlinked.js index e7374da543..3b6d6920a8 100644 --- a/deps/v8/test/mjsunit/deopt-unlinked.js +++ b/deps/v8/test/mjsunit/deopt-unlinked.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --turbo --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen function foo() {} diff --git a/deps/v8/test/mjsunit/deopt-with-fp-regs.js b/deps/v8/test/mjsunit/deopt-with-fp-regs.js index bdb08053ae..0fff838de6 100644 --- a/deps/v8/test/mjsunit/deopt-with-fp-regs.js +++ b/deps/v8/test/mjsunit/deopt-with-fp-regs.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen deopt_trigger = 0; side_effect = 0; diff --git a/deps/v8/test/mjsunit/duplicate-parameters.js b/deps/v8/test/mjsunit/duplicate-parameters.js index 43fb1c919b..6530128556 100644 --- a/deps/v8/test/mjsunit/duplicate-parameters.js +++ b/deps/v8/test/mjsunit/duplicate-parameters.js @@ -126,7 +126,7 @@ function testHelper(type, strict, lazy, duplicate_params_string, ok) { function test(type, strict, lazy, ok_if_param_list_simple) { // Simple duplicate params. - testHelper(type, strict, lazy, "dup, dup", ok_if_param_list_simple) + testHelper(type, strict, lazy, "a, dup, dup, b", ok_if_param_list_simple) if (strict != Strictness.STRICT_FUNCTION) { // Generate test cases where the duplicate parameter occurs because of @@ -134,12 +134,12 @@ function test(type, strict, lazy, ok_if_param_list_simple) { // parameters are only allowed in simple parameter lists. These tests are // not possible if a function declares itself strict, since non-simple // parameters are not allowed then. - testHelper(type, strict, lazy, "[dup], dup", false); - testHelper(type, strict, lazy, "dup, {a: dup}", false); - testHelper(type, strict, lazy, "{dup}, [dup]", false); - testHelper(type, strict, lazy, "dup, ...dup", false); - testHelper(type, strict, lazy, "dup, dup, ...rest", false); - testHelper(type, strict, lazy, "dup, dup, a = 1", false); + testHelper(type, strict, lazy, "a, [dup], dup, b", false); + testHelper(type, strict, lazy, "a, dup, {b: dup}, c", false); + testHelper(type, strict, lazy, "a, {dup}, [dup], b", false); + testHelper(type, strict, lazy, "a, dup, ...dup", false); + testHelper(type, strict, lazy, "a, dup, dup, ...rest", false); + testHelper(type, strict, lazy, "a, dup, dup, b = 1", false); } } diff --git a/deps/v8/test/mjsunit/elements-kind.js b/deps/v8/test/mjsunit/elements-kind.js index 5ff5116ae2..e220f16533 100644 --- a/deps/v8/test/mjsunit/elements-kind.js +++ b/deps/v8/test/mjsunit/elements-kind.js @@ -44,9 +44,9 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; if (%HasFixedInt8Elements(obj)) { diff --git a/deps/v8/test/mjsunit/elements-length-no-holey.js b/deps/v8/test/mjsunit/elements-length-no-holey.js index 5bac296e1a..73ffa21b68 100644 --- a/deps/v8/test/mjsunit/elements-length-no-holey.js +++ b/deps/v8/test/mjsunit/elements-length-no-holey.js @@ -29,5 +29,5 @@ a = [1,2,3]; a.length = 1; -assertFalse(%HasFastHoleyElements(a)); -assertTrue(%HasFastSmiElements(a)); +assertFalse(%HasHoleyElements(a)); +assertTrue(%HasSmiElements(a)); diff --git a/deps/v8/test/mjsunit/elements-transition-hoisting.js b/deps/v8/test/mjsunit/elements-transition-hoisting.js index 2b67b62b92..dcd742e621 100644 --- a/deps/v8/test/mjsunit/elements-transition-hoisting.js +++ b/deps/v8/test/mjsunit/elements-transition-hoisting.js @@ -95,8 +95,8 @@ function test_wrapper() { a[1] = 2.5; } a.foo = object; // This map check should NOT be hoistable because it - // includes a check for the FAST_ELEMENTS map as well as - // the FAST_DOUBLE_ELEMENTS map, which depends on the + // includes a check for the PACKED_ELEMENTS map as well as + // the PACKED_DOUBLE_ELEMENTS map, which depends on the // double transition above in the if, which cannot be // hoisted. } while (--count > 0); diff --git a/deps/v8/test/mjsunit/elements-transition.js b/deps/v8/test/mjsunit/elements-transition.js index 7365ed7014..ac0b9a1403 100644 --- a/deps/v8/test/mjsunit/elements-transition.js +++ b/deps/v8/test/mjsunit/elements-transition.js @@ -48,21 +48,21 @@ function test(test_double, test_object, set, length) { var array_2 = make_array(length); // false, true, nice setter function, 20 - assertTrue(%HasFastSmiElements(array_1)); - assertTrue(%HasFastSmiElements(array_2)); + assertTrue(%HasSmiElements(array_1)); + assertTrue(%HasSmiElements(array_2)); for (var i = 0; i < length; i++) { if (i == length - 5 && test_double) { // Trigger conversion to fast double elements at length-5. set(array_1, i, 0.5); set(array_2, i, 0.5); - assertTrue(%HasFastDoubleElements(array_1)); - assertTrue(%HasFastDoubleElements(array_2)); + assertTrue(%HasDoubleElements(array_1)); + assertTrue(%HasDoubleElements(array_2)); } else if (i == length - 3 && test_object) { // Trigger conversion to fast object elements at length-3. set(array_1, i, 'object'); set(array_2, i, 'object'); - assertTrue(%HasFastObjectElements(array_1)); - assertTrue(%HasFastObjectElements(array_2)); + assertTrue(%HasObjectElements(array_1)); + assertTrue(%HasObjectElements(array_2)); } else if (i != length - 7) { // Set the element to an integer but leave a hole at length-7. set(array_1, i, 2*i+1); diff --git a/deps/v8/test/mjsunit/ensure-growing-store-learns.js b/deps/v8/test/mjsunit/ensure-growing-store-learns.js index 7cb8aaa8ba..fc7b6c2543 100644 --- a/deps/v8/test/mjsunit/ensure-growing-store-learns.js +++ b/deps/v8/test/mjsunit/ensure-growing-store-learns.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts -// Flags: --opt --no-always-opt +// Flags: --opt --no-always-opt --no-stress-fullcodegen // --noverify-heap and --noenable-slow-asserts are set because the test is too // slow with it on. @@ -62,13 +62,13 @@ foo2(a, 40); assertOptimized(foo2); - assertTrue(%HasFastSmiElements(a)); + assertTrue(%HasSmiElements(a)); // Grow a large array into large object space through the keyed store // without deoptimizing. Grow by 9s. If we set elements too sparsely, the // array will convert to dictionary mode. a = new Array(99999); - assertTrue(%HasFastSmiElements(a)); + assertTrue(%HasSmiElements(a)); for (var i = 0; i < 263000; i += 9) { foo2(a, i); } @@ -76,7 +76,7 @@ // Verify that we are over 1 page in size, and foo2 remains optimized. // This means we've smoothly transitioned to allocating in large object // space. - assertTrue(%HasFastSmiElements(a)); + assertTrue(%HasSmiElements(a)); assertTrue(a.length * 4 > (1024 * 1024)); assertOptimized(foo2); diff --git a/deps/v8/test/mjsunit/es6/array-iterator-turbo.js b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js index c9182f89e0..3a159b6337 100644 --- a/deps/v8/test/mjsunit/es6/array-iterator-turbo.js +++ b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo --turbo-escape --allow-natives-syntax --no-always-opt +// Flags: --turbo-escape --allow-natives-syntax --no-always-opt // Flags: --opt --turbo-filter=* "use strict"; @@ -11,13 +11,13 @@ let global = this; let tests = { FastElementsKind() { let runners = { - FAST_SMI_ELEMENTS(array) { + PACKED_SMI_ELEMENTS(array) { let sum = 0; for (let x of array) sum += x; return sum; }, - FAST_HOLEY_SMI_ELEMENTS(array) { + HOLEY_SMI_ELEMENTS(array) { let sum = 0; for (let x of array) { if (x) sum += x; @@ -25,19 +25,19 @@ let tests = { return sum; }, - FAST_ELEMENTS(array) { + PACKED_ELEMENTS(array) { let ret = ""; for (let str of array) ret += `> ${str}`; return ret; }, - FAST_HOLEY_ELEMENTS(array) { + HOLEY_ELEMENTS(array) { let ret = ""; for (let str of array) ret += `> ${str}`; return ret; }, - FAST_DOUBLE_ELEMENTS(array) { + PACKED_DOUBLE_ELEMENTS(array) { let sum = 0.0; for (let x of array) sum += x; return sum; @@ -45,7 +45,7 @@ let tests = { // TODO(6587): Re-enable the below test case once we no longer deopt due // to non-truncating uses of {CheckFloat64Hole} nodes. - /*FAST_HOLEY_DOUBLE_ELEMENTS(array) { + /*HOLEY_DOUBLE_ELEMENTS(array) { let sum = 0.0; for (let x of array) { if (x) sum += x; @@ -55,32 +55,32 @@ let tests = { }; let tests = { - FAST_SMI_ELEMENTS: { + PACKED_SMI_ELEMENTS: { array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], expected: 55, array2: [1, 2, 3], expected2: 6 }, - FAST_HOLEY_SMI_ELEMENTS: { + HOLEY_SMI_ELEMENTS: { array: [1, , 3, , 5, , 7, , 9, ,], expected: 25, array2: [1, , 3], expected2: 4 }, - FAST_ELEMENTS: { + PACKED_ELEMENTS: { array: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], expected: "> a> b> c> d> e> f> g> h> i> j", array2: ["a", "b", "c"], expected2: "> a> b> c" }, - FAST_HOLEY_ELEMENTS: { + HOLEY_ELEMENTS: { array: ["a", , "c", , "e", , "g", , "i", ,], expected: "> a> undefined> c> undefined> e> undefined> g" + "> undefined> i> undefined", array2: ["a", , "c"], expected2: "> a> undefined> c" }, - FAST_DOUBLE_ELEMENTS: { + PACKED_DOUBLE_ELEMENTS: { array: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], expected: 5.5, array2: [0.6, 0.4, 0.2], @@ -88,7 +88,7 @@ let tests = { }, // TODO(6587): Re-enable the below test case once we no longer deopt due // to non-truncating uses of {CheckFloat64Hole} nodes. - /*FAST_HOLEY_DOUBLE_ELEMENTS: { + /*HOLEY_DOUBLE_ELEMENTS: { array: [0.1, , 0.3, , 0.5, , 0.7, , 0.9, ,], expected: 2.5, array2: [0.1, , 0.3], diff --git a/deps/v8/test/mjsunit/es6/block-sloppy-function.js b/deps/v8/test/mjsunit/es6/block-sloppy-function.js index 2cdcbce3d6..d527a7debb 100644 --- a/deps/v8/test/mjsunit/es6/block-sloppy-function.js +++ b/deps/v8/test/mjsunit/es6/block-sloppy-function.js @@ -612,7 +612,6 @@ eval(` `); }(); -// This test is incorrect BUG(v8:5168). The commented assertions are correct. (function evalHoistingThroughSimpleCatch() { try { throw 0; @@ -636,12 +635,10 @@ eval(` return 4; } }`); - // assertEquals(0, f); - assertEquals(4, f()); + assertEquals(0, f); } - // assertEquals(4, f()); - assertEquals(undefined, f); + assertEquals(4, f()); })(); let dontHoistGlobal; diff --git a/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js b/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js index a68e2960f6..ef18cd3f33 100644 --- a/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js +++ b/deps/v8/test/mjsunit/es6/call-with-spread-modify-array-iterator.js @@ -17,7 +17,7 @@ testMax(1, 2); testMax(1, 2); - % OptimizeFunctionOnNextCall(testMax); + %OptimizeFunctionOnNextCall(testMax); var r = testMax(1, 2); assertEquals(2, r); diff --git a/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js b/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js index d206a14d35..d22a1eaec0 100644 --- a/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js +++ b/deps/v8/test/mjsunit/es6/call-with-spread-modify-next.js @@ -22,7 +22,7 @@ testMax(1, 2); testMax(1, 2); - % OptimizeFunctionOnNextCall(testMax); + %OptimizeFunctionOnNextCall(testMax); var r = testMax(1, 2); assertEquals(2, r); diff --git a/deps/v8/test/mjsunit/es6/call-with-spread.js b/deps/v8/test/mjsunit/es6/call-with-spread.js index e372e416d0..3a1744a72a 100644 --- a/deps/v8/test/mjsunit/es6/call-with-spread.js +++ b/deps/v8/test/mjsunit/es6/call-with-spread.js @@ -10,7 +10,7 @@ function testBaselineAndOpt(func) { func(-1, -2); func(-1, -2); - % OptimizeFunctionOnNextCall(func); + %OptimizeFunctionOnNextCall(func); return func(-1, -2); } @@ -78,7 +78,7 @@ function testBaselineAndOpt(func) { func(-1, -2); func(-1, -2); - % OptimizeFunctionOnNextCall(func); + %OptimizeFunctionOnNextCall(func); return func(-1, -2); } diff --git a/deps/v8/test/mjsunit/es6/collection-iterator.js b/deps/v8/test/mjsunit/es6/collection-iterator.js index a92c9aeda0..5a9b2f54e6 100644 --- a/deps/v8/test/mjsunit/es6/collection-iterator.js +++ b/deps/v8/test/mjsunit/es6/collection-iterator.js @@ -4,8 +4,14 @@ // Flags: --allow-natives-syntax - -(function TestSetIterator() { +function test(f) { + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); +} + +test(function TestSetIterator() { var s = new Set; var iter = s.values(); assertEquals('Set Iterator', %_ClassOf(iter)); @@ -28,10 +34,10 @@ assertTrue(desc.configurable); assertFalse(desc.writable); assertEquals("Set Iterator", desc.value); -})(); +}); -(function TestSetIteratorValues() { +test(function TestSetIteratorValues() { var s = new Set; s.add(1); s.add(2); @@ -43,15 +49,15 @@ assertEquals({value: 3, done: false}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); -(function TestSetIteratorKeys() { +test(function TestSetIteratorKeys() { assertEquals(Set.prototype.keys, Set.prototype.values); -})(); +}); -(function TestSetIteratorEntries() { +test(function TestSetIteratorEntries() { var s = new Set; s.add(1); s.add(2); @@ -63,10 +69,10 @@ assertEquals({value: [3, 3], done: false}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); -(function TestSetIteratorMutations() { +test(function TestSetIteratorMutations() { var s = new Set; s.add(1); var iter = s.values(); @@ -82,28 +88,65 @@ assertEquals({value: undefined, done: true}, iter.next()); s.add(4); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); + + +test(function TestSetIteratorMutations2() { + var s = new Set; + s.add(1); + s.add(2); + var i = s.values(); + assertEquals({value: 1, done: false}, i.next()); + s.delete(2); + s.delete(1); + s.add(2); + assertEquals({value: 2, done: false}, i.next()); + assertEquals({value: undefined, done: true}, i.next()); +}); + + +test(function TestSetIteratorMutations3() { + var s = new Set; + s.add(1); + s.add(2); + var i = s.values(); + assertEquals({value: 1, done: false}, i.next()); + s.delete(2); + s.delete(1); + for (var x = 2; x < 500; ++x) s.add(x); + for (var x = 2; x < 500; ++x) s.delete(x); + for (var x = 2; x < 1000; ++x) s.add(x); + assertEquals({value: 2, done: false}, i.next()); + for (var x = 1001; x < 2000; ++x) s.add(x); + s.delete(3); + for (var x = 6; x < 2000; ++x) s.delete(x); + assertEquals({value: 4, done: false}, i.next()); + s.delete(5); + assertEquals({value: undefined, done: true}, i.next()); + s.add(4); + assertEquals({value: undefined, done: true}, i.next()); +}); -(function TestSetInvalidReceiver() { +test(function TestSetInvalidReceiver() { assertThrows(function() { Set.prototype.values.call({}); }, TypeError); assertThrows(function() { Set.prototype.entries.call({}); }, TypeError); -})(); +}); -(function TestSetIteratorInvalidReceiver() { +test(function TestSetIteratorInvalidReceiver() { var iter = new Set().values(); assertThrows(function() { iter.next.call({}); }); -})(); +}); -(function TestSetIteratorSymbol() { +test(function TestSetIteratorSymbol() { assertEquals(Set.prototype[Symbol.iterator], Set.prototype.values); assertTrue(Set.prototype.hasOwnProperty(Symbol.iterator)); assertFalse(Set.prototype.propertyIsEnumerable(Symbol.iterator)); @@ -111,10 +154,10 @@ var iter = new Set().values(); assertEquals(iter, iter[Symbol.iterator]()); assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]'); -})(); +}); -(function TestMapIterator() { +test(function TestMapIterator() { var m = new Map; var iter = m.values(); assertEquals('Map Iterator', %_ClassOf(iter)); @@ -138,10 +181,10 @@ assertTrue(desc.configurable); assertFalse(desc.writable); assertEquals("Map Iterator", desc.value); -})(); +}); -(function TestMapIteratorValues() { +test(function TestMapIteratorValues() { var m = new Map; m.set(1, 11); m.set(2, 22); @@ -153,10 +196,10 @@ assertEquals({value: 33, done: false}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); -(function TestMapIteratorKeys() { +test(function TestMapIteratorKeys() { var m = new Map; m.set(1, 11); m.set(2, 22); @@ -168,10 +211,10 @@ assertEquals({value: 3, done: false}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); -(function TestMapIteratorEntries() { +test(function TestMapIteratorEntries() { var m = new Map; m.set(1, 11); m.set(2, 22); @@ -183,10 +226,10 @@ assertEquals({value: [3, 33], done: false}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); assertEquals({value: undefined, done: true}, iter.next()); -})(); +}); -(function TestMapInvalidReceiver() { +test(function TestMapInvalidReceiver() { assertThrows(function() { Map.prototype.values.call({}); }, TypeError); @@ -196,18 +239,18 @@ assertThrows(function() { Map.prototype.entries.call({}); }, TypeError); -})(); +}); -(function TestMapIteratorInvalidReceiver() { +test(function TestMapIteratorInvalidReceiver() { var iter = new Map().values(); assertThrows(function() { iter.next.call({}); }, TypeError); -})(); +}); -(function TestMapIteratorSymbol() { +test(function TestMapIteratorSymbol() { assertEquals(Map.prototype[Symbol.iterator], Map.prototype.entries); assertTrue(Map.prototype.hasOwnProperty(Symbol.iterator)); assertFalse(Map.prototype.propertyIsEnumerable(Symbol.iterator)); @@ -215,4 +258,4 @@ var iter = new Map().values(); assertEquals(iter, iter[Symbol.iterator]()); assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]'); -})(); +}); diff --git a/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js b/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js index a5f380ceac..36afbe2ced 100644 --- a/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js +++ b/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-async-iteration function ID(x) { return x; @@ -67,13 +68,25 @@ function assertIteratorResult(value, done, result) { *['a']() { yield 1; yield 2; + }, + async ['b']() { + return 42; + }, + async *['c']() { + yield 1; + yield 2; } }; + assertEquals('a', object.a.name); + assertEquals('b', object.b.name); + assertEquals('c', object.c.name); + var iter = object.a(); assertIteratorResult(1, false, iter.next()); assertIteratorResult(2, false, iter.next()); assertIteratorResult(undefined, true, iter.next()); - assertArrayEquals(['a'], Object.keys(object)); + + assertArrayEquals(['a', 'b', 'c'], Object.keys(object)); })(); diff --git a/deps/v8/test/mjsunit/es6/function-name.js b/deps/v8/test/mjsunit/es6/function-name.js index 95bc2d4416..c292edf0cd 100644 --- a/deps/v8/test/mjsunit/es6/function-name.js +++ b/deps/v8/test/mjsunit/es6/function-name.js @@ -43,6 +43,7 @@ x: function withName() { }, y: class { }, z: class ClassName { }, + ''() {}, 42: function() {}, 4.2: function() {}, __proto__: function() {}, @@ -57,6 +58,7 @@ assertEquals('withName', obj.x.name); assertEquals('y', obj.y.name); assertEquals('ClassName', obj.z.name); + assertEquals('', obj[''].name); assertEquals('42', obj[42].name); assertEquals('4.2', obj[4.2].name); assertEquals('', obj.__proto__.name); @@ -69,6 +71,8 @@ static b() { } get c() { } set c(val) { } + ''() { } + static ''() { } 42() { } static 43() { } get 44() { } @@ -82,6 +86,8 @@ var descriptor = Object.getOwnPropertyDescriptor(C.prototype, 'c'); assertEquals('get c', descriptor.get.name); assertEquals('set c', descriptor.set.name); + assertEquals('', C.prototype[''].name); + assertEquals('', C[''].name); assertEquals('42', C.prototype[42].name); assertEquals('43', C[43].name); var descriptor = Object.getOwnPropertyDescriptor(C.prototype, '44'); @@ -100,35 +106,46 @@ var sym2 = Symbol('2'); var sym3 = Symbol('3'); var symNoDescription = Symbol(); + var proto = "__proto__"; var obj = { + ['']: function() {}, [a]: function() {}, [sym1]: function() {}, [sym2]: function withName() {}, [symNoDescription]: function() {}, + [proto]: function() {}, get [sym3]() {}, set [b](val) {}, }; + assertEquals('', obj[''].name); assertEquals('a', obj[a].name); assertEquals('[1]', obj[sym1].name); assertEquals('withName', obj[sym2].name); assertEquals('', obj[symNoDescription].name); + assertEquals('__proto__', obj[proto].name); assertEquals('get [3]', Object.getOwnPropertyDescriptor(obj, sym3).get.name); assertEquals('set b', Object.getOwnPropertyDescriptor(obj, 'b').set.name); var objMethods = { + ['']() {}, [a]() {}, [sym1]() {}, - [symNoDescription]: function() {}, + [symNoDescription]() {}, + [proto]() {}, }; + assertEquals('', objMethods[''].name); assertEquals('a', objMethods[a].name); assertEquals('[1]', objMethods[sym1].name); assertEquals('', objMethods[symNoDescription].name); + assertEquals('__proto__', objMethods[proto].name); class C { + ['']() { } + static ''() {} [a]() { } [sym1]() { } static [sym2]() { } @@ -138,6 +155,8 @@ static set [b](val) { } } + assertEquals('', C.prototype[''].name); + assertEquals('', C[''].name); assertEquals('a', C.prototype[a].name); assertEquals('[1]', C.prototype[sym1].name); assertEquals('[2]', C[sym2].name); @@ -377,6 +396,15 @@ (function testClassNameOrder() { assertEquals(['length', 'prototype'], Object.getOwnPropertyNames(class {})); + var tmp = {'': class {}}; + var Tmp = tmp['']; + assertEquals(['length', 'prototype', 'name'], Object.getOwnPropertyNames(Tmp)); + + var name = () => ''; + var tmp = {[name()]: class {}}; + var Tmp = tmp[name()]; + assertEquals(['length', 'prototype', 'name'], Object.getOwnPropertyNames(Tmp)); + class A { } assertEquals(['length', 'prototype', 'name'], Object.getOwnPropertyNames(A)); diff --git a/deps/v8/test/mjsunit/es6/proxies-apply.js b/deps/v8/test/mjsunit/es6/proxies-apply.js index a94541c01a..d42353a792 100644 --- a/deps/v8/test/mjsunit/es6/proxies-apply.js +++ b/deps/v8/test/mjsunit/es6/proxies-apply.js @@ -86,6 +86,133 @@ assertTrue(called_handler); })(); +(function testCallProxyTrapArrayArg() { + var called_target = false; + var called_handler = false; + var target = function(a, b) { + called_target = true; + assertArrayEquals([1, 2], a); + assertEquals(3, b); + } + var handler = { + apply: function(target, this_arg, args) { + target.apply(this_arg, args); + called_handler = true; + } + } + var proxy = new Proxy(target, handler); + assertFalse(called_target); + assertFalse(called_handler); + proxy([1,2], 3); + assertTrue(called_target); + assertTrue(called_handler); +})(); + +(function testCallProxyTrapObjectArg() { + var called_target = false; + var called_handler = false; + var target = function(o) { + called_target = true; + assertEquals({a: 1, b: 2}, o); + } + var handler = { + apply: function(target, this_arg, args) { + target.apply(this_arg, args); + called_handler = true; + } + } + var proxy = new Proxy(target, handler); + assertFalse(called_target); + assertFalse(called_handler); + proxy({a: 1, b: 2}); + assertTrue(called_target); + assertTrue(called_handler); +})(); + +(function testCallProxyTrapGeneratorArg() { + function* gen() { + yield 1; + yield 2; + yield 3; + } + var called_target = false; + var called_handler = false; + var target = function(g) { + called_target = true; + assertArrayEquals([1,2,3], [...g]); + } + var handler = { + apply: function(target, this_arg, args) { + target.apply(this_arg, args); + called_handler = true; + } + } + var proxy = new Proxy(target, handler); + assertFalse(called_target); + assertFalse(called_handler); + proxy(gen()); + assertTrue(called_target); + assertTrue(called_handler); +})(); + +(function testProxyTrapContext() { + var _target, _args, _handler, _context; + var target = function(a, b) { return a + b; }; + var handler = { + apply: function(t, c, args) { + _handler = this; + _target = t; + _context = c; + _args = args; + } + }; + var proxy = new Proxy(target, handler); + + var context = {}; + + proxy.call(context, 1, 2); + + assertEquals(_handler, handler); + assertEquals(_target, target); + assertEquals(_context, context); + assertEquals(_args.length, 2); + assertEquals(_args[0], 1); + assertEquals(_args[1], 2); +})(); + +(function testCallProxyNonCallableTrap() { + var called_target = false; + var target = function() { + called_target = true; + }; + var handler = { + apply: 'non callable trap' + }; + + var proxy = new Proxy(target, handler); + assertThrows(function(){ proxy() }, TypeError); + + assertFalse(called_target); +})(); + +(function testCallProxyNullTrap() { + var _args; + var target = function(a, b) { + _args = [a, b]; + return a + b; + }; + var handler = { + apply: null + }; + + var proxy = new Proxy(target, handler); + var result = proxy(1, 2); + + assertEquals(result, 3); + assertEquals(_args.length, 2); + assertEquals(_args[0], 1); + assertEquals(_args[1], 2); +})(); (function testCallProxyNonCallableTarget() { var values = [NaN, 1.5, 100, /RegExp/, "string", {}, [], Symbol(), diff --git a/deps/v8/test/mjsunit/es6/proxies-constructor.js b/deps/v8/test/mjsunit/es6/proxies-constructor.js new file mode 100644 index 0000000000..5b30725a52 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/proxies-constructor.js @@ -0,0 +1,96 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +(function testNonObjectTargetTypes() { + assertThrows(function(){ new Proxy(undefined, {}); }, TypeError); + + assertThrows(function(){ new Proxy(null, {}); }, TypeError); + + assertThrows(function(){ new Proxy('', {}); }, TypeError); + + assertThrows(function(){ new Proxy(0, {}); }, TypeError); + + assertThrows(function(){ new Proxy(0.5, {}); }, TypeError); + + assertThrows(function(){ new Proxy(false, {}); }, TypeError); +})(); + + +(function testRevokedTarget() { + var revocable = Proxy.revocable({}, {}); + revocable.revoke(); + + assertThrows(function(){ new Proxy(revocable.proxy, {}); }, TypeError); +})(); + + +(function testNonObjectHandlerTypes() { + assertThrows(function(){ new Proxy({}, undefined); }, TypeError); + + assertThrows(function(){ new Proxy({}, null); }, TypeError); + + assertThrows(function(){ new Proxy({}, ''); }, TypeError); + + assertThrows(function(){ new Proxy({}, 0); }, TypeError); + + assertThrows(function(){ new Proxy({}, 0.5); }, TypeError); + + assertThrows(function(){ new Proxy({}, false); }, TypeError); +})(); + + +(function testRevokedHandler() { + var revocable = Proxy.revocable({}, {}); + revocable.revoke(); + + assertThrows(function(){ new Proxy({}, revocable.proxy); }, TypeError); +})(); + + +(function testConstructionWithoutArguments() { + assertThrows(function(){ new Proxy(); }, TypeError); + + assertThrows(function(){ new Proxy(42); }, TypeError); + + assertThrows(function(){ new Proxy({}); }, TypeError); +})(); + + +(function testConstructionFromArray() { + var p = new Proxy([42], {}); + assertTrue(p instanceof Array); + assertEquals(p[0], 42); +})(); + + +(function testConstructionFromObject() { + var p = new Proxy({ + prop: 42 + }, {}); + assertTrue(p instanceof Object); + assertEquals(p.prop, 42); +})(); + + +(function testConstructionFromCallable() { + var p = new Proxy(() => { return 42; }, {}); + assertTrue(p instanceof Function); + assertEquals(p(), 42); +})(); + + +(function testConstructionFromConstructor() { + class foo {}; + var p = new Proxy(foo, {}); + assertTrue(p instanceof Function); + assertTrue(new p() instanceof foo); +})(); + + +(function testConstructionFromProxy() { + var q = new Proxy({}, {}); + var p = new Proxy(q, {}); + assertTrue(p instanceof Object); +})(); diff --git a/deps/v8/test/mjsunit/es6/reflect-construct.js b/deps/v8/test/mjsunit/es6/reflect-construct.js index 9de5158005..03e8397a9b 100644 --- a/deps/v8/test/mjsunit/es6/reflect-construct.js +++ b/deps/v8/test/mjsunit/es6/reflect-construct.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Flags: --allow-unsafe-function-constructor +// Flags: --allow-unsafe-function-constructor --harmony-async-iteration (function testReflectConstructArity() { @@ -322,10 +322,10 @@ "Float64Array", ["Function", ["return 153;"]], ["Function", ["'use strict'; return 153;"]], - ["Function", ["'use strong'; return 153;"]], ["((function*(){}).constructor)", ["yield 153;"]], // GeneratorFunction ["((function*(){}).constructor)", ["'use strict'; yield 153;"]], - ["((function*(){}).constructor)", ["'use strong'; yield 153;"]], + // AsyncGeneratorFunction + ["((async function*(){}).constructor)", ["return 153;"]], "Int8Array", "Int16Array", "Int32Array", diff --git a/deps/v8/test/mjsunit/es6/regress/regress-5598.js b/deps/v8/test/mjsunit/es6/regress/regress-5598.js index 600a866470..b07894f0fa 100644 --- a/deps/v8/test/mjsunit/es6/regress/regress-5598.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-5598.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo --turbo-escape --allow-natives-syntax +// Flags: --turbo-escape --allow-natives-syntax function fn(a) { var [b] = a; diff --git a/deps/v8/test/mjsunit/es6/regress/regress-6322.js b/deps/v8/test/mjsunit/es6/regress/regress-6322.js index 41f66171ed..8ec49fb0c8 100644 --- a/deps/v8/test/mjsunit/es6/regress/regress-6322.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-6322.js @@ -4,3 +4,8 @@ // Crash with --verify-heap (function*() { for (let { a = class b { } } of [{}]) { } })().next(); +(function() { for (let { a = class b { } } of [{}]) { } })(); +(function() { var a; for ({ a = class b { } } of [{}]) { } })(); + +(function() { for (let [a = class b { } ] = [[]]; ;) break; })(); +(function() { var a; for ([a = class b { } ] = [[]]; ;) break; })(); diff --git a/deps/v8/test/mjsunit/es6/spread-call.js b/deps/v8/test/mjsunit/es6/spread-call.js index 33d55a815f..cdedd990c8 100644 --- a/deps/v8/test/mjsunit/es6/spread-call.js +++ b/deps/v8/test/mjsunit/es6/spread-call.js @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function testSpreadCallsStrict() { +// Flags: --allow-natives-syntax + +function testSpreadCallsStrict() { "use strict" function countArgs() { return arguments.length; } @@ -158,7 +160,10 @@ // Interleaved spread/unspread args assertEquals(36, O.sum(0, ...[1], 2, 3, ...[4, 5], 6, 7, 8)); assertEquals(45, O.sum(0, ...[1], 2, 3, ...[4, 5], 6, 7, 8, ...[9])); -})(); +}; +testSpreadCallsStrict(); +%OptimizeFunctionOnNextCall(testSpreadCallsStrict); +testSpreadCallsStrict(); (function testSpreadCallsSloppy() { diff --git a/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js b/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js index 70ce9ca159..c1311af81f 100644 --- a/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js +++ b/deps/v8/test/mjsunit/es6/super-with-spread-modify-array-iterator.js @@ -25,7 +25,7 @@ } testRestPoint(1, 2); testRestPoint(1, 2); - % OptimizeFunctionOnNextCall(testRestPoint); + %OptimizeFunctionOnNextCall(testRestPoint); var r = testRestPoint(1, 2); assertInstanceof(r, RestPoint); diff --git a/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js b/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js index 8ae0d6c589..299917dbf1 100644 --- a/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js +++ b/deps/v8/test/mjsunit/es6/super-with-spread-modify-next.js @@ -30,7 +30,7 @@ } testArgumentsPoint(1, 2); testArgumentsPoint(1, 2); - % OptimizeFunctionOnNextCall(testArgumentsPoint); + %OptimizeFunctionOnNextCall(testArgumentsPoint); var r = testArgumentsPoint(1, 2); assertInstanceof(r, ArgumentsPoint); diff --git a/deps/v8/test/mjsunit/es6/super-with-spread.js b/deps/v8/test/mjsunit/es6/super-with-spread.js index 260704f7a4..b0aea826d4 100644 --- a/deps/v8/test/mjsunit/es6/super-with-spread.js +++ b/deps/v8/test/mjsunit/es6/super-with-spread.js @@ -17,7 +17,7 @@ function testBaselineAndOpt(func) { func(1, 2); func(1, 2); - % OptimizeFunctionOnNextCall(func); + %OptimizeFunctionOnNextCall(func); return func(1, 2); } diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard0.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard0.js deleted file mode 100644 index 87fe29e136..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard0.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(0); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard1.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard1.js deleted file mode 100644 index 10deb28357..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard1.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(1); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard2.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard2.js deleted file mode 100644 index 7d2bd97783..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard2.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(2); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard3.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard3.js deleted file mode 100644 index 7bce6c4a0e..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard3.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(3); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard4.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard4.js deleted file mode 100644 index 6c43d3ef6f..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard4.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(4); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard5.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard5.js deleted file mode 100644 index a91bd3f3c2..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard5.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(5); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard6.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard6.js deleted file mode 100644 index 0d70a4203b..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard6.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(6); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard7.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard7.js deleted file mode 100644 index 63477af08b..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard7.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(7); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard8.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard8.js deleted file mode 100644 index 0c68827602..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard8.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(8); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard9.js b/deps/v8/test/mjsunit/es6/tail-call-megatest-shard9.js deleted file mode 100644 index 82f991a329..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest-shard9.js +++ /dev/null @@ -1,13 +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 --harmony-tailcalls - -try { - load("mjsunit/es6/tail-call-megatest.js"); -} catch(e) { - load("test/mjsunit/es6/tail-call-megatest.js"); -} - -run_tests(9); diff --git a/deps/v8/test/mjsunit/es6/tail-call-megatest.js b/deps/v8/test/mjsunit/es6/tail-call-megatest.js deleted file mode 100644 index a3b5cecbe0..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-megatest.js +++ /dev/null @@ -1,423 +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 --harmony-tailcalls - - -Error.prepareStackTrace = (error,stack) => { - error.strace = stack; - return error.message + "\n at " + stack.join("\n at "); -} - -var verbose = typeof(arguments) !== "undefined" && arguments.indexOf("-v") >= 0; - -function checkStackTrace(expected) { - var e = new Error(); - e.stack; // prepare stack trace - var stack = e.strace; - assertEquals("checkStackTrace", stack[0].getFunctionName()); - for (var i = 0; i < expected.length; i++) { - assertEquals(expected[i].name, stack[i + 1].getFunctionName()); - } -} - - -var CAN_INLINE_COMMENT = "// Let it be inlined."; -var DONT_INLINE_COMMENT = (function() { - var line = "1"; - for (var i = 0; i < 200; ++i) { - line += "," + i; - } - line += ";\n"; - return line; -})(); - - -function ident_source(source, ident) { - ident = " ".repeat(ident); - return ident + source.replace(/\n/gi, "\n" + ident); -} - -var SHARDS_COUNT = 10; - -function run_tests(shard) { - function inlinable_comment(inlinable) { - return inlinable ? CAN_INLINE_COMMENT : DONT_INLINE_COMMENT; - } - - // Check arguments manually to avoid bailing out with reason "bad value - // context for arguments value". - function check_arguments_template(expected_name) { - var lines = [ - ` assertEquals_(${expected_name}.length, arguments.length);`, - ` for (var i = 0; i < ${expected_name}.length; i++) {`, - ` assertEquals_(${expected_name}[i], arguments[i]);`, - ` }`, - ]; - return lines.join("\n"); - } - var check_arguments = check_arguments_template("expected_args"); - - function deopt_template(deopt_mode) { - switch(deopt_mode) { - case "none": - return " // Don't deoptimize"; - case "f": - case "g": - case "test": - return ` %DeoptimizeFunction(${deopt_mode});`; - default: - assertUnreachable(); - } - } - - var f_cfg_sloppy = { - func_name: 'f', - source_template: function(cfg) { - var receiver = cfg.f_receiver != undefined ? cfg.f_receiver - : "global"; - var do_checks = [ - ` assertEquals_(${receiver}, this);`, - ` ${!cfg.check_new_target ? "// " : ""}assertEquals_(undefined, new.target);`, - check_arguments, - ` checkStackTrace_([f, test]);`, - ].join("\n"); - - var lines = [ - `function f(a) {`, - ` ${inlinable_comment(cfg.f_inlinable)}`, - ` counter++;`, - ` var expected_args = [${cfg.f_args}];`, - do_checks, - deopt_template(cfg.deopt_mode), - do_checks, - ` return 42;`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - var f_cfg_strict = { - func_name: 'f', - source_template: function(cfg) { - var receiver = cfg.f_receiver != undefined ? cfg.f_receiver - : "undefined"; - var do_checks = [ - ` assertEquals_(${receiver}, this);`, - ` ${!cfg.check_new_target ? "// " : ""}assertEquals_(undefined, new.target);`, - check_arguments, - ` checkStackTrace_([f, test]);`, - ].join("\n"); - - var lines = [ - `function f(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.f_inlinable)}`, - ` counter++;`, - ` var expected_args = [${cfg.f_args}];`, - do_checks, - deopt_template(cfg.deopt_mode), - do_checks, - ` return 42;`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - var f_cfg_possibly_eval = { - func_name: 'eval', - source_template: function(cfg) { - var receiver = cfg.f_receiver != undefined ? cfg.f_receiver - : "global"; - var do_checks = [ - ` assertEquals_(${receiver}, this);`, - ` ${!cfg.check_new_target ? "// " : ""}assertEquals_(undefined, new.target);`, - check_arguments, - ` checkStackTrace_([f, test]);`, - ].join("\n"); - - var lines = [ - `function f(a) {`, - ` ${inlinable_comment(cfg.f_inlinable)}`, - ` counter++;`, - ` var expected_args = [${cfg.f_args}];`, - do_checks, - deopt_template(cfg.deopt_mode), - do_checks, - ` return 42;`, - `}`, - `var eval = f;`, - ]; - return lines.join("\n"); - }, - }; - - var f_cfg_bound = { - func_name: 'bound', - source_template: function(cfg) { - var do_checks = [ - ` assertEquals_(receiver, this);`, - ` ${!cfg.check_new_target ? "// " : ""}assertEquals_(undefined, new.target);`, - check_arguments, - ` checkStackTrace_([f, test]);`, - ].join("\n"); - - var lines = [ - `function f(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.f_inlinable)}`, - ` counter++;`, - ` var expected_args = [${cfg.f_args}];`, - do_checks, - deopt_template(cfg.deopt_mode), - do_checks, - ` return 42;`, - `}`, - `var receiver = {a: 153};`, - `var bound = f.bind(receiver);`, - ]; - return lines.join("\n"); - }, - }; - - var f_cfg_proxy = { - func_name: 'p', - source_template: function(cfg) { - var receiver = cfg.f_receiver != undefined ? cfg.f_receiver - : "global"; - var do_checks = [ - ` assertEquals_(${receiver}, this);`, - ` ${!cfg.check_new_target ? "// " : ""}assertEquals_(undefined, new.target);`, - check_arguments, - ` checkStackTrace_([f, test]);`, - ].join("\n"); - - var lines = [ - `function f(a) {`, - ` ${inlinable_comment(cfg.f_inlinable)}`, - ` counter++;`, - ` var expected_args = [${cfg.f_args}];`, - do_checks, - deopt_template(cfg.deopt_mode), - do_checks, - ` return 42;`, - `}`, - `var p = new Proxy(f, {});`, - ]; - return lines.join("\n"); - }, - }; - - var g_cfg_normal = { - receiver: undefined, - source_template: function(cfg) { - var lines = [ - `function g(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.g_inlinable)}`, - ` var expected_args = [${cfg.g_args}];`, - check_arguments, - ` return ${cfg.f_name}(${cfg.f_args});`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - - var g_cfg_reflect_apply = { - receiver: "the_receiver", - source_template: function(cfg) { - var lines = [ - `function g(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.g_inlinable)}`, - ` var expected_args = [${cfg.g_args}];`, - check_arguments, - ` return Reflect.apply(${cfg.f_name}, the_receiver, [${cfg.f_args}]);`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - - var g_cfg_function_apply = { - receiver: "the_receiver", - source_template: function(cfg) { - var lines = [ - `function g(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.g_inlinable)}`, - ` var expected_args = [${cfg.g_args}];`, - check_arguments, - ` return ${cfg.f_name}.apply(the_receiver, [${cfg.f_args}]);`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - - var g_cfg_function_apply_arguments_object = { - receiver: "the_receiver", - source_template: function(cfg) { - cfg.f_args = cfg.g_args; - var lines = [ - `function g(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.g_inlinable)}`, - ` var expected_args = [${cfg.g_args}];`, - check_arguments, - ` return ${cfg.f_name}.apply(the_receiver, arguments);`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - - var g_cfg_function_call = { - receiver: "the_receiver", - source_template: function(cfg) { - var f_args = "the_receiver"; - if (cfg.f_args !== "") f_args += ", "; - f_args += cfg.f_args; - - var lines = [ - `function g(a) {`, - ` "use strict";`, - ` ${inlinable_comment(cfg.g_inlinable)}`, - ` var expected_args = [${cfg.g_args}];`, - check_arguments, - ` return ${cfg.f_name}.call(${f_args});`, - `}`, - ]; - return lines.join("\n"); - }, - }; - - - function test_template(cfg) { - // Note: g_source_template modifies cfg.f_args in some cases. - var g_source = cfg.g_source_template(cfg); - g_source = ident_source(g_source, 2); - - var f_source = cfg.f_source_template(cfg); - f_source = ident_source(f_source, 2); - - var lines = [ - `(function() {`, - ` // Avoid bailing out because of "Reference to a variable which requires dynamic lookup".`, - ` var assertEquals_ = assertEquals;`, - ` var checkStackTrace_ = checkStackTrace;`, - ` var undefined = void 0;`, - ` var global = Function('return this')();`, - ` var the_receiver = {receiver: 1};`, - ` var counter = 0;`, - ``, - ` // Don't inline helper functions`, - ` %NeverOptimizeFunction(assertEquals);`, - ` %NeverOptimizeFunction(checkStackTrace);`, - ``, - f_source, - g_source, - ` function test() {`, - ` "use strict";`, - ` assertEquals_(42, g(${cfg.g_args}));`, - ` }`, - ` ${"test();".repeat(cfg.test_warmup_count)}`, - ` ${cfg.f_inlinable ? "%SetForceInlineFlag(f)" : "%OptimizeFunctionOnNextCall(f)"};`, - ` ${cfg.g_inlinable ? "%SetForceInlineFlag(g)" : "%OptimizeFunctionOnNextCall(g)"};`, - ` %OptimizeFunctionOnNextCall(test);`, - ` test();`, - ` assertEquals(${1 + cfg.test_warmup_count}, counter);`, - `})();`, - ``, - ]; - var source = lines.join("\n"); - return source; - } - - var f_args_variants = [/*"", "1",*/ "1, 2"]; - var g_args_variants = [/*"", "10",*/ "10, 20"]; - var f_inlinable_variants = [true, false]; - var g_inlinable_variants = [true, false]; - // This is to avoid bailing out because of referencing new.target. - var check_new_target_variants = [/*true,*/ false]; - var deopt_mode_variants = ["none", "f", "g", "test"]; - var f_variants = [ - f_cfg_sloppy, - f_cfg_strict, - f_cfg_bound, - f_cfg_proxy, -// f_cfg_possibly_eval, - ]; - var g_variants = [ - g_cfg_normal, -// g_cfg_reflect_apply, - g_cfg_function_apply, -// g_cfg_function_apply_arguments_object, - g_cfg_function_call, - ]; - var test_warmup_counts = [0, 1, 2]; - - var iter = 0; - var tests_executed = 0; - if (verbose && shard !== undefined) { - print("Running shard #" + shard); - } - f_variants.forEach((f_cfg) => { - check_new_target_variants.forEach((check_new_target) => { - deopt_mode_variants.forEach((deopt_mode) => { - g_variants.forEach((g_cfg) => { - f_args_variants.forEach((f_args) => { - g_args_variants.forEach((g_args) => { - f_inlinable_variants.forEach((f_inlinable) => { - g_inlinable_variants.forEach((g_inlinable) => { - test_warmup_counts.forEach((test_warmup_count) => { - if (shard !== undefined && (iter++) % SHARDS_COUNT != shard) { - if (verbose) { - print("skipping..."); - } - return; - } - tests_executed++; - var cfg = { - f_source_template: f_cfg.source_template, - f_inlinable, - f_args, - f_name: f_cfg.func_name, - f_receiver: g_cfg.receiver, - g_source_template: g_cfg.source_template, - g_inlinable, - g_args, - test_warmup_count, - check_new_target, - deopt_mode, - }; - var source = test_template(cfg); - if (verbose) { - // print("===================="); - // print(source); - } - eval(source); - }); - }); - }); - }); - }); - }); - }); - }); - }); - if (verbose) { - print("Number of tests executed: " + tests_executed); - } -} - -// Uncomment to run all the tests at once or use shard runners. -//run_tests(); diff --git a/deps/v8/test/mjsunit/es6/tail-call-proxies.js b/deps/v8/test/mjsunit/es6/tail-call-proxies.js deleted file mode 100644 index 251ac0c20f..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-proxies.js +++ /dev/null @@ -1,97 +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 --harmony-tailcalls -"use strict"; - -Error.prepareStackTrace = (e,s) => s; - -function CheckStackTrace(expected) { - var stack = (new Error()).stack; - assertEquals("CheckStackTrace", stack[0].getFunctionName()); - for (var i = 0; i < expected.length; i++) { - assertEquals(expected[i].name, stack[i + 1].getFunctionName()); - } -} - - -// Tail call proxy function when caller does not have an arguments -// adaptor frame. -(function test() { - // Caller and callee have same number of arguments. - function f1(a) { - CheckStackTrace([f1, test]); - return 10 + a; - } - var p1 = new Proxy(f1, {}); - function g1(a) { return p1(2); } - assertEquals(12, g1(1)); - - // Caller has more arguments than callee. - function f2(a) { - CheckStackTrace([f2, test]); - return 10 + a; - } - var p2 = new Proxy(f2, {}); - function g2(a, b, c) { return p2(2); } - assertEquals(12, g2(1, 2, 3)); - - // Caller has less arguments than callee. - function f3(a, b, c) { - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - var p3 = new Proxy(f3, {}); - function g3(a) { return p3(2, 3, 4); } - assertEquals(19, g3(1)); - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - CheckStackTrace([f4, test]); - return 10 + a; - } - var p4 = new Proxy(f4, {}); - function g4(a) { return p4(2); } - assertEquals(12, g4(1)); -})(); - - -// Tail call proxy function when caller has an arguments adaptor frame. -(function test() { - // Caller and callee have same number of arguments. - function f1(a) { - CheckStackTrace([f1, test]); - return 10 + a; - } - var p1 = new Proxy(f1, {}); - function g1(a) { return p1(2); } - assertEquals(12, g1()); - - // Caller has more arguments than callee. - function f2(a) { - CheckStackTrace([f2, test]); - return 10 + a; - } - var p2 = new Proxy(f2, {}); - function g2(a, b, c) { return p2(2); } - assertEquals(12, g2()); - - // Caller has less arguments than callee. - function f3(a, b, c) { - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - var p3 = new Proxy(f3, {}); - function g3(a) { return p3(2, 3, 4); } - assertEquals(19, g3()); - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - CheckStackTrace([f4, test]); - return 10 + a; - } - var p4 = new Proxy(f4, {}); - function g4(a) { return p4(2); } - assertEquals(12, g4()); -})(); diff --git a/deps/v8/test/mjsunit/es6/tail-call-simple.js b/deps/v8/test/mjsunit/es6/tail-call-simple.js deleted file mode 100644 index cc638082be..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call-simple.js +++ /dev/null @@ -1,143 +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 --harmony-tailcalls --stack-size=100 - -// -// Tail calls work only in strict mode. -// -(function() { - function f(n) { - if (n <= 0) { - return "foo"; - } - return f(n - 1); - } - assertThrows(()=>{ f(1e5) }); - %OptimizeFunctionOnNextCall(f); - assertThrows(()=>{ f(1e5) }); -})(); - - -// -// Tail call normal functions. -// -(function() { - "use strict"; - function f(n) { - if (n <= 0) { - return "foo"; - } - return f(n - 1); - } - assertEquals("foo", f(1e5)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); -})(); - - -(function() { - "use strict"; - function f(n) { - if (n <= 0) { - return "foo"; - } - return f(n - 1, 42); // Call with arguments adaptor. - } - assertEquals("foo", f(1e5)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); -})(); - - -(function() { - "use strict"; - function f(n){ - if (n <= 0) { - return "foo"; - } - return g(n - 1); - } - function g(n){ - if (n <= 0) { - return "bar"; - } - return f(n - 1); - } - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); -})(); - - -(function() { - "use strict"; - function f(n){ - if (n <= 0) { - return "foo"; - } - return g(n - 1, 42); // Call with arguments adaptor. - } - function g(n){ - if (n <= 0) { - return "bar"; - } - return f(n - 1, 42); // Call with arguments adaptor. - } - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); -})(); - - -// -// Tail call bound functions. -// -(function() { - "use strict"; - function f0(n) { - if (n <= 0) { - return "foo"; - } - return f_bound(n - 1); - } - var f_bound = f0.bind({}); - function f(n) { - return f_bound(n); - } - assertEquals("foo", f(1e5)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); -})(); - - -(function() { - "use strict"; - function f0(n){ - if (n <= 0) { - return "foo"; - } - return g_bound(n - 1); - } - function g0(n){ - if (n <= 0) { - return "bar"; - } - return f_bound(n - 1); - } - var f_bound = f0.bind({}); - var g_bound = g0.bind({}); - function f(n) { - return f_bound(n); - } - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); - %OptimizeFunctionOnNextCall(f); - assertEquals("foo", f(1e5)); - assertEquals("bar", f(1e5 + 1)); -})(); diff --git a/deps/v8/test/mjsunit/es6/tail-call.js b/deps/v8/test/mjsunit/es6/tail-call.js deleted file mode 100644 index 4df4836021..0000000000 --- a/deps/v8/test/mjsunit/es6/tail-call.js +++ /dev/null @@ -1,663 +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 --harmony-tailcalls -// Flags: --harmony-do-expressions - -"use strict"; - -Error.prepareStackTrace = (error,stack) => { - error.strace = stack; - return error.message + "\n at " + stack.join("\n at "); -} - - -function CheckStackTrace(expected) { - var e = new Error(); - e.stack; // prepare stack trace - var stack = e.strace; - assertEquals("CheckStackTrace", stack[0].getFunctionName()); - for (var i = 0; i < expected.length; i++) { - assertEquals(expected[i].name, stack[i + 1].getFunctionName()); - } -} -%NeverOptimizeFunction(CheckStackTrace); - - -function f(expected_call_stack, a, b) { - CheckStackTrace(expected_call_stack); - return a; -} - -function f_153(expected_call_stack, a) { - CheckStackTrace(expected_call_stack); - return 153; -} - - -// Tail call when caller does not have an arguments adaptor frame. -(function() { - // Caller and callee have same number of arguments. - function f1(a) { - CheckStackTrace([f1, test]); - return 10 + a; - } - function g1(a) { return f1(2); } - - // Caller has more arguments than callee. - function f2(a) { - CheckStackTrace([f2, test]); - return 10 + a; - } - function g2(a, b, c) { return f2(2); } - - // Caller has less arguments than callee. - function f3(a, b, c) { - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - function g3(a) { return f3(2, 3, 4); } - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - CheckStackTrace([f4, test]); - return 10 + a; - } - function g4(a) { return f4(2); } - - function test() { - assertEquals(12, g1(1)); - assertEquals(12, g2(1, 2, 3)); - assertEquals(19, g3(1)); - assertEquals(12, g4(1)); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail call when caller has an arguments adaptor frame. -(function() { - // Caller and callee have same number of arguments. - function f1(a) { - CheckStackTrace([f1, test]); - return 10 + a; - } - function g1(a) { return f1(2); } - - // Caller has more arguments than callee. - function f2(a) { - CheckStackTrace([f2, test]); - return 10 + a; - } - function g2(a, b, c) { return f2(2); } - - // Caller has less arguments than callee. - function f3(a, b, c) { - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - function g3(a) { return f3(2, 3, 4); } - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - CheckStackTrace([f4, test]); - return 10 + a; - } - function g4(a) { return f4(2); } - - function test() { - assertEquals(12, g1()); - assertEquals(12, g2()); - assertEquals(19, g3()); - assertEquals(12, g4()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail call bound function when caller does not have an arguments -// adaptor frame. -(function() { - // Caller and callee have same number of arguments. - function f1(a) { - assertEquals(153, this.a); - CheckStackTrace([f1, test]); - return 10 + a; - } - var b1 = f1.bind({a: 153}); - function g1(a) { return b1(2); } - - // Caller has more arguments than callee. - function f2(a) { - assertEquals(153, this.a); - CheckStackTrace([f2, test]); - return 10 + a; - } - var b2 = f2.bind({a: 153}); - function g2(a, b, c) { return b2(2); } - - // Caller has less arguments than callee. - function f3(a, b, c) { - assertEquals(153, this.a); - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - var b3 = f3.bind({a: 153}); - function g3(a) { return b3(2, 3, 4); } - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - assertEquals(153, this.a); - CheckStackTrace([f4, test]); - return 10 + a; - } - var b4 = f4.bind({a: 153}); - function g4(a) { return b4(2); } - - function test() { - assertEquals(12, g1(1)); - assertEquals(12, g2(1, 2, 3)); - assertEquals(19, g3(1)); - assertEquals(12, g4(1)); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail call bound function when caller has an arguments adaptor frame. -(function() { - // Caller and callee have same number of arguments. - function f1(a) { - assertEquals(153, this.a); - CheckStackTrace([f1, test]); - return 10 + a; - } - var b1 = f1.bind({a: 153}); - function g1(a) { return b1(2); } - - // Caller has more arguments than callee. - function f2(a) { - assertEquals(153, this.a); - CheckStackTrace([f2, test]); - return 10 + a; - } - var b2 = f2.bind({a: 153}); - function g2(a, b, c) { return b2(2); } - - // Caller has less arguments than callee. - function f3(a, b, c) { - assertEquals(153, this.a); - CheckStackTrace([f3, test]); - return 10 + a + b + c; - } - var b3 = f3.bind({a: 153}); - function g3(a) { return b3(2, 3, 4); } - - // Callee has arguments adaptor frame. - function f4(a, b, c) { - assertEquals(153, this.a); - CheckStackTrace([f4, test]); - return 10 + a; - } - var b4 = f4.bind({a: 153}); - function g4(a) { return b4(2); } - - function test() { - assertEquals(12, g1()); - assertEquals(12, g2()); - assertEquals(19, g3()); - assertEquals(12, g4()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail calling from getter. -(function() { - function g(v) { - CheckStackTrace([g, test]); - %DeoptimizeFunction(test); - return 153; - } - %NeverOptimizeFunction(g); - - function f(v) { - return g(); - } - %SetForceInlineFlag(f); - - function test() { - var o = {}; - o.__defineGetter__('p', f); - assertEquals(153, o.p); - } - - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail calling from setter. -(function() { - function g() { - CheckStackTrace([g, test]); - %DeoptimizeFunction(test); - return 153; - } - %NeverOptimizeFunction(g); - - function f(v) { - return g(); - } - %SetForceInlineFlag(f); - - function test() { - var o = {}; - o.__defineSetter__('q', f); - assertEquals(1, o.q = 1); - } - - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail calling from constructor. -(function() { - function g(context) { - CheckStackTrace([g, test]); - %DeoptimizeFunction(test); - return {x: 153}; - } - %NeverOptimizeFunction(g); - - function A() { - this.x = 42; - return g(); - } - - function test() { - var o = new A(); - //%DebugPrint(o); - assertEquals(153, o.x); - } - - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail calling via various expressions. -(function() { - function g1(a) { - return f([f, g1, test], false) || f([f, test], true); - } - - function g2(a) { - return f([f, g2, test], true) && f([f, test], true); - } - - function g3(a) { - return f([f, g3, test], 13), f([f, test], 153); - } - - function g4(a) { - return f([f, g4, test], false) || - (f([f, g4, test], true) && f([f, test], true)); - } - - function g5(a) { - return f([f, g5, test], true) && - (f([f, g5, test], false) || f([f, test], true)); - } - - function g6(a) { - return f([f, g6, test], 13), f([f, g6, test], 42), - f([f, test], 153); - } - - function g7(a) { - return f([f, g7, test], false) || - (f([f, g7, test], false) ? f([f, test], true) - : f([f, test], true)); - } - - function g8(a) { - return f([f, g8, test], false) || f([f, g8, test], true) && - f([f, test], true); - } - - function g9(a) { - return f([f, g9, test], true) && f([f, g9, test], false) || - f([f, test], true); - } - - function g10(a) { - return f([f, g10, test], true) && f([f, g10, test], false) || - f([f, g10, test], true) ? - f([f, g10, test], true) && f([f, g10, test], false) || - f([f, test], true) : - f([f, g10, test], true) && f([f, g10, test], false) || - f([f, test], true); - } - - function test() { - assertEquals(true, g1()); - assertEquals(true, g2()); - assertEquals(153, g3()); - assertEquals(true, g4()); - assertEquals(true, g5()); - assertEquals(153, g6()); - assertEquals(true, g7()); - assertEquals(true, g8()); - assertEquals(true, g9()); - assertEquals(true, g10()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Tail calling from various statements. -(function() { - function g1() { - for (var v in {a:0}) { - return f_153([f_153, g1, test]); - } - } - - function g1let() { - for (let v in {a:0}) { - return f_153([f_153, g1let, test]); - } - } - - function g1nodecl() { - var v; - for (v in {a:0}) { - return f_153([f_153, g1nodecl, test]); - } - } - - function g2() { - for (var v of [1, 2, 3]) { - return f_153([f_153, g2, test]); - } - } - - function g2let() { - for (let v of [1, 2, 3]) { - return f_153([f_153, g2let, test]); - } - } - - function g2nodecl() { - var v; - for (v of [1, 2, 3]) { - return f_153([f_153, g2nodecl, test]); - } - } - - function g3() { - for (var i = 0; i < 10; i++) { - return f_153([f_153, test]); - } - } - - function g3let() { - for (let i = 0; i < 10; i++) { - return f_153([f_153, test]); - } - } - - function g3nodecl() { - var i; - for (i = 0; i < 10; i++) { - return f_153([f_153, test]); - } - } - - function g4() { - while (true) { - return f_153([f_153, test]); - } - } - - function g5() { - do { - return f_153([f_153, test]); - } while (true); - } - - function test() { - assertEquals(153, g1()); - assertEquals(153, g1let()); - assertEquals(153, g1nodecl()); - assertEquals(153, g2()); - assertEquals(153, g2let()); - assertEquals(153, g2nodecl()); - assertEquals(153, g3()); - assertEquals(153, g3let()); - assertEquals(153, g3nodecl()); - assertEquals(153, g4()); - assertEquals(153, g5()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Test tail calls from try-catch constructs. -(function() { - function tc1(a) { - try { - f_153([f_153, tc1, test]); - return f_153([f_153, tc1, test]); - } catch(e) { - f_153([f_153, tc1, test]); - } - } - - function tc2(a) { - try { - f_153([f_153, tc2, test]); - throw new Error("boom"); - } catch(e) { - f_153([f_153, tc2, test]); - return f_153([f_153, test]); - } - } - - function tc3(a) { - try { - f_153([f_153, tc3, test]); - throw new Error("boom"); - } catch(e) { - f_153([f_153, tc3, test]); - } - f_153([f_153, tc3, test]); - return f_153([f_153, test]); - } - - function test() { - assertEquals(153, tc1()); - assertEquals(153, tc2()); - assertEquals(153, tc3()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Test tail calls from try-finally constructs. -(function() { - function tf1(a) { - try { - f_153([f_153, tf1, test]); - return f_153([f_153, tf1, test]); - } finally { - f_153([f_153, tf1, test]); - } - } - - function tf2(a) { - try { - f_153([f_153, tf2, test]); - throw new Error("boom"); - } finally { - f_153([f_153, tf2, test]); - return f_153([f_153, test]); - } - } - - function tf3(a) { - try { - f_153([f_153, tf3, test]); - } finally { - f_153([f_153, tf3, test]); - } - return f_153([f_153, test]); - } - - function test() { - assertEquals(153, tf1()); - assertEquals(153, tf2()); - assertEquals(153, tf3()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Test tail calls from try-catch-finally constructs. -(function() { - function tcf1(a) { - try { - f_153([f_153, tcf1, test]); - return f_153([f_153, tcf1, test]); - } catch(e) { - } finally { - f_153([f_153, tcf1, test]); - } - } - - function tcf2(a) { - try { - f_153([f_153, tcf2, test]); - throw new Error("boom"); - } catch(e) { - f_153([f_153, tcf2, test]); - return f_153([f_153, tcf2, test]); - } finally { - f_153([f_153, tcf2, test]); - } - } - - function tcf3(a) { - try { - f_153([f_153, tcf3, test]); - throw new Error("boom"); - } catch(e) { - f_153([f_153, tcf3, test]); - } finally { - f_153([f_153, tcf3, test]); - return f_153([f_153, test]); - } - } - - function tcf4(a) { - try { - f_153([f_153, tcf4, test]); - throw new Error("boom"); - } catch(e) { - f_153([f_153, tcf4, test]); - } finally { - f_153([f_153, tcf4, test]); - } - return f_153([f_153, test]); - } - - function test() { - assertEquals(153, tcf1()); - assertEquals(153, tcf2()); - assertEquals(153, tcf3()); - assertEquals(153, tcf4()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Test tail calls from arrow functions. -(function () { - function g1(a) { - return (() => { return f_153([f_153, test]); })(); - } - - function g2(a) { - return (() => f_153([f_153, test]))(); - } - - function g3(a) { - var closure = () => f([f, closure, test], true) - ? f_153([f_153, test]) - : f_153([f_153, test]); - return closure(); - } - - function test() { - assertEquals(153, g1()); - assertEquals(153, g2()); - assertEquals(153, g3()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); - - -// Test tail calls from do expressions. -(function () { - function g1(a) { - var a = do { return f_153([f_153, test]); 42; }; - return a; - } - - function test() { - assertEquals(153, g1()); - } - test(); - test(); - %OptimizeFunctionOnNextCall(test); - test(); -})(); diff --git a/deps/v8/test/mjsunit/es6/templates.js b/deps/v8/test/mjsunit/es6/templates.js index 3c4584d337..efe314ed95 100644 --- a/deps/v8/test/mjsunit/es6/templates.js +++ b/deps/v8/test/mjsunit/es6/templates.js @@ -476,7 +476,7 @@ var obj = { (function testLegacyOctal() { assertEquals('\u0000', `\0`); assertEquals('\u0000a', `\0a`); - for (var i = 0; i < 8; i++) { + for (var i = 0; i < 10; i++) { var code = "`\\0" + i + "`"; assertThrows(code, SyntaxError); code = "(function(){})" + code; @@ -502,8 +502,6 @@ var obj = { (function testValidNumericEscapes() { assertEquals("8", `\8`); assertEquals("9", `\9`); - assertEquals("\u00008", `\08`); - assertEquals("\u00009", `\09`); })(); 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 7d17812a8d..66316f300e 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 @@ -196,6 +196,12 @@ tests.push(function TestOffsetIsUsed(constr) { TestOffsetIsUsedRunner(constr, 128); }); +tests.push(function TestLengthIsNonSmiNegativeNumber(constr) { + var ta = new constr({length: -%_MaxSmi() - 2}); + + assertEquals(0, ta.length); +}); + // Helpers for above tests. function TestOffsetIsUsedRunner(constr, n) { diff --git a/deps/v8/test/mjsunit/es7/array-includes-receiver.js b/deps/v8/test/mjsunit/es7/array-includes-receiver.js index 85915d4958..edeae88631 100644 --- a/deps/v8/test/mjsunit/es7/array-includes-receiver.js +++ b/deps/v8/test/mjsunit/es7/array-includes-receiver.js @@ -12,15 +12,15 @@ var kIterCount = 1; var kTests = { Array: { - FAST_ELEMENTS() { + PACKED_ELEMENTS() { var r = /foo/; var s = new String("bar"); var p = new Proxy({}, {}); var o = {}; var array = [r, s, p]; - assertTrue(%HasFastObjectElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasObjectElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(p)); @@ -28,14 +28,14 @@ var kTests = { } }, - FAST_HOLEY_ELEMENTS() { + HOLEY_ELEMENTS() { var r = /foo/; var p = new Proxy({}, {}); var o = {}; var array = [r, , p]; - assertTrue(%HasFastObjectElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasObjectElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(p)); @@ -43,10 +43,10 @@ var kTests = { } }, - FAST_SMI_ELEMENTS() { + PACKED_SMI_ELEMENTS() { var array = [0, 88, 9999, 1, -5, 7]; - assertTrue(%HasFastSmiElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasSmiElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(9999)); @@ -57,10 +57,10 @@ var kTests = { } }, - FAST_HOLEY_SMI_ELEMENTS() { + HOLEY_SMI_ELEMENTS() { var array = [49, , , 72, , , 67, -48]; - assertTrue(%HasFastSmiElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasSmiElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(72)); @@ -72,11 +72,11 @@ var kTests = { } }, - FAST_DOUBLE_ELEMENTS() { + PACKED_DOUBLE_ELEMENTS() { var array = [7.00000001, -13000.89412, 73451.4124, 5824.48, 6.0000495, 48.3488, 44.0, 76.35, NaN, 78.4]; - assertTrue(%HasFastDoubleElements(array)); - assertFalse(%HasFastHoleyElements(array)); + assertTrue(%HasDoubleElements(array)); + assertFalse(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(7.00000001)); @@ -89,11 +89,11 @@ var kTests = { } }, - FAST_HOLEY_DOUBLE_ELEMENTS() { + HOLEY_DOUBLE_ELEMENTS() { var array = [7.00000001, -13000.89412, , 5824.48, , 48.3488, , NaN, , 78.4]; - assertTrue(%HasFastDoubleElements(array)); - assertTrue(%HasFastHoleyElements(array)); + assertTrue(%HasDoubleElements(array)); + assertTrue(%HasHoleyElements(array)); for (var i = 0; i < kIterCount; ++i) { assertTrue(array.includes(7.00000001)); @@ -125,16 +125,16 @@ var kTests = { }, Object: { - FAST_ELEMENTS() { + PACKED_ELEMENTS() { var r = /foo/; var s = new String("bar"); var p = new Proxy({}, {}); var o = {}; var object = { 0: r, 1: s, 2: p, length: 3 }; - assertTrue(%HasFastObjectElements(object)); - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertFalse(%HasFastHoleyElements(object)); + assertTrue(%HasObjectElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, p)); @@ -142,14 +142,14 @@ var kTests = { } }, - FAST_HOLEY_ELEMENTS() { + HOLEY_ELEMENTS() { var r = /foo/; var p = new Proxy({}, {}); var o = {}; var object = { 0: r, 2: p, length: 3 }; - assertTrue(%HasFastObjectElements(object)); - assertTrue(%HasFastHoleyElements(object)); + assertTrue(%HasObjectElements(object)); + assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, p)); @@ -157,11 +157,11 @@ var kTests = { } }, - FAST_SMI_ELEMENTS() { + PACKED_SMI_ELEMENTS() { var object = { 0: 0, 1: 88, 2: 9999, 3: 1, 4: -5, 5: 7, length: 6 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastSmiElements(object)); - // assertFalse(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasSmiElements(object)); + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, 9999)); @@ -172,11 +172,11 @@ var kTests = { } }, - FAST_HOLEY_SMI_ELEMENTS() { + HOLEY_SMI_ELEMENTS() { var object = { 0: 49, 3: 72, 6: 67, 7: -48, length: 8 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastSmiElements(object)); - // assertTrue(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasSmiElements(object)); + // assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, 72)); @@ -188,13 +188,13 @@ var kTests = { } }, - FAST_DOUBLE_ELEMENTS() { + PACKED_DOUBLE_ELEMENTS() { var object = { 0: 7.00000001, 1: -13000.89412, 2: 73451.4124, 3: 5824.48, 4: 6.0000495, 5: 48.3488, 6: 44.0, 7: 76.35, 8: NaN, 9: 78.4, length: 10 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastDoubleElements(object)); - // assertFalse(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasDoubleElements(object)); + // assertFalse(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, 7.00000001)); @@ -207,12 +207,12 @@ var kTests = { } }, - FAST_HOLEY_DOUBLE_ELEMENTS() { + HOLEY_DOUBLE_ELEMENTS() { var object = { 0: 7.00000001, 1: -13000.89412, 3: 5824.48, 5: 48.3488, 7: NaN, 9: 78.4, length: 10 }; - // TODO(caitp): JSObjects always seem to start with FAST_HOLEY_ELEMENTS - // assertTrue(%HasFastDoubleElements(object)); - // assertTrue(%HasFastHoleyElements(object)); + // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS + // assertTrue(%HasDoubleElements(object)); + // assertTrue(%HasHoleyElements(object)); for (var i = 0; i < kIterCount; ++i) { assertTrue(Array.prototype.includes.call(object, 7.00000001)); diff --git a/deps/v8/test/mjsunit/es8/async-await-species.js b/deps/v8/test/mjsunit/es8/async-await-species.js index e789ccab92..b3e925433a 100644 --- a/deps/v8/test/mjsunit/es8/async-await-species.js +++ b/deps/v8/test/mjsunit/es8/async-await-species.js @@ -46,7 +46,8 @@ function getStack(error) { filter(function(line) { return /^\s*at @?[a-zA-Z0-9_]/.test(line); }). - map(line => line.replace(/^\s*at (@?[a-zA-Z0-9_\.\[\]]+)(.*)/, "$1")); + map(line => + line.replace(/^\s*at (@?(?:new )?[a-zA-Z0-9_\.\[\]]+)(.*)/, "$1")); // remove `Promise.then()` invocation by assertEqualsAsync() if (stack[2] === "assertEqualsAsync") return []; @@ -96,6 +97,6 @@ assertEqualsAsync( }), "should call Promise[@@Species] after non-internal Then"); assertEquals([ - "@@Species: [@testThenOnReturnedPromise > Promise.then > FakePromise]", + "@@Species: [@testThenOnReturnedPromise > Promise.then > new FakePromise]", "Then: foo" ], log); diff --git a/deps/v8/test/mjsunit/es8/object-entries.js b/deps/v8/test/mjsunit/es8/object-entries.js index 71f121b896..c59d81c823 100644 --- a/deps/v8/test/mjsunit/es8/object-entries.js +++ b/deps/v8/test/mjsunit/es8/object-entries.js @@ -276,12 +276,12 @@ TestMutateDuringEnumeration(); } var element_kinds = { - FAST_SMI_ELEMENTS: [ [1, 2, 3], [ ["0", 1], ["1", 2], ["2", 3] ] ], - FAST_HOLEY_SMI_ELEMENTS: [ [, , 3], [ ["2", 3] ] ], - FAST_ELEMENTS: [ [O1, O2, O3], [ ["0", O1], ["1", O2], ["2", O3] ] ], - FAST_HOLEY_ELEMENTS: [ [, , O3], [ ["2", O3] ] ], - FAST_DOUBLE_ELEMENTS: [ [E, NaN, PI], [ ["0", E], ["1", NaN], ["2", PI] ] ], - FAST_HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [ ["2", NaN] ] ], + PACKED_SMI_ELEMENTS: [ [1, 2, 3], [ ["0", 1], ["1", 2], ["2", 3] ] ], + HOLEY_SMI_ELEMENTS: [ [, , 3], [ ["2", 3] ] ], + PACKED_ELEMENTS: [ [O1, O2, O3], [ ["0", O1], ["1", O2], ["2", O3] ] ], + HOLEY_ELEMENTS: [ [, , O3], [ ["2", O3] ] ], + PACKED_DOUBLE_ELEMENTS: [ [E, NaN, PI], [ ["0", E], ["1", NaN], ["2", PI] ] ], + HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [ ["2", NaN] ] ], DICTIONARY_ELEMENTS: [ Object.defineProperties({ 10000: "world" }, { 100: { enumerable: true, value: "hello" }, diff --git a/deps/v8/test/mjsunit/es8/object-values.js b/deps/v8/test/mjsunit/es8/object-values.js index ed200373a9..23fcaed1bc 100644 --- a/deps/v8/test/mjsunit/es8/object-values.js +++ b/deps/v8/test/mjsunit/es8/object-values.js @@ -256,12 +256,12 @@ TestMutateDuringEnumeration(); } var element_kinds = { - FAST_SMI_ELEMENTS: [ [1, 2, 3], [1, 2, 3] ], - FAST_HOLEY_SMI_ELEMENTS: [ [, , 3], [ 3 ] ], - FAST_ELEMENTS: [ [O1, O2, O3], [O1, O2, O3] ], - FAST_HOLEY_ELEMENTS: [ [, , O3], [O3] ], - FAST_DOUBLE_ELEMENTS: [ [E, NaN, PI], [E, NaN, PI] ], - FAST_HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [NaN] ], + PACKED_SMI_ELEMENTS: [ [1, 2, 3], [1, 2, 3] ], + HOLEY_SMI_ELEMENTS: [ [, , 3], [ 3 ] ], + PACKED_ELEMENTS: [ [O1, O2, O3], [O1, O2, O3] ], + HOLEY_ELEMENTS: [ [, , O3], [O3] ], + PACKED_DOUBLE_ELEMENTS: [ [E, NaN, PI], [E, NaN, PI] ], + HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [NaN] ], DICTIONARY_ELEMENTS: [ Object.defineProperties({ 10000: "world" }, { 100: { enumerable: true, value: "hello" }, diff --git a/deps/v8/test/mjsunit/fast-array-length.js b/deps/v8/test/mjsunit/fast-array-length.js index 3917d97f2c..2a759114c0 100644 --- a/deps/v8/test/mjsunit/fast-array-length.js +++ b/deps/v8/test/mjsunit/fast-array-length.js @@ -31,6 +31,6 @@ var a = [0, 1, 2, 3, 4, 5]; -assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasSmiElements(a)); a.length = (1 << 30); -assertFalse(%HasFastSmiElements(a)); +assertFalse(%HasSmiElements(a)); diff --git a/deps/v8/test/mjsunit/field-type-tracking.js b/deps/v8/test/mjsunit/field-type-tracking.js index 2e0cb8bd6f..4afc7456e2 100644 --- a/deps/v8/test/mjsunit/field-type-tracking.js +++ b/deps/v8/test/mjsunit/field-type-tracking.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --nostress-opt --track-field-types -// Flags: --opt --no-always-opt +// Flags: --opt --no-always-opt --no-stress-fullcodegen (function() { var o = { text: "Hello World!" }; diff --git a/deps/v8/test/mjsunit/function-caller.js b/deps/v8/test/mjsunit/function-caller.js index 7443cf71a9..86794e8105 100644 --- a/deps/v8/test/mjsunit/function-caller.js +++ b/deps/v8/test/mjsunit/function-caller.js @@ -46,11 +46,9 @@ f(null); // Check called from eval. eval('f(null)'); -// Check called from strict builtin functions. +// Check called from builtin functions. [null, null].sort(f); [null].forEach(f, null); - -// Check called from sloppy builtin functions. "abel".replace(/b/g, function h() { - assertEquals(String.prototype.replace, h.caller); + assertEquals(null, h.caller); }); diff --git a/deps/v8/test/mjsunit/fuzz-accessors.js b/deps/v8/test/mjsunit/fuzz-accessors.js index f3602cca09..8d5bec1b9d 100644 --- a/deps/v8/test/mjsunit/fuzz-accessors.js +++ b/deps/v8/test/mjsunit/fuzz-accessors.js @@ -26,7 +26,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. var builtInPropertyNames = [ - 'prototype', 'length', 'caller', 0, 1, '$1', 'arguments', 'name', 'message', 'constructor' + 'prototype', 'length', 0, 1, '$1', 'name', 'message', 'constructor' +]; + +var builtInPropertyNamesMayThrow = [ + 'caller', 'arguments' ]; function getAnException() { @@ -77,6 +81,13 @@ function runTest(fun) { var propertyName = builtInPropertyNames[k]; fun(obj, propertyName); } + for (var k in builtInPropertyNamesMayThrow) { + var propertyName = builtInPropertyNamesMayThrow[k]; + try { + fun(obj, propertyName); + } catch (e) { + } + } } } } diff --git a/deps/v8/test/mjsunit/generated-transition-stub.js b/deps/v8/test/mjsunit/generated-transition-stub.js index 9e3fa923b2..dadaa3c99e 100644 --- a/deps/v8/test/mjsunit/generated-transition-stub.js +++ b/deps/v8/test/mjsunit/generated-transition-stub.js @@ -44,22 +44,22 @@ function test() { transition1(a1, 0, 2.5); var a2 = [0, 1, 2, 3, 4]; transition1(a2, 0, 2.5); - assertFalse(%HasFastHoleyElements(a2)); + assertFalse(%HasHoleyElements(a2)); %OptimizeFunctionOnNextCall(transition1); var a3 = [0, 1, 2, 3, 4]; - assertTrue(%HasFastSmiElements(a3)); + assertTrue(%HasSmiElements(a3)); transition1(a3, 0, 2.5); - assertFalse(%HasFastHoleyElements(a3)); + assertFalse(%HasHoleyElements(a3)); assertEquals(4, a3[4]); assertEquals(2.5, a3[0]); // Test handling of hole. var a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; a4.length = 7; - assertTrue(%HasFastSmiElements(a4)); + assertTrue(%HasSmiElements(a4)); transition1(a4, 0, 2.5); - assertFalse(%HasFastHoleyElements(a4)); + assertFalse(%HasHoleyElements(a4)); assertEquals(2.5, a4[0]); assertEquals(undefined, a4[8]); @@ -69,7 +69,7 @@ function test() { for (i = 0; i < 0x40000; ++i) { a5[i] = 0; } - assertTrue(%HasFastSmiElements(a5) || %HasFastDoubleElements(a5)); + assertTrue(%HasSmiElements(a5) || %HasDoubleElements(a5)); transition1(a5, 0, 2.5); assertEquals(2.5, a5[0]); } @@ -86,14 +86,14 @@ function test() { transition2(b1, 0, 2.5); var b2 = [0, 1, 2, , 4]; transition2(b2, 0, 2.5); - assertTrue(%HasFastHoleyElements(b2)); + assertTrue(%HasHoleyElements(b2)); %OptimizeFunctionOnNextCall(transition2); var b3 = [0, 1, 2, , 4]; - assertTrue(%HasFastSmiElements(b3)); - assertTrue(%HasFastHoleyElements(b3)); + assertTrue(%HasSmiElements(b3)); + assertTrue(%HasHoleyElements(b3)); transition2(b3, 0, 2.5); - assertTrue(%HasFastHoleyElements(b3)); + assertTrue(%HasHoleyElements(b3)); assertEquals(4, b3[4]); assertEquals(2.5, b3[0]); @@ -103,7 +103,7 @@ function test() { for (i = 3; i < 0x40000; ++i) { b4[i] = 0; } - assertTrue(%HasFastSmiElements(b4)); + assertTrue(%HasSmiElements(b4)); transition2(b4, 0, 2.5); assertEquals(2.5, b4[0]); } @@ -120,16 +120,16 @@ function test() { transition3(c1, 0, new Object()); var c2 = [0, 1, 2, 3.5, 4]; transition3(c2, 0, new Object()); - assertTrue(%HasFastObjectElements(c2)); - assertTrue(!%HasFastHoleyElements(c2)); + assertTrue(%HasObjectElements(c2)); + assertTrue(!%HasHoleyElements(c2)); %OptimizeFunctionOnNextCall(transition3); var c3 = [0, 1, 2, 3.5, 4]; - assertTrue(%HasFastDoubleElements(c3)); - assertTrue(!%HasFastHoleyElements(c3)); + assertTrue(%HasDoubleElements(c3)); + assertTrue(!%HasHoleyElements(c3)); transition3(c3, 0, new Array()); - assertTrue(!%HasFastHoleyElements(c3)); - assertTrue(%HasFastObjectElements(c3)); + assertTrue(!%HasHoleyElements(c3)); + assertTrue(%HasObjectElements(c3)); assertEquals(4, c3[4]); assertEquals(0, c3[0].length); @@ -140,11 +140,11 @@ function test() { for (i = 3; i < 0xa000; ++i) { c4[i] = 0; } - assertTrue(%HasFastDoubleElements(c4)); - assertTrue(!%HasFastHoleyElements(c4)); + assertTrue(%HasDoubleElements(c4)); + assertTrue(!%HasHoleyElements(c4)); transition3(c4, 0, new Array(5)); - assertTrue(!%HasFastHoleyElements(c4)); - assertTrue(%HasFastObjectElements(c4)); + assertTrue(!%HasHoleyElements(c4)); + assertTrue(%HasObjectElements(c4)); assertEquals(5, c4[0].length); } @@ -154,11 +154,11 @@ function test() { for (i = 3; i < 0x40000; ++i) { c5[i] = 0; } - assertTrue(%HasFastDoubleElements(c5)); - assertTrue(!%HasFastHoleyElements(c5)); + assertTrue(%HasDoubleElements(c5)); + assertTrue(!%HasHoleyElements(c5)); transition3(c5, 0, new Array(5)); - assertTrue(!%HasFastHoleyElements(c5)); - assertTrue(%HasFastObjectElements(c5)); + assertTrue(!%HasHoleyElements(c5)); + assertTrue(%HasObjectElements(c5)); assertEquals(5, c5[0].length); } @@ -174,16 +174,16 @@ function test() { transition4(d1, 0, new Object()); var d2 = [0, 1, , 3.5, 4]; transition4(d2, 0, new Object()); - assertTrue(%HasFastObjectElements(d2)); - assertTrue(%HasFastHoleyElements(d2)); + assertTrue(%HasObjectElements(d2)); + assertTrue(%HasHoleyElements(d2)); %OptimizeFunctionOnNextCall(transition4); var d3 = [0, 1, , 3.5, 4]; - assertTrue(%HasFastDoubleElements(d3)); - assertTrue(%HasFastHoleyElements(d3)); + assertTrue(%HasDoubleElements(d3)); + assertTrue(%HasHoleyElements(d3)); transition4(d3, 0, new Array()); - assertTrue(%HasFastHoleyElements(d3)); - assertTrue(%HasFastObjectElements(d3)); + assertTrue(%HasHoleyElements(d3)); + assertTrue(%HasObjectElements(d3)); assertEquals(4, d3[4]); assertEquals(0, d3[0].length); @@ -194,11 +194,11 @@ function test() { for (i = 3; i < 0xa000; ++i) { d4[i] = 0; } - assertTrue(%HasFastDoubleElements(d4)); - assertTrue(%HasFastHoleyElements(d4)); + assertTrue(%HasDoubleElements(d4)); + assertTrue(%HasHoleyElements(d4)); transition4(d4, 0, new Array(5)); - assertTrue(%HasFastHoleyElements(d4)); - assertTrue(%HasFastObjectElements(d4)); + assertTrue(%HasHoleyElements(d4)); + assertTrue(%HasObjectElements(d4)); assertEquals(5, d4[0].length); assertEquals(undefined, d4[2]); } @@ -209,11 +209,11 @@ function test() { for (i = 3; i < 0x40000; ++i) { d5[i] = 0; } - assertTrue(%HasFastDoubleElements(d5)); - assertTrue(%HasFastHoleyElements(d5)); + assertTrue(%HasDoubleElements(d5)); + assertTrue(%HasHoleyElements(d5)); transition4(d5, 0, new Array(5)); - assertTrue(%HasFastHoleyElements(d5)); - assertTrue(%HasFastObjectElements(d5)); + assertTrue(%HasHoleyElements(d5)); + assertTrue(%HasObjectElements(d5)); assertEquals(5, d5[0].length); assertEquals(undefined, d5[2]); } diff --git a/deps/v8/test/mjsunit/getters-on-elements.js b/deps/v8/test/mjsunit/getters-on-elements.js index c80cdb3f86..d40c56f4e0 100644 --- a/deps/v8/test/mjsunit/getters-on-elements.js +++ b/deps/v8/test/mjsunit/getters-on-elements.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --noalways-opt --opt +// Flags: --allow-natives-syntax --noalways-opt --opt --no-stress-fullcodegen // It's nice to run this in other browsers too. var standalone = false; @@ -80,7 +80,7 @@ function base_getter_test(create_func) { assertUnoptimized(foo); // Smi and Double elements transition the KeyedLoadIC to Generic state // here, because they miss twice with the same map when loading the hole. - // For FAST_HOLEY_ELEMENTS, however, the IC knows how to convert the hole + // For HOLEY_ELEMENTS, however, the IC knows how to convert the hole // to undefined if the prototype is the original array prototype, so it // stays monomorphic for now... foo(a); diff --git a/deps/v8/test/mjsunit/harmony/async-for-of-non-iterable.js b/deps/v8/test/mjsunit/harmony/async-for-of-non-iterable.js new file mode 100644 index 0000000000..c84c9c6884 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/async-for-of-non-iterable.js @@ -0,0 +1,21 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-async-iteration +var done = false; + +async function f() { + try { + for await ([a] of {}) { + UNREACHABLE(); + } + UNREACHABLE(); + } catch (e) { + assertEquals(e.message, "{} is not async iterable"); + done = true; + } +} + +f(); +assertTrue(done); 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 0d9965b165..d965bd070c 100644 --- a/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js +++ b/deps/v8/test/mjsunit/harmony/async-from-sync-iterator.js @@ -625,6 +625,11 @@ if (testFailed) { } (function ExtractedAsyncFromSyncIteratorMethods() { + // TODO(ishell, caitp): Rewrite the test without using function.caller. + // According to ES#sec-built-in-function-objects all built-in functions + // must be strict. And ES#sec-forbidden-extensions states that the value of + // a function.caller must not be a strict function. + return; // Async-from-Sync iterator methods can be extracted via function.caller. // TODO(caitp): test extracted `throw` method using yield* in async generator. let extractor = [0, 1, 2, 3, 4,5,6,7,8,9]; diff --git a/deps/v8/test/mjsunit/harmony/do-expressions.js b/deps/v8/test/mjsunit/harmony/do-expressions.js index ea0ed2b04e..c238bc6330 100644 --- a/deps/v8/test/mjsunit/harmony/do-expressions.js +++ b/deps/v8/test/mjsunit/harmony/do-expressions.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // Flags: --harmony-do-expressions --allow-natives-syntax --no-always-opt -// Flags: --opt +// Flags: --opt --no-stress-fullcodegen function returnValue(v) { return v; } function MyError() {} diff --git a/deps/v8/test/mjsunit/harmony/futex.js b/deps/v8/test/mjsunit/harmony/futex.js index 458e234dc7..4dbd9cd61d 100644 --- a/deps/v8/test/mjsunit/harmony/futex.js +++ b/deps/v8/test/mjsunit/harmony/futex.js @@ -48,7 +48,7 @@ var i32a = new Int32Array(sab); // Valid indexes are 0-3. - [-1, 4, 100].forEach(function(invalidIndex) { + [-1, 4, 100, 0xffffffff].forEach(function(invalidIndex) { assertThrows(function() { Atomics.wait(i32a, invalidIndex, 0); }, RangeError); @@ -59,7 +59,7 @@ }); i32a = new Int32Array(sab, 8); - [-1, 2, 100].forEach(function(invalidIndex) { + [-1, 2, 100, 0xffffffff].forEach(function(invalidIndex) { assertThrows(function() { Atomics.wait(i32a, invalidIndex, 0); }, RangeError); diff --git a/deps/v8/test/mjsunit/harmony/generators-reduced.js b/deps/v8/test/mjsunit/harmony/generators-reduced.js new file mode 100644 index 0000000000..8ea96c6ba5 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/generators-reduced.js @@ -0,0 +1,15 @@ +// 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 + + +function* h() { try {yield 42} finally {yield 43} }; +function* g() { yield* h(); }; + +let x = g(); +x.next(); +%OptimizeFunctionOnNextCall(g); +x.throw(670); +try { x.next() } catch (e) { } diff --git a/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js new file mode 100644 index 0000000000..3c99498d0e --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/import-from-compilation-errored.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony-dynamic-import + +var error1, error2; +import('modules-skip-12.js').catch(e => error1 = e); +import('modules-skip-12.js').catch(e => error2 = e); +%RunMicrotasks(); + +assertEquals(error1, error2); +assertInstanceof(error1, SyntaxError); diff --git a/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js new file mode 100644 index 0000000000..3623091777 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/import-from-evaluation-errored.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony-dynamic-import + +var error1, error2; +import('modules-skip-11.js').catch(e => error1 = e); +import('modules-skip-11.js').catch(e => error2 = e); +%RunMicrotasks(); + +assertEquals(error1, error2); +assertEquals(typeof error1, "symbol"); diff --git a/deps/v8/test/mjsunit/harmony/import-from-fetch-errored.js b/deps/v8/test/mjsunit/harmony/import-from-fetch-errored.js new file mode 100644 index 0000000000..f3db881eb2 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/import-from-fetch-errored.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony-dynamic-import + +var error1, error2; +import('no-such-file').catch(e => error1 = e); +import('no-such-file').catch(e => error2 = e); +%RunMicrotasks(); + +assertEquals(error1, error2); +assertEquals(typeof error1, "string"); diff --git a/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js b/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js new file mode 100644 index 0000000000..2a481d5965 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/import-from-instantiation-errored.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony-dynamic-import + +var error1, error2; +import('modules-skip-10.js').catch(e => error1 = e); +import('modules-skip-10.js').catch(e => error2 = e); +%RunMicrotasks(); + +assertEquals(error1, error2); +assertInstanceof(error1, SyntaxError); diff --git a/deps/v8/test/mjsunit/harmony/intl-numberformat-formattoparts.js b/deps/v8/test/mjsunit/harmony/intl-numberformat-formattoparts.js new file mode 100644 index 0000000000..3ffe6ced68 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/intl-numberformat-formattoparts.js @@ -0,0 +1,336 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-number-format-to-parts + +// Adapted from Gecko's js/src/tests/Intl/NumberFormat/formatToParts.js, +// which was dedicated to the public domain. + +// NOTE: Some of these tests exercise standard behavior (e.g. that format and +// formatToParts expose the same formatted string). But much of this, +// like the exact-formatted-string expectations, is technically +// implementation-dependent. This is necessary as a practical matter to +// properly test the conversion from ICU's nested-field exposure to +// ECMA-402's sequential-parts exposure. + +if (this.Intl) { + + function GenericPartCreator(type) + { + return function(str) { return { type, value: str }; }; + } + + var Nan = GenericPartCreator("nan"); + var Inf = GenericPartCreator("infinity"); + var Integer = GenericPartCreator("integer"); + var Group = GenericPartCreator("group"); + var Decimal = GenericPartCreator("decimal"); + var Fraction = GenericPartCreator("fraction"); + var MinusSign = GenericPartCreator("minusSign"); + var PlusSign = GenericPartCreator("plusSign"); + var PercentSign = GenericPartCreator("percentSign"); + var Currency = GenericPartCreator("currency"); + var Literal = GenericPartCreator("literal"); + + function assertParts(nf, x, expected) + { + var parts = nf.formatToParts(x); + assertEquals(nf.format(x), + parts.map(part => part.value).join("")); + + var len = parts.length; + assertEquals(expected.length, len); + for (var i = 0; i < len; i++) + { + assertEquals(expected[i].type, parts[i].type); + assertEquals(expected[i].value, parts[i].value); + } + } + + //----------------------------------------------------------------------------- + + // Test behavior of a currency with code formatting. + var usdCodeOptions = + { + style: "currency", + currency: "USD", + currencyDisplay: "code", + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }; + var usDollarsCode = new Intl.NumberFormat("en-US", usdCodeOptions); + + assertParts(usDollarsCode, 25, + [Currency("USD"), Integer("25")]); + + // ISO 4217 currency codes are formed from an ISO 3166-1 alpha-2 country code + // followed by a third letter. ISO 3166 guarantees that no country code + // starting with "X" will ever be assigned. Stepping carefully around a few + // 4217-designated special "currencies", XQQ will never have a representation. + // Thus, yes: this really is specified to work, as unrecognized or unsupported + // codes pass into the string unmodified. + var xqqCodeOptions = + { + style: "currency", + currency: "XQQ", + currencyDisplay: "code", + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }; + var xqqMoneyCode = new Intl.NumberFormat("en-US", xqqCodeOptions); + + assertParts(xqqMoneyCode, 25, + [Currency("XQQ"), Integer("25")]); + + // Test currencyDisplay: "name". + var usdNameOptions = + { + style: "currency", + currency: "USD", + currencyDisplay: "name", + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }; + var usDollarsName = new Intl.NumberFormat("en-US", usdNameOptions); + + assertParts(usDollarsName, 25, + [Integer("25"), Literal(" "), Currency("US dollars")]); + + var usdNameGroupingOptions = + { + style: "currency", + currency: "USD", + currencyDisplay: "name", + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }; + var usDollarsNameGrouping = + new Intl.NumberFormat("en-US", usdNameGroupingOptions); + + assertParts(usDollarsNameGrouping, 12345678, + [Integer("12"), + Group(","), + Integer("345"), + Group(","), + Integer("678"), + Literal(" "), + Currency("US dollars")]); + + // But if the implementation doesn't recognize the currency, the provided code + // is used in place of a proper name, unmolested. + var xqqNameOptions = + { + style: "currency", + currency: "XQQ", + currencyDisplay: "name", + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }; + var xqqMoneyName = new Intl.NumberFormat("en-US", xqqNameOptions); + + assertParts(xqqMoneyName, 25, + [Integer("25"), Literal(" "), Currency("XQQ")]); + + // Test some currencies with fractional components. + + var usdNameFractionOptions = + { + style: "currency", + currency: "USD", + currencyDisplay: "name", + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }; + var usdNameFractionFormatter = + new Intl.NumberFormat("en-US", usdNameFractionOptions); + + // The US national surplus (i.e. debt) as of October 18, 2016. + // (Replicating data from a comment in Intl.cpp.) + var usNationalSurplus = -19766580028249.41; + + assertParts(usdNameFractionFormatter, usNationalSurplus, + [MinusSign("-"), + Integer("19"), + Group(","), + Integer("766"), + Group(","), + Integer("580"), + Group(","), + Integer("028"), + Group(","), + Integer("249"), + Decimal("."), + Fraction("41"), + Literal(" "), + Currency("US dollars")]); + + // Percents in various forms. + + var usPercentOptions = + { + style: "percent", + minimumFractionDigits: 1, + maximumFractionDigits: 1, + }; + var usPercentFormatter = + new Intl.NumberFormat("en-US", usPercentOptions); + + assertParts(usPercentFormatter, 0.375, + [Integer("37"), Decimal("."), Fraction("5"), PercentSign("%")]); + + assertParts(usPercentFormatter, -1284.375, + [MinusSign("-"), + Integer("128"), + Group(","), + Integer("437"), + Decimal("."), + Fraction("5"), + PercentSign("%")]); + + assertParts(usPercentFormatter, NaN, + [Nan("NaN")]); + + assertParts(usPercentFormatter, Infinity, + [Inf("∞"), PercentSign("%")]); + + assertParts(usPercentFormatter, -Infinity, + [MinusSign("-"), Inf("∞"), PercentSign("%")]); + + var arPercentOptions = + { + style: "percent", + minimumFractionDigits: 2, + }; + var arPercentFormatter = + new Intl.NumberFormat("ar-IQ", arPercentOptions); + + assertParts(arPercentFormatter, -135.32, + [MinusSign("\u{061C}-"), + Integer("١٣"), + Group("٬"), + Integer("٥٣٢"), + Decimal("٫"), + Fraction("٠٠"), + Literal("\xA0"), + PercentSign("٪\u{061C}")]); + + // Decimals. + + var usDecimalOptions = + { + style: "decimal", + maximumFractionDigits: 7 // minimum defaults to 0 + }; + var usDecimalFormatter = + new Intl.NumberFormat("en-US", usDecimalOptions); + + assertParts(usDecimalFormatter, 42, + [Integer("42")]); + + assertParts(usDecimalFormatter, 1337, + [Integer("1"), Group(","), Integer("337")]); + + assertParts(usDecimalFormatter, -6.25, + [MinusSign("-"), Integer("6"), Decimal("."), Fraction("25")]); + + assertParts(usDecimalFormatter, -1376.25, + [MinusSign("-"), + Integer("1"), + Group(","), + Integer("376"), + Decimal("."), + Fraction("25")]); + + assertParts(usDecimalFormatter, 124816.8359375, + [Integer("124"), + Group(","), + Integer("816"), + Decimal("."), + Fraction("8359375")]); + + var usNoGroupingDecimalOptions = + { + style: "decimal", + useGrouping: false, + maximumFractionDigits: 7 // minimum defaults to 0 + }; + var usNoGroupingDecimalFormatter = + new Intl.NumberFormat("en-US", usNoGroupingDecimalOptions); + + assertParts(usNoGroupingDecimalFormatter, 1337, + [Integer("1337")]); + + assertParts(usNoGroupingDecimalFormatter, -6.25, + [MinusSign("-"), Integer("6"), Decimal("."), Fraction("25")]); + + assertParts(usNoGroupingDecimalFormatter, -1376.25, + [MinusSign("-"), + Integer("1376"), + Decimal("."), + Fraction("25")]); + + assertParts(usNoGroupingDecimalFormatter, 124816.8359375, + [Integer("124816"), + Decimal("."), + Fraction("8359375")]); + + var deDecimalOptions = + { + style: "decimal", + maximumFractionDigits: 7 // minimum defaults to 0 + }; + var deDecimalFormatter = + new Intl.NumberFormat("de-DE", deDecimalOptions); + + assertParts(deDecimalFormatter, 42, + [Integer("42")]); + + assertParts(deDecimalFormatter, 1337, + [Integer("1"), Group("."), Integer("337")]); + + assertParts(deDecimalFormatter, -6.25, + [MinusSign("-"), Integer("6"), Decimal(","), Fraction("25")]); + + assertParts(deDecimalFormatter, -1376.25, + [MinusSign("-"), + Integer("1"), + Group("."), + Integer("376"), + Decimal(","), + Fraction("25")]); + + assertParts(deDecimalFormatter, 124816.8359375, + [Integer("124"), + Group("."), + Integer("816"), + Decimal(","), + Fraction("8359375")]); + + var deNoGroupingDecimalOptions = + { + style: "decimal", + useGrouping: false, + maximumFractionDigits: 7 // minimum defaults to 0 + }; + var deNoGroupingDecimalFormatter = + new Intl.NumberFormat("de-DE", deNoGroupingDecimalOptions); + + assertParts(deNoGroupingDecimalFormatter, 1337, + [Integer("1337")]); + + assertParts(deNoGroupingDecimalFormatter, -6.25, + [MinusSign("-"), Integer("6"), Decimal(","), Fraction("25")]); + + assertParts(deNoGroupingDecimalFormatter, -1376.25, + [MinusSign("-"), + Integer("1376"), + Decimal(","), + Fraction("25")]); + + assertParts(deNoGroupingDecimalFormatter, 124816.8359375, + [Integer("124816"), + Decimal(","), + Fraction("8359375")]); + +} diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-10.js b/deps/v8/test/mjsunit/harmony/modules-skip-10.js new file mode 100644 index 0000000000..fff168a581 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-skip-10.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {x} from "./modules-skip-10.js" diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-11.js b/deps/v8/test/mjsunit/harmony/modules-skip-11.js new file mode 100644 index 0000000000..8981f50ad4 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-skip-11.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +throw Symbol(); diff --git a/deps/v8/test/mjsunit/harmony/modules-skip-12.js b/deps/v8/test/mjsunit/harmony/modules-skip-12.js new file mode 100644 index 0000000000..05fedfa8d1 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/modules-skip-12.js @@ -0,0 +1,5 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +$^#$%@#@^^%^%$^#%%#!#$%!#$@#$% diff --git a/deps/v8/test/mjsunit/harmony/object-rest-basic.js b/deps/v8/test/mjsunit/harmony/object-rest-basic.js index f03eccdc16..e539ccbb3b 100644 --- a/deps/v8/test/mjsunit/harmony/object-rest-basic.js +++ b/deps/v8/test/mjsunit/harmony/object-rest-basic.js @@ -130,8 +130,13 @@ assertEquals({ 3: 3 }, z); var [...{...z}] = [{ x: 1}]; assertEquals({ 0: { x: 1} }, z); -var {...{x}} = { x: 1}; -assertEquals(1, x); +var x = {}; +({ ...x.f } = { a: 1 }); +assertEquals(x.f, { a: 1 }); + +var x = []; +({ ...x[0] } = { a: 1 }); +assertEquals(x[0], {a: 1}); var {4294967297: y, ...x} = {4294967297: 1, x: 1}; assertEquals(1, y); diff --git a/deps/v8/test/mjsunit/harmony/private.js b/deps/v8/test/mjsunit/harmony/private.js index cd65af1c70..39376f3ea9 100644 --- a/deps/v8/test/mjsunit/harmony/private.js +++ b/deps/v8/test/mjsunit/harmony/private.js @@ -340,19 +340,37 @@ function TestGetOwnPropertySymbols() { TestGetOwnPropertySymbols() -function TestSealAndFreeze(freeze) { +function TestSealAndFreeze(factory, freeze, isFrozen) { var sym = %CreatePrivateSymbol("private") - var obj = {} + var obj = factory(); obj[sym] = 1 freeze(obj) + assertTrue(isFrozen(obj)) obj[sym] = 2 assertEquals(2, obj[sym]) assertTrue(delete obj[sym]) assertEquals(undefined, obj[sym]) } -TestSealAndFreeze(Object.seal) -TestSealAndFreeze(Object.freeze) -TestSealAndFreeze(Object.preventExtensions) + +var fastObj = () => { + var obj = {} + assertTrue(%HasFastProperties(obj)) + return obj +} +var dictObj = () => { + var obj = Object.create(null) + obj.a = 1 + delete obj.a + assertFalse(%HasFastProperties(obj)) + return obj +} + +TestSealAndFreeze(fastObj, Object.seal, Object.isSealed) +TestSealAndFreeze(fastObj, Object.freeze, Object.isFrozen) +TestSealAndFreeze(fastObj, Object.preventExtensions, obj => !Object.isExtensible(obj)) +TestSealAndFreeze(dictObj, Object.seal, Object.isSealed) +TestSealAndFreeze(dictObj, Object.freeze, Object.isFrozen) +TestSealAndFreeze(dictObj, Object.preventExtensions, obj => !Object.isExtensible(obj)) var s = %CreatePrivateSymbol("s"); diff --git a/deps/v8/test/mjsunit/es8/async-let-asi.js b/deps/v8/test/mjsunit/harmony/regress-generators-resume.js index 2e7349da94..c72ac30b48 100644 --- a/deps/v8/test/mjsunit/es8/async-let-asi.js +++ b/deps/v8/test/mjsunit/harmony/regress-generators-resume.js @@ -4,19 +4,15 @@ // Flags: --allow-natives-syntax -var let = 0; -async function asyncFn() { - let - await 0; + +function* foo() { + for (let i = 0; i < 10; i++) { + yield 1; + } return 0; } -asyncFn().then(value => { - assertEquals(0, value); -}, error => { - assertUnreachable(); -}).catch(error => { - %AbortJS(String(error)); -}); - -%RunMicrotasks(); +g = foo(); +%OptimizeFunctionOnNextCall(foo); +g.next(); +g.next(); diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-6322.js b/deps/v8/test/mjsunit/harmony/regress/regress-6322.js new file mode 100644 index 0000000000..9c312a35a5 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regress/regress-6322.js @@ -0,0 +1,9 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-async-iteration + +// Crash with --verify-heap +(async function() { for await (let { a = class b { } } of [{}]) { } })(); +(async function() { var a; for await ({ a = class b { } } of [{}]) { } })(); diff --git a/deps/v8/test/mjsunit/harmony/trailing-commas-length.js b/deps/v8/test/mjsunit/harmony/trailing-commas-length.js index 9d5e59c16b..8e2fd51408 100644 --- a/deps/v8/test/mjsunit/harmony/trailing-commas-length.js +++ b/deps/v8/test/mjsunit/harmony/trailing-commas-length.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-trailing-commas - function f1(a,) {} function f2(a,b,) {} function f3(a,b,c,) {} diff --git a/deps/v8/test/mjsunit/ignition/ignition-statistics-extension.js b/deps/v8/test/mjsunit/ignition/ignition-statistics-extension.js index 47f02a3689..18097aac5c 100644 --- a/deps/v8/test/mjsunit/ignition/ignition-statistics-extension.js +++ b/deps/v8/test/mjsunit/ignition/ignition-statistics-extension.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --turbo --trace-ignition-dispatches +// Flags: --no-stress-fullcodegen --trace-ignition-dispatches assertEquals(typeof getIgnitionDispatchCounters, "function"); diff --git a/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js b/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js index 8f9c1be3af..e281eca33f 100644 --- a/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js +++ b/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --ignition-osr +// Flags: --allow-natives-syntax --no-stress-fullcodegen --ignition-osr function f() { for (var i = 0; i < 10; i++) { diff --git a/deps/v8/test/mjsunit/ignition/regress-599001-verifyheap.js b/deps/v8/test/mjsunit/ignition/regress-599001-verifyheap.js index ce5b46de95..6ec9464e17 100644 --- a/deps/v8/test/mjsunit/ignition/regress-599001-verifyheap.js +++ b/deps/v8/test/mjsunit/ignition/regress-599001-verifyheap.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --verify-heap --expose-gc +// Flags: --no-stress-fullcodegen --verify-heap --expose-gc // Tests that verify heap works for BytecodeArrays in the large object space. diff --git a/deps/v8/test/mjsunit/ignition/regress-612386-smi-to-double-transition.js b/deps/v8/test/mjsunit/ignition/regress-612386-smi-to-double-transition.js index 275f7d62d3..ddf884eec4 100644 --- a/deps/v8/test/mjsunit/ignition/regress-612386-smi-to-double-transition.js +++ b/deps/v8/test/mjsunit/ignition/regress-612386-smi-to-double-transition.js @@ -19,10 +19,10 @@ function foo() { keyed_store(obj, "dbl", 100); keyed_store(obj, "obj", 100); - // Now call with a FAST_SMI_ELEMENTS object. + // Now call with a PACKED_SMI_ELEMENTS object. var smi_array = [5, 1, 1]; keyed_store(smi_array, 1, 6); - // Transition from FAST_SMI_ELEMENTS to FAST_DOUBLE_ELEMENTS. + // Transition from PACKED_SMI_ELEMENTS to PACKED_DOUBLE_ELEMENTS. keyed_store(smi_array, 2, 1.2); } diff --git a/deps/v8/test/mjsunit/ignition/regress-616064.js b/deps/v8/test/mjsunit/ignition/regress-616064.js index 06de873293..27c3becf76 100644 --- a/deps/v8/test/mjsunit/ignition/regress-616064.js +++ b/deps/v8/test/mjsunit/ignition/regress-616064.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition +// Flags: --no-stress-fullcodegen function foo() { if (this.Worker) { diff --git a/deps/v8/test/mjsunit/ignition/string-concat-external-thin-string.js b/deps/v8/test/mjsunit/ignition/string-concat-external-thin-string.js new file mode 100644 index 0000000000..f9f538c5f5 --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/string-concat-external-thin-string.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-externalize-string + +// Calculate string so that it isn't internalized. +var string = ((a,b) => { return a + b; })('foo', 'bar'); + +// Now externalize it. +externalizeString(string, false); + +// Then internalize it by using it as a keyed property name +// to turn it a thin string. +var obj = {}; +obj[string]; + +// Perform a string concatination. +assertEquals('"' + string + '"', '"foobar"'); diff --git a/deps/v8/test/mjsunit/ignition/throw-if-hole.js b/deps/v8/test/mjsunit/ignition/throw-if-hole.js new file mode 100644 index 0000000000..ac155e0c9c --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/throw-if-hole.js @@ -0,0 +1,20 @@ +// 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: --opt --allow-natives-syntax --no-always-opt --no-stress-fullcodegen + +function f(b) { + if (b == 1) { + let a = a = 20; + } +} + +f(0); +f(0); +%OptimizeFunctionOnNextCall(f); +f(0); +assertOptimized(f); +// Check that hole checks are handled correctly in optimized code. +assertThrowsEquals(() => {f(1)}, ReferenceError()); +assertOptimized(f); diff --git a/deps/v8/test/mjsunit/ignition/throw-if-not-hole.js b/deps/v8/test/mjsunit/ignition/throw-if-not-hole.js new file mode 100644 index 0000000000..672e42ddf5 --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/throw-if-not-hole.js @@ -0,0 +1,28 @@ +// 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: --opt --allow-natives-syntax --no-always-opt + +class A { + constructor() { } +} +class B extends A { + constructor(call_super) { + super(); + if (call_super) { + super(); + } + } +} + +test = new B(0); +test = new B(0); +assertThrowsEquals(() => {new B(1)}, ReferenceError()); +assertThrowsEquals(() => {new B(1)}, ReferenceError()); +%OptimizeFunctionOnNextCall(B); +test = new B(0); +assertOptimized(B); +// Check that hole checks are handled correctly in optimized code. +assertThrowsEquals(() => {new B(1)}, ReferenceError()); +assertOptimized(B); diff --git a/deps/v8/test/mjsunit/ignition/throw-super-not-called.js b/deps/v8/test/mjsunit/ignition/throw-super-not-called.js new file mode 100644 index 0000000000..c95509e6ce --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/throw-super-not-called.js @@ -0,0 +1,25 @@ +// 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: --opt --allow-natives-syntax --no-always-opt + +class A { + constructor() { } +} +class B extends A { + constructor(call_super) { + if (call_super) { + super(); + } + } +} + +test = new B(1); +test = new B(1); +%OptimizeFunctionOnNextCall(B); +test = new B(1); +assertOptimized(B); +// Check that hole checks are handled correctly in optimized code. +assertThrowsEquals(() => {new B(0)}, ReferenceError()); +assertOptimized(B); diff --git a/deps/v8/test/mjsunit/induction-variable-turbofan.js b/deps/v8/test/mjsunit/induction-variable-turbofan.js index 6957859f9e..6ef804eb1c 100644 --- a/deps/v8/test/mjsunit/induction-variable-turbofan.js +++ b/deps/v8/test/mjsunit/induction-variable-turbofan.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax // TurboFan optimizes integer loops. These tests check that we compute // the correct upper and lower bounds. diff --git a/deps/v8/test/mjsunit/json2.js b/deps/v8/test/mjsunit/json2.js index 75e25f8924..917e8c88e6 100644 --- a/deps/v8/test/mjsunit/json2.js +++ b/deps/v8/test/mjsunit/json2.js @@ -131,21 +131,21 @@ TestStringify('{"y":"xy"}', {y: obj}); var fast_smi = [1, 2, 3, 4]; fast_smi.__proto__ = [7, 7, 7, 7]; delete fast_smi[2]; -assertTrue(%HasFastSmiElements(fast_smi)); +assertTrue(%HasSmiElements(fast_smi)); TestStringify("[1,2,7,4]", fast_smi); var fast_double = [1.1, 2, 3, 4]; fast_double.__proto__ = [7, 7, 7, 7]; delete fast_double[2]; -assertTrue(%HasFastDoubleElements(fast_double)); +assertTrue(%HasDoubleElements(fast_double)); TestStringify("[1.1,2,7,4]", fast_double); var fast_obj = [1, 2, {}, {}]; fast_obj.__proto__ = [7, 7, 7, 7]; delete fast_obj[2]; -assertTrue(%HasFastObjectElements(fast_obj)); +assertTrue(%HasObjectElements(fast_obj)); TestStringify("[1,2,7,{}]", fast_obj); var getter_side_effect = { a: 1, diff --git a/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js b/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js index 47dc65b0a0..251bde27b2 100644 --- a/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js +++ b/deps/v8/test/mjsunit/keyed-load-hole-to-undefined.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax -// Flags: --no-stress-opt --opt --no-always-opt +// Flags: --no-stress-opt --opt --no-always-opt --no-stress-fullcodegen // --nostress-opt is specified because the test corrupts the "pristine" // array prototype chain by storing an element, and this is tracked diff --git a/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js b/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js index d0be0a0545..301d4e4855 100644 --- a/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js +++ b/deps/v8/test/mjsunit/keyed-load-with-symbol-key.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen var s = Symbol("foo"); diff --git a/deps/v8/test/mjsunit/large-object-literal-2.js b/deps/v8/test/mjsunit/large-object-literal-2.js new file mode 100644 index 0000000000..5e908b32bc --- /dev/null +++ b/deps/v8/test/mjsunit/large-object-literal-2.js @@ -0,0 +1,34 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function TestLargeObjectDictionaryLiteral() { + // Create potential large-space object literal. + let properties = []; + // Constant chosen so the dictionary properties store lies in large object + // space. + const max = 0x1ef3e / 3; + for (let i = 0; i < max; i++) { + properties.push("p"+i); + } + let source = "return { __proto__:null, " + properties.join(":'',") + ":''}" + let createObject = new Function(source); + let object = createObject(); + %HeapObjectVerify(object); + assertFalse(%HasFastProperties(object)); + assertEquals(Object.getPrototypeOf(object ), null); + let keys = Object.keys(object); + // modify original object + object['new_property'] = {}; + object[1] = 12; + %HeapObjectVerify(object); + + let object2 = createObject(); + %HeapObjectVerify(object2); + assertFalse(object2 === object); + assertFalse(%HasFastProperties(object2)); + assertEquals(Object.getPrototypeOf(object2), null); + assertEquals(keys, Object.keys(object2)); +})(); diff --git a/deps/v8/test/mjsunit/large-object-literal-slow-elements.js b/deps/v8/test/mjsunit/large-object-literal-slow-elements.js new file mode 100644 index 0000000000..eefde1b988 --- /dev/null +++ b/deps/v8/test/mjsunit/large-object-literal-slow-elements.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test Object literal with large-object elements. +let indices = []; +const max = 0x1ef3e + 100; +for (let i = 0; i < max; i++) { + indices.push(""+i); +} +let source = "return {" + indices.join(":0,") + ":0};" +let largeElementsLiteral = new Function(source); + +function TestLargeObjectElements() { + // Corresponds to FixedArray::kMaxRegularLength. + let object = largeElementsLiteral(); + %HeapObjectVerify(object); + for (let i = 0; i < max; i++) { + assertEquals(0, object[i]); + } + object[0] = 0xFF; + assertEquals(0xFF, object[0]); + object[1] = 1.23; + assertEquals(1.23, object[1]); + %HeapObjectVerify(object); +} + +TestLargeObjectElements(); +TestLargeObjectElements(); +%OptimizeFunctionOnNextCall(TestLargeObjectElements); +TestLargeObjectElements(); diff --git a/deps/v8/test/mjsunit/large-object-literal.js b/deps/v8/test/mjsunit/large-object-literal.js index 47ba56e101..e44c05794a 100644 --- a/deps/v8/test/mjsunit/large-object-literal.js +++ b/deps/v8/test/mjsunit/large-object-literal.js @@ -26,6 +26,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Test that we can create object literals of various sizes. + +// Flags: --allow-natives-syntax + function testLiteral(size) { // Build object-literal string. @@ -45,6 +48,25 @@ function testLiteral(size) { assertEquals(i, o["a"+i]); } } +function testElementLiteral(size) { + + // Build object-literal string. + var literal = "var o = { "; + + for (var i = 0; i < size; i++) { + if (i > 0) literal += ","; + literal += (i + ":'" + i+"'"); + } + literal += "}"; + + // Create the object literal. + eval(literal); + + // Check that the properties have the expected values. + for (var i = 0; i < size; i++) { + assertEquals(i+"", o[i]); + } +} // The sizes to test. var sizes = [0, 1, 2, 100, 200, 400, 1000]; @@ -52,4 +74,33 @@ var sizes = [0, 1, 2, 100, 200, 400, 1000]; // Run the test. for (var i = 0; i < sizes.length; i++) { testLiteral(sizes[i]); + testElementLiteral(sizes[i]); } + + +// Larg Object dictionary mode literal. + + +function TestSlowLiteralOptimized() { + function f() { + return {__proto__:null, bar:"barValue"}; + } + let obj = f(); + assertFalse(%HasFastProperties(obj)); + assertEquals(Object.getPrototypeOf(obj), null); + assertEquals(["bar"], Object.keys(obj)); + assertEquals("barValue", obj.bar); + obj.bar = "barValue2"; + assertEquals("barValue2", obj.bar); + + %OptimizeFunctionOnNextCall(f); + obj = f(); + assertFalse(%HasFastProperties(obj)); + assertEquals(Object.getPrototypeOf(obj), null); + assertEquals(["bar"], Object.keys(obj)); + assertEquals("barValue", obj.bar); + obj.bar = "barValue2"; + assertEquals("barValue2", obj.bar); +}; +TestSlowLiteralOptimized(); +TestSlowLiteralOptimized(); diff --git a/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js b/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js index 7418a4e257..a721467b5a 100644 --- a/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js +++ b/deps/v8/test/mjsunit/math-floor-of-div-minus-zero.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nouse-inlining --opt +// Flags: --allow-natives-syntax --opt // Test for negative zero that doesn't need bail out diff --git a/deps/v8/test/mjsunit/math-floor-of-div-nosudiv.js b/deps/v8/test/mjsunit/math-floor-of-div-nosudiv.js index f5b1f299b7..5340f8353b 100644 --- a/deps/v8/test/mjsunit/math-floor-of-div-nosudiv.js +++ b/deps/v8/test/mjsunit/math-floor-of-div-nosudiv.js @@ -25,8 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nouse-inlining --noenable-sudiv -// Flags: --noenable-armv8 +// Flags: --allow-natives-syntax --noenable-sudiv --noenable-armv8 // Use this function as reference. Make sure it is not inlined. function div(a, b) { diff --git a/deps/v8/test/mjsunit/math-floor-of-div.js b/deps/v8/test/mjsunit/math-floor-of-div.js index 9769561c1c..d0026e963a 100644 --- a/deps/v8/test/mjsunit/math-floor-of-div.js +++ b/deps/v8/test/mjsunit/math-floor-of-div.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nouse-inlining --enable-sudiv +// Flags: --allow-natives-syntax --enable-sudiv // Use this function as reference. Make sure it is not inlined. function div(a, b) { diff --git a/deps/v8/test/mjsunit/messages.js b/deps/v8/test/mjsunit/messages.js index ff91185a72..3281fc897d 100644 --- a/deps/v8/test/mjsunit/messages.js +++ b/deps/v8/test/mjsunit/messages.js @@ -28,7 +28,7 @@ test(function() { // kApplyNonFunction test(function() { - Function.prototype.apply.call(1, []); + Reflect.apply(1, []); }, "Function.prototype.apply was called on 1, which is a number " + "and not a function", TypeError); diff --git a/deps/v8/test/mjsunit/mjsunit-assertion-error.js b/deps/v8/test/mjsunit/mjsunit-assertion-error.js new file mode 100644 index 0000000000..08c6ff619d --- /dev/null +++ b/deps/v8/test/mjsunit/mjsunit-assertion-error.js @@ -0,0 +1,102 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +let fileName = 'mjsunit-assertion-error.js'; + +function addDefaultFrames(frameExpectations) { + // The last frame contains the error instantiation. + frameExpectations.unshift('assertTrue.*mjsunit.js'); + // Frist frame is the top-level script. + frameExpectations.push(fileName); +} + +function assertErrorMessage(frameExpectations, error) { + let stack = error.stack.split("\n"); + let title = stack.shift(); + assertContains('MjsUnitAssertionError', title); + addDefaultFrames(frameExpectations); + // Add default frames to the expectations. + assertEquals(frameExpectations.length, stack.length); + for (let i = 0; i < stack.length; i++) { + let frame = stack[i]; + let expectation = frameExpectations[i]; + assertTrue(frame.search(expectation) != -1, + `Frame ${i}: Did not find '${expectation}' in '${frame}'`); + } +} + +// Toplevel +try { + assertTrue(false); +} catch(e) { + assertErrorMessage([], e); +} + +// Single function. +function throwError() { + assertTrue(false); +} +try { + throwError(); + assertUnreachable(); +} catch(e) { + assertErrorMessage(['throwError'], e); +} + +// Nested function. +function outer() { + throwError(); +} +try { + outer(); + assertUnreachable(); +} catch(e) { + assertErrorMessage(['throwError', 'outer'], e); +} + +// Test Array helper nesting +try { + [1].map(throwError); + assertUnreachable(); +} catch(e) { + assertErrorMessage(['throwError', 'Array.map'], e); +} +try { + Array.prototype.map.call([1], throwError); + assertUnreachable(); +} catch(e) { + assertErrorMessage(['throwError', 'Array.map'], e); +} + +// Test eval +try { + eval("assertTrue(false);"); + assertUnreachable(); +} catch(e) { + assertErrorMessage(['eval'], e); +} + +(function testNestedEval() { + try { + eval("assertTrue(false);"); + assertUnreachable(); + } catch(e) { + assertErrorMessage(['eval', 'testNestedEval'], e); + } +})(); + + +(function testConstructor() { + class Failer { + constructor() { + assertTrue(false); + } + } + try { + new Failer(); + assertUnreachable(); + } catch(e) { + assertErrorMessage(['new Failer', 'testConstructor'], e); + } +})(); diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 754dcbb3de..90551f6e6f 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -27,8 +27,16 @@ function MjsUnitAssertionError(message) { this.message = message; - // This allows fetching the stack trace using TryCatch::StackTrace. - this.stack = new Error("").stack; + // Temporarily install a custom stack trace formatter and restore the + // previous value. + let prevPrepareStackTrace = Error.prepareStackTrace; + try { + Error.prepareStackTrace = MjsUnitAssertionError.prepareStackTrace; + // This allows fetching the stack trace using TryCatch::StackTrace. + this.stack = new Error("MjsUnitAssertionError").stack; + } finally { + Error.prepareStackTrace = prevPrepareStackTrace; + } } /* @@ -37,7 +45,6 @@ function MjsUnitAssertionError(message) { * the f-word and ignore all other lines. */ - MjsUnitAssertionError.prototype.toString = function () { return this.message + "\n\nStack: " + this.stack; }; @@ -54,6 +61,11 @@ var assertSame; // and the properties of non-Array objects). var assertEquals; +// Expected and found values are not identical primitive values or functions +// or similarly structured objects (checking internal properties +// of, e.g., Number and Date objects, the elements of arrays +// and the properties of non-Array objects). +var assertNotEquals; // The difference between expected and found value is within certain tolerance. var assertEqualsDelta; @@ -167,8 +179,10 @@ var failWithMessage; var StringPrototypeValueOf = String.prototype.valueOf; var DatePrototypeValueOf = Date.prototype.valueOf; var RegExpPrototypeToString = RegExp.prototype.toString; - var ArrayPrototypeMap = Array.prototype.map; + var ArrayPrototypeForEach = Array.prototype.forEach; var ArrayPrototypeJoin = Array.prototype.join; + var ArrayPrototypeMap = Array.prototype.map; + var ArrayPrototypePush = Array.prototype.push; function classOf(object) { // Argument must not be null or undefined. @@ -345,6 +359,12 @@ var failWithMessage; } }; + assertNotEquals = function assertNotEquals(expected, found, name_opt) { + if (deepEquals(found, expected)) { + fail("not equals to " + PrettyPrint(expected), found, name_opt); + } + }; + assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt) { @@ -425,12 +445,16 @@ var failWithMessage; 'invalid use of assertThrows, maybe you want assertThrowsEquals'); } if (arguments.length >= 3) { - assertEquals(cause_opt, e.message); + if (cause_opt instanceof RegExp) { + assertMatches(cause_opt, e.message, "Error message"); + } else { + assertEquals(cause_opt, e.message, "Error message"); + } } // Success. return; } - failWithMessage('Did not throw exception'); + failWithMessage("Did not throw exception"); }; @@ -550,7 +574,7 @@ var failWithMessage; assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { if (sync_opt === undefined) sync_opt = ""; var opt_status = OptimizationStatus(fun, sync_opt); - // Tests that use assertOptimized() do not make sense if --always-opt + // Tests that use assertUnoptimized() do not make sense if --always-opt // option is provided. Such tests must add --no-always-opt to flags comment. assertFalse((opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0, "test does not make sense with --always-opt"); @@ -622,4 +646,64 @@ var failWithMessage; (opt_status & V8OptimizationStatus.kTurboFanned) !== 0; } + // Custom V8-specific stack trace formatter that is temporarily installed on + // the Error object. + MjsUnitAssertionError.prepareStackTrace = function(error, stack) { + // Trigger default formatting with recursion. + try { + // Filter-out all but the first mjsunit frame. + let filteredStack = []; + let inMjsunit = true; + for (let i = 0; i < stack.length; i++) { + let frame = stack[i]; + if (inMjsunit) { + let file = frame.getFileName(); + if (!file || !file.endsWith("mjsunit.js")) { + inMjsunit = false; + // Push the last mjsunit frame, typically containing the assertion + // function. + if (i > 0) ArrayPrototypePush.call(filteredStack, stack[i-1]); + ArrayPrototypePush.call(filteredStack, stack[i]); + } + continue; + } + ArrayPrototypePush.call(filteredStack, frame); + } + stack = filteredStack; + + // Infer function names and calculate {max_name_length} + let max_name_length = 0; + ArrayPrototypeForEach.call(stack, each => { + let name = each.getFunctionName(); + if (name == null) name = ""; + if (each.isEval()) { + name = name; + } else if (each.isConstructor()) { + name = "new " + name; + } else if (each.isNative()) { + name = "native " + name; + } else if (!each.isToplevel()) { + name = each.getTypeName() + "." + name; + } + each.name = name; + max_name_length = Math.max(name.length, max_name_length) + }); + + // Format stack frames. + stack = ArrayPrototypeMap.call(stack, each => { + let frame = " at " + each.name.padEnd(max_name_length); + let fileName = each.getFileName(); + if (each.isEval()) return frame + " " + each.getEvalOrigin(); + frame += " " + (fileName ? fileName : ""); + let line= each.getLineNumber(); + frame += " " + (line ? line : ""); + let column = each.getColumnNumber(); + frame += (column ? ":" + column : ""); + return frame; + }); + return "" + error.message + "\n" + ArrayPrototypeJoin.call(stack, "\n"); + } catch(e) {}; + return error.stack; + } + })(); diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 6c6911999b..20c7555e70 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -42,15 +42,12 @@ # Issue 1719: Slow to collect arrays over several contexts. 'regress/regress-524': [SKIP], # When that bug is fixed, revert the expectation to: - # Skip long running test in debug and allow it to timeout in release mode. - # regress/regress-524: [PASS, TIMEOUT, ['mode == debug', SKIP]], + # Skip long running test in debug. + # regress/regress-524: [PASS, ['mode == debug', SKIP]], # This test non-deterministically runs out of memory on Windows ia32. 'regress/regress-crbug-160010': [SKIP], - # Issue 3389: deopt_every_n_garbage_collections is unsafe - 'regress/regress-2653': [SKIP], - # Issue 3784: setters-on-elements is flaky 'setters-on-elements': [PASS, FAIL], @@ -63,7 +60,7 @@ ############################################################################## # Too slow in debug mode for validation of elements. - 'regress/regress-430201': [PASS, ['mode == debug', SKIP]], + 'regress/regress-430201': [PASS, ['mode == debug', SKIP], ['tsan', SKIP]], 'regress/regress-430201b': [PASS, ['mode == debug', SKIP]], 'regress/regress-716044': [PASS, ['mode == debug', SKIP]], @@ -88,15 +85,11 @@ # TODO(arm): This seems to flush out a bug on arm with simulator. 'array-constructor': [PASS, SLOW, ['arch == arm and simulator == True', SKIP]], - # Issue 4413: this test sometimes times out with TSAN because we trigger - # the slow path in C++ with holey arrays in Function.prototype.apply. - # TODO(bmeurer): Add fast support for holey arrays in apply. - 'apply': [PASS, TIMEOUT], - # 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', TIMEOUT]], + '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]], 'regress/regress-3976': [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-482998': [PASS, NO_VARIANTS, ['arch == arm or arch == arm64 or arch == android_arm or arch == android_arm64 or arch == mipsel or arch == mips64el or arch == mips', SKIP]], + 'regress/regress-740784': [PASS, NO_VARIANTS, ['arch == arm or arch == arm64 or arch == android_arm or arch == android_arm64 or arch == mipsel or arch == mips64el or arch == mips', SKIP]], ############################################################################## # Skip long running tests that time out in debug mode. @@ -131,9 +124,8 @@ 'compiler/alloc-number-debug': [PASS, ['mode == release', SKIP]], 'regress/regress-634-debug': [PASS, ['mode == release', SKIP]], - # BUG(v8:2989). PASS/FAIL on linux32 because crankshaft is turned off for - # nosse2. Also for arm novfp3. - 'regress/regress-2989': [FAIL, NO_VARIANTS, ['system == linux and arch == x87 or arch == arm and simulator == True', PASS]], + # BUG(v8:2989). + 'regress/regress-2989': [FAIL, NO_VARIANTS], # This test variant makes only sense on arm. 'math-floor-of-div-nosudiv': [PASS, SLOW, ['arch not in [arm, arm64, android_arm, android_arm64]', SKIP]], @@ -145,7 +137,6 @@ # Slow tests. 'copy-on-write-assert': [PASS, SLOW], - 'es6/tail-call-megatest*': [PASS, SLOW, FAST_VARIANTS, ['tsan', SKIP]], 'es6/typedarray-construct-offset-not-smi': [PASS, SLOW], 'harmony/regexp-property-script-extensions': [PASS, SLOW], 'numops-fuzz-part*': [PASS, ['mode == debug', SLOW]], @@ -186,6 +177,9 @@ # BUG(v8:6306). 'wasm/huge-memory': [SKIP], + + # BUG(v8:6577). + 'wasm/exceptions': [SKIP], }], # ALWAYS ['novfp3 == True', { @@ -269,9 +263,6 @@ ############################################################################## ['arch == arm64 or arch == android_arm64', { - # arm64 TF timeout. - 'regress/regress-1257': [PASS, TIMEOUT], - # Requires bigger stack size in the Genesis and if stack size is increased, # the test requires too much time to run. However, the problem test covers # should be platform-independent. @@ -330,21 +321,23 @@ 'unicodelctest-no-optimization': [PASS, SLOW], 'unicodelctest': [PASS, SLOW], 'unicode-test': [PASS, SLOW], - 'whitespaces': [PASS, TIMEOUT, SLOW], + 'whitespaces': [PASS, SLOW], }], # 'arch == arm64' ['arch == arm64 and mode == debug and simulator_run', { # Pass but take too long with the simulator in debug mode. - 'array-sort': [PASS, TIMEOUT], + 'array-sort': [PASS, SLOW], 'packed-elements': [SKIP], 'regexp-global': [SKIP], - 'math-floor-of-div': [PASS, TIMEOUT], - 'math-floor-of-div-nosudiv': [PASS, TIMEOUT], - 'unicodelctest': [PASS, TIMEOUT], - 'unicodelctest-no-optimization': [PASS, TIMEOUT], + 'math-floor-of-div': [PASS, SLOW], + 'math-floor-of-div-nosudiv': [PASS, SLOW], + 'unicodelctest': [PASS, SLOW], + 'unicodelctest-no-optimization': [PASS, SLOW], # Issue 3219: 'getters-on-elements': [PASS, ['gc_stress == True', FAIL]], + # Expects to finish in a certain time, but sometimes doesn't. + 'regress/regress-165637': [SKIP], }], # 'arch == arm64 and mode == debug and simulator_run' ############################################################################## @@ -399,9 +392,9 @@ # Flaky test that can hit compilation-time stack overflow in debug mode. 'unicode-test': [PASS, ['mode == debug', PASS, FAIL]], - # Times out often in release mode on ARM. - 'compiler/regress-stacktrace-methods': [PASS, ['mode == release', TIMEOUT]], - 'array-splice': [PASS, TIMEOUT], + # Slow in release mode on ARM. + 'compiler/regress-stacktrace-methods': [PASS, SLOW], + 'array-splice': [PASS, SLOW], # Long running tests. Skipping because having them timeout takes too long on # the buildbot. @@ -427,7 +420,7 @@ 'regress/regress-2790': [PASS, SLOW], 'regress/regress-91008': [PASS, SLOW], 'regress/regress-json-stringify-gc': [PASS, SLOW], - 'string-indexof-2': [PASS, TIMEOUT], + 'string-indexof-2': [PASS, SLOW], }], # 'arch == arm or arch == android_arm' ############################################################################## @@ -442,7 +435,7 @@ }], # 'arch == mipsel or arch == mips or arch == mips64el or arch == mips64' ############################################################################## -['arch == mipsel or arch == mips or arch == mips64el or arch == mips64', { +['arch == mipsel or arch == mips or arch == mips64el or arch == mips64 or arch == ppc or arch == ppc64', { # These tests fail because qNaN and sNaN values are encoded differently on # MIPS and ARM/x86 architectures 'wasm/float-constant-folding': [SKIP], @@ -455,12 +448,12 @@ 'try': [PASS, ['mode == debug', SKIP]], 'array-constructor': [PASS, ['mode == debug', SKIP]], - # Times out often in release mode on MIPS. - 'compiler/regress-stacktrace-methods': [PASS, ['mode == release', TIMEOUT]], - 'array-splice': [PASS, TIMEOUT], + # Slow in release mode on MIPS. + 'compiler/regress-stacktrace-methods': [PASS, SLOW], + 'array-splice': [PASS, SLOW], # Long running test. - 'string-indexof-2': [PASS, TIMEOUT], + 'string-indexof-2': [PASS, SLOW], # Long running tests. Skipping because having them timeout takes too long on # the buildbot. @@ -485,12 +478,12 @@ 'try': [PASS, ['mode == debug', SKIP]], 'array-constructor': [PASS, ['mode == debug', SKIP]], - # Times out often in release mode on MIPS. - 'compiler/regress-stacktrace-methods': [PASS, PASS, ['mode == release', TIMEOUT]], - 'array-splice': [PASS, TIMEOUT], + # Slow in release mode on MIPS. + 'compiler/regress-stacktrace-methods': [PASS, SLOW], + 'array-splice': [PASS, SLOW], # Long running test. - 'string-indexof-2': [PASS, TIMEOUT], + 'string-indexof-2': [PASS, SLOW], # BUG(3251035): Timeouts in long looping crankshaft optimization # tests. Skipping because having them timeout takes too long on the @@ -526,12 +519,6 @@ 'math-floor-of-div-minus-zero': [SKIP], }], # 'arch == mips64el or arch == mips64' -['arch == x87', { - # The result produced by Gcc on linux platform is extended 80-bit double - # precision and not the expected standard 64-bit double precision. - 'number-tostring-big-integer': [SKIP], -}], # 'arch == x87' - ############################################################################## ['system == windows', { # TODO(mstarzinger): Too slow with turbo fan. @@ -571,17 +558,10 @@ # Deopting uses just enough memory to make this one OOM. 'regress/regress-3976': [SKIP], - # Deopt every n garbage collections collides with deopt every n times. - 'regress/regress-2653': [SKIP], - - # Too slow. - 'es6/tail-call-megatest*': [SKIP], - # Forced optimisation path tests. 'shared-function-tier-up-turbo': [SKIP], - # Fails deopt_fuzzer due to --deopt_every_n_times or - # deopt_every_n_garbage_collections + # Fails deopt_fuzzer due to --deopt_every_n_times 'es6/array-iterator-turbo': [SKIP] }], # 'deopt_fuzzer == True' @@ -591,9 +571,6 @@ # Skip tests that are known to be non-deterministic. 'd8-worker-sharedarraybuffer': [SKIP], 'd8-os': [SKIP], - - # crbug.com/v8/5803 - 'wasm/gc-frame': [SKIP], }], # 'predictable == True' ############################################################################## @@ -629,40 +606,12 @@ }], # variant == stress ############################################################################## -['variant == noturbofan_stress', { - # Slow tests. - 'ignition/regress-599001-verifyheap': [SKIP], - 'regress/regress-2185-2': [SKIP], -}], # variant == noturbofan_stress - -############################################################################## ['variant == nooptimization', { # Slow tests. 'regress/regress-2185-2': [SKIP], }], # variant == nooptimization ############################################################################## -['variant == noturbofan and no_snap', { - # Too slow for old pipeline and nosnap. - 'regress/regress-2249': [SKIP], - 'harmony/futex': [SKIP], -}], # variant == noturbofan and no_snap - -############################################################################## -['variant == turbofan_opt', { - 'es6/array-iterator-turbo': [SKIP], - - # TODO(jgruber): Fails in --turbo --always-opt mode. - 'regress/regress-105': [FAIL], - - # Too slow. - 'big-object-literal': [SKIP], - 'ignition/regress-599001-verifyheap': [SKIP], - 'unicode-test': [SKIP], - -}], # variant == turbofan_opt - -############################################################################## ['gcov_coverage', { # Tests taking too long. 'array-functions-prototype-misc': [SKIP], @@ -691,12 +640,10 @@ }], # variant == wasm_traps ############################################################################## -# This test allocates a 2G block of memory and if there are multiple -# varients this leads kills by the OOM killer, crashes or messages -# indicating the OS cannot allocate memory, exclude for Node.js runs -# re-evalute when we move up to v8 5.1 -[ALWAYS, { -'regress/regress-crbug-514081': [PASS, NO_VARIANTS], -}], # ALWAYS +['no_harness', { + # skip assertion tests since the stack trace is broken if mjsunit is + # included in the snapshot + 'mjsunit-assertion-error' : [SKIP], +}], # no_harness ] diff --git a/deps/v8/test/mjsunit/modules-turbo1.js b/deps/v8/test/mjsunit/modules-turbo1.js index c8877d1f06..20df5c04dd 100644 --- a/deps/v8/test/mjsunit/modules-turbo1.js +++ b/deps/v8/test/mjsunit/modules-turbo1.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // MODULE -// Flags: --allow-natives-syntax --turbo --opt --turbo-filter=* +// Flags: --allow-natives-syntax --opt --turbo-filter=* export let x = 0; function foo() { x++ }; diff --git a/deps/v8/test/mjsunit/modules-turbo2.js b/deps/v8/test/mjsunit/modules-turbo2.js index 734b2c4093..2e08086377 100644 --- a/deps/v8/test/mjsunit/modules-turbo2.js +++ b/deps/v8/test/mjsunit/modules-turbo2.js @@ -3,7 +3,7 @@ // found in the LICENSE file. // MODULE -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax export let x = 0; diff --git a/deps/v8/test/mjsunit/never-baseline.js b/deps/v8/test/mjsunit/never-baseline.js index 5d25c82c79..8be55d24a4 100644 --- a/deps/v8/test/mjsunit/never-baseline.js +++ b/deps/v8/test/mjsunit/never-baseline.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --turbo +// Flags: --allow-natives-syntax --no-stress-fullcodegen function f(a, b) { %DeoptimizeNow(); diff --git a/deps/v8/test/mjsunit/newline-in-string.js b/deps/v8/test/mjsunit/newline-in-string.js index e71d8cf6a2..d52b0e5941 100644 --- a/deps/v8/test/mjsunit/newline-in-string.js +++ b/deps/v8/test/mjsunit/newline-in-string.js @@ -35,10 +35,14 @@ var str = 'asdf\ '; assertEquals('asdf\nasdf\rasdf\tasdf\\', str); -// Allow CR+LF in multiline string literals. +// Allow escaped CR+LF in multiline string literals. var code = "'asdf\\" + String.fromCharCode(0xD) + String.fromCharCode(0xA) + "asdf'"; -assertEquals('asdfasdf', eval(code)); +assertEquals("asdfasdf", eval(code)); -// Allow LF+CR in multiline string literals. +// Allow individually escaped LF+CR in multiline string literals. +code = "'asdf\\" + String.fromCharCode(0xA) + "\\" + String.fromCharCode(0xD) + "asdf'"; +assertEquals("asdfasdf", eval(code)); + +// Do not allow LF+CR in multiline string literals. (crbug.com/v8/6401) code = "'asdf\\" + String.fromCharCode(0xA) + String.fromCharCode(0xD) + "asdf'"; -assertEquals('asdfasdf', eval(code)); +assertThrows(code); diff --git a/deps/v8/test/mjsunit/object-literal.js b/deps/v8/test/mjsunit/object-literal.js index 5717837e34..79c4df1de9 100644 --- a/deps/v8/test/mjsunit/object-literal.js +++ b/deps/v8/test/mjsunit/object-literal.js @@ -27,6 +27,22 @@ // Flags: --allow-natives-syntax +function runTest(fn) { + // The first run creates an copy directly from the boilerplate decsription. + fn(); + // The second run will create the boilerplate. + fn(); + // The third run might copy literals directly in the stub. + fn(); + // Several invocations more to trigger map deprecations. + fn(); + fn(); + fn(); + // Make sure literals keep on workin in optimized code. + %OptimizeFunctionOnNextCall(fn); + fn(); +} + function testBasicPrototype() { var obj = { a: 7, @@ -81,7 +97,7 @@ function testSparseElements() { '0': { x: 12, y: 24 }, '1000000': { x: 1, y: 2 } }; - + %HeapObjectVerify(sa1); assertEquals(['0', '1000000'], Object.keys(sa1)); assertEquals(12, sa1[0].x); assertEquals(24, sa1[0].y); @@ -252,18 +268,73 @@ function TestNumericNames() { 7E-0: 7, 0x8: 8, 0X9: 9, - } + }; + %HeapObjectVerify(o); assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9'], Object.keys(o)); o = { 1.2: 1.2, 1.30: 1.3 }; + %HeapObjectVerify(o); assertEquals(['1.2', '1.3'], Object.keys(o)); } TestNumericNames(); TestNumericNames(); +function TestDictionaryElements() { + let o = {1024: true}; + assertTrue(%HasDictionaryElements(o)); + assertEquals(true, o[1024]); + assertEquals(["1024"], Object.keys(o)); + assertEquals([true], Object.values(o)); + %HeapObjectVerify(o); + o[1024] = "test"; + assertEquals(["test"], Object.values(o)); + + let o2 = {1024: 1024}; + assertTrue(%HasDictionaryElements(o2)); + assertEquals(1024, o2[1024]); + assertEquals(["1024"], Object.keys(o2)); + assertEquals([1024], Object.values(o2)); + %HeapObjectVerify(o2); + o2[1024] = "test"; + assertEquals(["test"], Object.values(o2)); +} +TestDictionaryElements(); +TestDictionaryElements(); +%OptimizeFunctionOnNextCall(TestDictionaryElements); +TestDictionaryElements(); + +function TestLiteralElementsKind() { + let o = {0:0, 1:1, 2:2}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + o = {0:0, 2:2}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + + o = {0:0.1, 1:1, 2:2}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + o = {0:0.1, 2:2}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + + o = {0:0.1, 1:1, 2:true}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + o = {0:0.1, 2:true}; + assertTrue(%HasObjectElements(o)); + assertTrue(%HasHoleyElements(o)); + + assertTrue(%HasDictionaryElements({0xFFFFFF:true})); +} +TestLiteralElementsKind(); +TestLiteralElementsKind(); +%OptimizeFunctionOnNextCall(TestLiteralElementsKind); +TestLiteralElementsKind(); + function TestNonNumberElementValues() { var o = { 1: true, @@ -271,7 +342,14 @@ function TestNonNumberElementValues() { 3: undefined, 4: "" }; + %HeapObjectVerify(o); assertEquals(['1', '2', '3', '4'], Object.keys(o)); + assertEquals([true, false, undefined, ""], Object.values(o)); + o[1] = 'a'; + o[2] = 'b'; + assertEquals(['1', '2', '3', '4'], Object.keys(o)); + assertEquals(['a', 'b', undefined, ""], Object.values(o)); + var o2 = { 1: true, 2: false, @@ -280,7 +358,14 @@ function TestNonNumberElementValues() { a: 'a', b: 'b' }; + %HeapObjectVerify(o2); assertEquals(['1', '2', '3', '4', 'a', 'b'], Object.keys(o2)); + assertEquals([true, false, undefined, "", 'a', 'b'], Object.values(o2)); + o2[1] = 'a'; + o2[2] = 'b'; + assertEquals(['1', '2', '3', '4', 'a', 'b'], Object.keys(o2)); + assertEquals(['a', 'b', undefined, "", 'a', 'b'], Object.values(o2)); + var o3 = { __proto__:null, 1: true, @@ -288,7 +373,9 @@ function TestNonNumberElementValues() { 3: undefined, 4: "" }; + %HeapObjectVerify(o3); assertEquals(['1', '2', '3', '4'], Object.keys(o3)); + var o4 = { __proto__:null, 1: true, @@ -298,10 +385,12 @@ function TestNonNumberElementValues() { a: 'a', b: 'b' }; + %HeapObjectVerify(o4); assertEquals(['1', '2', '3', '4', 'a', 'b'], Object.keys(o4)); } TestNonNumberElementValues(); TestNonNumberElementValues(); +TestNonNumberElementValues(); %OptimizeFunctionOnNextCall(TestNonNumberElementValues); TestNonNumberElementValues(); @@ -1464,16 +1553,19 @@ TestSlowLiteralOptimized(); } } let object = createObject(); - assertFalse(%HasFastProperties(object )); + %HeapObjectVerify(object); + assertFalse(%HasFastProperties(object)); assertEquals(Object.getPrototypeOf(object ), null); let keys = Object.keys(object); // modify original object object['new_property'] = {}; object[1] = 12; + %HeapObjectVerify(object); let object2 = createObject(); - assertFalse(object === object2 ); - assertFalse(%HasFastProperties(object2 )); + %HeapObjectVerify(object2); + assertFalse(object2 === object); + assertFalse(%HasFastProperties(object2)); assertEquals(Object.getPrototypeOf(object2), null); assertEquals(keys, Object.keys(object2)); })(); diff --git a/deps/v8/test/mjsunit/object-seal.js b/deps/v8/test/mjsunit/object-seal.js index f685b41927..1a3a555535 100644 --- a/deps/v8/test/mjsunit/object-seal.js +++ b/deps/v8/test/mjsunit/object-seal.js @@ -28,7 +28,7 @@ // Tests the Object.seal and Object.isSealed methods - ES 19.1.2.17 and // ES 19.1.2.13 -// Flags: --allow-natives-syntax --opt --noalways-opt +// Flags: --allow-natives-syntax --opt --noalways-opt --no-stress-fullcodegen // Test that we return obj if non-object is passed as argument var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test")); diff --git a/deps/v8/test/mjsunit/opt-elements-kind.js b/deps/v8/test/mjsunit/opt-elements-kind.js index 472f6eddf7..8634366a7c 100644 --- a/deps/v8/test/mjsunit/opt-elements-kind.js +++ b/deps/v8/test/mjsunit/opt-elements-kind.js @@ -49,9 +49,9 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; if (%HasFixedInt8Elements(obj)) { diff --git a/deps/v8/test/mjsunit/optimized-foreach-holey-2.js b/deps/v8/test/mjsunit/optimized-foreach-holey-2.js new file mode 100644 index 0000000000..6779377dbb --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-foreach-holey-2.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +(function() { + var result = 0; + var proto_set_func = function(p, s) { + %NeverOptimizeFunction(proto_set_func); + if (s) { + p[0] = 1; + } + } + var f = function(s) { + var b = [,,]; + proto_set_func(b.__proto__, s); + b[1] = 0; + b[2] = 2; + var sum = function(v,i,o) { + result += v; + }; + b.forEach(sum); + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); + f(true); + f(); + assertEquals(12, result); +})(); diff --git a/deps/v8/test/mjsunit/optimized-foreach-holey-3.js b/deps/v8/test/mjsunit/optimized-foreach-holey-3.js new file mode 100644 index 0000000000..a397a0ab08 --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-foreach-holey-3.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +(function() { + var result = 0; + var proto_set_func = function(p, s) { + %NeverOptimizeFunction(proto_set_func); + if (s) { + p[0] = 1; + } + } + var f = function(s) { + var b = [,,]; + b[1] = 0; + b[2] = 2; + var sum = function(v,i,o) { + if (i==1) proto_set_func(b.__proto__, s); + result += v; + }; + b.forEach(sum); + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); + f(true); + f(); + assertEquals(11, result); +})(); diff --git a/deps/v8/test/mjsunit/optimized-foreach-holey.js b/deps/v8/test/mjsunit/optimized-foreach-holey.js new file mode 100644 index 0000000000..90145bfe5d --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-foreach-holey.js @@ -0,0 +1,25 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +(function() { + var result = 0; + var f = function() { + var b = [,,]; + b[0] = 0; + b[2] = 2; + var sum = function(v,i,o) { + result += i; + }; + b.forEach(sum); + } + f(); + f(); + %OptimizeFunctionOnNextCall(f); + f(); + f(); + f(); + assertEquals(10, result); +})(); diff --git a/deps/v8/test/mjsunit/optimized-foreach.js b/deps/v8/test/mjsunit/optimized-foreach.js new file mode 100644 index 0000000000..a6e4341420 --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-foreach.js @@ -0,0 +1,313 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +var a = [0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,0,0]; +var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; +var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; + +// Unknown field access leads to soft-deopt unrelated to forEach, should still +// lead to correct result. +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var sum = function(v,i,o) { + result += v; + if (i == 13 && deopt) { + a.abc = 25; + } + } + a.forEach(sum); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(1500, result); +})(); + +// Length change detected during loop, must cause properly handled eager deopt. +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var sum = function(v,i,o) { + result += v; + a.length = (i == 13 && deopt) ? 25 : 27; + } + a.forEach(sum); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(1500, result); +})(); + +// Escape analyzed array +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var a_noescape = [0,1,2,3,4,5]; + var sum = function(v,i,o) { + result += v; + if (i == 13 && deopt) { + a_noescape.length = 25; + } + } + a_noescape.forEach(sum); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(75, result); +})(); + +// Escape analyzed array where sum function isn't inlined, forcing a lazy deopt +// with GC that relies on the stashed-away return result fro the lazy deopt +// being properly stored in a place on the stack that gets GC'ed. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var sum = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + %DeoptimizeFunction(lazyDeopt); + } + gc(); gc(); + }; + %NeverOptimizeFunction(sum); + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); +})(); + +// Lazy deopt from runtime call from inlined callback function. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var sum = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + } + } + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +// Lazy deopt from runtime call from non-inline callback function. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var sum = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + } + }; + %NeverOptimizeFunction(sum); + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var sum = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + gc(); + gc(); + gc(); + } + } + c.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +// Call to a.forEach is done inside a try-catch block and the callback function +// being called actually throws. +(function() { + var caught = false; + var result = 0; + var lazyDeopt = function(deopt) { + var sum = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + throw("a"); + } + } + try { + c.forEach(sum); + } catch (e) { + caught = true; + } + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + assertDoesNotThrow(lazyDeopt.bind(this, true)); + assertTrue(caught); + lazyDeopt(); +})(); + +// Call to a.forEach is done inside a try-catch block and the callback function +// being called actually throws, but the callback is not inlined. +(function() { + var caught = false; + var result = 0; + var lazyDeopt = function(deopt) { + var sum = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + throw("a"); + } + }; + %NeverOptimizeFunction(sum); + try { + c.forEach(sum); + } catch (e) { + caught = true; + } + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + assertDoesNotThrow(lazyDeopt.bind(this, true)); + assertTrue(caught); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.forEach/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var sum = function(v,i,o) { + result += v; + if (i == 1) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + }; + var o = [1,2,3]; + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.forEach/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var sum = function(v,i,o) { + result += v; + if (i == 1) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + }; + %NeverOptimizeFunction(sum); + var o = [1,2,3]; + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.forEach/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var sum = function(v,i,o) { + result += v; + if (i == 1) { + %DeoptimizeNow(); + } else if (i == 2) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + }; + var o = [1,2,3]; + b.forEach(sum); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.forEach/; + var a = [1,2,3]; + var result = 0; + var lazyDeopt = function() { + var sum = function(v,i,o) { + result += i; + if (i == 1) { + %DeoptimizeFunction(lazyDeopt); + throw new Error(); + } + }; + a.forEach(sum); + } + assertThrows(() => lazyDeopt()); + assertThrows(() => lazyDeopt()); + try { + lazyDeopt(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } + %OptimizeFunctionOnNextCall(lazyDeopt); + try { + lazyDeopt(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } +})(); diff --git a/deps/v8/test/mjsunit/optimized-map.js b/deps/v8/test/mjsunit/optimized-map.js new file mode 100644 index 0000000000..c53d77b61b --- /dev/null +++ b/deps/v8/test/mjsunit/optimized-map.js @@ -0,0 +1,379 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins +// Flags: --opt --no-always-opt --no-stress-fullcodegen + +var a = [0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,0,0]; +var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; +var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; + +// Unknown field access leads to soft-deopt unrelated to map, should still +// lead to correct result. +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var callback = function(v,i,o) { + result += v; + if (i == 13 && deopt) { + a.abc = 25; + } + return v; + } + a.map(callback); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(1500, result); +})(); + +// Length change detected during loop, must cause properly handled eager deopt. +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var callback = function(v,i,o) { + result += v; + a.length = (i == 13 && deopt) ? 25 : 27; + return v; + } + a.map(callback); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(1500, result); +})(); + +// Escape analyzed array +(function() { + var result = 0; + var eagerDeoptInCalled = function(deopt) { + var a_noescape = [0,1,2,3,4,5]; + var callback = function(v,i,o) { + result += v; + if (i == 13 && deopt) { + a_noescape.length = 25; + } + return v; + } + a_noescape.map(callback); + } + eagerDeoptInCalled(); + eagerDeoptInCalled(); + %OptimizeFunctionOnNextCall(eagerDeoptInCalled); + eagerDeoptInCalled(); + eagerDeoptInCalled(true); + eagerDeoptInCalled(); + assertEquals(75, result); +})(); + +// Escape analyzed array where callback function isn't inlined, forcing a lazy +// deopt with GC that relies on the stashed-away return result fro the lazy +// deopt being properly stored in a place on the stack that gets GC'ed. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var callback = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + %DeoptimizeFunction(lazyDeopt); + } + gc(); gc(); + return v; + }; + %NeverOptimizeFunction(callback); + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); +})(); + +// Lazy deopt from runtime call from inlined callback function. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var callback = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + } + return v; + } + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +// Lazy deopt from runtime call from non-inline callback function. +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var callback = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + } + return v; + }; + %NeverOptimizeFunction(callback); + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +(function() { + var result = 0; + var lazyDeopt = function(deopt) { + var callback = function(v,i,o) { + result += i; + if (i == 13 && deopt) { + %DeoptimizeNow(); + gc(); + gc(); + gc(); + } + return v; + } + c.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + lazyDeopt(true); + lazyDeopt(); + assertEquals(1500, result); +})(); + +// Call to a.map is done inside a try-catch block and the callback function +// being called actually throws. +(function() { + var caught = false; + var result = 0; + var lazyDeopt = function(deopt) { + var callback = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + throw("a"); + } + return v; + } + try { + c.map(callback); + } catch (e) { + caught = true; + } + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + assertDoesNotThrow(lazyDeopt.bind(this, true)); + assertTrue(caught); + lazyDeopt(); +})(); + +// Call to a.map is done inside a try-catch block and the callback function +// being called actually throws, but the callback is not inlined. +(function() { + var caught = false; + var result = 0; + var lazyDeopt = function(deopt) { + var callback = function(v,i,o) { + result += i; + if (i == 1 && deopt) { + throw("a"); + } + return v; + }; + %NeverOptimizeFunction(callback); + try { + c.map(callback); + } catch (e) { + caught = true; + } + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); + assertDoesNotThrow(lazyDeopt.bind(this, true)); + assertTrue(caught); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.map/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var callback = function(v,i,o) { + result += v; + if (i == 1) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + return v; + }; + var o = [1,2,3]; + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.map/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var callback = function(v,i,o) { + result += v; + if (i == 1) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + return v; + }; + %NeverOptimizeFunction(callback); + var o = [1,2,3]; + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.map/; + var lazyDeopt = function(deopt) { + var b = [1,2,3]; + var result = 0; + var callback = function(v,i,o) { + result += v; + if (i == 1) { + %DeoptimizeNow(); + } else if (i == 2) { + var e = new Error(); + assertTrue(re.exec(e.stack) !== null); + } + return v; + }; + var o = [1,2,3]; + b.map(callback); + } + lazyDeopt(); + lazyDeopt(); + %OptimizeFunctionOnNextCall(lazyDeopt); + lazyDeopt(); +})(); + +(function() { + var re = /Array\.map/; + var a = [1,2,3]; + var result = 0; + var lazyDeopt = function() { + var callback = function(v,i,o) { + result += i; + if (i == 1) { + %DeoptimizeFunction(lazyDeopt); + throw new Error(); + } + return v; + }; + a.map(callback); + } + assertThrows(() => lazyDeopt()); + assertThrows(() => lazyDeopt()); + try { + lazyDeopt(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } + %OptimizeFunctionOnNextCall(lazyDeopt); + try { + lazyDeopt(); + } catch (e) { + assertTrue(re.exec(e.stack) !== null); + } +})(); + +// Verify that we remain in optimized code despite transitions in the output +// array. +(function() { + var result = 0; + var to_double = function() { + var callback = function(v,i,o) { + result += v; + if (i < 5) { + // First transition the output array to PACKED_DOUBLE_ELEMENTS. + return v + 0.5; + } else if (i < 10) { + // Then return smi values and make sure they can live in the double + // array. + return v; + } else { + // Later, to PACKED_ELEMENTS. + return v + 'hello'; + } + } + return c.map(callback); + } + to_double(); + to_double(); + %OptimizeFunctionOnNextCall(to_double); + var output = to_double(); + assertEquals(975, result); + assertEquals("11hello", output[10]); + assertOptimized(to_double); +})(); + +// Messing with the Array species constructor causes deoptimization. +(function() { + var result = 0; + var a = [1,2,3]; + var species_breakage = function() { + var callback = function(v,i,o) { + result += v; + return v; + } + a.map(callback); + } + species_breakage(); + species_breakage(); + %OptimizeFunctionOnNextCall(species_breakage); + species_breakage(); + a.constructor = {}; + a.constructor[Symbol.species] = function() {}; + species_breakage(); + assertUnoptimized(species_breakage); + assertEquals(24, result); +})(); diff --git a/deps/v8/test/mjsunit/osr-elements-kind.js b/deps/v8/test/mjsunit/osr-elements-kind.js index 3f27bf2295..d68da9b61f 100644 --- a/deps/v8/test/mjsunit/osr-elements-kind.js +++ b/deps/v8/test/mjsunit/osr-elements-kind.js @@ -49,9 +49,9 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; if (%HasFixedInt8Elements(obj)) { diff --git a/deps/v8/test/mjsunit/packed-elements.js b/deps/v8/test/mjsunit/packed-elements.js index 3ce92d1186..d421c51f0d 100644 --- a/deps/v8/test/mjsunit/packed-elements.js +++ b/deps/v8/test/mjsunit/packed-elements.js @@ -29,62 +29,62 @@ function test1() { var a = Array(8); - assertTrue(%HasFastSmiOrObjectElements(a)); - assertTrue(%HasFastHoleyElements(a)); + assertTrue(%HasSmiOrObjectElements(a)); + assertTrue(%HasHoleyElements(a)); } function test2() { var a = Array(); - assertTrue(%HasFastSmiOrObjectElements(a)); - assertFalse(%HasFastHoleyElements(a)); + assertTrue(%HasSmiOrObjectElements(a)); + assertFalse(%HasHoleyElements(a)); } function test3() { var a = Array(1,2,3,4,5,6,7); - assertTrue(%HasFastSmiOrObjectElements(a)); - assertFalse(%HasFastHoleyElements(a)); + assertTrue(%HasSmiOrObjectElements(a)); + assertFalse(%HasHoleyElements(a)); } function test4() { var a = [1, 2, 3, 4]; - assertTrue(%HasFastSmiElements(a)); - assertFalse(%HasFastHoleyElements(a)); + assertTrue(%HasSmiElements(a)); + assertFalse(%HasHoleyElements(a)); var b = [1, 2,, 4]; - assertTrue(%HasFastSmiElements(b)); - assertTrue(%HasFastHoleyElements(b)); + assertTrue(%HasSmiElements(b)); + assertTrue(%HasHoleyElements(b)); } function test5() { var a = [1, 2, 3, 4.5]; - assertTrue(%HasFastDoubleElements(a)); - assertFalse(%HasFastHoleyElements(a)); + assertTrue(%HasDoubleElements(a)); + assertFalse(%HasHoleyElements(a)); var b = [1,, 3.5, 4]; - assertTrue(%HasFastDoubleElements(b)); - assertTrue(%HasFastHoleyElements(b)); + assertTrue(%HasDoubleElements(b)); + assertTrue(%HasHoleyElements(b)); var c = [1, 3.5,, 4]; - assertTrue(%HasFastDoubleElements(c)); - assertTrue(%HasFastHoleyElements(c)); + assertTrue(%HasDoubleElements(c)); + assertTrue(%HasHoleyElements(c)); } function test6() { var x = new Object(); var a = [1, 2, 3.5, x]; - assertTrue(%HasFastObjectElements(a)); - assertFalse(%HasFastHoleyElements(a)); + assertTrue(%HasObjectElements(a)); + assertFalse(%HasHoleyElements(a)); assertEquals(1, a[0]); assertEquals(2, a[1]); assertEquals(3.5, a[2]); assertEquals(x, a[3]); var b = [1,, 3.5, x]; - assertTrue(%HasFastObjectElements(b)); - assertTrue(%HasFastHoleyElements(b)); + assertTrue(%HasObjectElements(b)); + assertTrue(%HasHoleyElements(b)); assertEquals(1, b[0]); assertEquals(undefined, b[1]); assertEquals(3.5, b[2]); assertEquals(x, b[3]); var c = [1, 3.5, x,,]; - assertTrue(%HasFastObjectElements(c)); - assertTrue(%HasFastHoleyElements(c)); + assertTrue(%HasObjectElements(c)); + assertTrue(%HasHoleyElements(c)); assertEquals(1, c[0]); assertEquals(3.5, c[1]); assertEquals(x, c[2]); diff --git a/deps/v8/test/mjsunit/parallel-optimize-disabled.js b/deps/v8/test/mjsunit/parallel-optimize-disabled.js index f2a10f57ee..bcd7110263 100644 --- a/deps/v8/test/mjsunit/parallel-optimize-disabled.js +++ b/deps/v8/test/mjsunit/parallel-optimize-disabled.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --nodead-code-elimination --concurrent-recompilation +// Flags: --concurrent-recompilation // Flags: --allow-natives-syntax --no-always-opt if (!%IsConcurrentRecompilationSupported()) { diff --git a/deps/v8/test/mjsunit/regress/regress-1156.js b/deps/v8/test/mjsunit/regress/regress-1156.js index 8ec7f817de..344657816c 100644 --- a/deps/v8/test/mjsunit/regress/regress-1156.js +++ b/deps/v8/test/mjsunit/regress/regress-1156.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nouse-inlining +// Flags: --allow-natives-syntax // Test that we do not crash we invoke builtins from optimized code that // is then deoptimized. diff --git a/deps/v8/test/mjsunit/regress/regress-1849.js b/deps/v8/test/mjsunit/regress/regress-1849.js index 5b8fc50f31..d12c0c6b39 100644 --- a/deps/v8/test/mjsunit/regress/regress-1849.js +++ b/deps/v8/test/mjsunit/regress/regress-1849.js @@ -31,9 +31,9 @@ var count = 1e5; var arr = new Array(count); -assertFalse(%HasFastDoubleElements(arr)); +assertFalse(%HasDoubleElements(arr)); for (var i = 0; i < count; i++) { arr[i] = 0; } -assertFalse(%HasFastDoubleElements(arr)); -assertTrue(%HasFastSmiElements(arr)); +assertFalse(%HasDoubleElements(arr)); +assertTrue(%HasSmiElements(arr)); diff --git a/deps/v8/test/mjsunit/regress/regress-2596.js b/deps/v8/test/mjsunit/regress/regress-2596.js index a1a0af3b00..6500988bd6 100644 --- a/deps/v8/test/mjsunit/regress/regress-2596.js +++ b/deps/v8/test/mjsunit/regress/regress-2596.js @@ -37,7 +37,7 @@ assertTrue(isNaN(doubles[0])); var prototype = [2.5, 2.5]; var array = [3.5, 3.5]; array.__proto__ = prototype; -assertTrue(%HasFastDoubleElements(array)); +assertTrue(%HasDoubleElements(array)); function boom(index) { array[index] = doubles[0]; diff --git a/deps/v8/test/mjsunit/regress/regress-2612.js b/deps/v8/test/mjsunit/regress/regress-2612.js index ac6028f14c..600894845e 100644 --- a/deps/v8/test/mjsunit/regress/regress-2612.js +++ b/deps/v8/test/mjsunit/regress/regress-2612.js @@ -25,8 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --nodead-code-elimination -// Flags: --nofold-constants --nouse-gvn +// Flags: --allow-natives-syntax // Create a function to get a long series of removable simulates. // f() { diff --git a/deps/v8/test/mjsunit/regress/regress-2987.js b/deps/v8/test/mjsunit/regress/regress-2987.js index 7dd727e46c..02927e2227 100644 --- a/deps/v8/test/mjsunit/regress/regress-2987.js +++ b/deps/v8/test/mjsunit/regress/regress-2987.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --dead-code-elimination +// Flags: --allow-natives-syntax // This tests that stores on captured objects are correctly tracked even // when DCE is enabled. We cannot delete simulations of captured objects diff --git a/deps/v8/test/mjsunit/regress/regress-336820.js b/deps/v8/test/mjsunit/regress/regress-336820.js index 9b46629604..f305626596 100644 --- a/deps/v8/test/mjsunit/regress/regress-336820.js +++ b/deps/v8/test/mjsunit/regress/regress-336820.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --max-old-space-size=400 + assertThrows((function() { s = "Hello World!\n"; while (true) { diff --git a/deps/v8/test/mjsunit/regress/regress-346587.js b/deps/v8/test/mjsunit/regress/regress-346587.js index 40e3ac116c..e907002f38 100644 --- a/deps/v8/test/mjsunit/regress/regress-346587.js +++ b/deps/v8/test/mjsunit/regress/regress-346587.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --fold-constants --allow-natives-syntax +// Flags: --allow-natives-syntax function bar(obj) { assertTrue(obj.x === 'baz'); diff --git a/deps/v8/test/mjsunit/regress/regress-347543.js b/deps/v8/test/mjsunit/regress/regress-347543.js index aceddb5f87..ddea23a97f 100644 --- a/deps/v8/test/mjsunit/regress/regress-347543.js +++ b/deps/v8/test/mjsunit/regress/regress-347543.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --debug-code --fold-constants +// Flags: --allow-natives-syntax --debug-code function f(a) { a[5000000] = 256; diff --git a/deps/v8/test/mjsunit/regress/regress-351261.js b/deps/v8/test/mjsunit/regress/regress-351261.js index 48af5442fd..5a634fad12 100644 --- a/deps/v8/test/mjsunit/regress/regress-351261.js +++ b/deps/v8/test/mjsunit/regress/regress-351261.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --fold-constants +// Flags: --allow-natives-syntax function store(a) { a[5000000] = 1; diff --git a/deps/v8/test/mjsunit/regress/regress-3650-1.js b/deps/v8/test/mjsunit/regress/regress-3650-1.js index db91ec2d4e..f5aad4f259 100644 --- a/deps/v8/test/mjsunit/regress/regress-3650-1.js +++ b/deps/v8/test/mjsunit/regress/regress-3650-1.js @@ -3,7 +3,6 @@ // found in the LICENSE file. // Flags: --allow-natives-syntax --deopt-every-n-times=55 -// Flags: --nodead-code-elimination function f(t) { var result = []; diff --git a/deps/v8/test/mjsunit/regress/regress-3650-3.js b/deps/v8/test/mjsunit/regress/regress-3650-3.js index 6195b12441..83a030c806 100644 --- a/deps/v8/test/mjsunit/regress/regress-3650-3.js +++ b/deps/v8/test/mjsunit/regress/regress-3650-3.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt +// Flags: --allow-natives-syntax --opt --no-stress-fullcodegen function foo(a) { for (var d in a) { diff --git a/deps/v8/test/mjsunit/regress/regress-3709.js b/deps/v8/test/mjsunit/regress/regress-3709.js index ecb906a908..9ce484973e 100644 --- a/deps/v8/test/mjsunit/regress/regress-3709.js +++ b/deps/v8/test/mjsunit/regress/regress-3709.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen function getobj() { return { bar : function() { return 0}}; diff --git a/deps/v8/test/mjsunit/regress/regress-385565.js b/deps/v8/test/mjsunit/regress/regress-385565.js index 541e461d96..9004dde90a 100644 --- a/deps/v8/test/mjsunit/regress/regress-385565.js +++ b/deps/v8/test/mjsunit/regress/regress-385565.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --no-always-opt +// Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-fullcodegen var calls = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-4121.js b/deps/v8/test/mjsunit/regress/regress-4121.js index 2ca68be5ab..0f03e79cf2 100644 --- a/deps/v8/test/mjsunit/regress/regress-4121.js +++ b/deps/v8/test/mjsunit/regress/regress-4121.js @@ -7,21 +7,21 @@ function literals_sharing_test(warmup, optimize) { function closure() { // Ensure small array literals start in specific element kind mode. - assertTrue(%HasFastSmiElements([])); - assertTrue(%HasFastSmiElements([1])); - assertTrue(%HasFastSmiElements([1,2])); - assertTrue(%HasFastDoubleElements([1.1])); - assertTrue(%HasFastDoubleElements([1.1,2])); + assertTrue(%HasSmiElements([])); + assertTrue(%HasSmiElements([1])); + assertTrue(%HasSmiElements([1,2])); + assertTrue(%HasDoubleElements([1.1])); + assertTrue(%HasDoubleElements([1.1,2])); var a = [1, 2, 3]; if (warmup) { // Transition elements kind during warmup... - assertTrue(%HasFastSmiElements(a)); + assertTrue(%HasSmiElements(a)); assertEquals(4, a.push(1.3)); } // ... and ensure that the information about transitioning is // propagated to the next closure. - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); }; if (optimize) %OptimizeFunctionOnNextCall(closure); closure(); diff --git a/deps/v8/test/mjsunit/regress/regress-4173.js b/deps/v8/test/mjsunit/regress/regress-4173.js index 72a476bd60..9aa49be701 100644 --- a/deps/v8/test/mjsunit/regress/regress-4173.js +++ b/deps/v8/test/mjsunit/regress/regress-4173.js @@ -16,10 +16,10 @@ var second_smi_array = [2]; var first_object_array = ["first"]; var second_object_array = ["string"]; -assertTrue(%HasFastSmiElements(first_smi_array)); -assertTrue(%HasFastSmiElements(second_smi_array)); -assertTrue(%HasFastObjectElements(first_object_array)); -assertTrue(%HasFastObjectElements(second_object_array)); +assertTrue(%HasSmiElements(first_smi_array)); +assertTrue(%HasSmiElements(second_smi_array)); +assertTrue(%HasObjectElements(first_object_array)); +assertTrue(%HasObjectElements(second_object_array)); // Prepare identical transition chains for smi and object arrays. first_smi_array.foo = 0; @@ -49,8 +49,8 @@ for (var i = 0; i < 3; i++) Loader(second_smi_array); assertEquals("string", Loader(second_object_array)); // Any of the following checks will also fail: -assertTrue(%HasFastObjectElements(second_object_array)); -assertFalse(%HasFastSmiElements(second_object_array)); +assertTrue(%HasObjectElements(second_object_array)); +assertFalse(%HasSmiElements(second_object_array)); assertTrue(%HaveSameMap(first_object_array, second_object_array)); assertFalse(%HaveSameMap(first_smi_array, second_object_array)); diff --git a/deps/v8/test/mjsunit/regress/regress-430201.js b/deps/v8/test/mjsunit/regress/regress-430201.js index b53383e22e..dfd1346a01 100644 --- a/deps/v8/test/mjsunit/regress/regress-430201.js +++ b/deps/v8/test/mjsunit/regress/regress-430201.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc +// Flags: --allow-natives-syntax --expose-gc --nostress-incremental-marking var array_1 = []; diff --git a/deps/v8/test/mjsunit/regress/regress-437765.js b/deps/v8/test/mjsunit/regress/regress-437765.js index 88d5388e6e..698c39d378 100644 --- a/deps/v8/test/mjsunit/regress/regress-437765.js +++ b/deps/v8/test/mjsunit/regress/regress-437765.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --no-fold-constants +// Flags: --allow-natives-syntax function foo(x, y) { return Math.floor(x / y); diff --git a/deps/v8/test/mjsunit/regress/regress-460917.js b/deps/v8/test/mjsunit/regress/regress-460917.js index 68e1b63088..ed64c9cb78 100644 --- a/deps/v8/test/mjsunit/regress/regress-460917.js +++ b/deps/v8/test/mjsunit/regress/regress-460917.js @@ -7,7 +7,7 @@ function boom(a1, a2) { // Do something with a2 that needs a map check (for DOUBLE_ELEMENTS). var s = a2[0]; - // Emit a load that transitions a1 to FAST_ELEMENTS. + // Emit a load that transitions a1 to PACKED_ELEMENTS. var t = a1[0]; // Emit a store to a2 that assumes DOUBLE_ELEMENTS. // The map check is considered redundant and will be eliminated. diff --git a/deps/v8/test/mjsunit/regress/regress-4715.js b/deps/v8/test/mjsunit/regress/regress-4715.js index 0e38cdc27d..33041208e7 100644 --- a/deps/v8/test/mjsunit/regress/regress-4715.js +++ b/deps/v8/test/mjsunit/regress/regress-4715.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --dead-code-elimination --expose-gc +// Flags: --allow-natives-syntax --expose-gc var training = {}; training.a = "nop"; diff --git a/deps/v8/test/mjsunit/regress/regress-500831.js b/deps/v8/test/mjsunit/regress/regress-500831.js index 6d8cfaf05a..3895c4de04 100644 --- a/deps/v8/test/mjsunit/regress/regress-500831.js +++ b/deps/v8/test/mjsunit/regress/regress-500831.js @@ -90,5 +90,5 @@ function __f_6() { equals(__v_6[0]); } __f_6(); -__f_6(); % OptimizeFunctionOnNextCall(__f_6); +__f_6(); %OptimizeFunctionOnNextCall(__f_6); __f_6(); diff --git a/deps/v8/test/mjsunit/regress/regress-5252.js b/deps/v8/test/mjsunit/regress/regress-5252.js index c645416982..91cb53cd13 100644 --- a/deps/v8/test/mjsunit/regress/regress-5252.js +++ b/deps/v8/test/mjsunit/regress/regress-5252.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --ignition-osr +// Flags: --allow-natives-syntax --no-stress-fullcodegen --ignition-osr (function TestNonLoopyLoop() { function f() { diff --git a/deps/v8/test/mjsunit/regress/regress-5262.js b/deps/v8/test/mjsunit/regress/regress-5262.js index 0b54b80623..186ed054e3 100644 --- a/deps/v8/test/mjsunit/regress/regress-5262.js +++ b/deps/v8/test/mjsunit/regress/regress-5262.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --ignition-osr --allow-natives-syntax +// Flags: --no-stress-fullcodegen --ignition-osr --allow-natives-syntax function g() { return 23 } function h() { return 42 } diff --git a/deps/v8/test/mjsunit/regress/regress-543994.js b/deps/v8/test/mjsunit/regress/regress-543994.js index e0d6010287..950a3290ea 100644 --- a/deps/v8/test/mjsunit/regress/regress-543994.js +++ b/deps/v8/test/mjsunit/regress/regress-543994.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flass: --allow-natives-syntax --always-opt --gc-interval=163 --stress-compaction +// Flags: --allow-natives-syntax --always-opt --gc-interval=163 --stress-compaction try { a = f(); } catch(e) { diff --git a/deps/v8/test/mjsunit/regress/regress-5440.js b/deps/v8/test/mjsunit/regress/regress-5440.js index 4182146b1a..2c985e5013 100644 --- a/deps/v8/test/mjsunit/regress/regress-5440.js +++ b/deps/v8/test/mjsunit/regress/regress-5440.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo --always-opt +// Flags: --always-opt // The rightmost cons string is created first, resulting in an empty left part. eval(" " + ("" + "try {;} catch (_) {}")); diff --git a/deps/v8/test/mjsunit/regress/regress-5902.js b/deps/v8/test/mjsunit/regress/regress-5902.js index 69dde4387a..54cb90ee8a 100644 --- a/deps/v8/test/mjsunit/regress/regress-5902.js +++ b/deps/v8/test/mjsunit/regress/regress-5902.js @@ -19,7 +19,7 @@ Object.getOwnPropertyNames(global).forEach(function(name) { var obj = global[name]; // Skip non-receivers. - if (! % IsJSReceiver(obj)) return; + if (!%IsJSReceiver(obj)) return; // Skip non-natives. if (!obj.toString().includes('native')) return; @@ -57,6 +57,6 @@ assertEquals( [ 'Error.prototype', 'EvalError.prototype', 'RangeError.prototype', 'ReferenceError.prototype', - 'SyntaxError.prototype', 'TypeError.prototype', 'URIError.prototype', + 'SyntaxError.prototype', 'TypeError.prototype', 'URIError.prototype' ], log); diff --git a/deps/v8/test/mjsunit/regress/regress-593299.js b/deps/v8/test/mjsunit/regress/regress-593299.js index 255a033f59..ce6af1a1af 100644 --- a/deps/v8/test/mjsunit/regress/regress-593299.js +++ b/deps/v8/test/mjsunit/regress/regress-593299.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-tailcalls - "use strict"; function h(global) { return global.boom(); } diff --git a/deps/v8/test/mjsunit/regress/regress-5943.js b/deps/v8/test/mjsunit/regress/regress-5943.js index f51b1e9999..df21c20e95 100644 --- a/deps/v8/test/mjsunit/regress/regress-5943.js +++ b/deps/v8/test/mjsunit/regress/regress-5943.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax function createHTML() { return '' + '<div><div><di'; diff --git a/deps/v8/test/mjsunit/regress/regress-605470.js b/deps/v8/test/mjsunit/regress/regress-605470.js index 722e8ae130..58e87fc27f 100644 --- a/deps/v8/test/mjsunit/regress/regress-605470.js +++ b/deps/v8/test/mjsunit/regress/regress-605470.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition +// Flags: --no-stress-fullcodegen function function_with_m_args(m) { var source = '(function f() { return; })('; diff --git a/deps/v8/test/mjsunit/regress/regress-618657.js b/deps/v8/test/mjsunit/regress/regress-618657.js index cdec212fe7..9bb98d6e63 100644 --- a/deps/v8/test/mjsunit/regress/regress-618657.js +++ b/deps/v8/test/mjsunit/regress/regress-618657.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition +// Flags: --no-stress-fullcodegen function* foo() { yield 42 } function* goo() { yield 42 } diff --git a/deps/v8/test/mjsunit/regress-6223.js b/deps/v8/test/mjsunit/regress/regress-6223.js index ff1b53f2d3..ff1b53f2d3 100644 --- a/deps/v8/test/mjsunit/regress-6223.js +++ b/deps/v8/test/mjsunit/regress/regress-6223.js diff --git a/deps/v8/test/mjsunit/regress/regress-632289.js b/deps/v8/test/mjsunit/regress/regress-632289.js index 3f3059b2d4..3c982d24b7 100644 --- a/deps/v8/test/mjsunit/regress/regress-632289.js +++ b/deps/v8/test/mjsunit/regress/regress-632289.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --always-opt --allow-natives-syntax +// Flags: --no-stress-fullcodegen --always-opt --allow-natives-syntax try { } catch(e) {; } diff --git a/deps/v8/test/mjsunit/regress/regress-6373.js b/deps/v8/test/mjsunit/regress/regress-6373.js new file mode 100644 index 0000000000..8673e83f22 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6373.js @@ -0,0 +1,24 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var A = {} + +A[Symbol.hasInstance] = function(x) { + %DeoptimizeFunction(foo); + return 1; +} + +var a = {} + +function foo(o) { + return o instanceof A; +} + +foo(a); +foo(a); +assertTrue(foo(a) !== 1); +%OptimizeFunctionOnNextCall(foo); +assertTrue(foo(a) !== 1); diff --git a/deps/v8/test/mjsunit/regress/regress-639270.js b/deps/v8/test/mjsunit/regress/regress-639270.js index 67168e5e53..9a01b8dfeb 100644 --- a/deps/v8/test/mjsunit/regress/regress-639270.js +++ b/deps/v8/test/mjsunit/regress/regress-639270.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --es-staging --ignition --turbo +// Flags: --allow-natives-syntax --es-staging --no-stress-fullcodegen "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-6431.js b/deps/v8/test/mjsunit/regress/regress-6431.js new file mode 100644 index 0000000000..7b99b3fa87 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6431.js @@ -0,0 +1,32 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function TestImportSymbolValue() { + function Module(stdlib, foreign) { + "use asm"; + var x = +foreign.x; + function f() {} + return { f:f }; + } + var foreign = { x : Symbol("boom") }; + assertThrows(() => Module(this, foreign)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestImportMutatingObject() { + function Module(stdlib, foreign) { + "use asm"; + var x = +foreign.x; + var PI = stdlib.Math.PI; + function f() { return +(PI + x) } + return { f:f }; + } + var stdlib = { Math : { PI : Math.PI } }; + var foreign = { x : { valueOf : () => (stdlib.Math.PI = 23, 42) } }; + var m = Module(stdlib, foreign); + assertFalse(%IsAsmWasmCode(Module)); + assertEquals(65, m.f()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-648373-sloppy-arguments-includesValues.js b/deps/v8/test/mjsunit/regress/regress-648373-sloppy-arguments-includesValues.js index d586b80495..ecc58c0b3a 100644 --- a/deps/v8/test/mjsunit/regress/regress-648373-sloppy-arguments-includesValues.js +++ b/deps/v8/test/mjsunit/regress/regress-648373-sloppy-arguments-includesValues.js @@ -8,7 +8,7 @@ function getRandomProperty(v, rand) { var properties = Object.getOwnPropertyName var __v_4 = {}; __v_2 = { - FAST_ELEMENTS() { + PACKED_ELEMENTS() { return { get 0() { } }; diff --git a/deps/v8/test/mjsunit/regress/regress-6509.js b/deps/v8/test/mjsunit/regress/regress-6509.js new file mode 100644 index 0000000000..85a7815a61 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6509.js @@ -0,0 +1,24 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function testSloppy() { + var arrow = (sth = (function f() { + { + function f2() { } + } + })()) => 0; + + assertEquals(0, arrow()); +})(); + +(function testStrict() { + "use strict"; + var arrow = (sth = (function f() { + { + function f2() { } + } + })()) => 0; + + assertEquals(0, arrow()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-653407.js b/deps/v8/test/mjsunit/regress/regress-653407.js index 6dc28a9fd0..cca332c22b 100644 --- a/deps/v8/test/mjsunit/regress/regress-653407.js +++ b/deps/v8/test/mjsunit/regress/regress-653407.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --turbo +// Flags: --allow-natives-syntax --no-stress-fullcodegen // This is to test if 'this' gets correctly initialized when inlining // constructors in turbofan. diff --git a/deps/v8/test/mjsunit/regress/regress-6607-1.js b/deps/v8/test/mjsunit/regress/regress-6607-1.js new file mode 100644 index 0000000000..74b702b228 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6607-1.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --opt + +function get(a, i) { + return a[i]; +} + +get([1,,3], 0); +get([1,,3], 2); +%OptimizeFunctionOnNextCall(get); +get([1,,3], 0); +assertOptimized(get); + +// This unrelated change to the Array.prototype should be fine. +Array.prototype.unrelated = 1; +assertOptimized(get); diff --git a/deps/v8/test/mjsunit/regress/regress-6607-2.js b/deps/v8/test/mjsunit/regress/regress-6607-2.js new file mode 100644 index 0000000000..cfb0009845 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6607-2.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --opt + +function get(a, i) { + return a[i]; +} + +get([1,,3], 0); +get([1,,3], 2); +%OptimizeFunctionOnNextCall(get); +get([1,,3], 0); +assertOptimized(get); + +// This unrelated change to the Object.prototype should be fine. +Object.prototype.unrelated = 1; +assertOptimized(get); diff --git a/deps/v8/test/mjsunit/regress/regress-6657.js b/deps/v8/test/mjsunit/regress/regress-6657.js new file mode 100644 index 0000000000..49f8e649bd --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-6657.js @@ -0,0 +1,38 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function TestArrayNonEmptySpecies() { + class MyArray extends Array { + constructor() { return [1, 2, 3]; } + } + var a = [5, 4]; + a.__proto__ = MyArray.prototype; + var o = a.filter(() => true); + assertEquals([5, 4, 3], o); + assertEquals(3, o.length); +})(); + +(function TestArrayLeakingSpeciesInsertInCallback() { + var my_array = []; + class MyArray extends Array { + constructor() { return my_array; } + } + var a = [5, 4]; + a.__proto__ = MyArray.prototype; + var o = a.filter(() => (my_array[2] = 3, true)); + assertEquals([5, 4, 3], o); + assertEquals(3, o.length); +})(); + +(function TestArrayLeakingSpeciesRemoveInCallback() { + var my_array = []; + class MyArray extends Array { + constructor() { return my_array; } + } + var a = [5, 4, 3, 2, 1]; + a.__proto__ = MyArray.prototype; + var o = a.filter(() => (my_array.length = 0, true)); + assertEquals([,,,,1], o); + assertEquals(5, o.length); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-677685.js b/deps/v8/test/mjsunit/regress/regress-677685.js index c0c0ec0d08..bb7754c1af 100644 --- a/deps/v8/test/mjsunit/regress/regress-677685.js +++ b/deps/v8/test/mjsunit/regress/regress-677685.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --stack-size=100 +// Flags: --no-stress-fullcodegen --stack-size=100 function Module(stdlib) { "use asm"; diff --git a/deps/v8/test/mjsunit/regress/regress-678917.js b/deps/v8/test/mjsunit/regress/regress-678917.js index accb515623..cb88ead5ba 100644 --- a/deps/v8/test/mjsunit/regress/regress-678917.js +++ b/deps/v8/test/mjsunit/regress/regress-678917.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: --max-old-space-size=400 + s1 = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; s1 += s1; s1 += s1; diff --git a/deps/v8/test/mjsunit/regress/regress-682349.js b/deps/v8/test/mjsunit/regress/regress-682349.js index 162774fa0b..d94e0691d6 100644 --- a/deps/v8/test/mjsunit/regress/regress-682349.js +++ b/deps/v8/test/mjsunit/regress/regress-682349.js @@ -6,7 +6,7 @@ let success = false; function f() { - success = (f.caller.arguments === null); + success = (f.caller === null); } Promise.resolve().then(f); %RunMicrotasks(); diff --git a/deps/v8/test/mjsunit/regress/regress-696651.js b/deps/v8/test/mjsunit/regress/regress-696651.js index 66a474d8f5..650c9787f6 100644 --- a/deps/v8/test/mjsunit/regress/regress-696651.js +++ b/deps/v8/test/mjsunit/regress/regress-696651.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax function get_a() { return "aaaaaaaaaaaaaa"; } function get_b() { return "bbbbbbbbbbbbbb"; } diff --git a/deps/v8/test/mjsunit/regress/regress-698790.js b/deps/v8/test/mjsunit/regress/regress-698790.js index e20a77189a..8791cb5d17 100644 --- a/deps/v8/test/mjsunit/regress/regress-698790.js +++ b/deps/v8/test/mjsunit/regress/regress-698790.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax // Call RegExp constructor with a cons string. diff --git a/deps/v8/test/mjsunit/regress-707410.js b/deps/v8/test/mjsunit/regress/regress-707410.js index 4bacf8c670..4bacf8c670 100644 --- a/deps/v8/test/mjsunit/regress-707410.js +++ b/deps/v8/test/mjsunit/regress/regress-707410.js diff --git a/deps/v8/test/mjsunit/regress/regress-720247.js b/deps/v8/test/mjsunit/regress/regress-720247.js new file mode 100644 index 0000000000..571e7e47dc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-720247.js @@ -0,0 +1,7 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +assertEquals('function', typeof (function() { + return eval('with ({a: 1}) { function a() {} }; a') +})()); diff --git a/deps/v8/test/mjsunit/regress/regress-723366.js b/deps/v8/test/mjsunit/regress/regress-723366.js new file mode 100644 index 0000000000..ba1915db98 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-723366.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var o = {foo: 0, 0: 0, 2: 2, 3: 3}; +o.__defineSetter__("1", function(v) { this.foo = 0.1; }); + +for(var i = 0; i < 4; i++) { + switch (i) { + case 0: o.p1 = 0; break; + case 1: o.p2 = 0; break; + } + o[i] = i; +} diff --git a/deps/v8/test/mjsunit/regress/regress-726625.js b/deps/v8/test/mjsunit/regress/regress-726625.js new file mode 100644 index 0000000000..6a368f4118 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-726625.js @@ -0,0 +1,6 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function abc() { return; } +assertThrows("abc" + String.fromCharCode(65534) + "(1)"); diff --git a/deps/v8/test/mjsunit/regress/regress-727662.js b/deps/v8/test/mjsunit/regress/regress-727662.js new file mode 100644 index 0000000000..62b53b4187 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-727662.js @@ -0,0 +1,22 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc + +(function() { + function thingo(i, b) { + var s = b ? "ac" : "abcd"; + i = i >>> 0; + if (i < s.length) { + var c = s.charCodeAt(i); + gc(); + return c; + } + } + thingo(0, true); + thingo(0, true); + %OptimizeFunctionOnNextCall(thingo); + thingo(0, true); + +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-729671.js b/deps/v8/test/mjsunit/regress/regress-729671.js new file mode 100644 index 0000000000..90791c1307 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-729671.js @@ -0,0 +1,6 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var o = { 0: 11, 1: 9}; +assertThrows(() => JSON.parse('[0,0]', function() { this[1] = o; }), RangeError); diff --git a/deps/v8/test/mjsunit/regress/regress-730254.js b/deps/v8/test/mjsunit/regress/regress-730254.js new file mode 100644 index 0000000000..2db49ce4bd --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-730254.js @@ -0,0 +1,37 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --allow-natives-syntax --opt --no-always-opt + +var __v_0 = {}; +__v_0 = new Map(); +function __f_0() { + __v_0[0] --; +} +__f_0(); +%OptimizeFunctionOnNextCall(__f_0); +__f_0(); diff --git a/deps/v8/test/mjsunit/regress/regress-732836.js b/deps/v8/test/mjsunit/regress/regress-732836.js new file mode 100644 index 0000000000..20e852c317 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-732836.js @@ -0,0 +1,11 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function boom() { + var args = []; + for (var i = 0; i < 125000; i++) + args.push(1.1); + return Array.apply(Array, args); +} +var array = boom(); diff --git a/deps/v8/test/mjsunit/regress/regress-733059.js b/deps/v8/test/mjsunit/regress/regress-733059.js new file mode 100644 index 0000000000..1da8413c70 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-733059.js @@ -0,0 +1,25 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc --enable-slow-asserts + +a = new Proxy([], { + defineProperty() { + b.length = 1; gc(); + return Object.defineProperty.apply(this, arguments); + } +}); + +class MyArray extends Array { + static get[Symbol.species](){ + return function() { + return a; + } + }; +} + +b = new MyArray(65535); +b[1] = 0.1; +c = Array.prototype.concat.call(b); +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-740694.js b/deps/v8/test/mjsunit/regress/regress-740694.js new file mode 100644 index 0000000000..f07eb1b3a7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-740694.js @@ -0,0 +1,22 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony --allow-natives-syntax --stack-size=100 + +function __f_0() { + try { + return __f_0(); + } catch(e) { + return import('no-such-file'); + } +} + +var done = false; +var error; +var promise = __f_0(); +promise.then(assertUnreachable, + err => { done = true; error = err }); +%RunMicrotasks(); +assertTrue(error.startsWith('Error reading')); +assertTrue(done); diff --git a/deps/v8/test/mjsunit/regress/regress-740784.js b/deps/v8/test/mjsunit/regress/regress-740784.js new file mode 100644 index 0000000000..920f9f1d43 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-740784.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc --turbo-inline-array-builtins + +"".stack;;var isNeverOptimize;var isAlwaysOptimize;var isInterpreted;var isOptimized;var isCrankshafted;var isTurboFanned;var failWithMessage;(function(){{;} +function PrettyPrint(){switch(typeof value){case"string":return JSON.stringify();case"number":if(1/value<0);case"object":if(value===null);switch(objectClass){case"Number":case"String":case"Boolean":case"Date":return objectClass+"("+PrettyPrint();return objectClass+"(["+joined+"])";case"Object":break;default:return objectClass+"()";} +var name=value.constructor.name;if(name)return name+"()";return"Object()";default:return"-- unknown value --";}} +function fail(){var message="Fail"+"ure";if(name_opt){message+=" ("+name_opt+")";} +return true;} +assertSame=function assertSame(){if(found===expected){return;}else if((expected!==expected)&&(found!==found)){return;} +};assertThrows=function assertThrows(code){try{if(typeof code==='function'){code();}else{;}}catch(e){if(typeof type_opt==='function'){;}else if(type_opt!==void 0){;} +return;} +;;} +isTurboFanned=function isTurboFanned(){opt_status&V8OptimizationStatus.kOptimized!==0;}})(); +function __isPropertyOfType(){let desc;try{;}catch(e){return false;} +return false;return typeof type==='undefined'||typeof desc.value===type;} +function __getProperties(obj){if(typeof obj==="undefined"||obj===null) +return[];let properties=[];for(let name of Object.getOwnPropertyNames(obj)){ +properties.push(name);} +let proto=Object.getPrototypeOf(obj);while(proto&&proto!=Object.prototype){Object.getOwnPropertyNames(proto).forEach(name=>{if(name!=='constructor'){__isPropertyOfType() +;}});proto=Object.getPrototypeOf(proto);} +return properties;} +function*__getObjects(root=this,level=0){if(level>4) +return;let obj_names=__getProperties(root);for(let obj_name of obj_names){let obj=root[obj_name];if(obj===root) +continue;yield obj;yield*__getObjects();}} +function __getRandomObject(){let objects=[];for(let obj of __getObjects()){;} +return objects[seed%objects.length];} +for (var __v_0 = 0; __v_0 < 2000; __v_0++) { + Object.prototype['X'+__v_0] = true; +} + assertThrows(function() { ; try { __getRandomObject(); } catch(e) {; };try {; } catch(e) {; } }); diff --git a/deps/v8/test/mjsunit/regress/regress-743622.js b/deps/v8/test/mjsunit/regress/regress-743622.js new file mode 100644 index 0000000000..60512585c2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-743622.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --validate-asm + +function Module(stdlib, foreign, heap) { + "use asm"; + var a = stdlib.Math.PI; + function f() { return a } + return { f:f }; +} +Module.length diff --git a/deps/v8/test/mjsunit/regress/regress-744292.js b/deps/v8/test/mjsunit/regress/regress-744292.js new file mode 100644 index 0000000000..02c77cac20 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-744292.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Flags: --harmony-dynamic-import + +__v_1 = { +}; +function __f_8() { + try { + __f_8(); + } catch(e) { + import(__v_1); + } +} +__f_8(); diff --git a/deps/v8/test/mjsunit/regress/regress-747075.js b/deps/v8/test/mjsunit/regress/regress-747075.js new file mode 100644 index 0000000000..3b5116acd0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-747075.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +r = [ + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 +]; + + +for (i = -1; i < 100000; i++) { + r2 = r.map(function(y) {return y/64} ); + assertTrue(r2[0] < 1); +} diff --git a/deps/v8/test/mjsunit/regress/regress-747825.js b/deps/v8/test/mjsunit/regress/regress-747825.js new file mode 100644 index 0000000000..f61693e2cd --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-747825.js @@ -0,0 +1,27 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var g = 0; +g = function() {} + +function f() { + var r = /[abc]/i; // Optimized out. + g(r); +} + +f(); f(); %OptimizeFunctionOnNextCall(f); // Warm-up. + +var re; +g = function(r) { re = r; } +f(); // Lazy deopt is forced here. + +assertNotEquals(undefined, re); +assertEquals("[abc]", re.source); +assertEquals("i", re.flags); +assertEquals(0, re.lastIndex); +assertArrayEquals(["a"], re.exec("a")); +assertArrayEquals(["A"], re.exec("A")); +assertNull(re.exec("d")); diff --git a/deps/v8/test/mjsunit/regress/regress-91013.js b/deps/v8/test/mjsunit/regress/regress-91013.js index c61e2b1eee..cec3322ee0 100644 --- a/deps/v8/test/mjsunit/regress/regress-91013.js +++ b/deps/v8/test/mjsunit/regress/regress-91013.js @@ -37,7 +37,7 @@ for (var j = 0; j < i; j++) { a[j] = 0.5; } -assertTrue(%HasFastDoubleElements(a)); +assertTrue(%HasDoubleElements(a)); // Store some smis into it. for (var j = 0; j < 10; j++) { diff --git a/deps/v8/test/mjsunit/regress/regress-95113.js b/deps/v8/test/mjsunit/regress/regress-95113.js index aa526ae0b9..9d5a631465 100644 --- a/deps/v8/test/mjsunit/regress/regress-95113.js +++ b/deps/v8/test/mjsunit/regress/regress-95113.js @@ -30,18 +30,18 @@ function get_double_array() { var a = new Array(100000); var i = 0; - while (!%HasFastDoubleElements(a)) { + while (!%HasDoubleElements(a)) { a[i] = i + 0.1; i += 1; } - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); a.length = 1; a[0] = 1.5; a.length = 2; a[1] = 2.5; assertEquals(a[0], 1.5); assertEquals(a[1], 2.5); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); return a; } diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-122271.js b/deps/v8/test/mjsunit/regress/regress-crbug-122271.js index 8ae91e857a..8fb99230be 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-122271.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-122271.js @@ -39,11 +39,11 @@ function foo(array) { array.foo = "bar"; } -assertTrue(%HasFastSmiElements(a)); -assertTrue(%HasFastObjectElements(b)); +assertTrue(%HasSmiElements(a)); +assertTrue(%HasObjectElements(b)); foo(a); foo(b); -assertTrue(%HasFastSmiElements(a)); -assertTrue(%HasFastObjectElements(b)); +assertTrue(%HasSmiElements(a)); +assertTrue(%HasObjectElements(b)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-233737.js b/deps/v8/test/mjsunit/regress/regress-crbug-233737.js index 38b44e056f..df8aa15c93 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-233737.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-233737.js @@ -29,8 +29,8 @@ var a = new Array(2); a[0] = 1; -assertTrue(%HasFastSmiElements(a)); -assertTrue(%HasFastHoleyElements(a)); +assertTrue(%HasSmiElements(a)); +assertTrue(%HasHoleyElements(a)); function hole(i) { return a[i] << 0; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-245480.js b/deps/v8/test/mjsunit/regress/regress-crbug-245480.js index 07e46f8637..b8557c9d91 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-245480.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-245480.js @@ -28,7 +28,7 @@ // Flags: --allow-natives-syntax --expose-gc --noalways-opt function isHoley(obj) { - if (%HasFastHoleyElements(obj)) return true; + if (%HasHoleyElements(obj)) return true; return false; } @@ -36,16 +36,12 @@ function assertHoley(obj, name_opt) { assertEquals(true, isHoley(obj), name_opt); } -function assertNotHoley(obj, name_opt) { - assertEquals(false, isHoley(obj), name_opt); -} - function create_array(arg) { return new Array(arg); } obj = create_array(0); -assertNotHoley(obj); +assertHoley(obj); create_array(0); %OptimizeFunctionOnNextCall(create_array); obj = create_array(10); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-309623.js b/deps/v8/test/mjsunit/regress/regress-crbug-309623.js index 12473c7947..c77611af46 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-309623.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-309623.js @@ -33,7 +33,7 @@ u[1] = 0xEE6B2800; var a = [0, 1, 2]; a[0] = 0; // Kill the COW. -assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasSmiElements(a)); function foo(i) { a[0] = u[i]; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-349465.js b/deps/v8/test/mjsunit/regress/regress-crbug-349465.js index 335ea1e1a4..21887504cc 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-349465.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-349465.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --debug-code --use-gvn +// Flags: --allow-natives-syntax --debug-code function f(a, base) { a[base] = 1; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-351320.js b/deps/v8/test/mjsunit/regress/regress-crbug-351320.js index 24fc641797..3ffef0ba82 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-351320.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-351320.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --fold-constants +// Flags: --allow-natives-syntax var result = 0; var o1 = {}; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-380671.js b/deps/v8/test/mjsunit/regress/regress-crbug-380671.js index 891215e301..3b03064eb9 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-380671.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-380671.js @@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --mock-arraybuffer-allocator +// Flags: --mock-arraybuffer-allocator --expose-gc var buffer = new ArrayBuffer(0xc0000000); assertEquals(0xc0000000, buffer.byteLength); +// We call the GC here to free up the large array buffer. Otherwise, the +// mock allocator would allow us to allocate more than the physical memory +// available on 32bit platforms, leaving the internal counters in an invalid +// state. +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-485548-1.js b/deps/v8/test/mjsunit/regress/regress-crbug-485548-1.js index bbd0f7dd45..6a25dcd2df 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-485548-1.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-485548-1.js @@ -8,7 +8,7 @@ var inner = new Array(); inner.a = {x:1}; inner[0] = 1.5; inner.b = {x:2}; -assertTrue(%HasFastDoubleElements(inner)); +assertTrue(%HasDoubleElements(inner)); function foo(o) { return o.field.a.x; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-485548-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-485548-2.js index 7e449a6fd4..02c6326d12 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-485548-2.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-485548-2.js @@ -8,7 +8,7 @@ var inner = new Array(); inner.a = {x:1}; inner[0] = 1.5; inner.b = {x:2}; -assertTrue(%HasFastDoubleElements(inner)); +assertTrue(%HasDoubleElements(inner)); function foo(o) { return o.field.b.x; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-495493.js b/deps/v8/test/mjsunit/regress/regress-crbug-495493.js index 3dba236c37..149ebdcb3d 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-495493.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-495493.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --nofold-constants --enable-slow-asserts --debug-code +// Flags: --enable-slow-asserts --debug-code function foo(p) { for (var i = 0; i < 100000; ++i) { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-498022.js b/deps/v8/test/mjsunit/regress/regress-crbug-498022.js index cb8e0a460d..178eb8efce 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-498022.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-498022.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --debug-code --nouse-gvn +// Flags: --debug-code "use strict"; class Base { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-537444.js b/deps/v8/test/mjsunit/regress/regress-crbug-537444.js index 1cb1f9ad92..6f56fd148d 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-537444.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-537444.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-tailcalls --allow-natives-syntax +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js index 1fcbaebd83..c8af4a4e08 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-593697-2.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-595615.js b/deps/v8/test/mjsunit/regress/regress-crbug-595615.js index 33095013fa..f5d0ee5344 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-595615.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-595615.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-598998.js b/deps/v8/test/mjsunit/regress/regress-crbug-598998.js index 4cfe1a13af..bbabf1e31d 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-598998.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-598998.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-tailcalls --allow-natives-syntax +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-601617.js b/deps/v8/test/mjsunit/regress/regress-crbug-601617.js index 7d03fef838..e1a5cbd2c7 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-601617.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-601617.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax function h() { var res = g.arguments[0].x; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-604680.js b/deps/v8/test/mjsunit/regress/regress-crbug-604680.js index 3df2f2047a..8835807e86 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-604680.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-604680.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax function h() { var res = g.arguments; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-608278.js b/deps/v8/test/mjsunit/regress/regress-crbug-608278.js index 6840159f30..251ecad86c 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-608278.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-608278.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-tailcalls --allow-natives-syntax +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-621816.js b/deps/v8/test/mjsunit/regress/regress-crbug-621816.js index ca7f5ac6df..8ef291a00c 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-621816.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-621816.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax function f() { var o = {}; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-632800.js b/deps/v8/test/mjsunit/regress/regress-crbug-632800.js index a4c2301217..68158ef591 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-632800.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-632800.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --ignition-osr +// Flags: --no-stress-fullcodegen --ignition-osr function osr() { for (var i = 0; i < 50000; ++i) Math.random(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-633585.js b/deps/v8/test/mjsunit/regress/regress-crbug-633585.js index c483e47bbc..5b2a52b37d 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-633585.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-633585.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-gc --turbo --always-opt +// Flags: --expose-gc --always-opt function f() { this.x = this.x.x; } gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-635923.js b/deps/v8/test/mjsunit/regress/regress-crbug-635923.js index 5b697d74ad..41a7be06e9 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-635923.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-635923.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --turbo-filter=f +// Flags: --allow-natives-syntax --no-stress-fullcodegen --turbo-filter=f function f(x) { return x + 23 } function g(x) { return f(x) + 42 } diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-638551.js b/deps/v8/test/mjsunit/regress/regress-crbug-638551.js index 2bd492a48c..1f24140fa4 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-638551.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-638551.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --expose-gc --ignition --no-lazy +// Flags: --allow-natives-syntax --expose-gc --no-stress-fullcodegen --no-lazy function f() { for (var i = 0; i < 10; i++) if (i == 5) %OptimizeOsr(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-640497.js b/deps/v8/test/mjsunit/regress/regress-crbug-640497.js index c637badb66..3b90d1bcfe 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-640497.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-640497.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape // Warm up {g} with arrays and strings. function g(v) { return v.length; } diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-644111.js b/deps/v8/test/mjsunit/regress/regress-crbug-644111.js index 0426d2f8bc..63c6b4417f 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-644111.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-644111.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --turbo --validate-asm --always-opt +// Flags: --no-stress-fullcodegen --validate-asm --always-opt function Module() { "use asm"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-644215.js b/deps/v8/test/mjsunit/regress/regress-crbug-644215.js index c74112542d..969e672acc 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-644215.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-644215.js @@ -5,7 +5,7 @@ // Flags: --allow-natives-syntax var arr = [...[],,]; -assertTrue(%HasFastHoleyElements(arr)); +assertTrue(%HasHoleyElements(arr)); assertEquals(1, arr.length); assertFalse(arr.hasOwnProperty(0)); assertEquals(undefined, arr[0]); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-644245.js b/deps/v8/test/mjsunit/regress/regress-crbug-644245.js index 7f4e00599e..86714902c0 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-644245.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-644245.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape function f() { try { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-644631.js b/deps/v8/test/mjsunit/regress/regress-crbug-644631.js index bf845c7aee..2805fdbec4 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-644631.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-644631.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --always-opt +// Flags: --allow-natives-syntax --always-opt function f() { var obj = Object.freeze({}); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-645103.js b/deps/v8/test/mjsunit/regress/regress-crbug-645103.js index d7128d575e..0fb3ab1acd 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-645103.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-645103.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition --turbo +// Flags: --allow-natives-syntax --no-stress-fullcodegen class Base {} class Subclass extends Base { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-645888.js b/deps/v8/test/mjsunit/regress/regress-crbug-645888.js index 5ffacc75df..8a9bfb3cf6 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-645888.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-645888.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition +// Flags: --allow-natives-syntax --no-stress-fullcodegen function f() { for (var i = 0; i < 3; ++i) { diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-647217.js b/deps/v8/test/mjsunit/regress/regress-crbug-647217.js index 33baa730a0..92909682d6 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-647217.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-647217.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --stack-size=100 --ignition --turbo +// Flags: --allow-natives-syntax --stack-size=100 --no-stress-fullcodegen var source = "return 1" + new Array(2048).join(' + a') + ""; eval("function g(a) {" + source + "}"); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-648539.js b/deps/v8/test/mjsunit/regress/regress-crbug-648539.js index 399180f03e..c12f16dce4 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-648539.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-648539.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax function f() { "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-648737.js b/deps/v8/test/mjsunit/regress/regress-crbug-648737.js index 22f8551543..e78cb20d6f 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-648737.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-648737.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo --turbo-escape +// Flags: --allow-natives-syntax --turbo-escape function f(str) { var s = "We turn {" + str + "} into a ConsString now"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-651403-global.js b/deps/v8/test/mjsunit/regress/regress-crbug-651403-global.js index 8682d822a5..e27e076dc3 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-651403-global.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-651403-global.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo --always-opt +// Flags: --always-opt x = ""; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-651403.js b/deps/v8/test/mjsunit/regress/regress-crbug-651403.js index c84dd85f58..d10d8051bb 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-651403.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-651403.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --ignition --turbo --always-opt +// Flags: --no-stress-fullcodegen --always-opt function f () { var x = ""; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-658691.js b/deps/v8/test/mjsunit/regress/regress-crbug-658691.js index fee95f1eb3..1af2ed83eb 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-658691.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-658691.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls --ignition --turbo +// Flags: --allow-natives-syntax --no-stress-fullcodegen // The {f} function is compiled using TurboFan. // 1) The call to {Reflect.set} has no arguments adaptation. diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-662367.js b/deps/v8/test/mjsunit/regress/regress-crbug-662367.js index 8e1eafa30a..fcaf545427 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-662367.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-662367.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --fold-constants +// Flags: --allow-natives-syntax var zero = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-668795.js b/deps/v8/test/mjsunit/regress/regress-crbug-668795.js index a98bad03e5..fc94097a43 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-668795.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-668795.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --ignition +// Flags: --allow-natives-syntax --no-stress-fullcodegen function g() { return g.arguments; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-669850.js b/deps/v8/test/mjsunit/regress/regress-crbug-669850.js index daf5a24f45..50f5940f08 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-669850.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-669850.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax eval('function f(a) { return [' + new Array(1 << 17) + ',a] }'); assertEquals(23, f(23)[1 << 17]); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-685634.js b/deps/v8/test/mjsunit/regress/regress-crbug-685634.js index 2e647ce970..2032744539 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-685634.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-685634.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --harmony-tailcalls +// Flags: --allow-natives-syntax "use strict"; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-694416.js b/deps/v8/test/mjsunit/regress/regress-crbug-694416.js index 064b8fc9c2..14303f25bf 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-694416.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-694416.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax var good = 23; var boom = 42; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-694709.js b/deps/v8/test/mjsunit/regress/regress-crbug-694709.js index 2b1bf073a8..407b47732c 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-694709.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-694709.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --turbo +// Flags: --allow-natives-syntax function f(primitive) { return primitive.__proto__; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-719384.js b/deps/v8/test/mjsunit/regress/regress-crbug-719384.js new file mode 100644 index 0000000000..8b6a8385b0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-719384.js @@ -0,0 +1,34 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function TestThrowingObserver() { + function Module(stdlib, foreign) { + "use asm"; + var x = foreign.x | 0; + function f() {} + return { f:f }; + } + var observer = { get x() { throw new Error() } }; + assertThrows(() => Module(this, observer)); + assertFalse(%IsAsmWasmCode(Module)); +})(); + +(function TestMutatingObserver() { + function Module(stdlib, foreign) { + "use asm"; + var x = +foreign.x; + var PI = stdlib.Math.PI; + function f() { + return +(PI + x); + } + return { f:f }; + } + var stdlib = { Math : { PI : Math.PI } }; + var observer = { get x() { stdlib.Math.PI = 23; return 42; } }; + var m = Module(stdlib, observer); + assertFalse(%IsAsmWasmCode(Module)); + assertEquals(65, m.f()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-722348.js b/deps/v8/test/mjsunit/regress/regress-crbug-722348.js new file mode 100644 index 0000000000..6c99e70e43 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-722348.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function Module(global, env) { + "use asm"; + var unused_fun = env.fun; + function f() {} + return { f:f } +} +assertThrows(() => Module(), TypeError); +assertFalse(%IsAsmWasmCode(Module)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-724153.js b/deps/v8/test/mjsunit/regress/regress-crbug-724153.js new file mode 100644 index 0000000000..541a4937e0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-724153.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --no-turbo-verify + +(function TestParameterLimit() { + var src = '(function f(a,'; + for (var i = 0; i < 65535 - 2; i++) { + src += 'b' + i + ','; + } + src += 'c) { return a + c })'; + var f = eval(src); + assertEquals(NaN, f(1)); + assertEquals(NaN, f(2)); + %OptimizeFunctionOnNextCall(f); + assertEquals(NaN, f(3)); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-724608.js b/deps/v8/test/mjsunit/regress/regress-crbug-724608.js new file mode 100644 index 0000000000..cd91211f07 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-724608.js @@ -0,0 +1,13 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo(x) { + return {['p']: 0, x}; +} +foo(); +var a = {['p']: ''}; +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-725201.js b/deps/v8/test/mjsunit/regress/regress-crbug-725201.js new file mode 100644 index 0000000000..c540b6dffc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-725201.js @@ -0,0 +1,20 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function __f_1() { + function __f_2() { + Array.prototype.__proto__ = { 77e4 : null }; + } + __f_2(); + %OptimizeFunctionOnNextCall(__f_2); + __f_2(); +} +try { +__f_1(); +} catch(e) {; } +for (var __v_6 in [(1.2)]) { } + +%HeapObjectVerify([(1.2)]); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-725537.js b/deps/v8/test/mjsunit/regress/regress-crbug-725537.js new file mode 100644 index 0000000000..ed72d54a94 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-725537.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc --verify-heap + +const AsyncFunction = async function(){}.constructor; +class MyAsync extends AsyncFunction {} +var af = new MyAsync(); +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-728813.js b/deps/v8/test/mjsunit/regress/regress-crbug-728813.js new file mode 100644 index 0000000000..b5a8a997de --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-728813.js @@ -0,0 +1,9 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var p = new Proxy({}, { + has: function () { throw "nope"; } +}); +p.length = 2; +assertThrows(() => Array.prototype.indexOf.call(p)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-729573-1.js b/deps/v8/test/mjsunit/regress/regress-crbug-729573-1.js new file mode 100644 index 0000000000..1b596abe2f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-729573-1.js @@ -0,0 +1,67 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function() { + function foo() { + var a = foo.bind(this); + %DeoptimizeNow(); + if (!a) return a; + return 0; + } + + assertEquals(0, foo()); + assertEquals(0, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo()); +})(); + +(function() { + "use strict"; + + function foo() { + var a = foo.bind(this); + %DeoptimizeNow(); + if (!a) return a; + return 0; + } + + assertEquals(0, foo()); + assertEquals(0, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo()); +})(); + +(function() { + function foo() { + var a = foo.bind(this); + %DeoptimizeNow(); + if (!a) return a; + return 0; + } + foo.prototype = {custom: "prototype"}; + + assertEquals(0, foo()); + assertEquals(0, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo()); +})(); + +(function() { + "use strict"; + + function foo() { + var a = foo.bind(this); + %DeoptimizeNow(); + if (!a) return a; + return 0; + } + foo.prototype = {custom: "prototype"}; + + assertEquals(0, foo()); + assertEquals(0, foo()); + %OptimizeFunctionOnNextCall(foo); + assertEquals(0, foo()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-729573-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-729573-2.js new file mode 100644 index 0000000000..45486ec2a3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-729573-2.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function bar(x) { + "use strict"; + return this + x; +} + +function foo(f) { + var a = bar.bind(42, 1); + return f() ? 0 : a; +} + +function t() { return true; } + +assertEquals(0, foo(t)); +assertEquals(0, foo(t)); +%OptimizeFunctionOnNextCall(foo); +var a = foo(_ => false); +assertEquals(43, a()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-729597.js b/deps/v8/test/mjsunit/regress/regress-crbug-729597.js new file mode 100644 index 0000000000..b4c54e8e88 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-729597.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --verify-heap + +function __f_3(f) { + arguments.__defineGetter__('length', f); + return arguments; +} +function __f_4() { return "boom"; } + +__v_4 = []; +__v_13 = ""; + +for (var i = 0; i < 12800; ++i) { + __v_13 += __v_4.__proto__ = __f_3(__f_4); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-731193.js b/deps/v8/test/mjsunit/regress/regress-crbug-731193.js new file mode 100644 index 0000000000..6c1c088ce1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-731193.js @@ -0,0 +1,27 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function f() { +} + +// Make prototype of f go dictionary-mode. +for (var i = 0; i < 10000; i++) { + f.prototype["b" + i] = 1; +} + +var o = new f(); + +function access(o, k) { + return o[k]; +} + +// Create a thin string. +var p = "b"; +p += 10001; + +assertEquals(undefined, access(o, p)); +assertEquals(undefined, access(o, p)); +assertEquals(undefined, access(o, p)); +f.prototype[p] = 100; +assertEquals(100, access(o, p)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-732169.js b/deps/v8/test/mjsunit/regress/regress-crbug-732169.js new file mode 100644 index 0000000000..41dc9d2f38 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-732169.js @@ -0,0 +1,29 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function TestGeneratorMaterialization() { + function* f([x]) { yield x } + // No warm-up of {f} to trigger soft deopt. + %OptimizeFunctionOnNextCall(f); + var gen = f([23]); + assertEquals("[object Generator]", gen.toString()); + assertEquals({ done:false, value:23 }, gen.next()); + assertEquals({ done:true, value:undefined }, gen.next()); +})(); + +(function TestGeneratorMaterializationWithProperties() { + function* f(x = (%_DeoptimizeNow(), 23)) { yield x } + function g() { + var gen = f(); + gen.p = 42; + return gen; + } + function h() { f() } + // Enough warm-up to make {p} an in-object property. + for (var i = 0; i < 100; ++i) { g(); h(); } + %OptimizeFunctionOnNextCall(h); + h(); // In {h} the generator does not escape. +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-734051.js b/deps/v8/test/mjsunit/regress/regress-crbug-734051.js new file mode 100644 index 0000000000..2655db08a7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-734051.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function TestMutableHeapNumberLiteral() { + var data = { a: 0, b: 0 }; + data.a += 0.1; + assertEquals(0.1, data.a); + assertEquals(0, data.b); +}; +TestMutableHeapNumberLiteral(); +TestMutableHeapNumberLiteral(); +TestMutableHeapNumberLiteral(); +TestMutableHeapNumberLiteral(); +TestMutableHeapNumberLiteral(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-734162.js b/deps/v8/test/mjsunit/regress/regress-crbug-734162.js new file mode 100644 index 0000000000..24ea1f06f5 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-734162.js @@ -0,0 +1,48 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +(function TestSmi() { + var v_0 = {}; + function f_0(constructor, closure) { + var v_2 = { value: 0 }; + v_4 = closure(constructor, 1073741823, v_0, v_2); + assertEquals(1, v_2.value); + } + function f_1(constructor, val, deopt, v_2) { + if (!new constructor(val, deopt, v_2)) { + } + } + function f_10(constructor) { + f_0(constructor, f_1); + f_0(constructor, f_1); + f_0(constructor, f_1); + } + function f_12(val, deopt, v_2) { + v_2.value++; + } + f_10(f_12); +})(); + +(function TestHeapNumber() { + var v_0 = {}; + function f_0(constructor, closure) { + var v_2 = { value: 1.5 }; + v_4 = closure(constructor, 1073741823, v_0, v_2); + assertEquals(2.5, v_2.value); + } + function f_1(constructor, val, deopt, v_2) { + if (!new constructor(val, deopt, v_2)) { + } + } + function f_10(constructor) { + f_0(constructor, f_1); + f_0(constructor, f_1); + f_0(constructor, f_1); + } + function f_12(val, deopt, v_2) { + v_2.value++; + } + f_10(f_12); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-736633.js b/deps/v8/test/mjsunit/regress/regress-crbug-736633.js new file mode 100644 index 0000000000..4c9f0cc97d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-736633.js @@ -0,0 +1,21 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f(x) { + switch (x | 0) { + case 0: + case 1: + case 2: + case -2147483644: + case 2147483647: + return x + 1; + } + return 0; +} +assertEquals(1, f(0)); +assertEquals(2, f(1)); +%OptimizeFunctionOnNextCall(f); +assertEquals(3, f(2)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-737645.js b/deps/v8/test/mjsunit/regress/regress-crbug-737645.js new file mode 100644 index 0000000000..13d3087e3f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-737645.js @@ -0,0 +1,23 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +for (let i = 0; i < 100; i++) { + // - length > 2 to trigger sorting. + // - key > kRequiresSlowElementsLimit required to set the according bit on the + // dictionary elements store. + let key = 1073741800 + i; + var a = { length: 12, 1: 0xFA, [key]: 0xFB }; + %HeapObjectVerify(a); + assertEquals(["1", ""+key, "length"], Object.keys(a)); + // Sort, everything > length is ignored. + Array.prototype.sort.call(a); + %HeapObjectVerify(a); + assertEquals(["0", ""+key, "length"], Object.keys(a)); + // Sorting again to trigger bug caused by not setting requires_slow_elements + Array.prototype.sort.call(a); + %HeapObjectVerify(a); + assertEquals(["0", ""+key, "length"], Object.keys(a)); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-740116.js b/deps/v8/test/mjsunit/regress/regress-crbug-740116.js new file mode 100644 index 0000000000..dc6fb6401c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-740116.js @@ -0,0 +1,29 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function TestReflectGetPrototypeOfOnPrimitive() { + function f() { return Reflect.getPrototypeOf(""); } + assertThrows(f, TypeError); + assertThrows(f, TypeError); + %OptimizeFunctionOnNextCall(f); + assertThrows(f, TypeError); +})(); + +(function TestObjectGetPrototypeOfOnPrimitive() { + function f() { return Object.getPrototypeOf(""); } + assertSame(String.prototype, f()); + assertSame(String.prototype, f()); + %OptimizeFunctionOnNextCall(f); + assertSame(String.prototype, f()); +})(); + +(function TestDunderProtoOnPrimitive() { + function f() { return "".__proto__; } + assertSame(String.prototype, f()); + assertSame(String.prototype, f()); + %OptimizeFunctionOnNextCall(f); + assertSame(String.prototype, f()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-740398.js b/deps/v8/test/mjsunit/regress/regress-crbug-740398.js new file mode 100644 index 0000000000..26b8d9be3b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-740398.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var longString = (function() { + var str = ""; + for (var i = 0; i < 24; i++) { + str += "abcdefgh12345678" + str; + } + return str; +})(); + +assertThrows(() => { return { get[longString]() { } } }, RangeError); +assertThrows(() => { return { set[longString](v) { } } }, RangeError); +assertThrows(() => { return { [Symbol(longString)]: () => {} } }, RangeError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-740591.js b/deps/v8/test/mjsunit/regress/regress-crbug-740591.js new file mode 100644 index 0000000000..e0a904f00e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-740591.js @@ -0,0 +1,37 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function regressionCaseOne() { + var c; + for (let [a, b = c = function() { return a + b }] of [[0]]) { + function f() { return a }; + } + c(); +})(); + +(function testForInFunction() { + for (const {length: a, b = function() { return a, b }} in {foo: 42}) { + assertSame(b, (function() { return b() })()); + } +})(); + +(function testForOfFunction() { + for (const [a, b = function() { return a, b }] of [[42]]) { + assertSame(b, (function() { return b() })()); + } +})(); + +(function testForInVariableProxy() { + for (const {length: a, b = a} in {foo: 42}) { + assertEquals(3, a); + assertEquals(a, b); + } +})(); + +(function testForOfVariableProxy() { + for (const [a, b = a] of [[42]]) { + assertEquals(42, a); + assertEquals(a, b); + } +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-741078.js b/deps/v8/test/mjsunit/regress/regress-crbug-741078.js new file mode 100644 index 0000000000..8dfea72617 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-741078.js @@ -0,0 +1,19 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc + +function* gen() {} + +(function warmup() { + for (var i = 0; i < 100; ++i) { + var g = gen(); + g.p = 42; + } +})(); + +gc(); // Ensure no instance alive. +gen(); // Still has unused fields. +%OptimizeFunctionOnNextCall(gen); +gen(); // Was shrunk, boom! diff --git a/deps/v8/test/mjsunit/regress/regress-delete-empty-double.js b/deps/v8/test/mjsunit/regress/regress-delete-empty-double.js index f7af2b1e31..c27cb55a2a 100644 --- a/deps/v8/test/mjsunit/regress/regress-delete-empty-double.js +++ b/deps/v8/test/mjsunit/regress/regress-delete-empty-double.js @@ -31,10 +31,10 @@ a = [1.1,2.2,3.3]; a.length = 1; delete a[1]; -assertTrue(%HasFastDoubleElements(a)); -assertFalse(%HasFastHoleyElements(a)); +assertTrue(%HasDoubleElements(a)); +assertFalse(%HasHoleyElements(a)); delete a[0]; -assertTrue(%HasFastDoubleElements(a)); -assertTrue(%HasFastHoleyElements(a)); +assertTrue(%HasDoubleElements(a)); +assertTrue(%HasHoleyElements(a)); diff --git a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js index 08de6dbab1..b95b619d39 100644 --- a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js +++ b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js @@ -25,7 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --fold-constants --nodead-code-elimination // Flags: --expose-gc --allow-natives-syntax // Flags: --concurrent-recompilation --block-concurrent-recompilation // Flags: --opt --no-always-opt diff --git a/deps/v8/test/mjsunit/regress/regress-fast-literal-transition.js b/deps/v8/test/mjsunit/regress/regress-fast-literal-transition.js index 72110f5be2..2dc6a971d4 100644 --- a/deps/v8/test/mjsunit/regress/regress-fast-literal-transition.js +++ b/deps/v8/test/mjsunit/regress/regress-fast-literal-transition.js @@ -49,12 +49,12 @@ function g(x) { return [1.1, 1.2, 1.3, f(x)]; } -// Step 1: Optimize g() to contain a FAST_DOUBLE_ELEMENTS boilerplate. +// Step 1: Optimize g() to contain a PACKED_DOUBLE_ELEMENTS boilerplate. assertEquals([1.1, 1.2, 1.3, 1.4], g(1)); assertEquals([1.1, 1.2, 1.3, 1.5], g(2)); %OptimizeFunctionOnNextCall(g); -// Step 2: Deoptimize g() and transition to FAST_ELEMENTS boilerplate. +// Step 2: Deoptimize g() and transition to PACKED_ELEMENTS boilerplate. assertEquals([1.1, 1.2, 1.3, {}], g(3)); // Step 3: Cause a GC while broken clone of boilerplate is on the heap, diff --git a/deps/v8/test/mjsunit/regress/regress-gvn-ftt.js b/deps/v8/test/mjsunit/regress/regress-gvn-ftt.js index d2cb44381d..dee5765438 100644 --- a/deps/v8/test/mjsunit/regress/regress-gvn-ftt.js +++ b/deps/v8/test/mjsunit/regress/regress-gvn-ftt.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --track-field-types --use-gvn +// Flags: --allow-natives-syntax --track-field-types function A(id) { this.id = id; diff --git a/deps/v8/test/mjsunit/regress/regress-put-prototype-transition.js b/deps/v8/test/mjsunit/regress/regress-put-prototype-transition.js index 358db8932e..bc63d219c0 100644 --- a/deps/v8/test/mjsunit/regress/regress-put-prototype-transition.js +++ b/deps/v8/test/mjsunit/regress/regress-put-prototype-transition.js @@ -33,9 +33,9 @@ function __f_1(__v_4, add_first, __v_6, same_map_as) { assertFalse(%HasFastProperties(__v_1)); } else { __f_0(__v_1, __v_6); - assertTrue(__v_4 || %HasFastProperties(__v_1)); + assertTrue(__v_4 || !%HasFastProperties(__v_1)); __f_4(__v_1); - assertTrue(__v_4 || %HasFastProperties(__v_1)); + assertTrue(__v_4 || !%HasFastProperties(__v_1)); } } gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-refreeze-same-map.js b/deps/v8/test/mjsunit/regress/regress-refreeze-same-map.js new file mode 100644 index 0000000000..19cdb502a1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-refreeze-same-map.js @@ -0,0 +1,40 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// precondition +assertTrue(%HaveSameMap(Object.freeze({}), Object.freeze({}))); +assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.freeze({a: 1}))); +assertTrue(%HaveSameMap(Object.freeze([]), Object.freeze([]))); +assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.freeze([1,2]))); + +assertTrue(%HaveSameMap(Object.seal({}), Object.seal({}))); +assertTrue(%HaveSameMap(Object.seal({a: 1}), Object.seal({a: 1}))); +assertTrue(%HaveSameMap(Object.seal([]), Object.seal([]))); +assertTrue(%HaveSameMap(Object.seal([1,2]), Object.seal([1,2]))); + +// refreezing an already frozen obj does not keep adding transitions +assertTrue(%HaveSameMap(Object.freeze({}), Object.freeze( Object.freeze({}) ))); +assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.freeze( Object.freeze({a: 1}) ))); +assertTrue(%HaveSameMap(Object.freeze([]), Object.freeze( Object.freeze([]) ))); +assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.freeze( Object.freeze([1,2]) ))); + +// resealing a sealed object is idempotent +assertTrue(%HaveSameMap(Object.seal({}), Object.seal( Object.seal({}) ))); +assertTrue(%HaveSameMap(Object.seal({a: 1}), Object.seal( Object.seal({a: 1}) ))); +assertTrue(%HaveSameMap(Object.seal([]), Object.seal( Object.seal([]) ))); +assertTrue(%HaveSameMap(Object.seal([1,2]), Object.seal( Object.seal([1,2]) ))); + +// sealing a frozen object is idempotent +assertTrue(%HaveSameMap(Object.freeze({}), Object.seal( Object.freeze({}) ))); +assertTrue(%HaveSameMap(Object.freeze({a: 1}), Object.seal( Object.freeze({a: 1}) ))); +assertTrue(%HaveSameMap(Object.freeze([]), Object.seal( Object.freeze([]) ))); +assertTrue(%HaveSameMap(Object.freeze([1,2]), Object.seal( Object.freeze([1,2]) ))); + +// freezing a sealed empty is idempotent +assertTrue(%HaveSameMap(Object.freeze(Object.seal({})), Object.seal({}))); + +// sealing a unextensible empty object is idempotent +assertTrue(%HaveSameMap(Object.seal(Object.preventExtensions({})), Object.preventExtensions({}))); diff --git a/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js b/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js index 55ca2996ff..503f3064d6 100644 --- a/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js +++ b/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js @@ -33,5 +33,5 @@ var fast_array = ['a', 'b']; var array = fast_array.concat(fast_array); -assertTrue(%HasFastObjectElements(fast_array)); -assertTrue(%HasFastObjectElements(array)); +assertTrue(%HasObjectElements(fast_array)); +assertTrue(%HasObjectElements(array)); diff --git a/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js b/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js index 12baca0918..e31fb88354 100644 --- a/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js +++ b/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js @@ -12,9 +12,9 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastObjectElements(obj)) return elements_kind.fast; - if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; + if (%HasSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasObjectElements(obj)) return elements_kind.fast; + if (%HasDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; } diff --git a/deps/v8/test/mjsunit/regress/regress-v8-6716.js b/deps/v8/test/mjsunit/regress/regress-v8-6716.js new file mode 100644 index 0000000000..3033fa7c5f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-v8-6716.js @@ -0,0 +1,7 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function f() {} +var a = Array(2 ** 16); // Elements in large-object-space. +f.bind(...a); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-724846.js b/deps/v8/test/mjsunit/regress/wasm/regression-724846.js new file mode 100644 index 0000000000..628d58f294 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-724846.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +// Flags: --wasm-max-mem-pages=49152 + +let builder = new WasmModuleBuilder(); +const num_pages = 49152; +builder.addMemory(num_pages, num_pages); +// num_pages * 64k (page size) > kMaxInt. +assertThrows(() => builder.instantiate(), RangeError); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-724851.js b/deps/v8/test/mjsunit/regress/wasm/regression-724851.js new file mode 100644 index 0000000000..18834795d2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-724851.js @@ -0,0 +1,12 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let builder = new WasmModuleBuilder(); +builder.addFunction('f', kSig_i_v).addBody([kExprReturn]); +assertThrows(() => builder.instantiate(), WebAssembly.CompileError); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-724972.js b/deps/v8/test/mjsunit/regress/wasm/regression-724972.js new file mode 100644 index 0000000000..2af403ce20 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-724972.js @@ -0,0 +1,11 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +builder.addMemory(0, 0, true); +var instance = builder.instantiate(); +instance.exports.memory.buffer; diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-727219.js b/deps/v8/test/mjsunit/regress/wasm/regression-727219.js new file mode 100644 index 0000000000..af0d8725bc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-727219.js @@ -0,0 +1,22 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc --validate-asm + +function asm() { + "use asm"; + function f(a) { + a = a | 0; + tab[a & 0]() | 0; + } + function unused() { + return 0; + } + var tab = [ unused ]; + return f; +} + +asm(); +gc(); +asm(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-727222.js b/deps/v8/test/mjsunit/regress/wasm/regression-727222.js new file mode 100644 index 0000000000..6b3f2faf5f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-727222.js @@ -0,0 +1,14 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); +builder.addMemory(0, 0, false); +builder.addFunction('f', kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); +var instance = builder.instantiate(); +instance.exports.f(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-727560.js b/deps/v8/test/mjsunit/regress/wasm/regression-727560.js new file mode 100644 index 0000000000..f92d879a2e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-727560.js @@ -0,0 +1,18 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +{ + let builder = new WasmModuleBuilder(); + builder.addMemory(); + builder.exportMemoryAs("exported_mem"); + i1 = builder.instantiate(); +} +{ + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("fil", "imported_mem"); + i2 = builder.instantiate({fil: {imported_mem: i1.exports.exported_mem}}); +} diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-729991.js b/deps/v8/test/mjsunit/regress/wasm/regression-729991.js new file mode 100644 index 0000000000..85a9ae7231 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-729991.js @@ -0,0 +1,15 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let builder = new WasmModuleBuilder(); +builder.addCustomSection('BBBB', []); +builder.addCustomSection('AAAA', new Array(32).fill(0)); +let buffer = builder.toBuffer(); +// Shrink the buffer by 30 bytes (content of the unknown section named 'AAAA'). +buffer = buffer.slice(0, buffer.byteLength - 30); +// Instantiation should fail on the truncated buffer. +assertThrows(() => new WebAssembly.Module(buffer), WebAssembly.CompileError); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-734246.js b/deps/v8/test/mjsunit/regress/wasm/regression-734246.js new file mode 100644 index 0000000000..57f98949f8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-734246.js @@ -0,0 +1,16 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let builder = new WasmModuleBuilder(); +builder.addExplicitSection([ + kUnknownSectionCode, + // section length + 0x0f, + // name length: 0xffffffff + 0xf9, 0xff, 0xff, 0xff, 0x0f +]); +assertThrows(() => builder.instantiate(), WebAssembly.CompileError); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-734345.js b/deps/v8/test/mjsunit/regress/wasm/regression-734345.js new file mode 100644 index 0000000000..f55a06288e --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-734345.js @@ -0,0 +1,28 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +builder1 = new WasmModuleBuilder(); +builder1.addFunction('exp1', kSig_v_v).addBody([kExprUnreachable]).exportFunc(); + +builder2 = new WasmModuleBuilder(); +builder2.addImport('imp', 'imp', kSig_v_v); +builder2.addFunction('call_imp', kSig_v_v) + .addBody([kExprCallFunction, 0]) + .exportFunc(); + +export1 = builder1.instantiate().exports.exp1; +export2 = builder2.instantiate({imp: {imp: export1}}).exports.call_imp; +export1 = undefined; + +let a = [0]; +for (i = 0; i < 10; ++i) { + a = a.concat(new Array(i).fill(i)); + assertThrows(() => export2(), WebAssembly.RuntimeError); + gc(); +} diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-736584.js b/deps/v8/test/mjsunit/regress/wasm/regression-736584.js new file mode 100644 index 0000000000..39f03c1072 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-736584.js @@ -0,0 +1,17 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --wasm-lazy-compilation + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +let mem = new WebAssembly.Memory({}); +let builder = new WasmModuleBuilder(); +builder.addImportedMemory("mod", "imported_mem"); +builder.addFunction('mem_size', kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); +let instance = builder.instantiate({mod: {imported_mem: mem}}); +instance.exports.mem_size(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-739768.js b/deps/v8/test/mjsunit/regress/wasm/regression-739768.js new file mode 100644 index 0000000000..72843b909d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-739768.js @@ -0,0 +1,33 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +// Flags: --wasm-lazy-compilation + +let builder0 = new WasmModuleBuilder(); +builder0.setName('module_0'); +let sig_index = builder0.addType(kSig_i_v); +builder0.addFunction('main', kSig_i_i) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_index, kTableZero + ]) // -- + .exportAs('main'); +builder0.setFunctionTableLength(3); +builder0.addExportOfKind('table', kExternalTable); +let module0 = new WebAssembly.Module(builder0.toBuffer()); +let instance0 = new WebAssembly.Instance(module0); + +let builder1 = new WasmModuleBuilder(); +builder1.setName('module_1'); +builder1.addFunction('main', kSig_i_v).addBody([kExprUnreachable]); +builder1.addImportedTable('z', 'table'); +builder1.addFunctionTableInit(0, false, [0], true); +let module1 = new WebAssembly.Module(builder1.toBuffer()); +let 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/shared-function-tier-up-turbo.js b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js index 95fa8d337c..a9e3938dd3 100644 --- a/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js +++ b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js @@ -3,8 +3,7 @@ // found in the LICENSE file. // // Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax -// Flags: --ignition --turbo --opt --no-always-opt -// Flags: --turbo-filter=* +// Flags: --no-stress-fullcodegen --opt --no-always-opt --turbo-filter=* // If we are always or never optimizing it is useless. assertFalse(isAlwaysOptimize()); diff --git a/deps/v8/test/mjsunit/skipping-inner-functions.js b/deps/v8/test/mjsunit/skipping-inner-functions.js index 1c5538567f..4ca293625a 100644 --- a/deps/v8/test/mjsunit/skipping-inner-functions.js +++ b/deps/v8/test/mjsunit/skipping-inner-functions.js @@ -35,3 +35,171 @@ lazy(9)(); assertEquals(19, result); })(); + +(function TestCtxtAllocatingNonSimpleParams1() { + var result = 0; + + function lazy([other_param1, ctxt_alloc_param, other_param2]) { + function skip_me() { + result = ctxt_alloc_param; + } + return skip_me; + } + // Test that parameters and variables of the outer function get context + // allocated even if we skip the inner function. + lazy([30, 29, 28])(); + assertEquals(29, result); +})(); + +(function TestCtxtAllocatingNonSimpleParams2() { + var result = 0; + + function lazy({a: other_param1, b: ctxt_alloc_param, c: other_param2}) { + function skip_me() { + result = ctxt_alloc_param; + } + return skip_me; + } + // Test that parameters and variables of the outer function get context + // allocated even if we skip the inner function. + lazy({a: 31, b: 32, c: 33})(); + assertEquals(32, result); +})(); + +(function TestCtxtAllocatingNonSimpleParams3() { + var result = 0; + + function lazy(...ctxt_alloc_param) { + function skip_me() { + result = ctxt_alloc_param; + } + return skip_me; + } + // Test that parameters and variables of the outer function get context + // allocated even if we skip the inner function. + lazy(34, 35)(); + assertEquals([34, 35], result); +})(); + +// Skippable top level functions. +let result = 0; +function lazy_top_level(ctxt_alloc_param) { + let ctxt_alloc_var = 24; + function skip_me() { + result = ctxt_alloc_param + ctxt_alloc_var; + } + skip_me(); +} + +lazy_top_level(10); +assertEquals(34, result); + +// Tests for using a function name in an inner function. +var TestUsingNamedExpressionName1 = function this_is_the_name() { + function inner() { + this_is_the_name; + } + inner(); +} +TestUsingNamedExpressionName1(); + +function TestUsingNamedExpressionName2() { + let f = function this_is_the_name() { + function inner() { + this_is_the_name; + } + inner(); + } + f(); +} +TestUsingNamedExpressionName2(); + +function TestSkippedFunctionInsideLoopInitializer() { + let saved_func; + for (let i = 0, f = function() { return i }; i < 1; ++i) { + saved_func = f; + } + assertEquals(0, saved_func()); +} +TestSkippedFunctionInsideLoopInitializer(); + +(function TestSkippedFunctionWithParameters() { + var result = 0; + + function lazy(ctxt_alloc_param) { + var ctxt_alloc_var = 10; + function skip_me(param1, param2) { + result = ctxt_alloc_param + ctxt_alloc_var + param1 + param2; + } + return skip_me; + } + lazy(9)(8, 7); + assertEquals(34, result); +})(); + +function TestSkippingDeeperLazyFunctions() { + let result = 0; + function inner_lazy(ctxt_alloc_param) { + let ctxt_alloc_var = 13; + function skip_me() { + result = ctxt_alloc_param + ctxt_alloc_var; + } + return skip_me; + } + let f = inner_lazy(12); + f(); + assertEquals(25, result); +} + +TestSkippingDeeperLazyFunctions(); + +function TestEagerFunctionsBetweenLazyFunctions() { + let result = 0; + // We produce one data set for TestEagerFunctionsBetweenLazyFunctions and + // another one for inner. The variable data for eager belongs to the former + // data set. + let ctxt_allocated1 = 3; + (function eager() { + let ctxt_allocated2 = 4; + function inner() { + result = ctxt_allocated1 + ctxt_allocated2; + } + return inner; + })()(); + assertEquals(7, result); +} + +TestEagerFunctionsBetweenLazyFunctions(); + +function TestEagerNotIifeFunctionsBetweenLazyFunctions() { + let result = 0; + // We produce one data set for TestEagerFunctionsBetweenLazyFunctions and + // another one for inner. The variable data for eager belongs to the former + // data set. + let ctxt_allocated1 = 3; + (function eager_not_iife() { + let ctxt_allocated2 = 4; + function inner() { + result = ctxt_allocated1 + ctxt_allocated2; + } + return inner; + }); // Function not called; not an iife. + // This is just a regression test. We cannot test that the context allocation + // was done correctly (since there's no way to call eager_not_iife), but code + // like this used to trigger some DCHECKs. +} + +TestEagerNotIifeFunctionsBetweenLazyFunctions(); + +// Regression test for functions inside a lazy arrow function. (Only top-level +// arrow functions are lazy, so this cannot be wrapped in a function.) +result = 0; +let f1 = (ctxt_alloc_param) => { + let ctxt_alloc_var = 10; + function inner() { + result = ctxt_alloc_param + ctxt_alloc_var; + } + return inner; +} +f1(9)(); +assertEquals(19, result); diff --git a/deps/v8/test/mjsunit/smi-mul-const.js b/deps/v8/test/mjsunit/smi-mul-const.js index e5255014dc..64cc2e5f27 100644 --- a/deps/v8/test/mjsunit/smi-mul-const.js +++ b/deps/v8/test/mjsunit/smi-mul-const.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --noalways-opt +// Flags: --allow-natives-syntax --opt --noalways-opt --no-stress-fullcodegen function check(func, input, expected) { func(-1); diff --git a/deps/v8/test/mjsunit/smi-mul.js b/deps/v8/test/mjsunit/smi-mul.js index 12d206abec..ca1bf06b69 100644 --- a/deps/v8/test/mjsunit/smi-mul.js +++ b/deps/v8/test/mjsunit/smi-mul.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --opt --noalways-opt +// Flags: --allow-natives-syntax --opt --noalways-opt --no-stress-fullcodegen function mul(a, b) { return a * b; diff --git a/deps/v8/test/mjsunit/stack-overflow-arity-catch-noinline.js b/deps/v8/test/mjsunit/stack-overflow-arity-catch-noinline.js index a1f5d4e869..6d434c2ecb 100644 --- a/deps/v8/test/mjsunit/stack-overflow-arity-catch-noinline.js +++ b/deps/v8/test/mjsunit/stack-overflow-arity-catch-noinline.js @@ -32,7 +32,7 @@ function funcWith20Args(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, assertUnreachable("shouldn't arrive in non-inlined 20 arg function after stack overflow"); } -// If we should run with --turbo, then make sure {funcWith20Args} does +// If we should run with TurboFan, then make sure {funcWith20Args} does // not get inlined. %NeverOptimizeFunction(funcWith20Args); diff --git a/deps/v8/test/mjsunit/stack-traces.js b/deps/v8/test/mjsunit/stack-traces.js index 33552bbf5c..81418f70f7 100644 --- a/deps/v8/test/mjsunit/stack-traces.js +++ b/deps/v8/test/mjsunit/stack-traces.js @@ -391,9 +391,7 @@ assertTrue(desc.writable); // Check that exceptions thrown within prepareStackTrace throws an exception. Error.prepareStackTrace = function(e, frames) { throw 42; } - -var x = {} -assertThrows(() => Error.captureStackTrace(x)); +assertThrows(() => new Error().stack); // Check that we don't crash when CaptureSimpleStackTrace returns undefined. var o = {}; diff --git a/deps/v8/test/mjsunit/string-charcodeat.js b/deps/v8/test/mjsunit/string-charcodeat.js index 72dc8190af..335c4b317f 100644 --- a/deps/v8/test/mjsunit/string-charcodeat.js +++ b/deps/v8/test/mjsunit/string-charcodeat.js @@ -141,7 +141,6 @@ function TestStringType(generator, sixteen) { assertEquals(116, g().charCodeAt(3.14159), 26 + t); } - TestStringType(Cons, false); TestStringType(Deep, false); TestStringType(Slice, false); @@ -155,6 +154,15 @@ TestStringType(Slice16End, true); TestStringType(Flat16, true); TestStringType(NotAString16, true); +function Flat16Optimized() { + var str = Flat16(); + return str.charCodeAt(2); +} + +assertEquals(0x1234, Flat16Optimized()); +assertEquals(0x1234, Flat16Optimized()); +%OptimizeFunctionOnNextCall(Flat16Optimized); +assertEquals(0x1234, Flat16Optimized()); function ConsNotSmiIndex() { var str = Cons(); diff --git a/deps/v8/test/mjsunit/string-indexof-1.js b/deps/v8/test/mjsunit/string-indexof-1.js index d83c784fd1..0267b2c625 100644 --- a/deps/v8/test/mjsunit/string-indexof-1.js +++ b/deps/v8/test/mjsunit/string-indexof-1.js @@ -215,7 +215,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(0, f()); assertEquals(0, f()); assertEquals(0, f()); - % OptimizeFunctionOnNextCall(f); + %OptimizeFunctionOnNextCall(f); assertEquals(0, f()); function f2() { @@ -224,7 +224,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(-1, f2()); assertEquals(-1, f2()); assertEquals(-1, f2()); - % OptimizeFunctionOnNextCall(f2); + %OptimizeFunctionOnNextCall(f2); assertEquals(-1, f2()); function f3() { @@ -233,7 +233,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(0, f3()); assertEquals(0, f3()); assertEquals(0, f3()); - % OptimizeFunctionOnNextCall(f3); + %OptimizeFunctionOnNextCall(f3); assertEquals(0, f3()); function f4() { @@ -242,7 +242,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(3, f4()); assertEquals(3, f4()); assertEquals(3, f4()); - % OptimizeFunctionOnNextCall(f4); + %OptimizeFunctionOnNextCall(f4); assertEquals(3, f4()); function f5() { @@ -251,7 +251,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(1, f5()); assertEquals(1, f5()); assertEquals(1, f5()); - % OptimizeFunctionOnNextCall(f5); + %OptimizeFunctionOnNextCall(f5); assertEquals(1, f5()); function f6() { @@ -260,7 +260,7 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { assertEquals(1, f6()); assertEquals(1, f6()); assertEquals(1, f6()); - % OptimizeFunctionOnNextCall(f6); + %OptimizeFunctionOnNextCall(f6); assertEquals(1, f6()); })(); diff --git a/deps/v8/test/mjsunit/strong-rooted-literals.js b/deps/v8/test/mjsunit/strong-rooted-literals.js index 55ce89e4ef..68804e5a32 100644 --- a/deps/v8/test/mjsunit/strong-rooted-literals.js +++ b/deps/v8/test/mjsunit/strong-rooted-literals.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax --expose-gc --turbo --opt +// Flags: --allow-natives-syntax --expose-gc --opt // Make sure literals are strongly rooted and safe from weak-code deopts. @@ -15,7 +15,7 @@ foo(); foo(); - % OptimizeFunctionOnNextCall(foo); + %OptimizeFunctionOnNextCall(foo); foo(); gc(); assertOptimized(foo); @@ -32,7 +32,7 @@ var a = [1, 2, 3]; print(mapPlus(a, 1)); print(mapPlus(a, 2)); - % OptimizeFunctionOnNextCall(hot); + %OptimizeFunctionOnNextCall(hot); print(mapPlus(a, 3)); gc(); // BOOOM! assertOptimized(hot); diff --git a/deps/v8/test/mjsunit/test-builtins-setup.js b/deps/v8/test/mjsunit/test-builtins-setup.js new file mode 100644 index 0000000000..ba5e0587e4 --- /dev/null +++ b/deps/v8/test/mjsunit/test-builtins-setup.js @@ -0,0 +1,277 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +function CheckNoPrototype(object) { + var desc = Object.getOwnPropertyDescriptor(object, "prototype"); + assertEquals(undefined, desc); +} + +function CheckReadonlyPrototype(object) { + var desc = Object.getOwnPropertyDescriptor(object, "prototype"); + assertTrue(desc != undefined); + assertFalse(desc.enumerable); + assertFalse(desc.configurable); + assertFalse(desc.writable); +} + +function CheckMethodEx(object, prop_name, function_name, length) { + var desc = Object.getOwnPropertyDescriptor(object, prop_name); + assertTrue(desc != undefined); + assertEquals(function_name, desc.value.name); + assertEquals(length, desc.value.length, "Bad length of \"" + function_name + "\""); + assertFalse(desc.enumerable); + assertTrue(desc.configurable); + assertTrue(desc.writable); + assertThrows(() => new desc.value()); + // Check that built-in function is strict. + assertThrows(() => desc.value.arguments); + assertThrows(() => desc.value.caller); +} + +function CheckMethod(object, name, length) { + CheckMethodEx(object, name, name, length); +} + +function CheckGetter(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assertTrue(desc != undefined); + var expected_name = "get "; + if (typeof(name) == "symbol") { + name = name.toString().match("Symbol\\((.*)\\)")[1]; + expected_name += "[" + name + "]"; + } else { + expected_name += name; + } + assertEquals(expected_name, desc.get.name); + assertEquals(0, desc.get.length); + assertFalse(desc.enumerable); + assertTrue(desc.configurable); + // Check that built-in function is strict. + assertThrows(() => desc.get.arguments); + assertThrows(() => desc.get.caller); +} + + +(function TestIntrinsicConstructors() { + CheckReadonlyPrototype(Object); + CheckReadonlyPrototype(Function); + CheckReadonlyPrototype(Number); + CheckReadonlyPrototype(Boolean); + CheckReadonlyPrototype(Symbol); + CheckReadonlyPrototype(Date); + CheckReadonlyPrototype(RegExp); + CheckReadonlyPrototype(DataView); + CheckReadonlyPrototype(ArrayBuffer); + + var AsyncFunction = (async function(){}).constructor; + CheckReadonlyPrototype(AsyncFunction); + var GeneratorFunction = (function*(){}).constructor; + CheckReadonlyPrototype(GeneratorFunction); + + CheckReadonlyPrototype(Error); + CheckReadonlyPrototype(SyntaxError); + CheckReadonlyPrototype(RangeError); + CheckReadonlyPrototype(TypeError); + CheckReadonlyPrototype(ReferenceError); + CheckReadonlyPrototype(EvalError); + CheckReadonlyPrototype(URIError); + CheckReadonlyPrototype(Error); +})(); + + +(function TestIntl() { + if (typeof (Intl) == "undefined") return; + CheckMethod(Intl, "getCanonicalLocales", 1); + + CheckReadonlyPrototype(Intl.Collator); + CheckMethod(Intl.Collator, "supportedLocalesOf", 1); + CheckGetter(Intl.Collator.prototype, "compare"); + CheckMethod(Intl.Collator.prototype, "resolvedOptions", 0); + + CheckReadonlyPrototype(Intl.NumberFormat); + CheckMethod(Intl.NumberFormat, "supportedLocalesOf", 1); + CheckGetter(Intl.NumberFormat.prototype, "format"); + CheckMethod(Intl.NumberFormat.prototype, "resolvedOptions", 0); + + CheckReadonlyPrototype(Intl.DateTimeFormat); + CheckMethod(Intl.DateTimeFormat, "supportedLocalesOf", 1); + CheckGetter(Intl.DateTimeFormat.prototype, "format"); + CheckMethod(Intl.DateTimeFormat.prototype, "resolvedOptions", 0); + CheckMethod(Intl.DateTimeFormat.prototype, "formatToParts", 1); + + CheckReadonlyPrototype(Intl.v8BreakIterator); + CheckMethod(Intl.v8BreakIterator, "supportedLocalesOf", 1); + CheckMethod(Intl.v8BreakIterator.prototype, "resolvedOptions", 0); + CheckGetter(Intl.v8BreakIterator.prototype, "adoptText"); + CheckGetter(Intl.v8BreakIterator.prototype, "first"); + CheckGetter(Intl.v8BreakIterator.prototype, "next"); + CheckGetter(Intl.v8BreakIterator.prototype, "current"); + CheckGetter(Intl.v8BreakIterator.prototype, "breakType"); + + CheckMethod(String.prototype, "localeCompare", 1); + CheckMethod(String.prototype, "toLocaleLowerCase", 0); + CheckMethod(String.prototype, "toLocaleUpperCase", 0); + + CheckMethod(Number.prototype, "toLocaleString", 0); + + CheckMethod(Date.prototype, "toLocaleString", 0); + CheckMethod(Date.prototype, "toLocaleDateString", 0); + CheckMethod(Date.prototype, "toLocaleTimeString", 0); +})(); + + +(function TestCollection() { + CheckReadonlyPrototype(Set); + CheckMethod(Set.prototype, "add", 1); + CheckMethod(Set.prototype, "delete", 1); + CheckMethod(Set.prototype, "entries", 0); + assertTrue(Set.prototype.keys === Set.prototype.values); + assertTrue(Set.prototype[Symbol.iterator] === Set.prototype.values); + CheckMethod(Set.prototype, "values", 0); + + var SetIteratorPrototype = (new Set())[Symbol.iterator]().__proto__; + CheckMethod(SetIteratorPrototype, "next", 0); + assertEquals("Set Iterator", SetIteratorPrototype[Symbol.toStringTag]); + assertEquals( + undefined, + Object.getOwnPropertyDescriptor(SetIteratorPrototype, "constructor")); + + CheckReadonlyPrototype(Map); + CheckMethod(Map.prototype, "set", 2); + CheckMethod(Map.prototype, "delete", 1); + CheckMethod(Map.prototype, "entries", 0); + CheckMethod(Map.prototype, "keys", 0); + CheckMethod(Map.prototype, "values", 0); + assertTrue(Map.prototype[Symbol.iterator] === Map.prototype.entries); + + var MapIteratorPrototype = (new Map())[Symbol.iterator]().__proto__; + CheckMethod(MapIteratorPrototype, "next", 0); + assertEquals("Map Iterator", MapIteratorPrototype[Symbol.toStringTag]); + assertEquals( + undefined, + Object.getOwnPropertyDescriptor(MapIteratorPrototype, "constructor")); + + CheckReadonlyPrototype(WeakSet); + assertEquals(0, WeakSet.length); + CheckMethod(WeakSet.prototype, "add", 1); + CheckMethod(WeakSet.prototype, "delete", 1); + CheckMethod(WeakSet.prototype, "has", 1); + + CheckReadonlyPrototype(WeakMap); + assertEquals(0, WeakMap.length); + CheckMethod(WeakMap.prototype, "delete", 1); + CheckMethod(WeakMap.prototype, "get", 1); + CheckMethod(WeakMap.prototype, "has", 1); + CheckMethod(WeakMap.prototype, "set", 2); +})(); + + +(function TestTypedArrays() { + var TypedArray = Uint8Array.__proto__; + + CheckReadonlyPrototype(Int8Array); + CheckReadonlyPrototype(Uint8Array); + CheckReadonlyPrototype(Uint8ClampedArray); + CheckReadonlyPrototype(Int16Array); + CheckReadonlyPrototype(Uint16Array); + CheckReadonlyPrototype(Int32Array); + CheckReadonlyPrototype(Uint32Array); + CheckReadonlyPrototype(Float32Array); + CheckReadonlyPrototype(Float64Array); + + CheckReadonlyPrototype(TypedArray); + CheckMethod(TypedArray, "of", 0); + CheckMethod(TypedArray, "from", 1); + + CheckMethod(TypedArray.prototype, "subarray", 2); + CheckMethod(TypedArray.prototype, "set", 1); + CheckGetter(TypedArray.prototype, Symbol.toStringTag); + CheckMethod(TypedArray.prototype, "filter", 1); + CheckMethod(TypedArray.prototype, "find", 1); + CheckMethod(TypedArray.prototype, "findIndex", 1); + CheckMethod(TypedArray.prototype, "sort", 1); + CheckMethod(TypedArray.prototype, "toLocaleString", 0); + CheckMethod(TypedArray.prototype, "join", 1); +})(); + + +(function TestArray() { + CheckReadonlyPrototype(Array); + + CheckMethod(Array, "of", 0); + CheckMethod(Array, "from", 1); + + CheckMethod(Array.prototype, "concat", 1); + CheckMethod(Array.prototype, "copyWithin", 2); + CheckMethod(Array.prototype, "every", 1); + CheckMethod(Array.prototype, "fill", 1); + CheckMethod(Array.prototype, "filter", 1); + CheckMethod(Array.prototype, "find", 1); + CheckMethod(Array.prototype, "findIndex", 1); + CheckMethod(Array.prototype, "includes", 1); + CheckMethod(Array.prototype, "indexOf", 1); + CheckMethod(Array.prototype, "join", 1); + CheckMethod(Array.prototype, "lastIndexOf", 1); + CheckMethod(Array.prototype, "map", 1); + CheckMethod(Array.prototype, "pop", 0); + CheckMethod(Array.prototype, "push", 1); + CheckMethod(Array.prototype, "reduce", 1); + CheckMethod(Array.prototype, "reduceRight", 1); + CheckMethod(Array.prototype, "reverse", 0); + CheckMethod(Array.prototype, "shift", 0); + CheckMethod(Array.prototype, "slice", 2); + CheckMethod(Array.prototype, "some", 1); + CheckMethod(Array.prototype, "sort", 1); + CheckMethod(Array.prototype, "splice", 2); + CheckMethod(Array.prototype, "toLocaleString", 0); + CheckMethod(Array.prototype, "toString", 0); + CheckMethod(Array.prototype, "unshift", 1); + + CheckMethod(Array.prototype, "entries", 0); + CheckMethod(Array.prototype, "forEach", 1); + CheckMethod(Array.prototype, "keys", 0); + CheckMethodEx(Array.prototype, Symbol.iterator, "values", 0); +})(); + + +(function TestPromise() { + CheckReadonlyPrototype(Promise); + CheckMethod(Promise, "all", 1); + CheckMethod(Promise, "race", 1); + CheckMethod(Promise, "reject", 1); + CheckMethod(Promise, "resolve", 1); +})(); + + +(function TestProxy() { + CheckNoPrototype(Proxy); + CheckMethod(Proxy, "revocable", 2); +})(); + + +(function TestString() { + CheckReadonlyPrototype(String); + CheckMethod(String, "raw", 1); + + CheckMethod(String.prototype, "codePointAt", 1); + CheckMethod(String.prototype, "match", 1); + CheckMethod(String.prototype, "padEnd", 1); + CheckMethod(String.prototype, "padStart", 1); + CheckMethod(String.prototype, "repeat", 1); + CheckMethod(String.prototype, "search", 1); + CheckMethod(String.prototype, "link", 1); + CheckMethod(String.prototype, "anchor", 1); + CheckMethod(String.prototype, "fontcolor", 1); + CheckMethod(String.prototype, "fontsize", 1); + CheckMethod(String.prototype, "big", 0); + CheckMethod(String.prototype, "blink", 0); + CheckMethod(String.prototype, "bold", 0); + CheckMethod(String.prototype, "fixed", 0); + CheckMethod(String.prototype, "italics", 0); + CheckMethod(String.prototype, "small", 0); + CheckMethod(String.prototype, "strike", 0); + CheckMethod(String.prototype, "sub", 0); + CheckMethod(String.prototype, "sup", 0); +})(); diff --git a/deps/v8/test/mjsunit/type-profile/collect-type-profile.js b/deps/v8/test/mjsunit/type-profile/collect-type-profile.js index c0dfb75f13..deff079cdb 100644 --- a/deps/v8/test/mjsunit/type-profile/collect-type-profile.js +++ b/deps/v8/test/mjsunit/type-profile/collect-type-profile.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --type-profile --turbo --allow-natives-syntax +// Flags: --type-profile --no-stress-fullcodegen --allow-natives-syntax function check_collect_types(name, expected) { const type_profile = %TypeProfile(name); @@ -36,7 +36,7 @@ testFunction(123, true); testFunction('hello'); testFunction(123); -expected = `{\"503\":[\"Object\",\"number\",\"string\",\"number\"],\"510\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\"],\"699\":[\"Object\",\"number\",\"string\",\"number\"]}`; +expected = `{\"519\":[\"Object\",\"number\",\"string\",\"number\"],\"526\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\"],\"715\":[\"Object\",\"number\",\"string\",\"number\"]}`; check_collect_types(testFunction, expected); testFunction(undefined); @@ -45,7 +45,7 @@ testFunction({x: 12}, true); testFunction({x: 12}); testFunction(new MyClass()); -expected = `{\"503\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"],\"510\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\",\"undefined\",\"boolean\",\"boolean\",\"undefined\",\"undefined\"],\"699\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"]}`; +expected = `{\"519\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"],\"526\":[\"undefined\",\"boolean\",\"undefined\",\"undefined\",\"undefined\",\"boolean\",\"boolean\",\"undefined\",\"undefined\"],\"715\":[\"Object\",\"number\",\"string\",\"number\",\"undefined\",\"string\",\"Object\",\"Object\",\"MyClass\"]}`; check_collect_types(testFunction, expected); @@ -53,7 +53,7 @@ function testReturnOfNonVariable() { return 32; } testReturnOfNonVariable(); -expected = `{\"1732\":[\"number\"]}`; +expected = `{\"1748\":[\"number\"]}`; check_collect_types(testReturnOfNonVariable, expected); // Return statement is reached but its expression is never really returned. @@ -65,7 +65,7 @@ function try_finally() { } } try_finally(); -expected = `{\"2034\":[\"string\"]}`; +expected = `{\"2050\":[\"string\"]}`; check_collect_types(try_finally, expected); // Fall-off return. @@ -73,7 +73,7 @@ function fall_off() { //nothing } fall_off(); -expected = `{\"2188\":[\"undefined\"]}`; +expected = `{\"2204\":[\"undefined\"]}`; check_collect_types(fall_off, expected); // Do not collect types when the function is never run. @@ -86,5 +86,5 @@ function several_params(a, b, c, d) { //nothing } several_params(2, 'foo', {}, new MyClass()); -expected = `{\"2456\":[\"number\"],\"2459\":[\"string\"],\"2462\":[\"Object\"],\"2465\":[\"MyClass\"],\"2482\":[\"undefined\"]}`; +expected = `{\"2472\":[\"number\"],\"2475\":[\"string\"],\"2478\":[\"Object\"],\"2481\":[\"MyClass\"],\"2498\":[\"undefined\"]}`; check_collect_types(several_params, expected); diff --git a/deps/v8/test/mjsunit/unbox-double-arrays.js b/deps/v8/test/mjsunit/unbox-double-arrays.js index ef29bafebe..2bebddb449 100644 --- a/deps/v8/test/mjsunit/unbox-double-arrays.js +++ b/deps/v8/test/mjsunit/unbox-double-arrays.js @@ -47,7 +47,7 @@ function force_to_fast_double_array(a) { for (var i= 0; i < approx_dict_to_elements_threshold; ++i ) { a[i] = expected_array_value(i); } - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function make_object_like_array(size) { @@ -73,47 +73,47 @@ function testOneArrayType(allocator) { // Multiple versions of the test function makes sure that IC/Crankshaft state // doesn't get reused. function test_various_loads(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads2(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads3(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads4(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads5(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); if (value_5 != undefined) { assertEquals(value_5, a[5]); }; @@ -123,35 +123,35 @@ function testOneArrayType(allocator) { } assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads6(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_loads7(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); assertEquals(value_5, a[5]); assertEquals(value_6, a[6]); assertEquals(value_6, a[computed_6()]); // Test non-constant key assertEquals(value_7, a[7]); assertEquals(large_array_size, a.length); - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } function test_various_stores(a, value_5, value_6, value_7) { - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); a[5] = value_5; a[computed_6()] = value_6; a[7] = value_7; - assertTrue(%HasFastDoubleElements(a)); + assertTrue(%HasDoubleElements(a)); } // Test double and integer values @@ -346,7 +346,7 @@ function testOneArrayType(allocator) { expected_array_value(7)); // Make sure that we haven't converted from fast double. - assertTrue(%HasFastDoubleElements(large_array)); + assertTrue(%HasDoubleElements(large_array)); } // Force gc here to start with a clean heap if we repeat this test multiple @@ -357,7 +357,7 @@ testOneArrayType(Array); var large_array = new Array(large_array_size); force_to_fast_double_array(large_array); -assertTrue(%HasFastDoubleElements(large_array)); +assertTrue(%HasDoubleElements(large_array)); // Cause the array to grow beyond it's JSArray length. This will double the // size of the capacity and force the array into "slow" dictionary case. @@ -379,7 +379,7 @@ delete large_array2[5]; // Convert back to fast elements and make sure the contents of the array are // unchanged. large_array2[25] = new Object(); -assertTrue(%HasFastObjectElements(large_array2)); +assertTrue(%HasObjectElements(large_array2)); for (var i= 0; i < approx_dict_to_elements_threshold; i += 500 ) { if (i != 25 && i != 5) { assertEquals(expected_array_value(i), large_array2[i]); @@ -397,7 +397,7 @@ force_to_fast_double_array(large_array3); large_array3.length = 60000; assertEquals(60000, large_array3.length); assertEquals(undefined, large_array3[60000]); -assertTrue(%HasFastDoubleElements(large_array3)); +assertTrue(%HasDoubleElements(large_array3)); assertEquals(expected_array_value(5), large_array3[5]); assertEquals(expected_array_value(6), large_array3[6]); assertEquals(expected_array_value(7), large_array3[7]); @@ -413,7 +413,7 @@ for (var i= 0; i < large_array3.length; i += 501 ) { large_array3.length = 25; assertEquals(25, large_array3.length); -assertTrue(%HasFastDoubleElements(large_array3)); +assertTrue(%HasDoubleElements(large_array3)); assertEquals(undefined, large_array3[25]); assertEquals(expected_array_value(5), large_array3[5]); assertEquals(expected_array_value(6), large_array3[6]); @@ -431,7 +431,7 @@ for (var i= 0; i < large_array3.length; ++i) { large_array3.length = 100; assertEquals(100, large_array3.length); large_array3[95] = 95; -assertTrue(%HasFastDoubleElements(large_array3)); +assertTrue(%HasDoubleElements(large_array3)); assertEquals(undefined, large_array3[100]); assertEquals(95, large_array3[95]); assertEquals(expected_array_value(5), large_array3[5]); diff --git a/deps/v8/test/mjsunit/undetectable.js b/deps/v8/test/mjsunit/undetectable.js index f4871f995c..69a370a00a 100644 --- a/deps/v8/test/mjsunit/undetectable.js +++ b/deps/v8/test/mjsunit/undetectable.js @@ -72,16 +72,22 @@ function testFors() { assertEquals(1, j); } +function testCall() { + obj(); +} + for (var j = 0; j < 5; j++) { testCompares(); testIfs(); testWhiles(); testFors(); + testCall(); if (j == 3) { %OptimizeFunctionOnNextCall(testCompares); %OptimizeFunctionOnNextCall(testIfs); %OptimizeFunctionOnNextCall(testWhiles); %OptimizeFunctionOnNextCall(testFors); + %OptimizeFunctionOnNextCall(testCall); } } diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm.js b/deps/v8/test/mjsunit/wasm/asm-wasm.js index 9d7a807bc9..0a642f2ab7 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm.js @@ -1145,9 +1145,6 @@ function TestForeignVariables() { TestCase({baz: 345.7}, 0, NaN, 345, 345.7); // Check that undefined values are converted to proper defaults. TestCase({qux: 999}, 0, NaN, 0, NaN); - // Check that an undefined ffi is ok. - // TODO(v8:6127): Fix handling of this case and re-enable. -// TestCase(undefined, 0, NaN, 0, NaN); // Check that true values are converted properly. TestCase({foo: true, bar: true, baz: true}, 1, 1.0, 1, 1.0); // Check that false values are converted properly. @@ -1156,38 +1153,9 @@ function TestForeignVariables() { TestCase({foo: null, bar: null, baz: null}, 0, 0, 0, 0); // Check that string values are converted properly. TestCase({foo: 'hi', bar: 'there', baz: 'dude'}, 0, NaN, 0, NaN); - TestCase({foo: '0xff', bar: '234', baz: '456.1'}, 255, 234, 456, 456.1, 456); - // Check that Date values are converted properly. - TestCase({foo: new Date(123), bar: new Date(456), - baz: new Date(789)}, 123, 456, 789, 789); - // Check that list values are converted properly. - TestCase({foo: [], bar: [], baz: []}, 0, 0, 0, 0); - // Check that object values are converted properly. - TestCase({foo: {}, bar: {}, baz: {}}, 0, NaN, 0, NaN); - // Check that getter object values are converted properly. - var o = { - get foo() { - return 123.4; - } - }; - TestCase({foo: o.foo, bar: o.foo, baz: o.foo}, 123, 123.4, 123, 123.4); - // Check that getter object values are converted properly. - var o = { - get baz() { - return 123.4; - } - }; - TestCase(o, 0, NaN, 123, 123.4); - // Check that objects with valueOf are converted properly. - var o = { - valueOf: function() { return 99; } - }; - TestCase({foo: o, bar: o, baz: o}, 99, 99, 99, 99); + TestCase({foo: '0xff', bar: '234', baz: '456.1'}, 255, 234, 456, 456.1); // Check that function values are converted properly. TestCase({foo: TestCase, bar: TestCase, qux: TestCase}, 0, NaN, 0, NaN); - // Check that a missing ffi object is safe. - // TODO(v8:6127): Fix handling of this case and re-enable. -// TestCase(undefined, 0, NaN, 0, NaN); } print("TestForeignVariables..."); diff --git a/deps/v8/test/mjsunit/wasm/async-compile.js b/deps/v8/test/mjsunit/wasm/async-compile.js index b95930aa5a..854e8bb6c1 100644 --- a/deps/v8/test/mjsunit/wasm/async-compile.js +++ b/deps/v8/test/mjsunit/wasm/async-compile.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-wasm --allow-natives-syntax +// Flags: --wasm-async-compilation --expose-wasm --allow-natives-syntax load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); diff --git a/deps/v8/test/mjsunit/wasm/compilation-limits-asm.js b/deps/v8/test/mjsunit/wasm/compilation-limits-asm.js index 4a4d0c7618..1eb00e9ee6 100644 --- a/deps/v8/test/mjsunit/wasm/compilation-limits-asm.js +++ b/deps/v8/test/mjsunit/wasm/compilation-limits-asm.js @@ -4,7 +4,7 @@ // Flags: --allow-natives-syntax --validate-asm -// Compilation limits for WASM are not enforced for asm->wasm. +// Compilation limits for wasm are not enforced for asm->wasm. %SetWasmCompileControls(0, false); function AsmModule() { diff --git a/deps/v8/test/mjsunit/wasm/compilation-limits.js b/deps/v8/test/mjsunit/wasm/compilation-limits.js index 2cc38bdfea..2b79de008f 100644 --- a/deps/v8/test/mjsunit/wasm/compilation-limits.js +++ b/deps/v8/test/mjsunit/wasm/compilation-limits.js @@ -65,45 +65,10 @@ async function FailSyncInstantiate() { } } -async function FailAsyncCompile() { - print("FailAsyncCompile..."); - %SetWasmCompileControls(buffer.byteLength - 1, false); - assertThrows(() => new WebAssembly.Module(buffer), RangeError); - - print(" wait"); - try { - let m = await WebAssembly.compile(buffer); - print(" cont"); - assertUnreachable(); - } catch (e) { - print(" catch: " + e); - assertTrue(e instanceof RangeError); - } -} - -async function FailAsyncInstantiate() { - print("FailAsyncInstantiate..."); - %SetWasmCompileControls(buffer.byteLength - 1, false); - assertThrows(() => new WebAssembly.Instance(buffer), RangeError); - - print(" wait"); - try { - let m = await WebAssembly.instantiate(buffer); - print(" cont"); - assertUnreachable(); - } catch (e) { - print(" catch: " + e); - assertTrue(e instanceof RangeError); - } -} - - async function TestAll() { await SuccessfulTest(); await FailSyncCompile(); await FailSyncInstantiate(); - await FailAsyncCompile(); - await FailAsyncInstantiate(); } assertPromiseResult(TestAll()); diff --git a/deps/v8/test/mjsunit/wasm/exceptions.js b/deps/v8/test/mjsunit/wasm/exceptions.js index e7260cde36..dc5d1e5f32 100644 --- a/deps/v8/test/mjsunit/wasm/exceptions.js +++ b/deps/v8/test/mjsunit/wasm/exceptions.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-wasm --wasm-eh-prototype +// Flags: --expose-wasm --experimental-wasm-eh load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); diff --git a/deps/v8/test/mjsunit/wasm/export-global.js b/deps/v8/test/mjsunit/wasm/export-global.js new file mode 100644 index 0000000000..470851d87c --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/export-global.js @@ -0,0 +1,58 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function exportImmutableGlobal() { + var builder = new WasmModuleBuilder(); + let globals = [ + [kWasmI32, 'i32_noinit'], // - + [kWasmI32, 'i32', 4711], // - + [kWasmF32, 'f32_noinit'], // - + [kWasmF32, 'f32', Math.fround(3.14)], // - + [kWasmF64, 'f64_noinit'], // - + [kWasmF64, 'f64', 1 / 7] // - + ]; + for (let g of globals) { + let global_builder = builder.addGlobal(g[0], false).exportAs(g[1]); + if (g[2]) global_builder.init = g[2]; + } + var module = builder.instantiate(); + + for (let g of globals) { + assertEquals("number", typeof module.exports[g[1]], g[1]); + assertEquals(g[2] || 0, module.exports[g[1]], g[1]); + } +})(); + +(function cannotExportMutableGlobal() { + var builder = new WasmModuleBuilder(); + builder.addGlobal(kWasmI32, true).exportAs('g'); + assertThrows(() => builder.instantiate(), WebAssembly.CompileError); +})(); + +(function cannotExportI64Global() { + var builder = new WasmModuleBuilder(); + builder.addGlobal(kWasmI64, false).exportAs('g'); + assertThrows(() => builder.instantiate(), WebAssembly.LinkError); +})(); + +(function duplicateGlobalExportName() { + var builder = new WasmModuleBuilder(); + builder.addGlobal(kWasmI64, false).exportAs('g'); + builder.addGlobal(kWasmI64, false).exportAs('g'); + assertThrows( + () => builder.instantiate(), WebAssembly.CompileError, + /Duplicate export name 'g' for global 0 and global 1/); +})(); + +(function exportNameClashWithFunction() { + var builder = new WasmModuleBuilder(); + builder.addGlobal(kWasmI64, false).exportAs('foo'); + builder.addFunction('f', kSig_v_v).addBody([]).exportAs('foo'); + assertThrows( + () => builder.instantiate(), WebAssembly.CompileError, + /Duplicate export name 'foo' for global 0 and function 0/); +})(); diff --git a/deps/v8/test/mjsunit/wasm/export-table.js b/deps/v8/test/mjsunit/wasm/export-table.js index cc10b13789..cb9d565a7e 100644 --- a/deps/v8/test/mjsunit/wasm/export-table.js +++ b/deps/v8/test/mjsunit/wasm/export-table.js @@ -106,12 +106,8 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); builder.addFunction("two", kSig_v_v).addBody([kExprNop]).exportAs("other"); builder.addFunction("three", kSig_v_v).addBody([kExprNop]).exportAs("main"); - try { - builder.instantiate(); - assertUnreachable("should have thrown an exception"); - } catch (e) { - assertContains("Duplicate export", e.toString()); - } + assertThrows(() => builder.instantiate(), WebAssembly.CompileError, + /Duplicate export name 'main' for function 0 and function 2/); })(); diff --git a/deps/v8/test/mjsunit/wasm/gc-buffer.js b/deps/v8/test/mjsunit/wasm/gc-buffer.js index f187d7dabe..42cf6ae5ff 100644 --- a/deps/v8/test/mjsunit/wasm/gc-buffer.js +++ b/deps/v8/test/mjsunit/wasm/gc-buffer.js @@ -9,7 +9,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); function run(f) { // wrap the creation in a closure so that the only thing returned is - // the module (i.e. the underlying array buffer of WASM wire bytes dies). + // the module (i.e. the underlying array buffer of wasm wire bytes dies). var module = (() => { var builder = new WasmModuleBuilder(); builder.addImport("mod", "the_name_of_my_import", kSig_i_i); diff --git a/deps/v8/test/mjsunit/wasm/gc-stress.js b/deps/v8/test/mjsunit/wasm/gc-stress.js index a6c408d3db..db425ea81d 100644 --- a/deps/v8/test/mjsunit/wasm/gc-stress.js +++ b/deps/v8/test/mjsunit/wasm/gc-stress.js @@ -30,8 +30,8 @@ function run(f) { } (function test() { - for (var i = 0; i < 100; i++) { - run(x => (x + 19)); + for (var i = 0; i < 10; i++) { + run(x => (x + 19 + i)); run(x => (x - 18)); } })(); diff --git a/deps/v8/test/mjsunit/wasm/graceful_shutdown.js b/deps/v8/test/mjsunit/wasm/graceful_shutdown.js new file mode 100644 index 0000000000..53d3801368 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/graceful_shutdown.js @@ -0,0 +1,30 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm --wasm-async-compilation + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function CompileFunctionsTest() { + // Create a big module. + var builder = new WasmModuleBuilder(); + + builder.addMemory(1, 1, true); + for (i = 0; i < 100; i++) { + builder.addFunction("sub" + i, kSig_i_i) + .addBody([ // -- + kExprGetLocal, 0, // -- + kExprI32Const, i % 61, // -- + kExprI32Sub]) // -- + .exportFunc() + } + + var buffer = builder.toBuffer(); + // Start the compilation but do not wait for the promise to resolve + // with assertPromiseResult. This should not cause a crash. + WebAssembly.compile(buffer).then( + () => { print("success")}, + () => { print("failed"); }); +})(); diff --git a/deps/v8/test/mjsunit/wasm/grow-memory.js b/deps/v8/test/mjsunit/wasm/grow-memory.js index 71eb4fec95..a428896847 100644 --- a/deps/v8/test/mjsunit/wasm/grow-memory.js +++ b/deps/v8/test/mjsunit/wasm/grow-memory.js @@ -8,7 +8,7 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); var kPageSize = 0x10000; -var kV8MaxPages = 16384; +var kV8MaxPages = 32767; function genGrowMemoryBuilder() { var builder = new WasmModuleBuilder(); @@ -298,9 +298,8 @@ function testGrowMemoryTrapMaxPagesZeroInitialMemory() { var builder = genGrowMemoryBuilder(); builder.addMemory(0, kV8MaxPages, false); var module = builder.instantiate(); - var maxPages = 16385; function growMem(pages) { return module.exports.grow_memory(pages); } - assertEquals(-1, growMem(maxPages)); + assertEquals(-1, growMem(kV8MaxPages + 1)); } testGrowMemoryTrapMaxPagesZeroInitialMemory(); @@ -309,9 +308,8 @@ function testGrowMemoryTrapMaxPages() { var builder = genGrowMemoryBuilder(); builder.addMemory(1, 1, false); var module = builder.instantiate(); - var maxPages = 16384; function growMem(pages) { return module.exports.grow_memory(pages); } - assertEquals(-1, growMem(maxPages)); + assertEquals(-1, growMem(kV8MaxPages)); } testGrowMemoryTrapMaxPages(); @@ -493,3 +491,54 @@ function testGrowMemoryDeclaredSpecMaxTraps() { } testGrowMemoryDeclaredSpecMaxTraps(); + +function testGrowMemory2Gb() { + print("testGrowMemory2Gb"); + var builder = genGrowMemoryBuilder(); + builder.addMemory(1, kV8MaxPages, false); + var module = builder.instantiate(); + var offset, val; + function peek() { return module.exports.load(offset); } + function poke(value) { return module.exports.store(offset, value); } + function growMem(pages) { return module.exports.grow_memory(pages); } + + for(offset = 0; offset <= (kPageSize - 4); offset+=4) { + poke(100000 - offset); + assertEquals(100000 - offset, peek()); + } + + let result = growMem(kV8MaxPages - 1); + if (result == 1 ){ + for(offset = 0; offset <= (kPageSize - 4); offset+=4) { + assertEquals(100000 - offset, peek()); + } + + // Bounds check for large mem size + for(offset = (kV8MaxPages - 1) * kPageSize; + offset <= (kV8MaxPages * kPageSize - 4); offset+=4) { + poke(0xaced); + assertEquals(0xaced, peek()); + } + + for (offset = kV8MaxPages * kPageSize - 3; + offset <= kV8MaxPages * kPageSize + 4; offset++) { + assertTraps(kTrapMemOutOfBounds, poke); + } + + // Check traps around 3GB/4GB boundaries + let offset_3gb = 49152 * kPageSize; + let offset_4gb = 2 * kV8MaxPages * kPageSize; + for (offset = offset_3gb - 5; offset < offset_3gb + 4; offset++) { + assertTraps(kTrapMemOutOfBounds, poke); + } + for (offset = offset_4gb - 5; offset < offset_4gb; offset++) { + assertTraps(kTrapMemOutOfBounds, poke); + } + } else { + // Allocating big chunks of memory can fail on gc_stress, especially on 32 + // bit platforms. When grow_memory fails, expected result is -1. + assertEquals(-1, result); + } +} + +testGrowMemory2Gb(); diff --git a/deps/v8/test/mjsunit/wasm/import-memory.js b/deps/v8/test/mjsunit/wasm/import-memory.js index 178febdff4..b5dd620546 100644 --- a/deps/v8/test/mjsunit/wasm/import-memory.js +++ b/deps/v8/test/mjsunit/wasm/import-memory.js @@ -149,6 +149,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function TestGrowMemoryZeroInitialMemory() { print("ZeroInitialMemory"); + let kV8MaxPages = 32767; let memory = new WebAssembly.Memory({initial: 0}); assertEquals(0, memory.buffer.byteLength); let i32 = new Int32Array(memory.buffer); @@ -176,7 +177,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { assertThrows(load); } - assertThrows(() => memory.grow(16381)); + assertThrows(() => memory.grow(kV8MaxPages - 3)); })(); (function ImportedMemoryBufferLength() { diff --git a/deps/v8/test/mjsunit/wasm/indirect-sig-mismatch.js b/deps/v8/test/mjsunit/wasm/indirect-sig-mismatch.js new file mode 100644 index 0000000000..5e6e7169a1 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/indirect-sig-mismatch.js @@ -0,0 +1,152 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +const kTableSize = 3; + +var m_i_v; +var m_i_i; +var m_i_ii; + +(function BuildExportedMethods() { + print("BuildingExportedMethods..."); + let builder = new WasmModuleBuilder(); + + let sig_v_v = builder.addType(kSig_v_v); + let sig_i_ii = builder.addType(kSig_i_ii); + let sig_i_i = builder.addType(kSig_i_i); + let sig_i_v = builder.addType(kSig_i_v); + + print("exported[i_v] = " + sig_i_v); + print("exported[i_i] = " + sig_i_i); + print("exported[i_ii] = " + sig_i_ii); + + builder.addFunction("", sig_i_v) + .addBody([ + kExprI32Const, 41]) // -- + .exportAs("m_i_v"); + + builder.addFunction("m_i_i", sig_i_i) + .addBody([ + kExprI32Const, 42]) // -- + .exportAs("m_i_i"); + + builder.addFunction("m_i_ii", sig_i_ii) + .addBody([ + kExprI32Const, 43]) // -- + .exportAs("m_i_ii"); + + let module = new WebAssembly.Module(builder.toBuffer()); + let instance = new WebAssembly.Instance(module); + m_i_v = instance.exports.m_i_v; + m_i_i = instance.exports.m_i_i; + m_i_ii = instance.exports.m_i_ii; + + m_i_v.sig = kSig_i_v; + m_i_i.sig = kSig_i_i; + m_i_ii.sig = kSig_i_ii; +})(); + +function caller_module() { + let builder = new WasmModuleBuilder(); + + let sig_i_v = builder.addType(kSig_i_v); + let sig_i_ii = builder.addType(kSig_i_ii); + let sig_i_i = builder.addType(kSig_i_i); + + print("imported[i_v] = " + sig_i_v); + print("imported[i_i] = " + sig_i_i); + print("imported[i_ii] = " + sig_i_ii); + + + builder.addFunction("call1", sig_i_i) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_i_v, kTableZero]) // -- + .exportAs("call1"); + + builder.addFunction("call2", sig_i_i) + .addBody([ + kExprI32Const, 11, // -- + kExprGetLocal, 0, + kExprCallIndirect, sig_i_i, kTableZero]) // -- + .exportAs("call2"); + + builder.addFunction("call3", sig_i_i) + .addBody([ + kExprI32Const, 21, + kExprI32Const, 22, + kExprGetLocal, 0, + kExprCallIndirect, sig_i_ii, kTableZero]) // -- + .exportAs("call3"); + + builder.addImportedTable("imp", "table", kTableSize, kTableSize); + + return builder.toModule(); +} + +function call(func, ...args) { + try { + return "" + func.apply(undefined, args); + } catch (e) { + return "!" + e; + } +} + +function DoCalls(table, calls) { + for (func of calls) { + print("func = " + func); + for (var i = 0; i < 4; i++) { + print(" i = " + i); + var expectThrow = true; + var exp = null; + if (i < table.length) { + exported = table.get(i); + expectThrow = (exported.sig != func.sig); + print(" exp=" + exported); + print(" throw=" + expectThrow); + } else { + print(" exp=<oob>"); + } + print(" result=" + call(func, i)); + if (expectThrow) { + assertThrows(() => func(i), WebAssembly.RuntimeError); + } else { + assertEquals(exported(0), func(i)); + } + } + } +} + +(function TestExecute() { + print("TestExecute"); + let module = caller_module(); + let table = new WebAssembly.Table({element: "anyfunc", + initial: kTableSize, maximum: kTableSize}); + let instance = new WebAssembly.Instance(module, {imp: {table: table}}); + instance.exports.call1.sig = kSig_i_v; + instance.exports.call2.sig = kSig_i_i; + instance.exports.call3.sig = kSig_i_ii; + + let exports = [m_i_v, m_i_i, m_i_ii]; + let calls = [instance.exports.call1, + instance.exports.call2, + instance.exports.call3]; + + for (f0 of exports) { + for (f1 of exports) { + for (f2 of exports) { + table.set(0, f0); + table.set(1, f1); + table.set(2, f2); + + DoCalls(table, calls); + } + } + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/indirect-tables.js b/deps/v8/test/mjsunit/wasm/indirect-tables.js index 9bc646e2f0..e3e6e00773 100644 --- a/deps/v8/test/mjsunit/wasm/indirect-tables.js +++ b/deps/v8/test/mjsunit/wasm/indirect-tables.js @@ -524,10 +524,56 @@ function js_div(a, b) { return (a / b) | 0; } assertThrows(() => table.grow(21)); })(); +(function MultipleElementSegments() { + let kTableSize = 10; + print("MultipleElementSegments..."); + + let mul = (a, b) => a * b; + let add = (a, b) => a + b; + let sub = (a, b) => a - b; + + // Test 1 to 3 segments in the elements section. + // segment 1 sets [1, 2] to mul, + // segment 2 sets [2, 3, 4] to add, + // segment 3 sets [3, 4, 5, 6] to sub. + for (let num_segments = 1; num_segments < 4; ++num_segments) { + var builder = new WasmModuleBuilder(); + + builder.setFunctionTableLength(kTableSize); + builder.addExportOfKind("table", kExternalTable, 0); + let f = AddFunctions(builder); + let indexes = [f.mul.index, f.add.index, f.sub.index]; + for (let i = 0; i < num_segments; ++i) { + let offset = i + 1; + let len = i + 2; + let index = indexes[i]; + builder.addFunctionTableInit(offset, false, new Array(len).fill(index)); + } + + let instance = builder.instantiate(); + + let table = instance.exports.table; + assertEquals(kTableSize, table.length); + + for (let i = 0; i < num_segments; ++i) { + let exp = i < 1 || i > 2 ? null : mul; + if (num_segments > 1 && i >= 2 && i <= 4) exp = add; + if (num_segments > 2 && i >= 3 && i <= 6) exp = sub; + if (!exp) { + assertSame(null, table.get(i)); + } else { + assertEquals("function", typeof table.get(i)); + assertEquals(exp(6, 3), table.get(i)(6, 3)); + } + } + } +})(); + (function InitImportedTableSignatureMismatch() { // instance0 exports a function table and a main function which indirectly // calls a function from the table. let builder0 = new WasmModuleBuilder(); + builder0.setName('module_0'); let sig_index = builder0.addType(kSig_i_v); builder0.addFunction('main', kSig_i_i) .addBody([ @@ -542,6 +588,7 @@ function js_div(a, b) { return (a / b) | 0; } // instance1 imports the table and adds a function to it. let builder1 = new WasmModuleBuilder(); + builder1.setName('module_1'); builder1.addFunction('f', kSig_i_i).addBody([kExprGetLocal, 0]); builder1.addImportedTable('z', 'table'); builder1.addFunctionTableInit(0, false, [0], true); @@ -552,5 +599,6 @@ function js_div(a, b) { return (a / b) | 0; } // Calling the main method on instance0 should fail, because the signature of // the added function does not match. assertThrows( - () => instance0.exports.main(0), WebAssembly.RuntimeError); + () => instance0.exports.main(0), WebAssembly.RuntimeError, + /signature mismatch/); })(); diff --git a/deps/v8/test/mjsunit/wasm/interpreter-mixed.js b/deps/v8/test/mjsunit/wasm/interpreter-mixed.js index 3d5788c4d5..e0249ce799 100644 --- a/deps/v8/test/mjsunit/wasm/interpreter-mixed.js +++ b/deps/v8/test/mjsunit/wasm/interpreter-mixed.js @@ -39,7 +39,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js'); // Initially, we can load from offset 12, but not OOB. var oob_index = kNumPages * kPageSize; - var initial_interpreted = % WasmNumInterpretedCalls(instance); + var initial_interpreted = %WasmNumInterpretedCalls(instance); assertEquals(0, exp.load(12)); assertEquals(0, exp.load_interpreted(12)); assertTraps(kTrapMemOutOfBounds, () => exp.load(oob_index)); @@ -74,5 +74,5 @@ load('test/mjsunit/wasm/wasm-module-builder.js'); assertEquals(-1, exp.grow_memory(kMaxPages - kNumPages + 1)); assertEquals(-1, exp.grow_memory_interpreted(kMaxPages - kNumPages + 1)); // Overall, we executed 9 functions in the interpreter. - assertEquals(initial_interpreted + 9, % WasmNumInterpretedCalls(instance)); + assertEquals(initial_interpreted + 9, %WasmNumInterpretedCalls(instance)); })(); diff --git a/deps/v8/test/mjsunit/wasm/interpreter.js b/deps/v8/test/mjsunit/wasm/interpreter.js index e311616e6e..0f54dc97d3 100644 --- a/deps/v8/test/mjsunit/wasm/interpreter.js +++ b/deps/v8/test/mjsunit/wasm/interpreter.js @@ -33,13 +33,13 @@ function checkStack(stack, expected_lines) { var instance = builder.instantiate({mod: {func: func}}); // Test that this does not mess up internal state by executing it three times. for (var i = 0; i < 3; ++i) { - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); instance.exports.main(); - assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance)); checkStack(stripPath(stack), [ 'Error: test imported stack', // - /^ at func \(interpreter.js:\d+:28\)$/, // - - ' at main (<WASM>[1]+1)', // - + ' at main (wasm-function[1]:1)', // - /^ at testCallImported \(interpreter.js:\d+:22\)$/, // - /^ at interpreter.js:\d+:3$/ ]); @@ -69,10 +69,10 @@ function checkStack(stack, expected_lines) { ]) .exportFunc(); var instance = builder.instantiate({mod: {func1: func1, func2: func2}}); - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); var args = [11, 0.3]; var ret = instance.exports.main(...args); - assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance)); var passed_test_args = [...passed_args]; var expected = func1(args[0], args[0] + 1) + func2(args[1]) | 0; assertEquals(expected, ret); @@ -90,7 +90,7 @@ function checkStack(stack, expected_lines) { var instance = builder.instantiate(); // Test that this does not mess up internal state by executing it three times. for (var i = 0; i < 3; ++i) { - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); var stack; try { instance.exports.main(); @@ -98,11 +98,11 @@ function checkStack(stack, expected_lines) { } catch (e) { stack = e.stack; } - assertEquals(interpreted_before + 2, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance)); checkStack(stripPath(stack), [ 'RuntimeError: unreachable', // - - ' at foo (<WASM>[0]+3)', // - - ' at main (<WASM>[1]+2)', // - + ' at foo (wasm-function[0]:3)', // - + ' at main (wasm-function[1]:2)', // - /^ at testTrap \(interpreter.js:\d+:24\)$/, // - /^ at interpreter.js:\d+:3$/ ]); @@ -121,7 +121,7 @@ function checkStack(stack, expected_lines) { var instance = builder.instantiate({mod: {func: func}}); // Test that this does not mess up internal state by executing it three times. for (var i = 0; i < 3; ++i) { - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); var stack; try { instance.exports.main(); @@ -129,11 +129,11 @@ function checkStack(stack, expected_lines) { } catch (e) { stack = e.stack; } - assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance)); checkStack(stripPath(stack), [ 'Error: thrown from imported function', // - /^ at func \(interpreter.js:\d+:11\)$/, // - - ' at main (<WASM>[1]+1)', // - + ' at main (wasm-function[1]:1)', // - /^ at testThrowFromImport \(interpreter.js:\d+:24\)$/, // - /^ at interpreter.js:\d+:3$/ ]); @@ -205,18 +205,18 @@ function checkStack(stack, expected_lines) { instance = builder.instantiate({mod: {func: func}}); // Test that this does not mess up internal state by executing it three times. for (var i = 0; i < 3; ++i) { - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); stacks = []; instance.exports.main(0); - assertEquals(interpreted_before + 3, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 3, %WasmNumInterpretedCalls(instance)); assertEquals(3, stacks.length); for (var e = 0; e < stacks.length; ++e) { expected = ['Error: reentrant interpreter test #' + e]; expected.push(/^ at func \(interpreter.js:\d+:17\)$/); - expected.push(' at main (<WASM>[1]+3)'); + expected.push(' at main (wasm-function[1]:3)'); for (var k = e; k > 0; --k) { expected.push(/^ at func \(interpreter.js:\d+:33\)$/); - expected.push(' at main (<WASM>[1]+3)'); + expected.push(' at main (wasm-function[1]:3)'); } expected.push( /^ at testReentrantInterpreter \(interpreter.js:\d+:22\)$/); @@ -289,8 +289,8 @@ function checkStack(stack, expected_lines) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ 'TypeError: invalid type', // - - ' at direct (<WASM>[1]+1)', // - - ' at main (<WASM>[3]+3)', // - + ' at direct (wasm-function[1]:1)', // - + ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - /^ at interpreter.js:\d+:3$/ ]); @@ -302,8 +302,8 @@ function checkStack(stack, expected_lines) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ 'TypeError: invalid type', // - - ' at indirect (<WASM>[2]+1)', // - - ' at main (<WASM>[3]+3)', // - + ' at indirect (wasm-function[2]:1)', // - + ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - /^ at interpreter.js:\d+:3$/ ]); @@ -325,8 +325,8 @@ function checkStack(stack, expected_lines) { if (!(e instanceof RangeError)) throw e; checkStack(stripPath(e.stack), [ 'RangeError: Maximum call stack size exceeded', - ' at main (<WASM>[0]+0)' - ].concat(Array(9).fill(' at main (<WASM>[0]+2)'))); + ' at main (wasm-function[0]:0)' + ].concat(Array(9).fill(' at main (wasm-function[0]:2)'))); } })(); @@ -338,7 +338,7 @@ function checkStack(stack, expected_lines) { this.i = i; } - // We call WASM -> func 1 -> WASM -> func2. + // We call wasm -> func 1 -> wasm -> func2. // func2 throws, func 1 catches. function func1() { try { @@ -361,15 +361,15 @@ function checkStack(stack, expected_lines) { .exportFunc(); var instance = builder.instantiate({mod: {func1: func1, func2: func2}}); - var interpreted_before = % WasmNumInterpretedCalls(instance); + var interpreted_before = %WasmNumInterpretedCalls(instance); assertEquals(2 * (11 + 2), instance.exports.main()); - assertEquals(interpreted_before + 2, % WasmNumInterpretedCalls(instance)); + assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance)); })(); (function testInterpreterGC() { function run(f) { // wrap the creation in a closure so that the only thing returned is - // the module (i.e. the underlying array buffer of WASM wire bytes dies). + // the module (i.e. the underlying array buffer of wasm wire bytes dies). var module = (() => { var builder = new WasmModuleBuilder(); var imp = builder.addImport('mod', 'the_name_of_my_import', kSig_i_i); diff --git a/deps/v8/test/mjsunit/wasm/js-api.js b/deps/v8/test/mjsunit/wasm/js-api.js index 0f6b0816be..8053d2934e 100644 --- a/deps/v8/test/mjsunit/wasm/js-api.js +++ b/deps/v8/test/mjsunit/wasm/js-api.js @@ -8,11 +8,11 @@ load('test/mjsunit/wasm/wasm-constants.js'); load('test/mjsunit/wasm/wasm-module-builder.js'); function unexpectedSuccess() { - % AbortJS('unexpected success'); + %AbortJS('unexpected success'); } function unexpectedFail(error) { - % AbortJS('unexpected fail: ' + error); + %AbortJS('unexpected fail: ' + error); } function assertEq(val, expected) { diff --git a/deps/v8/test/mjsunit/wasm/jsapi-harness.js b/deps/v8/test/mjsunit/wasm/jsapi-harness.js index 4f0331d427..3506b592a4 100644 --- a/deps/v8/test/mjsunit/wasm/jsapi-harness.js +++ b/deps/v8/test/mjsunit/wasm/jsapi-harness.js @@ -14,6 +14,10 @@ const known_failures = { 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', "'WebAssembly.Table.prototype.set' method": 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', + "'WebAssembly.Instance.prototype.exports' accessor property": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', + "'WebAssembly.Memory.prototype.grow' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=6546' }; let failures = []; @@ -59,6 +63,7 @@ function promise_test(func, description) { } let assert_equals = assertEquals; +let assert_not_equals = assertNotEquals; let assert_true = assertEquals.bind(null, true); let assert_false = assertEquals.bind(null, false); @@ -102,7 +107,14 @@ assertPromiseResult(last_promise, _ => { "the bug, please remove the test from the known failures list.") } if (unexpected) { - quit(1); + print("\n"); + print(" #############################################################"); + print(" # #"); + print(" # Unexpected outcome. Did you forget to run 'gclient sync'? #"); + print(" # #"); + print(" #############################################################"); + print("\n"); + assertUnreachable("Unexpected outcome"); } } }); diff --git a/deps/v8/test/mjsunit/wasm/large-offset.js b/deps/v8/test/mjsunit/wasm/large-offset.js new file mode 100644 index 0000000000..7c458974d4 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/large-offset.js @@ -0,0 +1,26 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function testGrowMemoryOutOfBoundsOffset() { + print("testGrowMemoryOutOfBoundsOffset2"); + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 128, false); + builder.addFunction("main", kSig_v_v) + .addBody([ + kExprI32Const, 20, + kExprI32Const, 29, + kExprGrowMemory, kMemoryZero, + // Assembly equivalent Move <reg>,0xf5fffff + // with wasm memory reference relocation information + kExprI32StoreMem, 0, 0xFF, 0xFF, 0xFF, 0x7A + ]) + .exportAs("main"); + var module = builder.instantiate(); + assertTraps(kTrapMemOutOfBounds, module.exports.main); +} + +testGrowMemoryOutOfBoundsOffset(); diff --git a/deps/v8/test/mjsunit/wasm/memory-instance-validation.js b/deps/v8/test/mjsunit/wasm/memory-instance-validation.js index e0220e6ee9..9828cd2a8b 100644 --- a/deps/v8/test/mjsunit/wasm/memory-instance-validation.js +++ b/deps/v8/test/mjsunit/wasm/memory-instance-validation.js @@ -24,17 +24,15 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); for (var i = 0; i < 5; i++) { instances.push(builder.instantiate({mod: {imported_mem: memory}})); } - function grow_instance_0(pages) { return instances[0].exports.grow(pages); } - function grow_instance_1(pages) { return instances[1].exports.grow(pages); } - function grow_instance_2(pages) { return instances[2].exports.grow(pages); } - function grow_instance_3(pages) { return instances[3].exports.grow(pages); } - function grow_instance_4(pages) { return instances[4].exports.grow(pages); } + function grow_instance(index, pages) { + return instances[index].exports.grow(pages); + } - var start_index = 0; - var end_index = 5; function verify_mem_size(expected_pages) { + print(" checking size = " + expected_pages + " pages"); assertEquals(expected_pages*kPageSize, memory.buffer.byteLength); - for (var i = start_index; i < end_index; i++) { + for (let i = 0; i < instances.length; i++) { + if (instances[i] == null) continue; assertEquals(expected_pages, instances[i].exports.mem_size()); } } @@ -45,59 +43,49 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertEquals(5, memory.grow(6)); verify_mem_size(11); + print(" instances[1] = null, GC"); instances[1] = null; gc(); // i[0] - i[2] - i[3] - i[4] - start_index = 2; verify_mem_size(11); - assertEquals(11, instances[0].exports.mem_size()); - assertEquals(11, grow_instance_2(10)); - assertEquals(21*kPageSize, memory.buffer.byteLength); + assertEquals(11, grow_instance(2, 10)); verify_mem_size(21); - assertEquals(21, instances[0].exports.mem_size()); + print(" instances[4] = null, GC"); instances[4] = null; gc(); + verify_mem_size(21); - // i[0] - i[2] - i[3] - assertEquals(21, instances[0].exports.mem_size()); - assertEquals(21, instances[2].exports.mem_size()); - assertEquals(21, instances[3].exports.mem_size()); assertEquals(21, memory.grow(2)); - assertEquals(23*kPageSize, memory.buffer.byteLength); - assertEquals(23, instances[0].exports.mem_size()); - assertEquals(23, instances[2].exports.mem_size()); - assertEquals(23, instances[3].exports.mem_size()); + verify_mem_size(23); + print(" instances[0] = null, GC"); instances[0] = null; gc(); + gc(); + verify_mem_size(23); - // i[2] - i[3] - assertEquals(23, instances[2].exports.mem_size()); - assertEquals(23, instances[3].exports.mem_size()); - assertEquals(23, grow_instance_3(5)); - assertEquals(28*kPageSize, memory.buffer.byteLength); - assertEquals(28, instances[2].exports.mem_size()); - assertEquals(28, instances[3].exports.mem_size()); + assertEquals(23, grow_instance(3, 5)); + verify_mem_size(28); + print(" new instance, GC"); // Instantiate a new instance and verify that it can be grown correctly. instances.push(builder.instantiate({mod: {imported_mem: memory}})); - function grow_instance_5(pages) { return instances[5].exports.grow(pages); } + gc(); + gc(); - // i[2] - i[3] - i[5] - assertEquals(28, instances[2].exports.mem_size()); - assertEquals(28, instances[3].exports.mem_size()); - assertEquals(28, instances[5].exports.mem_size()); - assertEquals(28, grow_instance_5(2)); - assertEquals(30*kPageSize, memory.buffer.byteLength); - assertEquals(30, instances[2].exports.mem_size()); - assertEquals(30, instances[3].exports.mem_size()); - assertEquals(30, instances[5].exports.mem_size()); + verify_mem_size(28); + assertEquals(28, grow_instance(5, 2)); + verify_mem_size(30); assertEquals(30, memory.grow(5)); - assertEquals(35*kPageSize, memory.buffer.byteLength); - assertEquals(35, instances[2].exports.mem_size()); - assertEquals(35, instances[3].exports.mem_size()); - assertEquals(35, instances[5].exports.mem_size()); + verify_mem_size(35); + + for (let i = 0; i < instances.length; i++) { + print(" instances[" + i + "] = null, GC"); + instances[i] = null; + gc(); + verify_mem_size(35); + } })(); diff --git a/deps/v8/test/mjsunit/wasm/shared-memory.js b/deps/v8/test/mjsunit/wasm/shared-memory.js new file mode 100644 index 0000000000..98ebd57e79 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/shared-memory.js @@ -0,0 +1,52 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --experimental-wasm-threads + +function assertMemoryIsValid(memory) { + assertSame(WebAssembly.Memory.prototype, memory.__proto__); + assertSame(WebAssembly.Memory, memory.constructor); + assertTrue(memory instanceof Object); + assertTrue(memory instanceof WebAssembly.Memory); +} + +(function TestConstructorWithShared() { + print("TestConstructorWithShared"); + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: true}); + assertMemoryIsValid(memory); + // Assert that the buffer is frozen when memory is shared. + assertTrue(Object.isFrozen(memory.buffer)); +})(); + +(function TestConstructorWithUndefinedShared() { + print("TestConstructorWithUndefinedShared"); + // Maximum = undefined, shared = undefined. + let memory = new WebAssembly.Memory({ + initial: 0, maximum: undefined, shared: undefined}); + assertMemoryIsValid(memory); +})(); + +(function TestConstructorWithNumericShared() { + print("TestConstructorWithNumericShared"); + // For numeric values, shared = true. + let memory = new WebAssembly.Memory({ + initial: 0, maximum: 10, shared: 2098665}); + assertMemoryIsValid(memory); +})(); + +(function TestConstructorWithEmptyStringShared() { + print("TestConstructorWithEmptyStringShared"); + // Maximum = undefined, shared = false. + let memory = new WebAssembly.Memory({ + initial: 0, maximum: undefined, shared: ""}); + assertMemoryIsValid(memory); +})(); + +(function TestConstructorWithUndefinedMaxShared() { + print("TestConstructorWithUndefinedMaxShared"); + // New memory with Maximum = undefined, shared = true => TypeError. + assertThrows(() => new WebAssembly.Memory({initial: 0, shared: true}), + TypeError); +})(); diff --git a/deps/v8/test/mjsunit/wasm/stack.js b/deps/v8/test/mjsunit/wasm/stack.js index ba2818925d..57e57d6467 100644 --- a/deps/v8/test/mjsunit/wasm/stack.js +++ b/deps/v8/test/mjsunit/wasm/stack.js @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// clang-format off // Flags: --expose-wasm load("test/mjsunit/wasm/wasm-constants.js"); @@ -25,8 +24,8 @@ function verifyStack(frames, expected) { assertContains(exp[4], frames[i].getFileName(), "["+i+"].getFileName()"); var toString; if (exp[0]) { - var fun_str = exp[1] !== null ? exp[1] : "<WASM UNNAMED>"; - toString = fun_str + " (<WASM>[" + exp[2] + "]+" + exp[3] + ")"; + toString = "wasm-function[" + exp[2] + "]:" + exp[3]; + if (exp[1] !== null) toString = exp[1] + " (" + toString + ")"; } else { toString = exp[4] + ":" + exp[2] + ":"; } @@ -61,7 +60,7 @@ var mem_oob_func = builder.addFunction(undefined, kSig_i_v) .addBody([kExprI32Const, 0x7f, kExprI32LoadMem8S, 0, 0]) .exportAs("mem_out_of_bounds"); -// Call the mem_out_of_bounds function, in order to have two WASM stack frames. +// Call the mem_out_of_bounds function, in order to have two wasm stack frames. builder.addFunction("call_mem_out_of_bounds", kSig_i_v) .addBody([kExprCallFunction, mem_oob_func.index]) .exportAs("call_mem_out_of_bounds"); @@ -69,12 +68,12 @@ builder.addFunction("call_mem_out_of_bounds", kSig_i_v) var module = builder.instantiate({mod: {func: STACK}}); (function testSimpleStack() { - var expected_string = "Error\n" + - // The line numbers below will change as this test gains / loses lines.. - " at STACK (stack.js:40:11)\n" + // -- - " at main (<WASM>[1]+1)\n" + // -- - " at testSimpleStack (stack.js:79:18)\n" + // -- - " at stack.js:81:3"; // -- + var expected_string = 'Error\n' + + // The line numbers below will change as this test gains / loses lines.. + ' at STACK (stack.js:39:11)\n' + // -- + ' at main (wasm-function[1]:1)\n' + // -- + ' at testSimpleStack (stack.js:78:18)\n' + // -- + ' at stack.js:80:3'; // -- module.exports.main(); assertEquals(expected_string, stripPath(stack)); @@ -91,10 +90,10 @@ Error.prepareStackTrace = function(error, frames) { verifyStack(stack, [ // isWasm function line pos file - [ false, "STACK", 40, 0, "stack.js"], + [ false, "STACK", 39, 0, "stack.js"], [ true, "main", 1, 1, null], - [ false, "testStackFrames", 90, 0, "stack.js"], - [ false, null, 99, 0, "stack.js"] + [ false, "testStackFrames", 89, 0, "stack.js"], + [ false, null, 98, 0, "stack.js"] ]); })(); @@ -107,8 +106,8 @@ Error.prepareStackTrace = function(error, frames) { verifyStack(e.stack, [ // isWasm function line pos file [ true, "exec_unreachable", 2, 1, null], - [ false, "testWasmUnreachable", 103, 0, "stack.js"], - [ false, null, 114, 0, "stack.js"] + [ false, "testWasmUnreachable", 102, 0, "stack.js"], + [ false, null, 113, 0, "stack.js"] ]); } })(); @@ -123,8 +122,8 @@ Error.prepareStackTrace = function(error, frames) { // isWasm function line pos file [ true, null, 3, 3, null], [ true, "call_mem_out_of_bounds", 4, 1, null], - [ false, "testWasmMemOutOfBounds", 118, 0, "stack.js"], - [ false, null, 130, 0, "stack.js"] + [ false, "testWasmMemOutOfBounds", 117, 0, "stack.js"], + [ false, null, 129, 0, "stack.js"] ]); } })(); diff --git a/deps/v8/test/mjsunit/wasm/start-function.js b/deps/v8/test/mjsunit/wasm/start-function.js index 8905f022af..d6ec34124e 100644 --- a/deps/v8/test/mjsunit/wasm/start-function.js +++ b/deps/v8/test/mjsunit/wasm/start-function.js @@ -29,7 +29,7 @@ function assertVerifies(sig, body) { assertVerifies(kSig_v_v, [kExprNop]); -// Arguments aren't allow to start functions. +// Arguments aren't allowed to start functions. assertThrows(() => {instantiate(kSig_i_i, [kExprGetLocal, 0]);}); assertThrows(() => {instantiate(kSig_i_ii, [kExprGetLocal, 0]);}); assertThrows(() => {instantiate(kSig_i_dd, [kExprGetLocal, 0]);}); @@ -122,3 +122,27 @@ assertThrows(() => {instantiate(kSig_i_v, [kExprI32Const, 0]);}); var module = builder.instantiate(ffi); assertTrue(ranned); })(); + +(function testStartFunctionThrowsExplicitly() { + print('testStartFunctionThrowsExplicitly'); + let error = new Error('my explicit error'); + function throw_fn() { + throw error; + } + let builder = new WasmModuleBuilder(); + builder.addImport('foo', 'bar', kSig_v_v); + let func = builder.addFunction('', kSig_v_v).addBody([kExprCallFunction, 0]); + builder.addStart(func.index); + + assertThrowsEquals(() => builder.instantiate(ffi), error); +})(); + +(function testStartFunctionThrowsImplicitly() { + print("testStartFunctionThrowsImplicitly"); + let builder = new WasmModuleBuilder(); + let func = builder.addFunction('', kSig_v_v).addBody([kExprUnreachable]); + builder.addStart(func.index); + + assertThrows( + () => builder.instantiate(), WebAssembly.RuntimeError, /unreachable/); +})(); diff --git a/deps/v8/test/mjsunit/wasm/table.js b/deps/v8/test/mjsunit/wasm/table.js index ed5c61f41a..c63eb5a2b2 100644 --- a/deps/v8/test/mjsunit/wasm/table.js +++ b/deps/v8/test/mjsunit/wasm/table.js @@ -14,13 +14,15 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var outOfUint32RangeValue = 1e12; var int32ButOob = 1073741824; var kMaxUint32 = (4 * 1024 * 1024 * 1024) - 1; +var kMaxUint31 = (2 * 1024 * 1024 * 1024) - 1; var kV8MaxWasmTableSize = 10000000; -function assertTableIsValid(table) { +function assertTableIsValid(table, length) { assertSame(WebAssembly.Table.prototype, table.__proto__); assertSame(WebAssembly.Table, table.constructor); assertTrue(table instanceof Object); assertTrue(table instanceof WebAssembly.Table); + assertEquals(length, table.length); } (function TestConstructor() { @@ -57,56 +59,48 @@ function assertTableIsValid(table) { let table; table = new WebAssembly.Table({element: "anyfunc", initial: 1}); - assertTableIsValid(table); - assertEquals(1, table.length); + assertTableIsValid(table, 1); assertEquals(null, table.get(0)); assertEquals(undefined, table[0]); table = new WebAssembly.Table({element: "anyfunc", initial: "2"}); - assertTableIsValid(table); - assertEquals(2, table.length); + assertTableIsValid(table, 2); assertEquals(null, table.get(0)); assertEquals(null, table.get(1)); assertEquals(undefined, table[0]); assertEquals(undefined, table[1]); table = new WebAssembly.Table({element: "anyfunc", initial: {valueOf() { return "1" }}}); - assertTableIsValid(table); - assertEquals(1, table.length); + assertTableIsValid(table, 1); assertEquals(null, table.get(0)); assertEquals(undefined, table[0]); table = new WebAssembly.Table({element: "anyfunc", initial: undefined}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc"}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", maximum: 10}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", maximum: "10"}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", maximum: {valueOf() { return "10" }}}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: undefined}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); + + table = new WebAssembly.Table({element: "anyfunc", maximum: kMaxUint31}); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", maximum: kMaxUint32}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); table = new WebAssembly.Table({element: "anyfunc", maximum: kV8MaxWasmTableSize + 1}); - assertTableIsValid(table); - assertEquals(0, table.length); + assertTableIsValid(table, 0); })(); (function TestMaximumIsReadOnce() { @@ -123,7 +117,7 @@ function assertTableIsValid(table) { } }}); let table = new WebAssembly.Table(desc); - assertTableIsValid(table); + assertTableIsValid(table, 10); })(); (function TestMaximumDoesHasProperty() { @@ -134,7 +128,7 @@ function assertTableIsValid(table) { }); Object.setPrototypeOf(desc, proxy); let table = new WebAssembly.Table(desc); - assertTableIsValid(table); + assertTableIsValid(table, 10); })(); (function TestLength() { diff --git a/deps/v8/test/mjsunit/wasm/unicode-validation.js b/deps/v8/test/mjsunit/wasm/unicode-validation.js index 2dd2d00bce..8932c32653 100644 --- a/deps/v8/test/mjsunit/wasm/unicode-validation.js +++ b/deps/v8/test/mjsunit/wasm/unicode-validation.js @@ -118,5 +118,4 @@ checkAll(toByteArray("\xff"), true); checkAll(toByteArray("\xed\xa0\x8f"), true); // surrogate code points checkAll(toByteArray("\xe0\x82\x80"), true); // overlong sequence checkAll(toByteArray("\xf4\x90\x80\x80"), true); // beyond limit: U+110000 -checkAll(toByteArray("\xef\xbf\xbe"), true); // non-character; U+FFFE checkAll(toByteArray("with\x00null"), false); diff --git a/deps/v8/test/mjsunit/wasm/unicode.js b/deps/v8/test/mjsunit/wasm/unicode.js new file mode 100644 index 0000000000..49c95da030 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/unicode.js @@ -0,0 +1,85 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function checkImport( + imported_module_name, imported_function_name) { + var builder = new WasmModuleBuilder(); + builder.addImport(imported_module_name, imported_function_name, kSig_i_i); + builder.addFunction('call_imp', kSig_i_i) + .addBody([kExprGetLocal, 0, kExprCallFunction, 0]) + .exportFunc(); + + let imp = i => i + 3; + let instance = builder.instantiate( + {[imported_module_name]: {[imported_function_name]: imp}}); + assertEquals(imp(0), instance.exports.call_imp(0)); + assertEquals(imp(4), instance.exports.call_imp(4)); +} + +checkImport('mod', 'foo'); // sanity check +checkImport('mod', '☺☺happy☺☺'); +checkImport('☺☺happy☺☺', 'foo'); +checkImport('☺☺happy☺☺', '☼+☃=☹'); + +function checkExports( + internal_name_mul, exported_name_mul, internal_name_add, + exported_name_add) { + var builder = new WasmModuleBuilder(); + builder.addFunction(internal_name_mul, kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Mul]) + .exportAs(exported_name_mul); + builder.addFunction(internal_name_add, kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add]) + .exportAs(exported_name_add); + + let instance = builder.instantiate(); + assertEquals(14, instance.exports[exported_name_add](3, 11)); + assertEquals(-7, instance.exports[exported_name_add](5, -12)); + assertEquals(28, instance.exports[exported_name_mul](4, 7)); + assertEquals(-6, instance.exports[exported_name_mul](-3, 2)); +} + +checkExports('mul', 'mul', 'add', 'add'); // sanity check +checkExports('☺☺mul☺☺', 'mul', '☺☺add☺☺', 'add'); +checkExports('☺☺mul☺☺', '☺☺mul☺☺', '☺☺add☺☺', '☺☺add☺☺'); + +(function errorMessageUnicodeInFuncName() { + var builder = new WasmModuleBuilder(); + builder.addFunction('three snowmen: ☃☃☃', kSig_i_v).addBody([]).exportFunc(); + assertThrows( + () => builder.instantiate(), WebAssembly.CompileError, + /Compiling wasm function #0:three snowmen: ☃☃☃ failed: /); +})(); + +(function errorMessageUnicodeInImportModuleName() { + var builder = new WasmModuleBuilder(); + builder.addImport('three snowmen: ☃☃☃', 'foo', kSig_i_v); + assertThrows( + () => builder.instantiate({}), TypeError, + /WebAssembly Instantiation: Import #0 module="three snowmen: ☃☃☃" error: /); +})(); + +(function errorMessageUnicodeInImportElemName() { + var builder = new WasmModuleBuilder(); + builder.addImport('mod', 'three snowmen: ☃☃☃', kSig_i_v); + assertThrows( + () => builder.instantiate({mod: {}}), WebAssembly.LinkError, + 'WebAssembly Instantiation: Import #0 module="mod" function="three ' + + 'snowmen: ☃☃☃" error: function import requires a callable'); +})(); + +(function errorMessageUnicodeInImportModAndElemName() { + var builder = new WasmModuleBuilder(); + let mod_name = '☮▁▂▃▄☾ ♛ ◡ ♛ ☽▄▃▂▁☮'; + let func_name = '☾˙❀‿❀˙☽'; + builder.addImport(mod_name, func_name, kSig_i_v); + assertThrows( + () => builder.instantiate({[mod_name]: {}}), WebAssembly.LinkError, + 'WebAssembly Instantiation: Import #0 module="' + mod_name + + '" function="' + func_name + + '" error: function import requires a callable'); +})(); diff --git a/deps/v8/test/mjsunit/wasm/user-properties.js b/deps/v8/test/mjsunit/wasm/user-properties.js new file mode 100644 index 0000000000..facc58cad7 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/user-properties.js @@ -0,0 +1,169 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm --expose-gc --verify-heap + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +const verifyHeap = gc; +let globalCounter = 10000000; + +function testProperties(obj) { + for (let i = 0; i < 3; i++) { + obj.x = 1001; + assertEquals(1001, obj.x); + + obj.y = "old"; + assertEquals("old", obj.y); + + delete obj.y; + assertEquals("undefined", typeof obj.y); + + let uid = globalCounter++; + let fresh = "f_" + uid; + + obj.z = fresh; + assertEquals(fresh, obj.z); + + obj[fresh] = uid; + assertEquals(uid, obj[fresh]); + + verifyHeap(); + + assertEquals(1001, obj.x); + assertEquals(fresh, obj.z); + assertEquals(uid, obj[fresh]); + } + + // These properties are special for JSFunctions. + Object.defineProperty(obj, 'name', {value: "crazy"}); + Object.defineProperty(obj, 'length', {value: 999}); +} + +function minus18(x) { return x - 18; } +function id(x) { return x; } + +function printName(when, f) { + print(" " + when + ": name=" + f.name + ", length=" + f.length); +} + +(function ExportedFunctionTest() { + print("ExportedFunctionTest"); + + print(" instance 1, exporting"); + var builder = new WasmModuleBuilder(); + builder.addFunction("exp", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprCallFunction, 0]) + .exportAs("exp"); + let module1 = builder.toModule(); + let instance1 = new WebAssembly.Instance(module1); + let g = instance1.exports.exp; + + testProperties(g); + + // The WASM-internal fields of {g} are only inspected when {g} is + // used as an import into another instance. + print(" instance 2, importing"); + var builder = new WasmModuleBuilder(); + builder.addImport("imp", "func", kSig_i_i); + let module2 = builder.toModule(); + let instance2 = new WebAssembly.Instance(module2, {imp: {func: g}}); + + testProperties(g); +})(); + +(function ImportReexportChain() { + print("ImportReexportChain"); + + var f = id; + + for (let i = 0; i < 5; i++) { + let builder = new WasmModuleBuilder(); + builder.addImport("imp", "func", kSig_i_i); + builder.addExport("exp", 0); + let module = builder.toModule(); + let instance = new WebAssembly.Instance(module, {imp: {func: f}}); + let g = instance.exports.exp; + assertInstanceof(g, Function); + printName("before", g); + testProperties(g); + printName(" after", g); + + // The WASM-internal fields of {g} are only inspected when {g} is + // used as an import into another instance. Use {g} as the import + // the next time through the loop. + f = g; + } +})(); + + +(function ModuleTest() { + for (f of [x => (x + 19 + globalCounter), minus18]) { + print("ModuleTest"); + + let builder = new WasmModuleBuilder(); + builder.addImport("m", "f", kSig_i_i); + builder.addFunction("main", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprCallFunction, 0]) + .exportAs("main"); + builder.addMemory(1, 1, false) + .exportMemoryAs("memory") + + let module = builder.toModule(); + testProperties(module); + + for (let i = 0; i < 3; i++) { + print(" instance " + i); + let instance = new WebAssembly.Instance(module, {m: {f: f}}); + testProperties(instance); + + print(" memory " + i); + let m = instance.exports.memory; + assertInstanceof(m, WebAssembly.Memory); + testProperties(m); + + print(" function " + i); + let g = instance.exports.main; + assertInstanceof(g, Function); + printName("before", g); + testProperties(g); + printName(" after", g); + assertInstanceof(g, Function); + testProperties(g); + for (let j = 10; j < 15; j++) { + assertEquals(f(j), g(j)); + } + verifyHeap(); + // The WASM-internal fields of {g} are only inspected when {g} is + // used as an import into another instance. Use {g} as the import + // the next time through the loop. + f = g; + } + } + +})(); + +(function ConstructedTest() { + print("ConstructedTest"); + + var memory = undefined, table = undefined; + for (let i = 0; i < 4; i++) { + print(" iteration " + i); + + let m = new WebAssembly.Memory({initial: 1}); + let t = new WebAssembly.Table({element: "anyfunc", initial: 1}); + m.old = memory; + t.old = table; + + memory = m; + table = t; + testProperties(memory); + testProperties(table); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/wasm-api-overloading.js b/deps/v8/test/mjsunit/wasm/wasm-api-overloading.js index 37320e54ce..6a39510208 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-api-overloading.js +++ b/deps/v8/test/mjsunit/wasm/wasm-api-overloading.js @@ -2,12 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --allow-natives-syntax - load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); -%ResetWasmOverloads(); let buffer = (() => { let builder = new WasmModuleBuilder(); builder.addFunction("f", kSig_i_v) @@ -19,35 +16,18 @@ let buffer = (() => { var module = new WebAssembly.Module(buffer); var wrapper = [module]; -assertPromiseResult( - WebAssembly.instantiateStreaming(wrapper), - assertUnreachable, - e => assertTrue(e instanceof TypeError)); - -assertPromiseResult( - WebAssembly.compileStreaming(wrapper), - assertUnreachable, - e => assertTrue(e instanceof TypeError)); - -assertPromiseResult( - (() => { - %SetWasmCompileFromPromiseOverload(); - return WebAssembly.compileStreaming(wrapper); - })(), - module => { - assertTrue(module instanceof WebAssembly.Module); - %ResetWasmOverloads(); - }, - assertUnreachable); - -assertPromiseResult( - (() => { - %SetWasmCompileFromPromiseOverload(); - return WebAssembly.instantiateStreaming(wrapper); - })(), - pair => { - assertTrue(pair.instance instanceof WebAssembly.Instance); - assertTrue(pair.module instanceof WebAssembly.Module); - %ResetWasmOverloads(); - }, - assertUnreachable); +try { + assertPromiseResult( + WebAssembly.instantiateStreaming(wrapper), + assertUnreachable, assertUnreachable); +} catch (e) { + assertTrue(e instanceof TypeError); +} + +try { + assertPromiseResult( + WebAssembly.compileStreaming(wrapper), + assertUnreachable, assertUnreachable); +} catch (e) { + assertTrue(e instanceof TypeError); +} diff --git a/deps/v8/test/mjsunit/wasm/wasm-constants.js b/deps/v8/test/mjsunit/wasm/wasm-constants.js index 7c0904a80a..bfadbef7dd 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-constants.js +++ b/deps/v8/test/mjsunit/wasm/wasm-constants.js @@ -66,6 +66,7 @@ let kDataSectionCode = 11; // Data segments let kNameSectionCode = 12; // Name section (encoded as string) // Name section types +let kModuleNameCode = 0; let kFunctionNamesCode = 1; let kLocalNamesCode = 2; diff --git a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js index 79a3e8da89..a26384e545 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js @@ -86,6 +86,15 @@ class WasmFunctionBuilder { this.body = []; } + numLocalNames() { + if (this.local_names === undefined) return 0; + let num_local_names = 0; + for (let loc_name of this.local_names) { + if (loc_name !== undefined) ++num_local_names; + } + return num_local_names; + } + exportAs(name) { this.module.addExport(name, this.index); return this; @@ -112,8 +121,9 @@ class WasmFunctionBuilder { return this; } - addLocals(locals) { + addLocals(locals, names) { this.locals = locals; + this.local_names = names; return this; } @@ -277,6 +287,11 @@ class WasmModuleBuilder { return this; } + setName(name) { + this.name = name; + return this; + } + toArray(debug = false) { let binary = new Binary; let wasm = this; @@ -336,16 +351,11 @@ class WasmModuleBuilder { } // Add functions declarations - let num_function_names = 0; - let names = false; if (wasm.functions.length > 0) { if (debug) print("emitting function decls @ " + binary.length); binary.emit_section(kFunctionSectionCode, section => { section.emit_u32v(wasm.functions.length); for (let func of wasm.functions) { - if (func.name !== undefined) { - ++num_function_names; - } section.emit_u32v(func.type_index); } }); @@ -458,9 +468,9 @@ class WasmModuleBuilder { binary.emit_section(kElementSectionCode, section => { var inits = wasm.function_table_inits; section.emit_u32v(inits.length); - section.emit_u8(0); // table index for (let init of inits) { + section.emit_u8(0); // table index if (init.is_global) { section.emit_u8(kExprGetGlobal); } else { @@ -545,19 +555,51 @@ class WasmModuleBuilder { binary.emit_bytes(exp); } - // Add function names. - if (num_function_names > 0) { + // Add names. + let num_function_names = 0; + let num_functions_with_local_names = 0; + for (let func of wasm.functions) { + if (func.name !== undefined) ++num_function_names; + if (func.numLocalNames() > 0) ++num_functions_with_local_names; + } + if (num_function_names > 0 || num_functions_with_local_names > 0 || + wasm.name !== undefined) { if (debug) print('emitting names @ ' + binary.length); binary.emit_section(kUnknownSectionCode, section => { section.emit_string('name'); - section.emit_section(kFunctionNamesCode, name_section => { - name_section.emit_u32v(num_function_names); - for (let func of wasm.functions) { - if (func.name === undefined) continue; - name_section.emit_u32v(func.index); - name_section.emit_string(func.name); - } - }); + // Emit module name. + if (wasm.name !== undefined) { + section.emit_section(kModuleNameCode, name_section => { + name_section.emit_string(wasm.name); + }); + } + // Emit function names. + if (num_function_names > 0) { + section.emit_section(kFunctionNamesCode, name_section => { + name_section.emit_u32v(num_function_names); + for (let func of wasm.functions) { + if (func.name === undefined) continue; + name_section.emit_u32v(func.index); + name_section.emit_string(func.name); + } + }); + } + // Emit local names. + if (num_functions_with_local_names > 0) { + section.emit_section(kLocalNamesCode, name_section => { + name_section.emit_u32v(num_functions_with_local_names); + for (let func of wasm.functions) { + if (func.numLocalNames() == 0) continue; + name_section.emit_u32v(func.index); + name_section.emit_u32v(func.numLocalNames()); + for (let i = 0; i < func.local_names.length; ++i) { + if (func.local_names[i] === undefined) continue; + name_section.emit_u32v(i); + name_section.emit_string(func.local_names[i]); + } + } + }); + } }); } @@ -581,4 +623,8 @@ class WasmModuleBuilder { let instance = new WebAssembly.Instance(module, ffi); return instance; } + + toModule(debug = false) { + return new WebAssembly.Module(this.toBuffer(debug)); + } } |