diff options
Diffstat (limited to 'deps/v8/test/mjsunit')
333 files changed, 7617 insertions, 11606 deletions
diff --git a/deps/v8/test/mjsunit/array-literal-transitions.js b/deps/v8/test/mjsunit/array-literal-transitions.js index cd9d96bcf4..1af02d8d2f 100644 --- a/deps/v8/test/mjsunit/array-literal-transitions.js +++ b/deps/v8/test/mjsunit/array-literal-transitions.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 --expose-gc -// Flags: --ignition-osr --turbo-from-bytecode +// Flags: --allow-natives-syntax --expose-gc --ignition-osr // IC and Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. diff --git a/deps/v8/test/mjsunit/asm/asm-validation.js b/deps/v8/test/mjsunit/asm/asm-validation.js index eae282ca57..06799dab67 100644 --- a/deps/v8/test/mjsunit/asm/asm-validation.js +++ b/deps/v8/test/mjsunit/asm/asm-validation.js @@ -8,6 +8,76 @@ function assertValidAsm(func) { assertTrue(%IsAsmWasmCode(func)); } +(function TestConst() { + function Module(s) { + "use asm"; + var fround = s.Math.fround; + // Global constants. These are treated just like numeric literals. + const fConst = fround(-3.0); + const dConst = -3.0; + const iConst = -3; + + // consts can be used to initialize other consts. + const fPrime = fConst; + + // The following methods verify that return statements with global constants + // do not need type annotations. + function f() { + return fPrime; + } + function d() { + return dConst; + } + function i() { + return iConst; + } + + // The following methods verify that locals initialized with global + // constants do not need type annotations. + function fVar() { + var v = fPrime; + return fround(v); + } + function iVar() { + var v = iConst; + return v|0; + } + function dVar() { + var v = dConst; + return +v; + } + + return { + f: f, d: d, i: i, + fVar: fVar, dVar: dVar, iVar: iVar, + }; + } + + function DisallowAssignToConstGlobal() { + const constant = 0; + function invalid(i) { + i = i|0; + constant = i; + return constant; + } + return invalid; + } + + var m = Module(this); + assertValidAsm(Module); + + assertEquals(-3, m.i()); + assertEquals(-3.0, m.d()); + assertEquals(Math.fround(-3.0), m.f()); + + assertEquals(-3, m.iVar()); + assertEquals(-3.0, m.dVar()); + assertEquals(Math.fround(-3.0), m.fVar()); + + var m = DisallowAssignToConstGlobal(); + assertTrue(%IsNotAsmWasmCode(DisallowAssignToConstGlobal)); +})(); + (function TestModuleArgs() { function Module1(stdlib) { "use asm"; @@ -213,3 +283,15 @@ function assertValidAsm(func) { assertValidAsm(Module); assertEquals(123, m.foo()); })(); + +(function TestBadConstUnsignedReturn() { + function Module() { + "use asm"; + const i = 0xffffffff; + function foo() { return i; } + return { foo: foo }; + } + var m = Module(); + assertTrue(%IsNotAsmWasmCode(Module)); + assertEquals(0xffffffff, m.foo()); +})(); diff --git a/deps/v8/test/mjsunit/asm/b5528-comma.js b/deps/v8/test/mjsunit/asm/b5528-comma.js new file mode 100644 index 0000000000..a6eab6d2ea --- /dev/null +++ b/deps/v8/test/mjsunit/asm/b5528-comma.js @@ -0,0 +1,31 @@ +// 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. + +function Module(stdlib, env, heap) { + "use asm"; + + var a = new stdlib.Int32Array(heap); + var b = new stdlib.Float32Array(heap); + var fround = stdlib.Math.fround; + var value = env.value|0; + + function foo() { + var x = fround(0.0); + x = (a[0]=value|0,fround(b[0])); + return fround(x); + } + + return { foo: foo }; +} + +var buffer = new ArrayBuffer(32); +assertEquals(0.0, Module(this, {value: 0x00000000}, buffer).foo()); +assertEquals(-0.0, Module(this, {value: 0x80000000}, buffer).foo()); +assertEquals(5.0, Module(this, {value: 0x40a00000}, buffer).foo()); +assertEquals(-5.0, Module(this, {value: 0xc0a00000}, buffer).foo()); +assertEquals(129.375, Module(this, {value: 0x43016000}, buffer).foo()); +assertEquals(-129.375, Module(this, {value: 0xc3016000}, buffer).foo()); +assertEquals(Infinity, Module(this, {value: 0x7f800000}, buffer).foo()); +assertEquals(-Infinity, Module(this, {value: 0xff800000}, buffer).foo()); +assertEquals(NaN, Module(this, {value: 0x7fffffff}, buffer).foo()); diff --git a/deps/v8/test/mjsunit/modules-fail-3.js b/deps/v8/test/mjsunit/asm/regress-660813.js index d29d44476d..e9bf5797c7 100644 --- a/deps/v8/test/mjsunit/modules-fail-3.js +++ b/deps/v8/test/mjsunit/asm/regress-660813.js @@ -1,7 +1,12 @@ // 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. -// -// MODULE -import foo from "modules-fail-3.js"; +function Module() { + "use asm"; + const i = 0xffffffff; + function foo() { + return i; + } +} +Module(); diff --git a/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js new file mode 100644 index 0000000000..51faef0952 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js @@ -0,0 +1,155 @@ +// 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() { + function foo(x, y) { return x << y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); + +(function() { + function foo(x, y) { return x >> y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); + +(function() { + function foo(x, y) { return x >>> y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); + +(function() { + function foo(x, y) { return x ^ y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); + +(function() { + function foo(x, y) { return x | y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); + +(function() { + function foo(x, y) { return x & y; } + + foo(1.1, 0.1); + %BaselineFunctionOnNextCall(foo); + foo(0.1, 1.1); + %OptimizeFunctionOnNextCall(foo); + foo(undefined, 1.1); + assertOptimized(foo); + foo(1.1, undefined); + assertOptimized(foo); + foo(null, 1.1); + assertOptimized(foo); + foo(1.1, null); + assertOptimized(foo); + foo(true, 1.1); + assertOptimized(foo); + foo(1.1, true); + assertOptimized(foo); + foo(false, 1.1); + assertOptimized(foo); + foo(1.1, false); + assertOptimized(foo); +})(); diff --git a/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js b/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js new file mode 100644 index 0000000000..2a9f6a1c38 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/deopt-string-outofbounds.js @@ -0,0 +1,31 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var s = "12345"; + +(function() { + function foo() { return s[5]; } + + foo(); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); + %OptimizeFunctionOnNextCall(foo); + foo(); + assertOptimized(foo); +})(); + +(function() { + function foo(i) { return s[i]; } + + foo(0); + foo(1); + %OptimizeFunctionOnNextCall(foo); + foo(5); + %OptimizeFunctionOnNextCall(foo); + foo(5); + assertOptimized(foo); +})(); diff --git a/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js b/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js index b2b63988ba..66245ef073 100644 --- a/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js +++ b/deps/v8/test/mjsunit/compiler/manual-concurrent-recompile.js @@ -53,9 +53,15 @@ f(g(1)); assertUnoptimized(f); assertUnoptimized(g); +%BaselineFunctionOnNextCall(f); +%BaselineFunctionOnNextCall(g); +f(g(2)); +assertUnoptimized(f); +assertUnoptimized(g); + %OptimizeFunctionOnNextCall(f, "concurrent"); %OptimizeFunctionOnNextCall(g, "concurrent"); -f(g(2)); // Kick off recompilation. +f(g(3)); // Kick off recompilation. assertUnoptimized(f, "no sync"); // Not yet optimized since recompilation assertUnoptimized(g, "no sync"); // is still blocked. diff --git a/deps/v8/test/mjsunit/compiler/regress-5538.js b/deps/v8/test/mjsunit/compiler/regress-5538.js new file mode 100644 index 0000000000..7e4c25d3bc --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-5538.js @@ -0,0 +1,53 @@ +// 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() { + function foo(x) { + x = x | 0; + return Number.parseInt(x + 1); + } + + assertEquals(1, foo(0)); + assertEquals(2, foo(1)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); +})(); + +(function() { + function foo(x) { + x = x | 0; + return Number.parseInt(x + 1, 0); + } + + assertEquals(1, foo(0)); + assertEquals(2, foo(1)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); +})(); + +(function() { + function foo(x) { + x = x | 0; + return Number.parseInt(x + 1, 10); + } + + assertEquals(1, foo(0)); + assertEquals(2, foo(1)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); +})(); + +(function() { + function foo(x) { + x = x | 0; + return Number.parseInt(x + 1, undefined); + } + + assertEquals(1, foo(0)); + assertEquals(2, foo(1)); + %OptimizeFunctionOnNextCall(foo); + assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/regress-664490.js b/deps/v8/test/mjsunit/compiler/regress-664490.js new file mode 100644 index 0000000000..94094c7362 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-664490.js @@ -0,0 +1,18 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var foo = function(msg) {}; + +foo = function (value) { + assertEquals(false, value); +} + +function f() { + foo(undefined == 0); +} + +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/compiler/regress-665680.js b/deps/v8/test/mjsunit/compiler/regress-665680.js new file mode 100644 index 0000000000..b014bee9ac --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-665680.js @@ -0,0 +1,18 @@ +// 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 invalidAsmFunction = (function() { + "use asm"; + return function() { + with (foo) foo(); + } +})(); + +invalidAsmFunction(); +%OptimizeFunctionOnNextCall(invalidAsmFunction); +invalidAsmFunction(); diff --git a/deps/v8/test/mjsunit/compiler/regress-673244.js b/deps/v8/test/mjsunit/compiler/regress-673244.js new file mode 100644 index 0000000000..b18d47b8dd --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-673244.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 f() { + var accumulator = false; + for (var i = 0; i < 4; i++) { + accumulator = accumulator.hasOwnProperty(3); + if (i === 1) %OptimizeOsr(); + } +} + +f(); diff --git a/deps/v8/test/mjsunit/compiler/regress-v8-5573.js b/deps/v8/test/mjsunit/compiler/regress-v8-5573.js new file mode 100644 index 0000000000..216b791a71 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-v8-5573.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 + +var global = true; +global = false; + +function f() { + return !global; +} + +%OptimizeFunctionOnNextCall(f); +assertTrue(f()); diff --git a/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js b/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js new file mode 100644 index 0000000000..66274d54d1 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/uint8-clamped-array.js @@ -0,0 +1,73 @@ +// 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() { + function foo(a, v) { + a[0] = v & 0xff; + } + + var a = new Uint8ClampedArray(4); + foo(a, 1); + foo(a, 2); + %OptimizeFunctionOnNextCall(foo); + foo(a, 256); + assertOptimized(foo); + assertEquals(0, a[0]); +})(); + +(function() { + function foo(a, v) { + a[0] = v >>> 0; + } + + var a = new Uint8ClampedArray(4); + foo(a, 1); + foo(a, 2); + %OptimizeFunctionOnNextCall(foo); + foo(a, 256); + assertOptimized(foo); + assertEquals(255, a[0]); +})(); + +(function() { + function foo(a, v) { + a[0] = v | 0; + } + + var a = new Uint8ClampedArray(4); + foo(a, 1); + foo(a, 2); + %OptimizeFunctionOnNextCall(foo); + foo(a, 256); + assertOptimized(foo); + assertEquals(255, a[0]); + foo(a, -1); + assertOptimized(foo); + assertEquals(0, a[0]); +})(); + +(function() { + function foo(a, v) { + a[0] = v; + } + + var a = new Uint8ClampedArray(4); + foo(a, 1); + foo(a, 2); + %OptimizeFunctionOnNextCall(foo); + foo(a, Infinity); + assertOptimized(foo); + assertEquals(255, a[0]); + foo(a, -Infinity); + assertOptimized(foo); + assertEquals(0, a[0]); + foo(a, 0.5); + assertOptimized(foo); + assertEquals(0, a[0]); + foo(a, 1.5); + assertOptimized(foo); + assertEquals(2, a[0]); +})(); diff --git a/deps/v8/test/mjsunit/debug-allscopes-on-debugger.js b/deps/v8/test/mjsunit/debug-allscopes-on-debugger.js deleted file mode 100644 index 17668cfc24..0000000000 --- a/deps/v8/test/mjsunit/debug-allscopes-on-debugger.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); - // Count number of expected breakpoints in this source file. - if (!break_count) { - var source_text = exec_state.frame(0).func().script().source(); - expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; - print("Expected breaks: " + expected_breaks); - } - var frameMirror = exec_state.frame(0); - - frameMirror.allScopes(); - var source = frameMirror.sourceLineText(); - print("paused at: " + source); - assertTrue(source.indexOf("// Break " + break_count + ".") > 0, - "Unexpected pause at: " + source + "\n" + - "Expected: // Break " + break_count + "."); - ++break_count; - - if (break_count !== expected_breaks) { - exec_state.prepareStep(Debug.StepAction.StepIn); - print("Next step prepared"); - } - } - } catch(e) { - exception = e; - print(e, e.stack); - } -}; - -Debug.setListener(listener); - -var sum = 0; -(function (){ - 'use strict'; - - debugger; // Break 0. - var i = 0; // Break 1. - i++; // Break 2. - i++; // Break 3. - debugger; // Break 4. - return i; // Break 5. -}()); // Break 6. - -assertNull(exception); // Break 7. -assertEquals(expected_breaks, break_count); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-break-inline.js b/deps/v8/test/mjsunit/debug-break-inline.js deleted file mode 100644 index 4418fa8d1b..0000000000 --- a/deps/v8/test/mjsunit/debug-break-inline.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug --allow-natives-syntax - -// This test tests that deoptimization due to debug breaks works for -// inlined functions where the full-code is generated before the -// debugger is attached. -// -//See http://code.google.com/p/chromium/issues/detail?id=105375 - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug; - -var count = 0; -var break_count = 0; - -// Debug event listener which sets a breakpoint first time it is hit -// and otherwise counts break points hit and checks that the expected -// state is reached. -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - break_count++; - if (break_count == 1) { - Debug.setBreakPoint(g, 3); - - for (var i = 0; i < exec_state.frameCount(); i++) { - var frame = exec_state.frame(i); - // When function f is optimized (1 means YES, see runtime.cc) we - // expect an optimized frame for f and g. - if (%GetOptimizationStatus(f) == 1) { - if (i == 1) { - assertTrue(frame.isOptimizedFrame()); - assertTrue(frame.isInlinedFrame()); - assertEquals(4 - i, frame.inlinedFrameIndex()); - } else if (i == 2) { - assertTrue(frame.isOptimizedFrame()); - assertFalse(frame.isInlinedFrame()); - } else { - assertFalse(frame.isOptimizedFrame()); - assertFalse(frame.isInlinedFrame()); - } - } - } - } - } -} - -function f() { - g(); -} - -function g() { - count++; - h(); - var b = 1; // Break point is set here. -} - -function h() { - debugger; -} - -f();f();f(); -%OptimizeFunctionOnNextCall(f); -f(); - -// Add the debug event listener. -Debug.setListener(listener); - -f(); - -assertEquals(5, count); -assertEquals(2, break_count); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-compile-optimized.js b/deps/v8/test/mjsunit/debug-compile-optimized.js deleted file mode 100644 index 468605abaa..0000000000 --- a/deps/v8/test/mjsunit/debug-compile-optimized.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --crankshaft - -Debug = debug.Debug; - -Debug.setListener(function() {}); - -function f() {} -f(); -f(); -%OptimizeFunctionOnNextCall(f); -f(); -assertOptimized(f); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-constructor.js b/deps/v8/test/mjsunit/debug-constructor.js deleted file mode 100644 index a4d50311e9..0000000000 --- a/deps/v8/test/mjsunit/debug-constructor.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple function which collects a simple call graph. -var call_graph = ""; -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) - { - call_graph += exec_state.frame().func().name(); - exec_state.prepareStep(Debug.StepAction.StepIn); - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Test debug event for constructor. -function a() { - new c(); -} - -function b() { - x = 1; - new c(); -} - -function c() { - this.x = 1; - d(); -} - -function d() { -} - -// Break point stops on "new c()" and steps into c. -Debug.setBreakPoint(a, 1); -call_graph = ""; -a(); -Debug.clearStepping(); // Clear stepping as the listener leaves it on. -assertEquals("accdca", call_graph); - -// Break point stops on "x = 1" and steps to "new c()" and then into c. -Debug.setBreakPoint(b, 1); -call_graph = ""; -b(); -Debug.clearStepping(); // Clear stepping as the listener leaves it on. -assertEquals("bbccdcb", call_graph); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-evaluate-arguments.js b/deps/v8/test/mjsunit/debug-evaluate-arguments.js deleted file mode 100644 index 92b745f1da..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-arguments.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -listenerComplete = false; -exception = false; - -function checkArguments(frame, names, values) { - var argc = Math.max(names.length, values.length); - assertEquals(argc, frame.argumentCount()); - for (var i = 0; i < argc; i++) { - if (i < names.length) { - assertEquals(names[i], frame.argumentName(i)); - } else { - assertEquals(void 0, frame.argumentName(i)); - } - - if (i < values.length) { - assertEquals(values[i], frame.argumentValue(i).value()); - } else { - assertEquals(void 0, frame.argumentValue(i).value()); - } - } -} - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) - { - // Frame 0 - called with less parameters than arguments. - checkArguments(exec_state.frame(0), ['x', 'y'], [1]); - - // Frame 1 - called with more parameters than arguments. - checkArguments(exec_state.frame(1), ['x', 'y'], [1, 2, 3]); - - // Frame 2 - called with same number of parameters than arguments. - checkArguments(exec_state.frame(2), ['x', 'y', 'z'], [1, 2, 3]); - - // Indicate that all was processed. - listenerComplete = true; - } - } catch (e) { - exception = e - }; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function h(x, y) { - debugger; // Breakpoint. -}; - -function g(x, y) { - h(x); -}; - -function f(x, y, z) { - g.apply(null, [x, y, z]); -}; - -f(1, 2, 3); - -// Make sure that the debug event listener vas invoked. -assertTrue(listenerComplete); -assertFalse(exception, "exception in listener") diff --git a/deps/v8/test/mjsunit/debug-evaluate-closure.js b/deps/v8/test/mjsunit/debug-evaluate-closure.js deleted file mode 100644 index ebd42f3ae9..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-closure.js +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2013 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: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug; -var listened = false; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals("goo", exec_state.frame(0).evaluate("goo").value()); - exec_state.frame(0).evaluate("goo = 'goo foo'"); - assertEquals("bar return", exec_state.frame(0).evaluate("bar()").value()); - assertEquals("inner bar", exec_state.frame(0).evaluate("inner").value()); - assertEquals("outer bar", exec_state.frame(0).evaluate("outer").value()); - - assertEquals("baz inner", exec_state.frame(0).evaluate("baz").value()); - assertEquals("baz outer", exec_state.frame(1).evaluate("baz").value()); - exec_state.frame(0).evaluate("w = 'w foo'"); - exec_state.frame(0).evaluate("inner = 'inner foo'"); - exec_state.frame(0).evaluate("outer = 'outer foo'"); - exec_state.frame(0).evaluate("baz = 'baz inner foo'"); - exec_state.frame(1).evaluate("baz = 'baz outer foo'"); - listened = true; - } catch (e) { - print(e); - print(e.stack); - } -} - -Debug.setListener(listener); - -var outer = "outer"; -var baz = "baz outer"; - -function foo() { - var inner = "inner"; - var baz = "baz inner"; - var goo = "goo"; - var withw = { w: "w" }; - var withv = { v: "v" }; - - with (withv) { - var bar = function bar() { - assertEquals("goo foo", goo); - inner = "inner bar"; - outer = "outer bar"; - v = "v bar"; - return "bar return"; - }; - } - - with (withw) { - debugger; - } - - assertEquals("inner foo", inner); - assertEquals("baz inner foo", baz); - assertEquals("w foo", withw.w); - assertEquals("v bar", withv.v); -} - -foo(); -assertEquals("outer foo", outer); -assertEquals("baz outer foo", baz); -assertTrue(listened); -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-evaluate-declaration.js b/deps/v8/test/mjsunit/debug-evaluate-declaration.js deleted file mode 100644 index c64498e097..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-declaration.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -// Test that debug-evaluate only resolves variables that are used by -// the function inside which we debug-evaluate. This is to avoid -// incorrect variable resolution when a context-allocated variable is -// shadowed by a stack-allocated variable. - -"use strict"; - -var Debug = debug.Debug - -var exception = null; -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - exec_state.frame(0).evaluate("var x = 2"); - exec_state.frame(0).evaluate("'use strict'; let y = 3"); - exec_state.frame(0).evaluate("var z = 4"); - exec_state.frame(0).evaluate("function bar() { return 5; }"); - } catch (e) { - exception = e; - print(e + e.stack); - } -} - -Debug.setListener(listener); - -var z = 1; - -(function() { - debugger; -})(); - -assertEquals(2, x); // declaration -assertThrows(() => y, ReferenceError); // let-declaration does not stick -assertEquals(4, z); // re-declaration -assertEquals(5, bar()); // function declaration - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-evaluate-locals-capturing.js b/deps/v8/test/mjsunit/debug-evaluate-locals-capturing.js deleted file mode 100644 index 5fdacba85c..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-locals-capturing.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug -var exception = null; -var break_count = 0; - -var f = null; -var i = null; -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - var frameMirror = exec_state.frame(0); - - var i = frameMirror.evaluate('f = function() { i = 5; }, f(), i').value(); - assertEquals(5, i); - } - } catch(e) { - exception = e; - print(e, e.stack); - } -}; - -Debug.setListener(listener); - -(function (){ - - var i = 0; - - try { - throw new Error(); - } catch (e) { - assertEquals(0, i); - debugger; - assertEquals(5, i); - } -}()); - -assertNull(exception); - -assertNull(i); -f(); -assertNull(i); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-evaluate-locals-optimized-double.js b/deps/v8/test/mjsunit/debug-evaluate-locals-optimized-double.js deleted file mode 100644 index 84b7e20fe6..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-locals-optimized-double.js +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug --expose-gc --allow-natives-syntax -// Flags: --inline-construct - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var listenerComplete = false; -var exception = false; - -var testingConstructCall = false; - -var input = [ - {a: 1, b: 2}, - {a: 3, b: 4}, - {a: 5, b: 6}, - {a: 7, b: 8}, - {a: 9, b: 10} -]; - -var expected = [ - { locals: {a0: 1.01, b0: 2.02}, - args: { names: ["i", "x0", "y0"], values: [0, 3.03, 4.04] } }, - { locals: {a1: 3.03, b1: 4.04}, - args: { names: ["i", "x1", "y1"], values: [1, 5.05, 6.06] } }, - { locals: {a2: 5.05, b2: 6.06}, - args: { names: ["i"], values: [2] } }, - { locals: {a3: 7.07, b3: 8.08}, - args: { names: ["i", "x3", "y3", "z3"], - values: [3, 9.09, 10.10, undefined] } }, - { locals: {a4: 9.09, b4: 10.10}, - args: { names: ["i", "x4", "y4"], values: [4, 11.11, 12.12] } } -]; - -function arraySum(arr) { - return arr.reduce(function (a, b) { return a + b; }, 0); -} - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) - { - assertEquals(6, exec_state.frameCount()); - - for (var i = 0; i < exec_state.frameCount(); i++) { - var frame = exec_state.frame(i); - if (i < exec_state.frameCount() - 1) { - var expected_args = expected[i].args; - var expected_locals = expected[i].locals; - - // All frames except the bottom one have expected locals. - var locals = {}; - for (var j = 0; j < frame.localCount(); j++) { - locals[frame.localName(j)] = frame.localValue(j).value(); - } - assertPropertiesEqual(expected_locals, locals); - - // All frames except the bottom one have expected arguments. - for (var j = 0; j < expected_args.names.length; j++) { - assertEquals(expected_args.names[j], frame.argumentName(j)); - assertEquals(expected_args.values[j], - frame.argumentValue(j).value()); - } - - // All frames except the bottom one have two scopes. - assertEquals(3, frame.scopeCount()); - assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType()); - assertEquals(debug.ScopeType.Script, frame.scope(1).scopeType()); - assertEquals(debug.ScopeType.Global, frame.scope(2).scopeType()); - - Object.keys(expected_locals).forEach(function (name) { - assertEquals(expected_locals[name], - frame.scope(0).scopeObject().value()[name]); - }); - - for (var j = 0; j < expected_args.names.length; j++) { - var arg_name = expected_args.names[j]; - var arg_value = expected_args.values[j]; - assertEquals(arg_value, - frame.scope(0).scopeObject().value()[arg_name]); - } - - // Evaluate in the inlined frame. - Object.keys(expected_locals).forEach(function (name) { - assertEquals(expected_locals[name], frame.evaluate(name).value()); - }); - - for (var j = 0; j < expected_args.names.length; j++) { - var arg_name = expected_args.names[j]; - var arg_value = expected_args.values[j]; - assertEquals(arg_value, frame.evaluate(arg_name).value()); - assertEquals(arg_value, frame.evaluate('arguments['+j+']').value()); - } - - var expected_args_sum = arraySum(expected_args.values); - var expected_locals_sum = - arraySum(Object.keys(expected_locals). - map(function (k) { return expected_locals[k]; })); - - assertEquals(expected_locals_sum + expected_args_sum, - frame.evaluate(Object.keys(expected_locals).join('+') + - ' + ' + - expected_args.names.join('+')).value()); - - var arguments_sum = expected_args.names.map(function(_, idx) { - return "arguments[" + idx + "]"; - }).join('+'); - assertEquals(expected_args_sum, - frame.evaluate(arguments_sum).value()); - } else { - // The bottom frame only have the global scope. - assertEquals(2, frame.scopeCount()); - assertEquals(debug.ScopeType.Script, frame.scope(0).scopeType()); - assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType()); - } - - // Check the frame function. - switch (i) { - case 0: assertEquals(h, frame.func().value()); break; - case 1: assertEquals(g3, frame.func().value()); break; - case 2: assertEquals(g2, frame.func().value()); break; - case 3: assertEquals(g1, frame.func().value()); break; - case 4: assertEquals(f, frame.func().value()); break; - case 5: break; - default: assertUnreachable(); - } - - // Check for construct call. - if (i == 4) { - assertEquals(testingConstructCall, frame.isConstructCall()); - } else if (i == 2) { - assertTrue(frame.isConstructCall()); - } else { - assertFalse(frame.isConstructCall()); - } - - if (i > 4) { - assertFalse(frame.isOptimizedFrame()); - assertFalse(frame.isInlinedFrame()); - } - } - - // Indicate that all was processed. - listenerComplete = true; - } - } catch (e) { - exception = e.toString() + e.stack; - }; -}; - -for (var i = 0; i < 4; i++) f(input.length - 1, 11.11, 12.12); -%OptimizeFunctionOnNextCall(f); -f(input.length - 1, 11.11, 12.12); - -// Add the debug event listener. -Debug.setListener(listener); - -function h(i, x0, y0) { - var a0 = input[i].a; - var b0 = input[i].b; - a0 = a0 + a0 / 100; - b0 = b0 + b0 / 100; - debugger; // Breakpoint. - return a0 + b0; -}; - -function g3(i, x1, y1) { - var a1 = input[i].a; - var b1 = input[i].b; - a1 = a1 + a1 / 100; - b1 = b1 + b1 / 100; - h(i - 1, a1, b1); - return a1 + b1; -}; - -function g2(i) { - var a2 = input[i].a; - var b2 = input[i].b; - a2 = a2 + a2 / 100; - b2 = b2 + b2 / 100; - g3(i - 1, a2, b2); - return a2 + b2; -}; - -function g1(i, x3, y3, z3) { - var a3 = input[i].a; - var b3 = input[i].b; - a3 = a3 + a3 / 100; - b3 = b3 + b3 / 100; - new g2(i - 1, a3, b3); - return a3 + b3; -}; - -function f(i, x4, y4) { - var a4 = input[i].a; - var b4 = input[i].b; - a4 = a4 + a4 / 100; - b4 = b4 + b4 / 100; - g1(i - 1, a4, b4); - return a4 + b4; -}; - -// Test calling f normally and as a constructor. -f(input.length - 1, 11.11, 12.12); -f(input.length - 1, 11.11, 12.12, ""); -testingConstructCall = true; -new f(input.length - 1, 11.11, 12.12); -new f(input.length - 1, 11.11, 12.12, ""); - -// Make sure that the debug event listener was invoked. -assertFalse(exception, "exception in listener " + exception) -assertTrue(listenerComplete); - -//Throw away type information for next run. -gc(); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-evaluate-locals-optimized.js b/deps/v8/test/mjsunit/debug-evaluate-locals-optimized.js deleted file mode 100644 index 9d539fe282..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-locals-optimized.js +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug --expose-gc --allow-natives-syntax -// Flags: --inline-construct - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var listenerComplete = false; -var exception = false; - -var testingConstructCall = false; - -var expected = [ - { locals: {a0: 1, b0: 2}, - args: { names: ["i", "x0", "y0"], values: [0, 3, 4] } }, - { locals: {a1: 3, b1: 4}, - args: { names: ["i", "x1", "y1"], values: [1, 5, 6] } }, - { locals: {a2: 5, b2: 6}, - args: { names: ["i"], values: [2] } }, - { locals: {a3: 7, b3: 8}, - args: { names: ["i", "x3", "y3", "z3"], values: [3, 9, 10, undefined] } }, - { locals: {a4: 9, b4: 10}, - args: { names: ["i", "x4", "y4"], values: [4, 11, 12] } } -]; - -function arraySum(arr) { - return arr.reduce(function (a, b) { return a + b; }, 0); -} - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) - { - assertEquals(6, exec_state.frameCount()); - - for (var i = 0; i < exec_state.frameCount(); i++) { - var frame = exec_state.frame(i); - if (i < exec_state.frameCount() - 1) { - var expected_args = expected[i].args; - var expected_locals = expected[i].locals; - - // All frames except the bottom one have expected locals. - var locals = {}; - for (var j = 0; j < frame.localCount(); j++) { - locals[frame.localName(j)] = frame.localValue(j).value(); - } - assertPropertiesEqual(expected_locals, locals); - - // All frames except the bottom one have expected arguments. - for (var j = 0; j < expected_args.names.length; j++) { - assertEquals(expected_args.names[j], frame.argumentName(j)); - assertEquals(expected_args.values[j], - frame.argumentValue(j).value()); - } - - // All frames except the bottom one have three scopes. - assertEquals(3, frame.scopeCount()); - assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType()); - assertEquals(debug.ScopeType.Script, frame.scope(1).scopeType()); - assertEquals(debug.ScopeType.Global, frame.scope(2).scopeType()); - - Object.keys(expected_locals).forEach(function (name) { - assertEquals(expected_locals[name], - frame.scope(0).scopeObject().value()[name]); - }); - - for (var j = 0; j < expected_args.names.length; j++) { - var arg_name = expected_args.names[j]; - var arg_value = expected_args.values[j]; - assertEquals(arg_value, - frame.scope(0).scopeObject().value()[arg_name]); - } - - // Evaluate in the inlined frame. - Object.keys(expected_locals).forEach(function (name) { - assertEquals(expected_locals[name], frame.evaluate(name).value()); - }); - - for (var j = 0; j < expected_args.names.length; j++) { - var arg_name = expected_args.names[j]; - var arg_value = expected_args.values[j]; - assertEquals(arg_value, frame.evaluate(arg_name).value()); - assertEquals(arg_value, frame.evaluate('arguments['+j+']').value()); - } - - var expected_args_sum = arraySum(expected_args.values); - var expected_locals_sum = - arraySum(Object.keys(expected_locals). - map(function (k) { return expected_locals[k]; })); - - assertEquals(expected_locals_sum + expected_args_sum, - frame.evaluate(Object.keys(expected_locals).join('+') + - ' + ' + - expected_args.names.join('+')).value()); - - var arguments_sum = expected_args.names.map(function(_, idx) { - return "arguments[" + idx + "]"; - }).join('+'); - assertEquals(expected_args_sum, - frame.evaluate(arguments_sum).value()); - } else { - // The bottom frame only have the script scope and the global scope. - assertEquals(2, frame.scopeCount()); - assertEquals(debug.ScopeType.Script, frame.scope(0).scopeType()); - assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType()); - } - - // Check the frame function. - switch (i) { - case 0: assertEquals(h, frame.func().value()); break; - case 1: assertEquals(g3, frame.func().value()); break; - case 2: assertEquals(g2, frame.func().value()); break; - case 3: assertEquals(g1, frame.func().value()); break; - case 4: assertEquals(f, frame.func().value()); break; - case 5: break; - default: assertUnreachable(); - } - - // Check for construct call. - if (i == 4) { - assertEquals(testingConstructCall, frame.isConstructCall()); - } else if (i == 2) { - assertTrue(frame.isConstructCall()); - } else { - assertFalse(frame.isConstructCall()); - } - - if (i > 4) { - assertFalse(frame.isOptimizedFrame()); - assertFalse(frame.isInlinedFrame()); - } - } - - // Indicate that all was processed. - listenerComplete = true; - } - } catch (e) { - exception = e.toString() + e.stack; - }; -}; - -for (var i = 0; i < 4; i++) f(expected.length - 1, 11, 12); -%OptimizeFunctionOnNextCall(f); -f(expected.length - 1, 11, 12); - -// Add the debug event listener. -Debug.setListener(listener); - -function h(i, x0, y0) { - var a0 = expected[i].locals.a0; - var b0 = expected[i].locals.b0; - debugger; // Breakpoint. - return a0 + b0; -} - -function g3(i, x1, y1) { - var a1 = expected[i].locals.a1; - var b1 = expected[i].locals.b1; - h(i - 1, a1, b1); - return a1 + b1; -} - -function g2(i) { - var a2 = expected[i].locals.a2; - var b2 = expected[i].locals.b2; - g3(i - 1, a2, b2); - return a2 + b2; -} - -function g1(i, x3, y3, z3) { - var a3 = expected[i].locals.a3; - var b3 = expected[i].locals.b3; - new g2(i - 1, a3, b3); - return a3 + b3; -} - -function f(i, x4, y4) { - var a4 = expected[i].locals.a4; - var b4 = expected[i].locals.b4; - g1(i - 1, a4, b4); - return a4 + b4; -} - -// Test calling f normally and as a constructor. -f(expected.length - 1, 11, 12); -f(expected.length - 1, 11, 12, 0); -testingConstructCall = true; -new f(expected.length - 1, 11, 12); -new f(expected.length - 1, 11, 12, 0); - -// Make sure that the debug event listener was invoked. -assertFalse(exception, "exception in listener " + exception) -assertTrue(listenerComplete); - -// Throw away type information for next run. -gc(); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-evaluate-modify-catch-block-scope.js b/deps/v8/test/mjsunit/debug-evaluate-modify-catch-block-scope.js deleted file mode 100644 index 676f78282d..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-modify-catch-block-scope.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - exec_state.frame(0).evaluate("a = 2"); - exec_state.frame(0).evaluate("e = 3"); - exec_state.frame(0).evaluate("bar()"); - exec_state.frame(0).evaluate("a++"); - exec_state.frame(0).evaluate("e++"); - } catch (e) { - exception = e; - print(e + e.stack); - } -} - -Debug.setListener(listener); - -(function() { - "use strict"; - try { - throw 1; - } catch (e) { - let a = 1; - function bar() { - a *= 2; - e *= 2; - } - debugger; - assertEquals(5, a); - assertEquals(7, e); - } -})(); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-evaluate-modify-this.js b/deps/v8/test/mjsunit/debug-evaluate-modify-this.js deleted file mode 100644 index 930f6ed043..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-modify-this.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; - -var f = () => { debugger; } -var g = function() { debugger; } -var h = (function() { return () => { debugger; }; }).call({}); - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertThrows(() => exec_state.frame(0).evaluate("this = 2")); - } catch (e) { - exception = e; - print("Caught something. " + e + " " + e.stack); - }; -}; - -Debug.setListener(listener); - -f(); -g(); -g.call({}); -h(); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-evaluate-nested-let.js b/deps/v8/test/mjsunit/debug-evaluate-nested-let.js deleted file mode 100644 index 8e9f8c157a..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-nested-let.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug - -var exception = null; - -function f() { - let a = 0; - function g() { - let a = 1; - { - let a = 2; - debugger; // Breakpoint. - if (a !== 3) { - // We cannot change stack locals in optimized frames. - assertEquals(2, a); - assertOptimized(g); - } - } - assertEquals(1, a); - } - g.call(1); - if (a !== 4) { - // We cannot change stack locals in optimized frames. - assertEquals(0, a); - assertOptimized(f); - } -} - - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - exec_state.frame(0).evaluate("a = 3"); - exec_state.frame(1).evaluate("a = 4"); - assertThrows(() => exec_state.frame(0).evaluate("this = 2")); - } catch (e) { - exception = e; - print("Caught something. " + e + " " + e.stack); - }; -}; - -Debug.setListener(listener); - -f(); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-evaluate-shadowed-context-2.js b/deps/v8/test/mjsunit/debug-evaluate-shadowed-context-2.js deleted file mode 100644 index 59352e06a5..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-shadowed-context-2.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --no-analyze-environment-liveness - -// Test that debug-evaluate correctly collects free outer variables -// and does not get confused by variables in nested scopes. - -Debug = debug.Debug - -var exception = null; -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertThrows(() => exec_state.frame(0).evaluate("x").value()); - } catch (e) { - exception = e; - print(e + e.stack); - } -} - -Debug.setListener(listener); - -(function() { - var x = 1; // context allocate x - (() => x); - (function() { - var x = 2; // stack allocate shadowing x - (function() { - { // context allocate x in a nested scope - let x = 3; - (() => x); - } - debugger; - })(); - })(); -})(); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-evaluate-with.js b/deps/v8/test/mjsunit/debug-evaluate-with.js deleted file mode 100644 index 4e02d9e188..0000000000 --- a/deps/v8/test/mjsunit/debug-evaluate-with.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -listenerComplete = false; -exception = false; -breakPointCount = 0; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) - { - breakPointCount++; - if (breakPointCount == 1) { - // Break point in first with block. - assertEquals(2, exec_state.frame(0).evaluate('a').value()); - assertEquals(2, exec_state.frame(0).evaluate('b').value()); - } else if (breakPointCount == 2) { - // Break point in second with block. - assertEquals(3, exec_state.frame(0).evaluate('a').value()); - assertEquals(1, exec_state.frame(0).evaluate('b').value()); - } else if (breakPointCount == 3) { - // Break point in eval with block. - assertEquals('local', exec_state.frame(0).evaluate('foo').value()); - } - } - } catch (e) { - exception = e - }; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function f() { - var a = 1; - var b = 2; - with ({a:2}) { - debugger; // Breakpoint. - x = {a:3,b:1}; - with (x) { - debugger; // Breakpoint. - } - } -}; - -f(); - -var foo = "global"; -eval("with({bar:'with'}) { (function g() { var foo = 'local'; debugger; })(); }"); - -// Make sure that the debug event listener vas invoked. -assertEquals(3, breakPointCount); -assertFalse(exception, "exception in listener") diff --git a/deps/v8/test/mjsunit/debug-event-listener.js b/deps/v8/test/mjsunit/debug-event-listener.js deleted file mode 100644 index a2eb5f009b..0000000000 --- a/deps/v8/test/mjsunit/debug-event-listener.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple function which stores the last debug event. -lastDebugEvent = new Object(); -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break || - event == Debug.DebugEvent.Exception) - { - lastDebugEvent.event = event; - lastDebugEvent.frameFuncName = exec_state.frame().func().name(); - lastDebugEvent.event_data = event_data; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); -// Get events from handled exceptions. -Debug.setBreakOnException(); - -// Test debug event for handled exception. -(function f(){ - try { - x(); - } catch(e) { - // Do nothing. Ignore exception. - } -})(); -assertTrue(lastDebugEvent.event == Debug.DebugEvent.Exception); -assertEquals(lastDebugEvent.frameFuncName, "f"); -assertFalse(lastDebugEvent.event_data.uncaught()); -Debug.clearBreakOnException(); - -// Test debug event for break point. -function a() { - x = 1; - y = 2; - z = 3; -}; -Debug.setBreakPoint(a, 1); -a(); -assertTrue(lastDebugEvent.event == Debug.DebugEvent.Break); -assertEquals(lastDebugEvent.frameFuncName, "a"); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-exceptions.js b/deps/v8/test/mjsunit/debug-exceptions.js deleted file mode 100644 index 1a0e222d51..0000000000 --- a/deps/v8/test/mjsunit/debug-exceptions.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - - -Debug = debug.Debug - -let error = false; -let uncaught; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Exception) return; - try { - uncaught = event_data.uncaught(); - } catch (e) { - error = true; - } -} - -Debug.setBreakOnException(); -Debug.setListener(listener); - - -function assertCaught(f) { - try {f()} finally { - assertFalse(uncaught); - return; - } -} - -function assertUncaught(f) { - try {f()} finally { - assertTrue(uncaught); - return; - } -} - - -assertUncaught(() => { - for (var a of [1, 2, 3]) { - throw a - } -}); - -assertUncaught(() => { - for (var a of [1, 2, 3]) { - try {throw a} finally {} - } -}); - -assertCaught(() => { - for (var a of [1, 2, 3]) { - try { - try {throw a} finally {} - } catch(_) {} - } -}); - -assertCaught(() => { - try { - for (var a of [1, 2, 3]) { - try {throw a} finally {} - } - } catch(_) {} -}); - - -// Check that an internal exception in our yield* desugaring is not observable. -{ - uncaught = null; - - let iter = { - next() {return {value:42, done:false}}, - throw() {return {done:true}} - }; - let iterable = {[Symbol.iterator]() {return iter}}; - function* f() { yield* iterable } - - let g = f(); - g.next(); - assertEquals({value: undefined, done: true}, g.throw()); - assertNull(uncaught); // No exception event was generated. -} - - -assertFalse(error); diff --git a/deps/v8/test/mjsunit/debug-generator-break-on-stack.js b/deps/v8/test/mjsunit/debug-generator-break-on-stack.js deleted file mode 100644 index 5a1a9c56c1..0000000000 --- a/deps/v8/test/mjsunit/debug-generator-break-on-stack.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - print(line); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - - -function* g() { - setbreaks(); - yield 1; // B1 -} - -function* f() { - yield* g(); - return 2; // B2 -} - -function setbreaks() { - Debug.setListener(listener); - Debug.setBreakPoint(g, 2); - Debug.setBreakPoint(f, 2); -} - -for (let _ of f()) { } - -assertEquals(2, break_count); -assertNull(exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-generator-break.js b/deps/v8/test/mjsunit/debug-generator-break.js deleted file mode 100644 index 34ed82c376..0000000000 --- a/deps/v8/test/mjsunit/debug-generator-break.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function* g() { - yield 1; -} - -function* f() { - yield* g(); // B1 - assertEquals(2, break_count); // B2 - return 1; // B3 -} - -Debug.setBreakPoint(f, 1); -Debug.setBreakPoint(f, 2); -Debug.setBreakPoint(f, 3); - -for (let _ of f()) { } - -assertEquals(3, break_count); -assertNull(exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-materialized.js b/deps/v8/test/mjsunit/debug-materialized.js deleted file mode 100644 index 0b01b78df4..0000000000 --- a/deps/v8/test/mjsunit/debug-materialized.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -function dbg(x) { - debugger; -} - -function foo() { - arguments[0]; - dbg(); -} - -function bar() { - var t = { a : 1 }; - dbg(); - return t.a; -} - -foo(1); -foo(1); -bar(1); -bar(1); -%OptimizeFunctionOnNextCall(foo); -%OptimizeFunctionOnNextCall(bar); - -var Debug = debug.Debug; -Debug.setListener(function(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - for (var i = 0; i < exec_state.frameCount(); i++) { - var f = exec_state.frame(i); - for (var j = 0; j < f.localCount(); j++) { - print("'" + f.localName(j) + "' = " + f.localValue(j).value()); - } - } -}); - -foo(1); -bar(1); diff --git a/deps/v8/test/mjsunit/debug-optimize.js b/deps/v8/test/mjsunit/debug-optimize.js deleted file mode 100644 index d1ce63d5a0..0000000000 --- a/deps/v8/test/mjsunit/debug-optimize.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --use-inlining - -var Debug = debug.Debug; - -function f1() { - return 1; -} - -function f2() { - return 2; -} - -function f3() { - return f1(); -} - -function f4() { - return 4; -} - - -function optimize(f) { - f(); - f(); - %OptimizeFunctionOnNextCall(f); - f(); -} - -optimize(f1); -optimize(f2); -optimize(f3); - -Debug.setListener(function() {}); - -assertOptimized(f1); -assertOptimized(f2); -assertOptimized(f3); - -Debug.setBreakPoint(f1, 1); - -// Setting break point deoptimizes f1 and f3 (which inlines f1). -assertUnoptimized(f1); -assertOptimized(f2); -assertUnoptimized(f3); - -// We can optimize with break points set. -optimize(f4); -assertOptimized(f4); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-print.js b/deps/v8/test/mjsunit/debug-print.js deleted file mode 100644 index b0e141d709..0000000000 --- a/deps/v8/test/mjsunit/debug-print.js +++ /dev/null @@ -1,47 +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 - -// Make sure printing different element kinds doesn't crash. - -var array; -var obj = {}; - -array = []; -%DebugPrint(array); - -// FAST_SMI_ELEMENTS -array = [1, 2, 3]; -%DebugPrint(array); - -// FAST_HOLEY_SMI_ELEMENTS -array[10] = 100; -array[11] = 100; -%DebugPrint(array); - -// FAST_ELEMENTS -array = [1, obj, obj]; -%DebugPrint(array); - -// FAST_HOLEY_ELEMENTS -array[100] = obj; -array[101] = obj; -%DebugPrint(array); - -// FAST_DOUBLE_ELEMENTS -array = [1.1, 2.2, 3.3, 3.3, 3.3, NaN]; -%DebugPrint(array); -array.push(NaN); -array.push(NaN); -%DebugPrint(array); - -// FAST_HOLEY_DOUBLE_ELEMENTS -array[100] = 1.2; -array[101] = 1.2; -%DebugPrint(array); - -// DICTIONARY_ELEMENTS -%NormalizeElements(array); -%DebugPrint(array); diff --git a/deps/v8/test/mjsunit/debug-script.js b/deps/v8/test/mjsunit/debug-script.js index 3bedb74a35..386e11606e 100644 --- a/deps/v8/test/mjsunit/debug-script.js +++ b/deps/v8/test/mjsunit/debug-script.js @@ -80,9 +80,9 @@ assertTrue(extension_count == 2 || extension_count == 3); assertTrue(normal_count == 2 || normal_count == 3); // Test a builtins script. -var math_script = Debug.findScript('native math.js'); -assertEquals('native math.js', math_script.name); -assertEquals(Debug.ScriptType.Native, math_script.type); +var array_script = Debug.findScript('native array.js'); +assertEquals('native array.js', array_script.name); +assertEquals(Debug.ScriptType.Native, array_script.type); // Test a debugger script. var debug_delay_script = Debug.findScript('native debug.js'); diff --git a/deps/v8/test/mjsunit/debug-set-variable-value.js b/deps/v8/test/mjsunit/debug-set-variable-value.js index 65434289d0..6f872dfecf 100644 --- a/deps/v8/test/mjsunit/debug-set-variable-value.js +++ b/deps/v8/test/mjsunit/debug-set-variable-value.js @@ -63,7 +63,7 @@ function RunPauseTest(scope_number, expected_old_result, variable_name, // Add the debug event listener. Debug.setListener(listener); - var actual_new_value; + var actual_new_result; try { actual_new_result = fun(); } finally { @@ -78,7 +78,7 @@ function RunPauseTest(scope_number, expected_old_result, variable_name, assertEquals(expected_new_result, actual_new_result); } -// Accepts a closure 'fun' that returns a variable from it's outer scope. +// Accepts a closure 'fun' that returns a variable from its outer scope. // The test changes the value of variable via the handle to function and checks // that the return value changed accordingly. function RunClosureTest(scope_number, expected_old_result, variable_name, @@ -307,3 +307,32 @@ assertSame(Number, DebugCommandProcessor.resolveValue_( {handle: Debug.MakeMirror(Number).handle()})); assertSame(RunClosureTest, DebugCommandProcessor.resolveValue_( {handle: Debug.MakeMirror(RunClosureTest).handle()})); + + +// Test script-scope variable. +let abc = 12; +{ + let exception; + function listener(event, exec_state) { + try { + if (event == Debug.DebugEvent.Break) { + let scope_count = exec_state.frame().scopeCount(); + let script_scope = exec_state.frame().scope(scope_count - 2); + assertTrue(script_scope.isScope()); + assertEquals(debug.ScopeType.Script, script_scope.scopeType()); + script_scope.setVariableValue('abc', 42); + } + } catch(e) { exception = e } + } + + Debug.setListener(listener); + assertEquals(12, abc); + debugger; + assertEquals(42, abc); + + if (exception != null) { + assertUnreachable("Exception in listener\n" + exception.stack); + } +} + +Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stack-check-position.js b/deps/v8/test/mjsunit/debug-stack-check-position.js deleted file mode 100644 index a5570ce904..0000000000 --- a/deps/v8/test/mjsunit/debug-stack-check-position.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var exception = null; -var loop = true; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertTrue(exec_state.frame(0).sourceLineText().indexOf("BREAK") > 0); - } catch (e) { - exception = e; - } -} - -function f() { // BREAK - return 1; -} - -Debug.setListener(listener); - -%ScheduleBreak(); // Break on function entry. -f(); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-step-2.js b/deps/v8/test/mjsunit/debug-step-2.js deleted file mode 100644 index 502b426ee2..0000000000 --- a/deps/v8/test/mjsunit/debug-step-2.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// This test tests that full code compiled without debug break slots -// is recompiled with debug break slots when debugging is started. - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var bp; -var done = false; -var step_count = 0; - -// Debug event listener which steps until the global variable done is true. -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); - step_count++; - } -}; - -// Set the global variables state to prpare the stepping test. -function prepare_step_test() { - done = false; - step_count = 0; -} - -// Test function to step through. -function f() { - var i = 1; - var j = 2; - done = true; -}; - -prepare_step_test(); -f(); - -// Add the debug event listener. -Debug.setListener(listener); - -bp = Debug.setBreakPoint(f, 1); - -prepare_step_test(); -f(); -assertEquals(4, step_count); -Debug.clearBreakPoint(bp); - -// Set a breakpoint on the first var statement (line 1). -bp = Debug.setBreakPoint(f, 1); - -// Step through the function ensuring that the var statements are hit as well. -prepare_step_test(); -f(); -assertEquals(4, step_count); - -// Clear the breakpoint and check that no stepping happens. -Debug.clearBreakPoint(bp); -prepare_step_test(); -f(); -assertEquals(0, step_count); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-step-3.js b/deps/v8/test/mjsunit/debug-step-3.js deleted file mode 100644 index 9cac0f5619..0000000000 --- a/deps/v8/test/mjsunit/debug-step-3.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// This test tests that full code compiled without debug break slots -// is recompiled with debug break slots when debugging is started. - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var bp; -var done = false; -var step_count = 0; -var set_bp = false - -// Debug event listener which steps until the global variable done is true. -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); - step_count++; - } -}; - -// Set the global variables state to prpare the stepping test. -function prepare_step_test() { - done = false; - step_count = 0; -} - -// Test function to step through. -function f() { - var a = 0; - if (set_bp) { bp = Debug.setBreakPoint(f, 3); } - var i = 1; - var j = 2; - done = true; -}; - -prepare_step_test(); -f(); - -// Add the debug event listener. -Debug.setListener(listener); - -// Make f set a breakpoint with an activation on the stack. -prepare_step_test(); -set_bp = true; -f(); -// TODO(1782): Fix issue to bring back this assert. -//assertEquals(4, step_count); -Debug.clearBreakPoint(bp); - -// Set a breakpoint on the first var statement (line 1). -set_bp = false; -bp = Debug.setBreakPoint(f, 3); - -// Step through the function ensuring that the var statements are hit as well. -prepare_step_test(); -f(); -assertEquals(4, step_count); - -// Clear the breakpoint and check that no stepping happens. -Debug.clearBreakPoint(bp); -prepare_step_test(); -f(); -assertEquals(0, step_count); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-step-4.js b/deps/v8/test/mjsunit/debug-step-4.js deleted file mode 100644 index 3992f622a6..0000000000 --- a/deps/v8/test/mjsunit/debug-step-4.js +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Tests how debugger can step over not necessarily in the top frame. - -// Simple 3 functions, that protocol their execution state in global -// variable state. -var state; - -function f() { - var a = 1978; - for (state[2] = 0; state[2] < 3; state[2]++) { - void String(a); - } -} -function g() { - for (state[1] = 0; state[1] < 3; state[1]++) { - f(); - } -} -function h() { - state = [-1, -1, -1]; - for (state[0] = 0; state[0] < 3; state[0]++) { - g(); - } -} - -function TestCase(expected_final_state) { - var listener_exception = null; - var state_snapshot; - var listener_state; - var bp; - - function listener(event, exec_state, event_data, data) { - print("Here ("+event+"/"+listener_state+"): " + - exec_state.frame(0).sourceLineText()); - try { - if (event == Debug.DebugEvent.Break) { - if (listener_state == 0) { - Debug.clearBreakPoint(bp); - exec_state.prepareStep(Debug.StepAction.StepNext); - listener_state = 1; - } else if (listener_state == 1) { - state_snapshot = String(state); - print("State: " + state_snapshot); - Debug.setListener(null); - listener_state = 2; - } - } - } catch (e) { - listener_exception = e; - } - } - - - // Add the debug event listener. - listener_state = 0; - Debug.setListener(listener); - bp = Debug.setBreakPoint(f, 1); - - h(); - Debug.setListener(null); - if (listener_exception !== null) { - print("Exception caught: " + listener_exception); - assertUnreachable(); - } - - assertEquals(expected_final_state, state_snapshot); -} - - -// Warm-up -- make sure all is compiled and ready for breakpoint. -h(); - -TestCase("0,0,-1"); diff --git a/deps/v8/test/mjsunit/debug-step-end-of-script.js b/deps/v8/test/mjsunit/debug-step-end-of-script.js deleted file mode 100644 index e8ffcc8bc1..0000000000 --- a/deps/v8/test/mjsunit/debug-step-end-of-script.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var expected = ["debugger;", "debugger;"]; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals(expected.shift(), exec_state.frame(0).sourceLineText()); - exec_state.prepareStep(Debug.StepAction.StepNext); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setListener(listener); -debugger; diff --git a/deps/v8/test/mjsunit/debug-step-into-json.js b/deps/v8/test/mjsunit/debug-step-into-json.js deleted file mode 100644 index d4ba7097c9..0000000000 --- a/deps/v8/test/mjsunit/debug-step-into-json.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue( - event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - } -}; - -function toJsonCallback() { - return "x"; // Break 2. -} // Break 3. -var o = {}; -o.toJSON = toJsonCallback; - -Debug.setListener(listener); -debugger; // Break 0. -var result = JSON.stringify(o); // Break 1. -Debug.setListener(null); // Break 4. - -assertEquals('"x"', result); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-step-into-valueof.js b/deps/v8/test/mjsunit/debug-step-into-valueof.js deleted file mode 100644 index b1d9cf1454..0000000000 --- a/deps/v8/test/mjsunit/debug-step-into-valueof.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue(event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - } -}; - -function valueOfCallback() { - return 2; // Break 2. -} // Break 3. -var o = {}; -o.valueOf = valueOfCallback; - -Debug.setListener(listener); -debugger; // Break 0. -var result = 1 + o; // Break 1. -Debug.setListener(null); // Break 4. - -assertEquals(3, result); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-step-stub-callfunction.js b/deps/v8/test/mjsunit/debug-step-stub-callfunction.js deleted file mode 100644 index 50d095b532..0000000000 --- a/deps/v8/test/mjsunit/debug-step-stub-callfunction.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple debug event handler which counts the number of breaks hit and steps. -var break_break_point_hit_count = 0; -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - break_break_point_hit_count++; - // Continue stepping until returned to bottom frame. - if (exec_state.frameCount() > 1) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Use 'eval' to ensure that the call to print is through CodeStub CallFunction. -// See Ia32CodeGenerator::VisitCall and Ia32CodeGenerator::CallWithArguments. -function f() { - debugger; - eval(''); - print('Hello, world!'); -}; - -break_break_point_hit_count = 0; -f(); -assertEquals(6, break_break_point_hit_count); - -// Use an inner function to ensure that the function call is through CodeStub -// CallFunction see Ia32CodeGenerator::VisitCall and -// Ia32CodeGenerator::CallWithArguments. -function g() { - function h() {} - debugger; - h(); -}; - -break_break_point_hit_count = 0; -g(); -assertEquals(5, break_break_point_hit_count); - - -// Use an inner function to ensure that the function call is through CodeStub -// CallFunction. -function testCallInExpreesion() { - function h() {} - debugger; - var x = 's' + h(10, 20); -}; - -break_break_point_hit_count = 0; -testCallInExpreesion(); -assertEquals(5, break_break_point_hit_count); - - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-step-turbofan.js b/deps/v8/test/mjsunit/debug-step-turbofan.js deleted file mode 100644 index 6c1fceff31..0000000000 --- a/deps/v8/test/mjsunit/debug-step-turbofan.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --turbo-filter=g --allow-natives-syntax - -// Test that Debug::PrepareForBreakPoints can deal with turbofan code (g) -// on the stack. Without deoptimization support, we will not be able to -// replace optimized code for g by unoptimized code with debug break slots. -// This would cause stepping to fail (V8 issue 3660). - -function f(x) { - g(x); - var a = 0; // Break 6 - return a; // Break 7 -} // Break 8 - -function g(x) { - if (x) h(); - var a = 0; // Break 2 - var b = 1; // Break 3 - return a + b; // Break 4 -} // Break 5 - -function h() { - debugger; // Break 0 -} // Break 1 - -Debug = debug.Debug; -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - exec_state.prepareStep(Debug.StepAction.StepNext); - print(exec_state.frame(0).sourceLineText()); - var match = exec_state.frame(0).sourceLineText().match(/Break (\d)/); - assertNotNull(match); - assertEquals(break_count++, parseInt(match[1])); - } catch (e) { - print(e + e.stack); - exception = e; - } -} - -f(0); -f(0); -%OptimizeFunctionOnNextCall(g); - -Debug.setListener(listener); - -f(1); - -Debug.setListener(null); // Break 9 -assertNull(exception); -assertEquals(10, break_count); diff --git a/deps/v8/test/mjsunit/debug-step.js b/deps/v8/test/mjsunit/debug-step.js deleted file mode 100644 index 6f5c8f410c..0000000000 --- a/deps/v8/test/mjsunit/debug-step.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple debug event handler which first time hit will perform 1000 steps and -// second time hit will evaluate and store the value of "i". If requires that -// the global property "state" is initially zero. - -var bp1, bp2; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - if (step_count > 0) { - exec_state.prepareStep(Debug.StepAction.StepIn); - step_count--; - } else { - result = exec_state.frame().evaluate("i").value(); - // Clear the break point on line 2 if set. - if (bp2) { - Debug.clearBreakPoint(bp2); - } - } - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Test debug event for break point. -function f() { - var i; // Line 1. - for (i = 0; i < 1000; i++) { // Line 2. - x = 1; // Line 3. - } -}; - -// Set a breakpoint on the for statement (line 1). -bp1 = Debug.setBreakPoint(f, 1); - -// Check that performing 1000 steps will make i 333. -var step_count = 1000; -result = -1; -f(); -assertEquals(333, result); -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-accessor-ic.js b/deps/v8/test/mjsunit/debug-stepin-accessor-ic.js deleted file mode 100644 index 66c0580fd6..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-accessor-ic.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -function get() { - return 3; // Break -} // Break - -function set(x) { - this.x = x; // Break -} // Break - -var o = {}; -Object.defineProperty(o, "get", { get : get }); -Object.defineProperty(o, "set", { set : set }); - -function f() { - for (var i = 0; i < 10; i++) { // Break - o.get; // Break - o.set = 1; // Break - } -} // Break - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var source_line = exec_state.frame(0).sourceLineText(); - assertTrue(source_line.indexOf("// Break") > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - break_count++; - } catch (e) { - exception = e; - } -} - -var Debug = debug.Debug; -Debug.setListener(listener); - -debugger; // Break -f(); // Break - -Debug.setListener(null); // Break -assertEquals(86, break_count); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-stepin-accessor.js b/deps/v8/test/mjsunit/debug-stepin-accessor.js deleted file mode 100644 index 8513ca0eae..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-accessor.js +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 1; -var expected_source_line_text = null; -var expected_function_name = null; - -// Simple debug event handler which first time will cause 'step in' action -// to get into g.call and than check that execution is stopped inside -// function 'g'. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state == 3) { - assertEquals(expected_source_line_text, - event_data.sourceLineText()); - assertEquals(expected_function_name, event_data.func().name()); - state = 4; - } else { - exec_state.prepareStep(Debug.StepAction.StepIn); - state++; - } - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - - -var c = { - name: 'name ', - get getter1() { - return this.name; // getter 1 - }, - get getter2() { - return { // getter 2 - 'a': c.name - }; - }, - set setter1(n) { - this.name = n; // setter 1 - } -}; - -c.__defineGetter__('y', function getterY() { - return this.name; // getter y -}); - -c.__defineGetter__(3, function getter3() { - return this.name; // getter 3 -}); - -c.__defineSetter__('y', function setterY(n) { - this.name = n; // setter y -}); - -c.__defineSetter__(3, function setter3(n) { - this.name = n; // setter 3 -}); - -var d = { - 'c': c, -}; - -function testGetter1_1() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - debugger; - var x = c.getter1; -} - -function testGetter1_2() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - debugger; - var x = c['getter1']; -} - -function testGetter1_3() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - for (var i = 1; i < 2; i++) { - debugger; - var x = c['getter' + i]; - } -} - -function testGetter1_4() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - debugger; - var x = d.c.getter1; -} - -function testGetter1_5() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - for (var i = 2; i != 1; i--); - debugger; - var x = d.c['getter' + i]; -} - -function testGetter2_1() { - expected_function_name = 'get getter2'; - expected_source_line_text = ' return { // getter 2'; - for (var i = 2; i != 1; i--); - debugger; - var t = d.c.getter2.name; -} - - -function testGetterY_1() { - expected_function_name = 'getterY'; - expected_source_line_text = ' return this.name; // getter y'; - debugger; - var t = d.c.y; -} - -function testIndexedGetter3_1() { - expected_function_name = 'getter3'; - expected_source_line_text = ' return this.name; // getter 3'; - debugger; - var r = d.c[3]; -} - -function testSetterY_1() { - expected_function_name = 'setterY'; - expected_source_line_text = ' this.name = n; // setter y'; - debugger; - d.c.y = 'www'; -} - -function testIndexedSetter3_1() { - expected_function_name = 'setter3'; - expected_source_line_text = ' this.name = n; // setter 3'; - var i = 3 - debugger; - d.c[3] = 'www'; -} - -function testSetter1_1() { - expected_function_name = 'set setter1'; - expected_source_line_text = ' this.name = n; // setter 1'; - debugger; - d.c.setter1 = 'aa'; -} - -function testSetter1_2() { - expected_function_name = 'set setter1'; - expected_source_line_text = ' this.name = n; // setter 1'; - debugger; - d.c['setter1'] = 'bb'; -} - -function testSetter1_3() { - expected_function_name = 'set setter1'; - expected_source_line_text = ' this.name = n; // setter 1'; - for (var i = 2; i != 1; i--); - debugger; - d.c['setter' + i] = i; -} - -var e = { - name: 'e' -}; -e.__proto__ = c; - -function testProtoGetter1_1() { - expected_function_name = 'get getter1'; - expected_source_line_text = ' return this.name; // getter 1'; - debugger; - var x = e.getter1; -} - -function testProtoSetter1_1() { - expected_function_name = 'set setter1'; - expected_source_line_text = ' this.name = n; // setter 1'; - debugger; - e.setter1 = 'aa'; -} - -function testProtoIndexedGetter3_1() { - expected_function_name = 'getter3'; - expected_source_line_text = ' return this.name; // getter 3'; - debugger; - var x = e[3]; -} - -function testProtoIndexedSetter3_1() { - expected_function_name = 'setter3'; - expected_source_line_text = ' this.name = n; // setter 3'; - debugger; - e[3] = 'new val'; -} - -function testProtoSetter1_2() { - expected_function_name = 'set setter1'; - expected_source_line_text = ' this.name = n; // setter 1'; - for (var i = 2; i != 1; i--); - debugger; - e['setter' + i] = 'aa'; -} - -for (var n in this) { - if (n.substr(0, 4) != 'test') { - continue; - } - state = 1; - this[n](); - if (exception) throw exception; - assertEquals(4, state); -} - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-builtin-callback-opt.js b/deps/v8/test/mjsunit/debug-stepin-builtin-callback-opt.js deleted file mode 100644 index 7e281ab220..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-builtin-callback-opt.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue( - event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - } -}; - -function replaceCallback(a) { - return "x"; // Break 2. -} // Break 3. - -var re = /x/g; -// Optimize the inner helper function for string replace. -for (var i = 0; i < 10000; i++) "x".replace(re, replaceCallback); - -Debug.setListener(listener); -debugger; // Break 0. -var result = "x".replace(re, replaceCallback); // Break 1. -Debug.setListener(null); // Break 4. - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-stepin-builtin-callback.js b/deps/v8/test/mjsunit/debug-stepin-builtin-callback.js deleted file mode 100644 index 4fde6e440f..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-builtin-callback.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug - -// Test stepping into callbacks passed to builtin functions. - -Debug = debug.Debug - -var exception = null; - -function array_listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - print(event_data.sourceLineText(), breaks); - assertTrue(event_data.sourceLineText().indexOf(`B${breaks++}`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } catch (e) { - print(e); - quit(); - exception = e; - } -}; - -function cb_false(num) { - print("element " + num); // B2 B5 B8 - return false; // B3 B6 B9 -} // B4 B7 B10 - -function cb_true(num) { - print("element " + num); // B2 B5 B8 - return true; // B3 B6 B9 -} // B4 B7 B10 - -function cb_reduce(a, b) { - print("elements " + a + " and " + b); // B2 B5 - return a + b; // B3 B6 -} // B4 B7 - -var a = [1, 2, 3]; - -var breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.forEach(cb_true); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.some(cb_false); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.every(cb_true); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.map(cb_true); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.filter(cb_true); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.reduce(cb_reduce); // B1 -Debug.setListener(null); // B8 -assertNull(exception); -assertEquals(9, breaks); - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.reduceRight(cb_reduce); // B1 -Debug.setListener(null); // B8 -assertNull(exception); -assertEquals(9, breaks); - - -// Test two levels of builtin callbacks: -// Array.forEach calls a callback function, which by itself uses -// Array.forEach with another callback function. - -function cb_true_2(num) { - print("element " + num); // B3 B6 B9 B15 B18 B21 B27 B30 B33 - return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34 -} // B5 B8 B11 B17 B20 B23 B29 B32 B35 - -function cb_foreach(num) { - a.forEach(cb_true_2); // B2 B14 B20 B26 - print("back."); // B12 B18 B24 B36 -} // B13 B19 B25 B37 - -breaks = 0; -Debug.setListener(array_listener); -debugger; // B0 -a.forEach(cb_foreach); // B1 -Debug.setListener(null); // B38 -assertNull(exception); -assertEquals(39, breaks); diff --git a/deps/v8/test/mjsunit/debug-stepin-builtin.js b/deps/v8/test/mjsunit/debug-stepin-builtin.js deleted file mode 100644 index f61098045c..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-builtin.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2009 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: --expose-debug-as debug - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 1; -var expected_source_line_text = null; -var expected_function_name = null; - -// Simple debug event handler which first time will cause 'step in' action -// and than check that execution is paused inside function -// expected_function_name. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state == 3) { - assertEquals(expected_function_name, event_data.func().name()); - assertEquals(expected_source_line_text, - event_data.sourceLineText()); - state = 4; - } else { - exec_state.prepareStep(Debug.StepAction.StepIn); - state++; - } - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -var a = [1,2,3,4,5]; - -// Test step into function call from a function without local variables. -function testStepInArraySlice() { - expected_function_name = 'testStepInArraySlice'; - expected_source_line_text = '} // expected line'; - debugger; - var s = Array.prototype.slice.call(a, 2,3); -} // expected line - -state = 1; -testStepInArraySlice(); -assertNull(exception); -assertEquals(4, state); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-call-function-stub.js b/deps/v8/test/mjsunit/debug-stepin-call-function-stub.js deleted file mode 100644 index b3e385bfb5..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-call-function-stub.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2009 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 0; -var expected_function_name = null; -var expected_source_line_text = null; -var expected_caller_source_line = null; -var step_in_count = 2; - -// Simple debug event handler which first time will cause 'step in' action -// to get into g.call and than check that execution is pauesed inside -// function 'g'. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state < step_in_count) { - // Step into f(). - exec_state.prepareStep(Debug.StepAction.StepIn); - state++; - } else { - assertEquals(expected_source_line_text, - event_data.sourceLineText()); - assertEquals(expected_function_name, event_data.func().name()); - state = 3; - } - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - - -function g() { - return "s"; // expected line -} - -function testFunction() { - var f = g; - var s = 1 +f(10); -} - -function g2() { - return "s2"; // expected line -} - -function testFunction2() { - var f = g2; - var s = 1 +f(10, 20); -} - -// Run three times. First time the function will be compiled lazily, -// second time cached version will be used. -for (var i = 0; i < 3; i++) { - state = 0; - expected_function_name = 'g'; - expected_source_line_text = ' return "s"; // expected line'; - step_in_count = 2; - // Set a break point and call to invoke the debug event listener. - Debug.setBreakPoint(testFunction, 1, 0); - testFunction(); - assertNull(exception); - assertEquals(3, state); -} - -// Test stepping into function call when a breakpoint is set at the place -// of call. Use different pair of functions so that g2 is compiled lazily. -// Run twice: first time function will be compiled lazily, second time -// cached version will be used. -for (var i = 0; i < 3; i++) { - state = 0; - expected_function_name = 'g2'; - expected_source_line_text = ' return "s2"; // expected line'; - step_in_count = 1; - // Set a break point and call to invoke the debug event listener. - Debug.setBreakPoint(testFunction2, 2, 0); - testFunction2(); - assertNull(exception); - assertEquals(3, state); -} - - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-construct-call.js b/deps/v8/test/mjsunit/debug-stepin-construct-call.js deleted file mode 100644 index 7dbf7b1d28..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-construct-call.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var source_line = exec_state.frame(0).sourceLineText(); - print(source_line); - exec_state.prepareStep(Debug.StepAction.StepIn); - break_count++; - } catch (e) { - exception = e; - } -} - -var Debug = debug.Debug; -Debug.setListener(listener); - - -function f() { - this.x = 1; -} - -function g() { - new f(); -} - -Debug.setBreakPoint(g, 6, Debug.BreakPositionAlignment.BreakPosition); -print(Debug.showBreakPoints(g, undefined, - Debug.BreakPositionAlignment.BreakPosition)); - -g(); -Debug.setListener(null); - -assertEquals(6, break_count); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/debug-stepin-constructor.js b/deps/v8/test/mjsunit/debug-stepin-constructor.js deleted file mode 100644 index 5549814a65..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-constructor.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple debug event handler which counts the number of breaks hit and steps. -var break_break_point_hit_count = 0; -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - break_break_point_hit_count++; - // Continue stepping until returned to bottom frame. - if (exec_state.frameCount() > 1) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - - // Test that there is a script. - assertTrue(typeof(event_data.func().script()) == 'object'); - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Test step into constructor with simple constructor. -function X() { -} - -function f() { - debugger; - new X(); -}; - -break_break_point_hit_count = 0; -f(); -assertEquals(5, break_break_point_hit_count); -f(); -assertEquals(10, break_break_point_hit_count); -f(); -assertEquals(15, break_break_point_hit_count); - -// Test step into constructor with builtin constructor. -function g() { - debugger; - new Date(); -}; - -break_break_point_hit_count = 0; -g(); -assertEquals(4, break_break_point_hit_count); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-foreach.js b/deps/v8/test/mjsunit/debug-stepin-foreach.js deleted file mode 100644 index 69ce3efab7..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-foreach.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug -// Tests stepping into through Array.prototype.forEach callbacks. - -Debug = debug.Debug -var exception = null; -var break_count = 0; -var expected_breaks = -1; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); - if (!break_count) { - // Count number of expected breakpoints in this source file. - var source_text = exec_state.frame(0).func().script().source(); - expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; - print("Expected breaks: " + expected_breaks); - } - var source = exec_state.frame(0).sourceLineText(); - print("paused at: " + source); - assertTrue(source.indexOf("// Break " + break_count + ".") > 0, - "Unexpected pause at: " + source + "\n" + - "Expected: // Break " + break_count + "."); - ++break_count; - if (break_count !== expected_breaks) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } - } catch(e) { - exception = e; - print(e, e.stack); - } -}; - -Debug.setListener(listener); -var bound_callback = callback.bind(null); - -debugger; // Break 0. -[1,2].forEach(callback); // Break 1. -[3,4].forEach(bound_callback); // Break 6. - -function callback(x) { - return x; // Break 2. // Break 4. // Break 7. // Break 9. -} // Break 3. // Break 5. // Break 8. // Break 10. - -assertNull(exception); // Break 11. -assertEquals(expected_breaks, break_count); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-function-call.js b/deps/v8/test/mjsunit/debug-stepin-function-call.js deleted file mode 100644 index 8af7aad19d..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-function-call.js +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 0; - -// Simple debug event handler which first time will cause 'step in' action -// to get into g.call and than check that execution is pauesed inside -// function 'g'. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state < 2) { - // Step into f2.call: - exec_state.prepareStep(Debug.StepAction.StepIn); - state++; - } else { - assertEquals('g', event_data.func().name()); - assertEquals(' return t + 1; // expected line', - event_data.sourceLineText()); - state = 3; - } - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - - -// Sample functions. -function g(t) { - return t + 1; // expected line -} - -// Test step into function call from a function without local variables. -function call1() { - debugger; - g.call(null, 3); -} - - -// Test step into function call from a function with some local variables. -function call2() { - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; - debugger; - g.call(null, 3); -} - -// Test step into function call which is a part of an expression. -function call3() { - var alias = g; - debugger; - var r = 10 + alias.call(null, 3); - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; -} - -// Test step into function call from a function with some local variables. -function call4() { - var alias = g; - debugger; - alias.call(null, 3); - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; -} - -// Test step into function apply from a function without local variables. -function apply1() { - debugger; - g.apply(null, [3]); -} - - -// Test step into function apply from a function with some local variables. -function apply2() { - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; - debugger; - g.apply(null, [3, 4]); -} - -// Test step into function apply which is a part of an expression. -function apply3() { - var alias = g; - debugger; - var r = 10 + alias.apply(null, [3, 'unused arg']); - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; -} - -// Test step into function apply from a function with some local variables. -function apply4() { - var alias = g; - debugger; - alias.apply(null, [3]); - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; -} - -// Test step into bound function. -function bind1() { - var bound = g.bind(null, 3); - debugger; - bound(); -} - -// Test step into apply of bound function. -function applyAndBind1() { - var bound = g.bind(null, 3); - debugger; - bound.apply(null, [3]); - var aLocalVar = 'test'; - var anotherLocalVar = g(aLocalVar) + 's'; - var yetAnotherLocal = 10; -} - -var testFunctions = - [call1, call2, call3, call4, apply1, apply2, apply3, apply4, bind1, - applyAndBind1]; - -for (var i = 0; i < testFunctions.length; i++) { - state = 0; - testFunctions[i](); - assertNull(exception); - assertEquals(3, state); -} - -// Test global bound function. -state = 0; -var globalBound = g.bind(null, 3); -debugger; -globalBound(); -assertNull(exception); -assertEquals(3, state); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepin-property-function-call.js b/deps/v8/test/mjsunit/debug-stepin-property-function-call.js deleted file mode 100644 index dff83c7e14..0000000000 --- a/deps/v8/test/mjsunit/debug-stepin-property-function-call.js +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2014 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: --expose-debug-as debug --nocrankshaft -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 1; - -// Simple debug event handler which first time will cause 'step in' action -// to get into g.call and than check that execution is stopped inside -// function 'g'. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state < 4) { - exec_state.prepareStep(Debug.StepAction.StepIn); - state++; - } else { - assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0, - "source line: \"" + event_data.sourceLineText() + "\""); - state = 5; - } - } - } catch(e) { - print("Exception: " + e); - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -var count = 0; -var obj = { - fun: function() { - ++count; - return count; // Expected to step - } -}; -obj.fun2 = obj.fun; - -function testCall_Dots() { - debugger; - obj.fun(); -} - -function testCall_Quotes() { - debugger; - obj["fun"](); -} - -function testCall_Call() { - debugger; - obj.fun.call(obj); -} - -function testCall_Apply() { - debugger; - obj.fun.apply(obj); -} - -function testCall_Variable() { - var functionName = "fun"; - debugger; - obj[functionName](); -} - -function testCall_Fun2() { - debugger; - obj.fun2(); -} - -function testCall_InternStrings() { - var cache = { "fun": "fun" }; - var functionName = "fu" + "n"; - debugger; - obj[cache[functionName]](); -} - -function testCall_ViaFunRef() { - var functionName = "fu" + "n"; - var funRef = obj[functionName]; - debugger; - funRef(); -} - -// bug 2888 -function testCall_RuntimeVariable1() { - var functionName = "fu" + "n"; - debugger; - obj[functionName](); -} - -// bug 2888 -function testCall_RuntimeVariable2() { - var functionName = "un".replace(/u/, "fu"); - debugger; - obj[functionName](); -} - -// bug 2888 -function testCall_RuntimeVariable3() { - var expr = "fu" + "n"; - const functionName = expr; - assertEquals("fun", functionName); - debugger; - obj[functionName](); -} - -var functionsCalled = 0; -for (var n in this) { - if (n.substr(0, 4) != 'test' || typeof this[n] !== "function") { - continue; - } - state = 1; - print("Running " + n + "..."); - this[n](); - ++functionsCalled; - assertNull(exception, n); - assertEquals(5, state, n); - assertEquals(functionsCalled, count, n); -} - -assertEquals(11, functionsCalled); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepnext-do-while.js b/deps/v8/test/mjsunit/debug-stepnext-do-while.js deleted file mode 100644 index bbb18bc436..0000000000 --- a/deps/v8/test/mjsunit/debug-stepnext-do-while.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2009 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var break_break_point_hit_count = 0; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (break_break_point_hit_count == 0) { - assertEquals(' debugger;', - event_data.sourceLineText()); - assertEquals('runDoWhile', event_data.func().name()); - } else if (break_break_point_hit_count == 1) { - assertEquals(' } while(condition());', - event_data.sourceLineText()); - assertEquals('runDoWhile', event_data.func().name()); - } - - break_break_point_hit_count++; - // Continue stepping until returned to bottom frame. - if (exec_state.frameCount() > 1) { - exec_state.prepareStep(Debug.StepAction.StepNext); - } - - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function condition() { - return false; -} - -function runDoWhile() { - do { - debugger; - } while(condition()); -}; - -break_break_point_hit_count = 0; -runDoWhile(); -assertNull(exception); -assertEquals(4, break_break_point_hit_count); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepout-recursive-function.js b/deps/v8/test/mjsunit/debug-stepout-recursive-function.js deleted file mode 100644 index 9082294b78..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-recursive-function.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2009 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; - -// Simple debug event handler which counts the number of breaks hit and steps. -var break_point_hit_count = 0; -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - break_point_hit_count++; - // Continue stepping until returned to bottom frame. - if (exec_state.frameCount() > 1) { - exec_state.prepareStep(Debug.StepAction.StepOut); - } - - } - } catch(e) { - exception = e; - } - -}; - -function BeginTest(name) { - test_name = name; - break_point_hit_count = 0; - exception = null; -} - -function EndTest(expected_break_point_hit_count) { - assertEquals(expected_break_point_hit_count, break_point_hit_count, test_name); - assertNull(exception, test_name); - test_name = null; -} - -// Add the debug event listener. -Debug.setListener(listener); - - -var shouldBreak = null; -function fact(x) { - if (shouldBreak(x)) { - debugger; - } - if (x < 2) { - return 1; - } else { - return x*fact(x-1); - } -} - -BeginTest('Test 1'); -shouldBreak = function(x) { return x == 3; }; -fact(3); -EndTest(2); - -BeginTest('Test 2'); -shouldBreak = function(x) { return x == 2; }; -fact(3); -EndTest(3); - -BeginTest('Test 3'); -shouldBreak = function(x) { return x == 1; }; -fact(3); -EndTest(4); - -BeginTest('Test 4'); -shouldBreak = function(x) { return x == 1 || x == 3; }; -fact(3); -EndTest(5); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part1.js b/deps/v8/test/mjsunit/debug-stepout-scope-part1.js deleted file mode 100644 index 27a91d4d02..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part1.js +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - - -function test1() { - debugger; - with ({x:1}) { - x = 2; - } -} -test1(); - - -function test2() { - if (true) { - with ({}) { - debugger; - } - } else { - with ({}) { - return 10; - } - } -} -test2(); - - -function test3() { - if (true) { - debugger; - } else { - with ({}) { - return 10; - } - } -} -test3(); - - -function test4() { - debugger; - with ({x:1}) x = 1 -} -test4(); - - -function test5() { - debugger; - var dummy = 1; - with ({}) { - with ({}) { - dummy = 2; - } - } - dummy = 3; -} -test5(); - - -function test6() { - debugger; - try { - throw 'stuff'; - } catch (e) { - e = 1; - } -} -test6(); - - -function test7() { - debugger; - function foo() {} -} -test7(); - - -function test8() { - debugger; - (function foo() {})(); -} -test8(); - - -function test10() { - debugger; - with ({}) { - return 10; - } -} -test10(); - - -function test11() { - debugger; - try { - throw 'stuff'; - } catch (e) { - return 10; - } -} -test11(); - - -var prefixes = [ - "debugger; ", - "if (false) { try { throw 0; } catch(x) { return x; } }; debugger; " ]; - - -// Return from function constructed with Function constructor. -var anon = 12; -for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - Function(pre + "return 42")(); - Function(pre + "return 42 ")(); - Function(pre + "return 42;")(); - Function(pre + "return 42; ")(); - Function(pre + "return anon")(); - Function(pre + "return anon ")(); - Function(pre + "return anon;")(); - Function(pre + "return anon; ")(); -} - - -try { - with({}) { - debugger; - eval("{}$%:^"); - } -} catch(e) { - nop(); -} - - -function nop() {} - - -// With block as the last(!) statement in global code. -with ({}) { debugger; } diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part2.js b/deps/v8/test/mjsunit/debug-stepout-scope-part2.js deleted file mode 100644 index 5b0b17b9e4..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part2.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ "debugger; ", - "if (false) { try { throw 0; } catch(x) { this.x = x; } }; debugger; " ]; -var bodies = [ "1", - "1 ", - "1;", - "1; ", - "q", - "q ", - "q;", - "q; ", - "try { throw 'stuff' } catch (e) { e = 1; }", - "try { throw 'stuff' } catch (e) { e = 1; } ", - "try { throw 'stuff' } catch (e) { e = 1; };", - "try { throw 'stuff' } catch (e) { e = 1; }; " ]; - - -function test9() { - debugger; - for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < bodies.length; ++j) { - var body = bodies[j]; - eval(pre + body); - eval("'use strict'; " + pre + body); - } - } -} -test9(); diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part3.js b/deps/v8/test/mjsunit/debug-stepout-scope-part3.js deleted file mode 100644 index 2584914681..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part3.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ - "debugger; ", - "if (false) { try { throw 0; } catch(x) { this.x = x; } }; debugger; " ]; -var with_bodies = [ "with ({}) {}", - "with ({x:1}) x", - "with ({x:1}) x = 1", - "with ({x:1}) x ", - "with ({x:1}) x = 1 ", - "with ({x:1}) x;", - "with ({x:1}) x = 1;", - "with ({x:1}) x; ", - "with ({x:1}) x = 1; " ]; - - -function test9() { - debugger; - for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < with_bodies.length; ++j) { - var body = with_bodies[j]; - eval(pre + body); - } - } -} -test9(); diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part4.js b/deps/v8/test/mjsunit/debug-stepout-scope-part4.js deleted file mode 100644 index 765bfe246b..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part4.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ - "debugger; ", - "if (false) { try { throw 0; } catch(x) { this.x = x; } }; debugger; " ]; -var bodies = [ "1", - "1 ", - "1;", - "1; ", - "q", - "q ", - "q;", - "q; ", - "try { throw 'stuff' } catch (e) { e = 1; }", - "try { throw 'stuff' } catch (e) { e = 1; } ", - "try { throw 'stuff' } catch (e) { e = 1; };", - "try { throw 'stuff' } catch (e) { e = 1; }; " ]; - - -// Test global eval and function constructor. -for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < bodies.length; ++j) { - var body = bodies[j]; - eval(pre + body); - } -} diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part5.js b/deps/v8/test/mjsunit/debug-stepout-scope-part5.js deleted file mode 100644 index e819e293ce..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part5.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ "debugger; ", - "if (false) { try { throw 0; } catch(x) { this.x = x; } }; debugger; " ]; -var with_bodies = [ "with ({}) {}", - "with ({x:1}) x", - "with ({x:1}) x = 1", - "with ({x:1}) x ", - "with ({x:1}) x = 1 ", - "with ({x:1}) x;", - "with ({x:1}) x = 1;", - "with ({x:1}) x; ", - "with ({x:1}) x = 1; " ]; - - -// Test global eval and function constructor. -for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < with_bodies.length; ++j) { - var body = with_bodies[j]; - eval(pre + body); - Function(pre + body)(); - } -} diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part6.js b/deps/v8/test/mjsunit/debug-stepout-scope-part6.js deleted file mode 100644 index fb009e6f7f..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part6.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ "debugger; ", - "if (false) { try { throw 0; } catch(x) { this.x = x; } }; debugger; " ]; -var bodies = [ "1", - "1 ", - "1;", - "1; ", - "q", - "q ", - "q;", - "q; ", - "try { throw 'stuff' } catch (e) { e = 1; }", - "try { throw 'stuff' } catch (e) { e = 1; } ", - "try { throw 'stuff' } catch (e) { e = 1; };", - "try { throw 'stuff' } catch (e) { e = 1; }; " ]; - - -// Test global eval and function constructor. -for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < bodies.length; ++j) { - var body = bodies[j]; - eval("'use strict'; " + pre + body); - } -} diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part7.js b/deps/v8/test/mjsunit/debug-stepout-scope-part7.js deleted file mode 100644 index 969fb7f9ed..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part7.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -var q = 42; -var prefixes = [ "debugger; ", - "if (false) { try { throw 0; } catch(x) { return x; } }; debugger; " ]; -var bodies = [ "1", - "1 ", - "1;", - "1; ", - "q", - "q ", - "q;", - "q; ", - "try { throw 'stuff' } catch (e) { e = 1; }", - "try { throw 'stuff' } catch (e) { e = 1; } ", - "try { throw 'stuff' } catch (e) { e = 1; };", - "try { throw 'stuff' } catch (e) { e = 1; }; " ]; - - -// Test global eval and function constructor. -for (var i = 0; i < prefixes.length; ++i) { - var pre = prefixes[i]; - for (var j = 0; j < bodies.length; ++j) { - var body = bodies[j]; - Function(pre + body)(); - } -} diff --git a/deps/v8/test/mjsunit/debug-stepout-scope-part8.js b/deps/v8/test/mjsunit/debug-stepout-scope-part8.js deleted file mode 100644 index 790caca7c3..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-scope-part8.js +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Check that the ScopeIterator can properly recreate the scope at -// every point when stepping through functions. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details. - var scope_count = exec_state.frame().scopeCount(); - for (var i = 0; i < scope_count; i++) { - var scope = exec_state.frame().scope(i); - // assertTrue(scope.isScope()); - scope.scopeType(); - scope.scopeObject(); - } - - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - - -function nop() {} - - -function stress() { - debugger; - - L: with ({x:12}) { - break L; - } - - - with ({x: 'outer'}) { - label: { - with ({x: 'inner'}) { - break label; - } - } - } - - - with ({x: 'outer'}) { - label: { - with ({x: 'inner'}) { - break label; - } - } - nop(); - } - - - with ({x: 'outer'}) { - label: { - with ({x: 'middle'}) { - with ({x: 'inner'}) { - break label; - } - } - } - } - - - with ({x: 'outer'}) { - label: { - with ({x: 'middle'}) { - with ({x: 'inner'}) { - break label; - } - } - } - nop(); - } - - - with ({x: 'outer'}) { - for (var i = 0; i < 3; ++i) { - with ({x: 'inner' + i}) { - continue; - } - } - } - - - with ({x: 'outer'}) { - label: for (var i = 0; i < 3; ++i) { - with ({x: 'middle' + i}) { - for (var j = 0; j < 3; ++j) { - with ({x: 'inner' + j}) { - continue label; - } - } - } - } - } - - - with ({x: 'outer'}) { - try { - with ({x: 'inner'}) { - throw 0; - } - } catch (e) { - } - } - - - with ({x: 'outer'}) { - try { - with ({x: 'inner'}) { - throw 0; - } - } catch (e) { - nop(); - } - } - - - with ({x: 'outer'}) { - try { - with ({x: 'middle'}) { - with ({x: 'inner'}) { - throw 0; - } - } - } catch (e) { - } - } - - - try { - with ({x: 'outer'}) { - try { - with ({x: 'inner'}) { - throw 0; - } - } finally { - } - } - } catch (e) { - } - - - try { - with ({x: 'outer'}) { - try { - with ({x: 'inner'}) { - throw 0; - } - } finally { - nop(); - } - } - } catch (e) { - } - - - function stress1() { - with ({x:12}) { - return x; - } - } - stress1(); - - - function stress2() { - with ({x: 'outer'}) { - with ({x: 'inner'}) { - return x; - } - } - } - stress2(); - - function stress3() { - try { - with ({x: 'inner'}) { - throw 0; - } - } catch (e) { - return e; - } - } - stress3(); - - - function stress4() { - try { - with ({x: 'inner'}) { - throw 0; - } - } catch (e) { - with ({x: 'inner'}) { - return e; - } - } - } - stress4(); - -} -stress(); diff --git a/deps/v8/test/mjsunit/debug-stepout-to-builtin.js b/deps/v8/test/mjsunit/debug-stepout-to-builtin.js deleted file mode 100644 index 2e5e7a25f8..0000000000 --- a/deps/v8/test/mjsunit/debug-stepout-to-builtin.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2009 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: --expose-debug-as debug - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -var exception = null; -var state = 1; -var expected_source_line_text = null; -var expected_function_name = null; - -// Simple debug event handler which first time will cause 'step out' action -// and than check that execution is paused inside function -// expected_function_name. -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - if (state == 1) { - exec_state.prepareStep(Debug.StepAction.StepOut); - state++; - } else { - assertEquals(expected_function_name, event_data.func().name()); - assertEquals(expected_source_line_text, - event_data.sourceLineText()); - state = 3; - } - } - } catch(e) { - exception = e; - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -var obj = {key:10}; - -function replacer(key, value) { - if (key == 'key') { - debugger; - } - return value; -} - -// Test step into function call from a function without local variables. -function testStepOutToBuiltIn() { - expected_function_name = 'testStepOutToBuiltIn'; - expected_source_line_text = '} // expected line'; - JSON.stringify(obj, replacer); -} // expected line - -state = 1; -testStepOutToBuiltIn(); -assertNull(exception); -assertEquals(3, state); - -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/debug-version.js b/deps/v8/test/mjsunit/debug-version.js deleted file mode 100644 index b1bc1e8d82..0000000000 --- a/deps/v8/test/mjsunit/debug-version.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -// Simple function which stores the last debug event. -listenerComplete = false; -exception = false; - -var base_version_request = '"seq":0,"type":"request","command":"version"' - -function safeEval(code) { - try { - return eval('(' + code + ')'); - } catch (e) { - assertEquals(void 0, e); - return undefined; - } -} - -function testArguments(exec_state) { - // Get the debug command processor in running state. - var dcp = exec_state.debugCommandProcessor(true); - - assertTrue(dcp.isRunning()); - - var version_request = '{' + base_version_request + '}' - var version_response = safeEval(dcp.processDebugJSONRequest(version_request)); - - assertTrue(version_response.success); - - var version_string = version_response.body.V8Version; - - assertTrue(!!version_string, version_request + ' -> expected version string'); - - var version_pattern = /^\d*\.\d*\.\d*/; - - assertTrue(!!(version_string.match(version_pattern)), "unexpected format of version: " + version_string); -} - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - - // Test simple suspend request. - testArguments(exec_state); - - // Indicate that all was processed. - listenerComplete = true; - } - } catch (e) { - exception = e - }; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Stop debugger and check that suspend command changes running flag. -debugger; - -assertFalse(exception, "exception in listener") -// Make sure that the debug event listener vas invoked. -assertTrue(listenerComplete, "listener did not run to completion"); diff --git a/deps/v8/test/mjsunit/es6/array-iterator-turbo.js b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js new file mode 100644 index 0000000000..c1b8d32072 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/array-iterator-turbo.js @@ -0,0 +1,243 @@ +// 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: --turbo --turbo-escape --allow-natives-syntax + +"use strict"; + +const kDeoptimized = 2; +const kTurbofanned = 7; +const kInterpreted = 8; + +function GetOptimizationStatus(fn) { + let status = %GetOptimizationStatus(fn); + switch (status) { + case kInterpreted: // Treat interpreted frames as unoptimized + status = kDeoptimized; + break; + } + + return status; +} + +let global = this; +let tests = { + FastElementsKind() { + let runners = { + FAST_SMI_ELEMENTS(array) { + let sum = 0; + for (let x of array) sum += x; + return sum; + }, + + FAST_HOLEY_SMI_ELEMENTS(array) { + let sum = 0; + for (let x of array) { + if (x) sum += x; + } + return sum; + }, + + FAST_ELEMENTS(array) { + let ret = ""; + for (let str of array) ret += `> ${str}`; + return ret; + }, + + FAST_HOLEY_ELEMENTS(array) { + let ret = ""; + for (let str of array) ret += `> ${str}`; + return ret; + }, + + FAST_DOUBLE_ELEMENTS(array) { + let sum = 0.0; + for (let x of array) sum += x; + return sum; + }, + + FAST_HOLEY_DOUBLE_ELEMENTS(array) { + let sum = 0.0; + for (let x of array) { + if (x) sum += x; + } + return sum; + } + }; + + let tests = { + FAST_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: { + array: [1, , 3, , 5, , 7, , 9, ,], + expected: 25, + array2: [1, , 3], + expected2: 4 + }, + FAST_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: { + 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: { + 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], + expected2: 1.2 + }, + FAST_HOLEY_DOUBLE_ELEMENTS: { + array: [0.1, , 0.3, , 0.5, , 0.7, , 0.9, ,], + expected: 2.5, + array2: [0.1, , 0.3], + expected2: 0.4 + } + }; + + for (let key of Object.keys(runners)) { + let fn = runners[key]; + let { array, expected, array2, expected2 } = tests[key]; + + // Warmup: + fn(array); + fn(array); + %OptimizeFunctionOnNextCall(fn); + fn(array); + + // TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when + // a hole is encountered. Test should be fixed once that is corrected. + let status = /HOLEY_DOUBLE/.test(key) ? kDeoptimized : kTurbofanned; + + assertEquals(status, GetOptimizationStatus(fn), key); + assertEquals(expected, fn(array), key); + assertEquals(status, GetOptimizationStatus(fn), key); + + // Check no deopt when another arra with the same map is used + assertTrue(%HaveSameMap(array, array2), key); + assertEquals(status, GetOptimizationStatus(fn), key); + assertEquals(expected2, fn(array2), key); + + // CheckMaps bailout + let newArray = Object.defineProperty( + [1, 2, 3], 2, { enumerable: false, configurable: false, + get() { return 7; } }); + fn(newArray); + assertEquals(kDeoptimized, GetOptimizationStatus(fn), key); + } + }, + + TypedArrays() { + let tests = { + Uint8Array: { + array: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, -1, 256]), + expected: 291, + array2: new Uint8Array([1, 2, 3]), + expected2: 6 + }, + + Int8Array: { + array: new Int8Array([1, 2, 3, 4, 5, 6, 7, 8, -129, 128]), + expected: 35, + array2: new Int8Array([1, 2, 3]), + expected2: 6 + }, + + Uint16Array: { + array: new Uint16Array([1, 2, 3, 4, 5, 6, 7, 8, -1, 0x10000]), + expected: 65571, + array2: new Uint16Array([1, 2, 3]), + expected2: 6 + }, + + Int16Array: { + array: new Int16Array([1, 2, 3, 4, 5, 6, 7, 8, -32769, 0x7FFF]), + expected: 65570, + array2: new Int16Array([1, 2, 3]), + expected2: 6 + }, + + Uint32Array: { + array: new Uint32Array([1, 2, 3, 4, 5, 6, 7, 8, -1, 0x100000000]), + expected: 4294967331, + array2: new Uint32Array([1, 2, 3]), + expected2: 6 + }, + + Int32Array: { + array: new Int32Array([1, 2, 3, 4, 5, 6, 7, 8, + -2147483649, 0x7FFFFFFF]), + expected: 4294967330, + array2: new Int32Array([1, 2, 3]), + expected2: 6 + }, + + Float32Array: { + array: new Float32Array([9.5, 8.0, 7.0, 7.0, 5.0, 4.0, 3.0, 2.0]), + expected: 45.5, + array2: new Float32Array([10.5, 5.5, 1.5]), + expected2: 17.5 + }, + + Float64Array: { + array: new Float64Array([9.5, 8.0, 7.0, 7.0, 5.0, 4.0, 3.0, 2.0]), + expected: 45.5, + array2: new Float64Array([10.5, 5.5, 1.5]), + expected2: 17.5 + }, + + Uint8ClampedArray: { + array: new Uint8ClampedArray([4.3, 7.45632, 3.14, 4.61, 5.0004, 6.493, + 7.12, 8, 1.7, 3.6]), + expected: 51, + array2: new Uint8ClampedArray([1, 2, 3]), + expected2: 6 + } + }; + + for (let key of Object.keys(tests)) { + let test = tests[key]; + let { array, expected, array2, expected2 } = test; + + let sum = function(array) { + let ret = 0; + for (let x of array) ret += x; + return ret; + }; + + // Warmup + sum(array); + sum(array); + %OptimizeFunctionOnNextCall(sum); + assertEquals(expected, sum(array), key); + + assertEquals(kTurbofanned, GetOptimizationStatus(sum), key); + + // Not deoptimized when called on typed array of same type / map + assertTrue(%HaveSameMap(array, array2)); + assertEquals(expected2, sum(array2), key); + assertEquals(kTurbofanned, GetOptimizationStatus(sum), key); + + // Throw when detached + let clone = new array.constructor(array); + %ArrayBufferNeuter(clone.buffer); + assertThrows(() => sum(clone), TypeError); + } + } +}; + +for (let name of Object.keys(tests)) { + let test = tests[name]; + test(); +} diff --git a/deps/v8/test/mjsunit/es6/classes-subclass-builtins.js b/deps/v8/test/mjsunit/es6/classes-subclass-builtins.js index dca514c294..23cb6c06df 100644 --- a/deps/v8/test/mjsunit/es6/classes-subclass-builtins.js +++ b/deps/v8/test/mjsunit/es6/classes-subclass-builtins.js @@ -920,7 +920,6 @@ function TestMapSetSubclassing(container, is_map) { assertEquals(["match", "tostring"], log); // TODO(littledan): Is the RegExp constructor correct to create // the internal slots and do these type checks this way? - assertEquals("biep", %_RegExpSource(o)); assertThrows(() => Object.getOwnPropertyDescriptor(RegExp.prototype, 'source').get(o), TypeError); diff --git a/deps/v8/test/mjsunit/es6/classes.js b/deps/v8/test/mjsunit/es6/classes.js index fb77dbb8e4..816d113263 100644 --- a/deps/v8/test/mjsunit/es6/classes.js +++ b/deps/v8/test/mjsunit/es6/classes.js @@ -164,14 +164,15 @@ SyntaxError); var D = class extends function() { - arguments.caller; + this.args = arguments; } {}; assertThrows(function() { Object.getPrototypeOf(D).arguments; }, TypeError); - assertThrows(function() { - new D; - }, TypeError); + var e = new D(); + assertThrows(() => e.args.callee, TypeError); + assertEquals(undefined, Object.getOwnPropertyDescriptor(e.args, 'caller')); + assertFalse('caller' in e.args); })(); diff --git a/deps/v8/test/mjsunit/es6/completion.js b/deps/v8/test/mjsunit/es6/completion.js index 988e9709bb..6bc7d47a02 100644 --- a/deps/v8/test/mjsunit/es6/completion.js +++ b/deps/v8/test/mjsunit/es6/completion.js @@ -146,3 +146,10 @@ assertUndef(eval( assertUndef(eval("1; try{2; throwOnReturn();} catch(e){}")); assertUndef(eval("1; twoFunc();")); assertEquals(2, eval("1; with ( { a: 0 } ) { 2; }")); + +assertUndef(eval('a: while(true) { do { 0 } while(false); switch(1) { case 0: 1; case 1: break a; }; 0 }')); +assertUndef(eval('a: while(true) { do { 0 } while(false); try {} finally { break a }; 0 }')); +assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; switch(1) { case 1: break a; }; 2 }')); +assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; while (true) { break a; }; 2 }')); +assertUndef(eval('while (true) { 20; a:{ break a; } with ({}) break; 30; }')); +assertEquals(42, eval('a: while(true) { switch(0) { case 0: 42; case 1: break a; }; 33 }')); diff --git a/deps/v8/test/mjsunit/es6/debug-break-default-constructor.js b/deps/v8/test/mjsunit/es6/debug-break-default-constructor.js deleted file mode 100644 index fc8bebd13d..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-break-default-constructor.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -"use strict"; - -var Debug = debug.Debug; -var exception = null; -var super_called = false; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - execState.prepareStep(Debug.StepAction.StepIn); - var s = execState.frame().sourceLineText(); - step_count++; - assertTrue(s.indexOf('// ' + step_count + '.') >= 0); - } catch (e) { - exception = e; - } -} - -class Base { - constructor() { - var x = 1; // 2. - } // 3. -} - -class Derived extends Base {} // 1. // 4. - -Debug.setListener(listener); -var bp = Debug.setBreakPoint(Derived, 0); - -new Derived(); - -Debug.setListener(null); // 5. - -assertNull(exception); -assertEquals(5, step_count); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/async-task-event.js b/deps/v8/test/mjsunit/es6/debug-promises/async-task-event.js deleted file mode 100644 index 0b0fa1e64f..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/async-task-event.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug; - -var base_id = -1; -var exception = null; -var expected = [ - "enqueue #1", - "willHandle #1", - "then #1", - "enqueue #2", - "didHandle #1", - "willHandle #2", - "then #2", - "didHandle #2", - "enqueue #3", - "willHandle #3", - "didHandle #3" -]; - -function assertLog(msg) { - print(msg); - assertTrue(expected.length > 0); - assertEquals(expected.shift(), msg); - if (!expected.length) { - Debug.setListener(null); - } -} - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.AsyncTaskEvent) return; - try { - if (base_id < 0) - base_id = event_data.id(); - var id = event_data.id() - base_id + 1; - assertEquals("Promise.resolve", event_data.name()); - assertLog(event_data.type() + " #" + id); - } catch (e) { - print(e + e.stack) - exception = e; - } -} - -Debug.setListener(listener); - -var resolver; -var p = new Promise(function(resolve, reject) { - resolver = resolve; -}); -p.then(function() { - assertLog("then #1"); -}).then(function() { - assertLog("then #2"); -}); -resolver(); - -%RunMicrotasks(); - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js b/deps/v8/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js deleted file mode 100644 index 73718eec7b..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/evaluate-across-microtasks.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var listenerComplete = false; -var exception = null; -var count = 0; -var log = []; -var done = false; - -function LogX(x) { - var stored_count = count; - return function() { - log.push(`[${stored_count}] ${x}`); - }; -} - -function DebuggerStatement() { - log.push(`[${count}] debugger`); - if (count++ < 3) { - debugger; - } -} - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var p = Promise.resolve(); - var q = p.then(LogX("then 1")); - p.then(LogX("then 2")); - q.then(LogX("then 3")); - q.then(DebuggerStatement); - var r = q.then(() => { throw 1; }); - r.catch(LogX("catch")); - listenerComplete = true; - } catch (e) { - exception = e; - print(e, e.stack); - quit(1); - }; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -DebuggerStatement(); -LogX("start")(); - -// Make sure that the debug event listener was invoked. -assertTrue(listenerComplete); - -%RunMicrotasks(); - -var expectation = - [ "[0] debugger", "[1] start", "[1] then 1", - "[1] then 2", "[1] then 3", "[1] debugger", - "[2] then 1", "[2] then 2", "[1] catch", - "[2] then 3", "[2] debugger", "[3] then 1", - "[3] then 2", "[2] catch", "[3] then 3", - "[3] debugger", "[3] catch", - ]; - -assertEquals(expectation, log); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/promise-all-caught.js b/deps/v8/test/mjsunit/es6/debug-promises/promise-all-caught.js deleted file mode 100644 index 2c940ce217..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/promise-all-caught.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions and a -// Promise p3 created by Promise.all has a catch handler, and is rejected -// because one of the Promises p2 passed to Promise.all is rejected. We -// expect no Exception debug event to be triggered, since p3 and by -// extension p2 have a catch handler. - -var Debug = debug.Debug; - -var expected_events = 2; - -var p1 = Promise.resolve(); -p1.name = "p1"; - -var p2 = p1.then(function() { - throw new Error("caught"); -}); - -p2.name = "p2"; - -var p3 = Promise.all([p2]); -p3.name = "p3"; - -p3.catch(function(e) {}); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception) - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/promise-race-caught.js b/deps/v8/test/mjsunit/es6/debug-promises/promise-race-caught.js deleted file mode 100644 index dd3ca83ee8..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/promise-race-caught.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions and a -// Promise p3 created by Promise.race has a catch handler, and is rejected -// because one of the Promises p2 passed to Promise.all is rejected. We -// expect no Exception debug event to be triggered, since p3 and by -// extension p2 have a catch handler. - -var Debug = debug.Debug; - -var expected_events = 2; - -var p1 = Promise.resolve(); -p1.name = "p1"; - -var p2 = p1.then(function() { - throw new Error("caught"); -}); - -p2.name = "p2"; - -var p3 = Promise.all([p2]); -p3.name = "p3"; - -p3.catch(function(e) {}); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception) - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reentry.js b/deps/v8/test/mjsunit/es6/debug-promises/reentry.js deleted file mode 100644 index cc98ed9efd..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/reentry.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -// Test reentry of special try catch for Promises. - -Debug = debug.Debug; - -Debug.setBreakOnUncaughtException(); -Debug.setListener(function(event, exec_state, event_data, data) { }); - -var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.then(function() { - new Promise(function(resolve, reject) { resolve(); }); -}); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-after-resolve.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-after-resolve.js deleted file mode 100644 index 5ec2da50e9..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-after-resolve.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we listen to uncaught exceptions and -// the Promise is rejected in a chained closure after it has been resolved. -// We expect no Exception debug event to be triggered. - -Debug = debug.Debug; - -var log = []; - -var p = new Promise(function(resolve, reject) { - log.push("resolve"); - resolve(reject); -}); - -var q = p.then( - function(value) { - assertEquals(["resolve", "end main"], log); - value(new Error("reject")); - }); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnException(); -Debug.setListener(listener); - -log.push("end main"); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-late.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-late.js deleted file mode 100644 index 44eb76728f..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-late.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions, the Promise -// is rejected, and a catch handler is installed right before the rejection. -// We expect no debug event to be triggered. - -Debug = debug.Debug; - -var p = new Promise(function(resolve, reject) { - resolve(); -}); - -var q = p.then( - function() { - q.catch(function(e) { - assertEquals("caught", e.message); - }); - return Promise.reject(Error("caught")); - }); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js deleted file mode 100644 index b2fe8b0a45..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions and -// there is a catch handler for the to-be-rejected Promise. -// We expect no debug event to be triggered. - -Debug = debug.Debug; - -var p = new Promise(function(resolve, reject) { - resolve(); -}); - -var q = p.then( - function() { - return Promise.reject(Error("caught reject")); - }); - -q.catch( - function(e) { - assertEquals("caught reject", e.message); - }); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/stepin-constructor.js b/deps/v8/test/mjsunit/es6/debug-promises/stepin-constructor.js deleted file mode 100644 index 6914ae0036..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/stepin-constructor.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; -var exception = null; -var breaks = []; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - breaks.push(exec_state.frame(0).sourceLineText().trimLeft()); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function resolver(resolve, reject) { - print(1); - print(2); - print(3); - resolve(); -} - -debugger; -var p = new Promise(resolver); - -Debug.setListener(null); - -var expected_breaks = [ - "debugger;", - "var p = new Promise(resolver);", - "print(1);", - "print(2);", - "print(3);", - "resolve();", - "}", - "Debug.setListener(null);" -]; - -assertEquals(expected_breaks, breaks); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/stepin-handler.js b/deps/v8/test/mjsunit/es6/debug-promises/stepin-handler.js deleted file mode 100644 index 8083c17103..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/stepin-handler.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --noalways-opt -// Tests stepping into through Promises. - -Debug = debug.Debug -var exception = null; -var break_count = 0; -var expected_breaks = -1; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); - if (!break_count) { - // Count number of expected breakpoints in this source file. - var source_text = exec_state.frame(0).func().script().source(); - expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; - print("Expected breaks: " + expected_breaks); - } - var source = exec_state.frame(0).sourceLineText(); - print("paused at: " + source); - assertTrue(source.indexOf("// Break " + break_count + ".") > 0, - "Unexpected pause at: " + source + "\n" + - "Expected: // Break " + break_count + "."); - ++break_count; - if (break_count !== expected_breaks) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } - } catch(e) { - exception = e; - print(e, e.stack); - } -}; - -Debug.setListener(listener); - -Promise.resolve(42) - .then( - function f0() { - debugger; // Break 0. - } // Break 1. - ) - .then(callback) - .then(callback.bind(null)) - .then(Object) - .then(callback.bind(null).bind(null)) - .then(finalize) - .catch(function(err) { - %AbortJS("FAIL: " + err); - }); - -function callback(x) { - return x; // Break 2. // Break 4. // Break 6. -} // Break 3. // Break 5. // Break 7. - -function finalize() { - assertNull(exception); // Break 8. - assertEquals(expected_breaks, break_count); - - Debug.setListener(null); -} diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-late.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-late.js deleted file mode 100644 index 0399e5cc34..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-late.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions, the Promise -// throws, and a catch handler is installed right before throwing. -// We expect no debug event to be triggered. - -Debug = debug.Debug; - -var p = new Promise(function(resolve, reject) { - resolve(); -}); - -var q = p.then( - function() { - q.catch(function(e) { - assertEquals("caught", e.message); - }); - throw new Error("caught"); - }); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js deleted file mode 100644 index 8e1524d519..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions and -// there is a catch handler for the exception thrown in a Promise. -// We expect no debug event to be triggered. - -Debug = debug.Debug; - -var p = new Promise(function(resolve, reject) { - resolve(); -}); - -var q = p.then( - function() { - throw new Error("caught throw"); - }); - -q.catch( - function(e) { - assertEquals("caught throw", e.message); - }); - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js deleted file mode 100644 index 19610f77e8..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -// Test debug events when we only listen to uncaught exceptions and -// there is a catch handler for the to-be-rejected Promise. -// We expect no Exception debug events, since the default reject handler passes -// the rejection on to a user-defined reject handler. - -Debug = debug.Debug; - -var resolve, reject; -var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; }); - -var p1 = p0.then(function() { - throw new Error(); -}); - -var p2 = p1.then(function() { }); -var p3 = p2.catch(function() { }); - -var q = new Promise(function(res, rej) { - res(); -}); - -q.then(function() { - resolve(); -}) - - -function listener(event, exec_state, event_data, data) { - try { - assertTrue(event != Debug.DebugEvent.Exception); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setBreakOnUncaughtException(); -Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-step-destructuring-assignment.js b/deps/v8/test/mjsunit/es6/debug-step-destructuring-assignment.js deleted file mode 100644 index 4fde928b38..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-step-destructuring-assignment.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var exception = null; -var Debug = debug.Debug; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var source = exec_state.frame(0).sourceLineText(); - print(source); - assertTrue(source.indexOf(`// B${break_count++}`) > 0); - if (source.indexOf("assertEquals") > 0) { - exec_state.prepareStep(Debug.StepAction.StepNext); - } else { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } catch (e) { - exception = e; - print(e); - } -}; - -Debug.setListener(listener); - -function f() { - var a, b, c, d; - debugger; // B0 - [ // B1 - a, // B2 - b, // B3 - c = 3 // B4 - ] = [1, 2]; - assertEquals({a:1,b:2,c:3}, {a, b, c}); // B5 - - [ // B6 - a, // B7 - [ - b, // B8 - c // B9 - ], - d // B10 - ] = [5, [6, 7], 8]; - assertEquals({a:5,b:6,c:7,d:8}, {a, b, c, d}); // B11 - - [ // B12 - a, // B13 - b, // B14 - ...c // B15 - ] = [1, 2, 3, 4]; - assertEquals({a:1,b:2,c:[3,4]}, {a, b, c}); // B16 - - ({ // B17 - a, // B18 - b, // B19 - c = 7 // B20 - } = {a: 5, b: 6}); - assertEquals({a:5,b:6,c:7}, {a, b, c}); // B21 - - ({ // B22 - a, // B23 - b = return1(), // B24 - c = return1() // B25 - } = {a: 5, b: 6}); - assertEquals({a:5,b:6,c:1}, {a, b, c}); // B28 - - ({ // B29 - x : a, // B30 - y : b, // B31 - z : c = 3 // B32 - } = {x: 1, y: 2}); - assertEquals({a:1,b:2,c:3}, {a, b, c}); // B33 -} // B34 - -function return1() { - return 1; // B26 -} // B27 - -f(); -Debug.setListener(null); // B35 -assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/debug-step-destructuring-bind.js b/deps/v8/test/mjsunit/es6/debug-step-destructuring-bind.js deleted file mode 100644 index f670f525af..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-step-destructuring-bind.js +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var exception = null; -var Debug = debug.Debug; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var source = exec_state.frame(0).sourceLineText(); - print(source, break_count); - assertTrue(source.indexOf(`B${break_count++}`) > 0); - if (source.indexOf("assertEquals") > 0) { - exec_state.prepareStep(Debug.StepAction.StepNext); - } else { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } catch (e) { - exception = e; - print(e); - } -}; - -Debug.setListener(listener); - -var id = x => x; // B9 B10 B36 B37 - -function test() { - debugger; // B0 - function fx1([ - a, // B2 - b // B3 - ]) { - assertEquals([1, 2], [a, b]); // B4 - } // B5 - fx1([1, 2, 3]); // B1 - - function f2([ - a, // B7 - b = id(3) // B8 - ]) { - assertEquals([4, 3], [a, b]); // B11 - } // B12 - f2([4]); // B6 - - function f3({ - x: a, // B14 - y: b // B15 - }) { - assertEquals([5, 6], [a, b]); // B16 - } // B17 - f3({y: 6, x: 5}); // B13 - - function f4([ - a, // B19 - { - b, // B20 - c, // B21 - } - ]) { - assertEquals([2, 4, 6], [a, b, c]); // B22 - } // B23 - f4([2, {c: 6, b: 4}]); // B18 - - function f5([ - { - a, // B25 - b = 7 // B26 - }, - c = 3 // B27 - ] = [{a:1}]) { - assertEquals([1, 7, 3], [a, b, c]); // B28 - } // B29 - f5(); // B24 - - var name = "x"; // B30 - function f6({ - [id(name)]: a, // B34 B35 - b = a // B38 - }) { - assertEquals([9, 9], [a, b]); // B39 - } // B40 - var o6 = {}; // B31 - o6[name] = 9; // B32 - f6(o6); // B33 - - try { - throw [3, 4]; // B41 - } catch ([ - a, // B42 - b, // B43 - c = 6 // B44 - ]) { - assertEquals([3, 4, 6], [a, b, c]); // B45 - } - - var { - x: a, // B46 - y: b = 9 // B47 - } = { x: 4 }; - assertEquals([4, 9], [a, b]); // B48 -} // B49 - -test(); -Debug.setListener(null); // B50 -assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js b/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js deleted file mode 100644 index 6c887ab08d..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -'use strict'; - -var Debug = debug.Debug - -var done = false; -var stepCount = 0; - -function listener(event, execState, eventData, data) { - if (event == Debug.DebugEvent.Break) { - if (!done) { - execState.prepareStep(Debug.StepAction.StepIn); - var s = execState.frame().sourceLineText(); - assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); - stepCount++; - } - } -}; - -Debug.setListener(listener); - -function GetBase() { - var x = 1; // 1. - var y = 2; // 2. - done = true; // 3. - return null; -} - -function f() { - class Derived extends GetBase() {} // 0. -} - -var bp = Debug.setBreakPoint(f, 0); -f(); -assertEquals(4, stepCount); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js b/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js deleted file mode 100644 index 96cdc93159..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -'use strict'; - -var Debug = debug.Debug -var done, stepCount; - -function listener(event, execState, eventData, data) { - if (event == Debug.DebugEvent.Break) { - if (!done) { - execState.prepareStep(Debug.StepAction.StepIn); - var s = execState.frame().sourceLineText(); - assertTrue(s.indexOf('// ' + stepCount + '.') !== -1); - stepCount++; - } - } -}; - -Debug.setListener(listener); - - -class Base { - constructor() { // 1. - var x = 1; // 2. - var y = 2; // 3. - done = true; // 4. - } -} - -class Derived extends Base {} - - -(function TestBreakPointInConstructor() { - done = false; - stepCount = 1; - var bp = Debug.setBreakPoint(Base, 0); - - new Base(); - assertEquals(1, stepCount); - - Debug.clearBreakPoint(bp); -})(); - - -(function TestDefaultConstructor() { - done = false; - stepCount = 1; - - var bp = Debug.setBreakPoint(Base, 0); - new Derived(); - assertEquals(1, stepCount); - - Debug.clearBreakPoint(bp); -})(); - - -(function TestStepInto() { - done = false; - stepCount = 0; - - function f() { - new Derived(); // 0. - } - - var bp = Debug.setBreakPoint(f, 0); - f(); - assertEquals(1, stepCount); - - Debug.clearBreakPoint(bp); -})(); - - -(function TestExtraIndirection() { - done = false; - stepCount = 0; - - class Derived2 extends Derived {} - - function f() { - new Derived2(); // 0. - } - - var bp = Debug.setBreakPoint(f, 0); - f(); - assertEquals(1, stepCount); - - Debug.clearBreakPoint(bp); -})(); - - -(function TestBoundClass() { - done = false; - stepCount = 0; - - var bound = Derived.bind(null); - - function f() { - new bound(); // 0. - } - - var bp = Debug.setBreakPoint(f, 0); - f(); - assertEquals(1, stepCount); - - Debug.clearBreakPoint(bp); -})(); - - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/es6/debug-step-into-regexp-subclass.js b/deps/v8/test/mjsunit/es6/debug-step-into-regexp-subclass.js deleted file mode 100644 index 5e5eb47d7f..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-step-into-regexp-subclass.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue( - event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - } -}; - -function customSplit() { - return "x"; // Break 2. -} // Break 3. -var o = {}; -o[Symbol.split] = customSplit; - -Debug.setListener(listener); -debugger; // Break 0. -var result = "".split(o); // Break 1. -Debug.setListener(null); // Break 4. - -assertEquals("x", result); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-collections-foreach.js b/deps/v8/test/mjsunit/es6/debug-stepin-collections-foreach.js deleted file mode 100644 index 5551843cb2..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-stepin-collections-foreach.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - exec_state.prepareStep(Debug.StepAction.StepIn); - print(event_data.sourceLineText()); - assertTrue( - event_data.sourceLineText().indexOf(`B${breaks++}`) > 0); - } - } catch (e) { - print(e); - quit(); - exception = e; - } -} - -function cb_set(num) { - print("element " + num); // B2 B5 B8 - return true; // B3 B6 B9 -} // B4 B7 B10 - -function cb_map(key, val) { - print("key " + key + ", value " + val); // B2 B5 B8 - return true; // B3 B6 B9 -} // B4 B7 B10 - -var s = new Set(); -s.add(1); -s.add(2); -s.add(3); - -var m = new Map(); -m.set('foo', 1); -m.set('bar', 2); -m.set('baz', 3); - -var breaks = 0; -Debug.setListener(listener); -debugger; // B0 -s.forEach(cb_set); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -breaks = 0; -Debug.setListener(listener); -debugger; // B0 -m.forEach(cb_map); // B1 -Debug.setListener(null); // B11 -assertNull(exception); -assertEquals(12, breaks); - -// Test two levels of builtin callbacks: -// Array.forEach calls a callback function, which by itself uses -// Array.forEach with another callback function. - -function cb_set_2(num) { - print("element " + num); // B3 B6 B9 B15 B18 B21 B27 B30 B33 - return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34 -} // B5 B8 B11 B17 B20 B23 B29 B32 B35 - -function cb_map_2(k, v) { - print(`key ${k}, value ${v}`); // B3 B6 B9 B15 B18 B21 B27 B30 B33 - return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34 -} // B5 B8 B11 B17 B20 B23 B29 B32 B35 - -function cb_set_foreach(num) { - s.forEach(cb_set_2); // B2 B14 B26 - print("back."); // B12 B24 B36 -} // B13 B25 B37 - -function cb_map_foreach(key, val) { - m.forEach(cb_map_2); // B2 B14 B26 - print("back."); // B12 B24 B36 -} // B13 B25 B37 - -breaks = 0; -Debug.setListener(listener); -debugger; // B0 -s.forEach(cb_set_foreach); // B1 -Debug.setListener(null); // B38 -assertNull(exception); -assertEquals(39, breaks); - -breaks = 0; -Debug.setListener(listener); -debugger; // B0 -m.forEach(cb_map_foreach); // B1 -Debug.setListener(null); // B38 -assertNull(exception); -assertEquals(39, breaks); diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-generators.js b/deps/v8/test/mjsunit/es6/debug-stepin-generators.js deleted file mode 100644 index 081dfb7063..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-stepin-generators.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug -var exception = null; -var yields = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var source = exec_state.frame(0).sourceLineText(); - print(source); - if (/stop stepping/.test(source)) return; - if (/yield/.test(source)) yields++; - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - print(e, e.stack); - exception = e; - } -}; - -Debug.setListener(listener); - -function* g() { - for (var i = 0; i < 3; ++i) { - yield i; - } -} - -var i = g(); -debugger; -for (var num of g()) {} -i.next(); - -print(); // stop stepping - -// Not stepped into. -i.next(); -i.next(); - -assertNull(exception); -assertEquals(4, yields); diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js b/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js index e541f0f4b4..9e3bd172c8 100644 --- a/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js +++ b/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js @@ -7,18 +7,12 @@ Debug = debug.Debug var exception = null; var break_count = 0; -var expected_breaks = -1; +const expected_breaks = 9; function listener(event, exec_state, event_data, data) { try { if (event == Debug.DebugEvent.Break) { assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); - if (!break_count) { - // Count number of expected breakpoints in this source file. - var source_text = exec_state.frame(0).func().script().source(); - expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; - print("Expected breaks: " + expected_breaks); - } var source = exec_state.frame(0).sourceLineText(); print("paused at: " + source); assertTrue(source.indexOf("// Break " + break_count + ".") > 0, diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-tailcalls.js b/deps/v8/test/mjsunit/es6/debug-stepin-tailcalls.js deleted file mode 100644 index 6020ba9d50..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-stepin-tailcalls.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --harmony-tailcalls - -"use strict"; - -var Debug = debug.Debug -var exception = null; -var breaks = 0; - -function f(x) { - if (x > 0) { // B3 B5 B7 B9 - return f(x - 1); // B4 B6 B8 - } -} // B10 - -function g(x) { - return f(x); // B2 -} - -function h(x) { - debugger; // B0 - g(x); // B1 -} // B11 - - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue(event_data.sourceLineText().indexOf(`B${breaks++}`) > 0); - exec_state.prepareStep(Debug.StepAction.StepIn); - } catch (e) { - exception = e; - }; -}; - -Debug.setListener(listener); - -h(3); - -Debug.setListener(null); // B12 -assertNull(exception); -assertEquals(13, breaks); diff --git a/deps/v8/test/mjsunit/es6/debug-stepout-tailcalls.js b/deps/v8/test/mjsunit/es6/debug-stepout-tailcalls.js deleted file mode 100644 index db0878d7a9..0000000000 --- a/deps/v8/test/mjsunit/es6/debug-stepout-tailcalls.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --harmony-tailcalls - -"use strict"; - -var Debug = debug.Debug -var exception = null; -var breaks = 0; - -function f(x) { - if (x > 0) { - return f(x - 1); // Tail call - } - debugger; // Break 0 -} - -function g(x) { - return f(x); // Tail call -} - -function h(x) { - g(x); // Not tail call -} // Break 1 - - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertTrue(event_data.sourceLineText().indexOf(`Break ${breaks++}`) > 0); - exec_state.prepareStep(Debug.StepAction.StepOut); - } catch (e) { - exception = e; - }; -}; - -Debug.setListener(listener); - -h(3); - -Debug.setListener(null); // Break 2 -assertNull(exception); -assertEquals(3, breaks); diff --git a/deps/v8/test/mjsunit/es6/default-parameters-debug.js b/deps/v8/test/mjsunit/es6/default-parameters-debug.js index 30e19c42af..49adfa4610 100644 --- a/deps/v8/test/mjsunit/es6/default-parameters-debug.js +++ b/deps/v8/test/mjsunit/es6/default-parameters-debug.js @@ -9,36 +9,31 @@ Debug = debug.Debug listenerComplete = false; breakPointCount = 0; +exception = null; function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { + if (event != Debug.DebugEvent.Break) return; + try { breakPointCount++; if (breakPointCount == 1) { // Break point in initializer for parameter `a`, invoked by // initializer for parameter `b` - assertEquals('default', exec_state.frame(1).evaluate('mode').value()); - - // initializer for `b` can't refer to `b` - assertThrows(function() { - exec_state.frame(1).evaluate('b').value(); - }, ReferenceError); - - assertThrows(function() { - exec_state.frame(1).evaluate('c'); - }, ReferenceError); + assertEquals('default', exec_state.frame(0).evaluate('mode').value()); + assertTrue(exec_state.frame(1).evaluate('b').isUndefined()); + assertTrue(exec_state.frame(1).evaluate('c').isUndefined()); } else if (breakPointCount == 2) { // Break point in IIFE initializer for parameter `c` assertEquals('modeFn', exec_state.frame(1).evaluate('a.name').value()); assertEquals('default', exec_state.frame(1).evaluate('b').value()); - assertThrows(function() { - exec_state.frame(1).evaluate('c'); - }, ReferenceError); + assertTrue(exec_state.frame(1).evaluate('c').isUndefined()); } else if (breakPointCount == 3) { // Break point in function body --- `c` parameter is shadowed assertEquals('modeFn', exec_state.frame(0).evaluate('a.name').value()); assertEquals('default', exec_state.frame(0).evaluate('b').value()); assertEquals('local', exec_state.frame(0).evaluate('d').value()); } + } catch (e) { + exception = e; } }; @@ -56,3 +51,4 @@ f(); // Make sure that the debug event listener vas invoked. assertEquals(3, breakPointCount); +assertNull(exception); diff --git a/deps/v8/test/mjsunit/es6/generators-relocation.js b/deps/v8/test/mjsunit/es6/generators-relocation.js deleted file mode 100644 index 2636f52d7b..0000000000 --- a/deps/v8/test/mjsunit/es6/generators-relocation.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -function assertIteratorResult(value, done, result) { - assertEquals({value: value, done: done}, result); -} - -function RunTest(formals_and_body, args, value1, value2) { - // A null listener. It isn't important what the listener does. - function listener(event, exec_state, event_data, data) { - } - - // Create the generator function outside a debugging context. It will probably - // be lazily compiled. - var gen = (function*(){}).constructor.apply(null, formals_and_body); - - // Instantiate the generator object. - var obj = gen.apply(null, args); - - // Advance to the first yield. - assertIteratorResult(value1, false, obj.next()); - - // Enable the debugger, which should force recompilation of the generator - // function and relocation of the suspended generator activation. - Debug.setListener(listener); - - // Add a breakpoint on line 3 (the second yield). - var bp = Debug.setBreakPoint(gen, 3); - - // Check that the generator resumes and suspends properly. - assertIteratorResult(value2, false, obj.next()); - - // Disable debugger -- should not force recompilation. - Debug.clearBreakPoint(bp); - Debug.setListener(null); - - // Run to completion. - assertIteratorResult(undefined, true, obj.next()); -} - -function prog(a, b, c) { - return a + ';\n' + 'yield ' + b + ';\n' + 'yield ' + c; -} - -// Simple empty local scope. -RunTest([prog('', '1', '2')], [], 1, 2); - -RunTest([prog('for (;;) break', '1', '2')], [], 1, 2); - -RunTest([prog('while (0) foo()', '1', '2')], [], 1, 2); - -RunTest(['a', prog('var x = 3', 'a', 'x')], [1], 1, 3); - -RunTest(['a', prog('', '1', '2')], [42], 1, 2); - -RunTest(['a', prog('for (;;) break', '1', '2')], [42], 1, 2); diff --git a/deps/v8/test/mjsunit/es6/reflect.js b/deps/v8/test/mjsunit/es6/reflect.js index d597a78901..9e21717a99 100644 --- a/deps/v8/test/mjsunit/es6/reflect.js +++ b/deps/v8/test/mjsunit/es6/reflect.js @@ -273,6 +273,14 @@ function prepare(target) { })(); +(function testReflectSetArrayLength() { + var y = []; + Object.defineProperty(y, 0, {value: 42, configurable: false}); + assertFalse(Reflect.set(y, 'length', 0)); + assertTrue(Reflect.set(y, 'length', 2)); +})(); + + //////////////////////////////////////////////////////////////////////////////// // Reflect.has @@ -352,6 +360,14 @@ function prepare(target) { })(); +(function testReflectDefinePropertyArrayLength() { + var y = []; + Object.defineProperty(y, 0, {value: 42, configurable: false}); + assertFalse(Reflect.defineProperty(y, 'length', {value: 0})); + assertTrue(Reflect.defineProperty(y, 'length', {value: 2})); +})(); + + // See reflect-define-property.js for further tests. diff --git a/deps/v8/test/mjsunit/es6/regexp-flags.js b/deps/v8/test/mjsunit/es6/regexp-flags.js index 2bcccfa760..9760cf8d5d 100644 --- a/deps/v8/test/mjsunit/es6/regexp-flags.js +++ b/deps/v8/test/mjsunit/es6/regexp-flags.js @@ -45,8 +45,12 @@ assertEquals(4, get_count); // Overridden flag getters affect string.replace // TODO(adamk): Add more tests here once we've switched // to use [[OriginalFlags]] in more cases. -assertEquals(expected, string.replace(r3, "X")); -assertEquals(5, get_count); +// TODO(jgruber): This exact case actually causes an infinite loop in the spec +// (@@replace sees global = true while BuiltinExec sees global = false). +// Comment the test for now and remove / fix once this has been resolved on +// the spec side. +//assertEquals(expected, string.replace(r3, "X")); +//assertEquals(5, get_count); function testName(name) { diff --git a/deps/v8/test/mjsunit/es6/regress/regress-3280.js b/deps/v8/test/mjsunit/es6/regress/regress-3280.js deleted file mode 100644 index 2dadd02840..0000000000 --- a/deps/v8/test/mjsunit/es6/regress/regress-3280.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -var listener_called; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - listener_called = true; - exec_state.frame().allScopes(); - } -} - -Debug.setListener(listener); - -function *generator_local_2(a) { - debugger; -} -generator_local_2(1).next(); - -assertTrue(listener_called, "listener not called"); diff --git a/deps/v8/test/mjsunit/es6/regress/regress-468661.js b/deps/v8/test/mjsunit/es6/regress/regress-468661.js index 4a58a71d30..db71352f74 100644 --- a/deps/v8/test/mjsunit/es6/regress/regress-468661.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-468661.js @@ -7,6 +7,7 @@ Debug = debug.Debug var exception = null; var break_count = 0; +const expected_breaks = 9; var expected_values = [ReferenceError, undefined, 0, 0, 0, 0, 1, @@ -16,12 +17,6 @@ function listener(event, exec_state, event_data, data) { try { if (event == Debug.DebugEvent.Break) { assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); - // Count number of expected breakpoints in this source file. - if (!break_count) { - var source_text = exec_state.frame(0).func().script().source(); - expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; - print("Expected breaks: " + expected_breaks); - } var frameMirror = exec_state.frame(0); var v = null;; diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases0.js b/deps/v8/test/mjsunit/es6/regress/regress-5598.js index 7a422c542b..600a866470 100644 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases0.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-5598.js @@ -2,7 +2,15 @@ // 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-async-await --expose-debug-as debug -// Files: test/mjsunit/harmony/async-debug-caught-exception-cases.js +// Flags: --turbo --turbo-escape --allow-natives-syntax -runPart(0); +function fn(a) { + var [b] = a; + return b; +} + +fn('a'); +fn('a'); +%OptimizeFunctionOnNextCall(fn); + +fn('a'); diff --git a/deps/v8/test/mjsunit/es6/regress/regress-660925.js b/deps/v8/test/mjsunit/es6/regress/regress-660925.js new file mode 100644 index 0000000000..12c370cb6c --- /dev/null +++ b/deps/v8/test/mjsunit/es6/regress/regress-660925.js @@ -0,0 +1,13 @@ +// 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. + +let array = new Array(0xFFFFFFFF); +let it = array.keys(); +assertEquals({ value: 0, done: false }, it.next()); + +it = array.entries(); +assertEquals({ value: [0, undefined], done: false }, it.next()); + +it = array[Symbol.iterator](); +assertEquals({ value: undefined, done: false }, it.next()); diff --git a/deps/v8/test/mjsunit/es6/regress/regress-666622.js b/deps/v8/test/mjsunit/es6/regress/regress-666622.js new file mode 100644 index 0000000000..56731ab28e --- /dev/null +++ b/deps/v8/test/mjsunit/es6/regress/regress-666622.js @@ -0,0 +1,39 @@ +// 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 iterateArray() { + var array = new Array(); + var it = array.entries(); + it.next(); +} + +function iterateTypedArray() { + var array = new Uint8Array(); + var it = array.entries(); + it.next(); +} + +function testArray() { + iterateArray(); + try { + } catch (e) { + } +} +testArray(); +testArray(); +%OptimizeFunctionOnNextCall(testArray); +testArray(); + +function testTypedArray() { + iterateTypedArray(); + try { + } catch (e) { + } +} +testTypedArray(); +testTypedArray(); +%OptimizeFunctionOnNextCall(testTypedArray); +testTypedArray(); diff --git a/deps/v8/test/mjsunit/es6/rest-params.js b/deps/v8/test/mjsunit/es6/rest-params.js index 9afe9b409e..2f122daffd 100644 --- a/deps/v8/test/mjsunit/es6/rest-params.js +++ b/deps/v8/test/mjsunit/es6/rest-params.js @@ -136,11 +136,9 @@ var O = { (function testUnmappedArguments() { // Strict/Unmapped arguments should always be used for functions with rest // parameters - assertThrows(function(...rest) { return arguments.caller; }, TypeError); assertThrows(function(...rest) { return arguments.callee; }, TypeError); // TODO(caitp): figure out why this doesn't throw sometimes, even though the // getter always does =) - // assertThrows(function(...rest) { arguments.caller = 1; }, TypeError); // assertThrows(function(...rest) { arguments.callee = 1; }, TypeError); })(); diff --git a/deps/v8/test/mjsunit/harmony/sloppy-restrictive-block-function.js b/deps/v8/test/mjsunit/es6/sloppy-restrictive-block-function.js index 07ce64b9ac..65734acd03 100644 --- a/deps/v8/test/mjsunit/harmony/sloppy-restrictive-block-function.js +++ b/deps/v8/test/mjsunit/es6/sloppy-restrictive-block-function.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-restrictive-declarations - // ES#sec-functiondeclarations-in-ifstatement-statement-clauses // Annex B 3.4 FunctionDeclarations in IfStatement Statement Clauses // In sloppy mode, function declarations in if statements act like diff --git a/deps/v8/test/mjsunit/es6/spread-call.js b/deps/v8/test/mjsunit/es6/spread-call.js index 05e17741d6..de38f129cd 100644 --- a/deps/v8/test/mjsunit/es6/spread-call.js +++ b/deps/v8/test/mjsunit/es6/spread-call.js @@ -24,6 +24,13 @@ assertEquals(5, countArgs(...[1, 2, 3, 4, 5])); assertEquals(6, countArgs(...[1, 2, 3, 4, 5, 6])); + assertEquals(1, countArgs(...[1.1])); + assertEquals(2, countArgs(...[1.1, 2.2])); + assertEquals(3, countArgs(...[1.1, 2.2, 3.3])); + assertEquals(4, countArgs(...[1.1, 2.2, 3.3, 4.4])); + assertEquals(5, countArgs(...[1.1, 2.2, 3.3, 4.4, 5.5])); + assertEquals(6, countArgs(...[1.1, 2.2, 3.3, 4.4, 5.5, 6.6])); + assertEquals(1, countArgs(...new Set([1]))); assertEquals(2, countArgs(...new Set([1, 2]))); assertEquals(3, countArgs(...new Set([1, 2, 3]))); @@ -346,6 +353,91 @@ assertEquals("ABXYC1C2DEBXYC1C2", log); })(); +(function testArrayPrototypeHoleGetterModifiesIteratorPrototypeNext() { + function sum() { + var sum = arguments[0]; + for (var i = 1; i < arguments.length; ++i) { + sum += arguments[i]; + } + return sum; + } + var a = [1, 2]; + a[3] = 4; + var called = 0; + + Object.defineProperty(Array.prototype, 2, { + get: function() { + var ai = a[Symbol.iterator](); + var original_next = ai.__proto__["next"]; + Object.defineProperty(ai.__proto__, "next", { + get: function() { + called++; + return original_next; + } + }); + return 3; + }, + configurable: true + }); + + assertEquals(10, sum(...a)); + assertEquals(2, called); + + Object.defineProperty(Array.prototype, 2, {}); +})(); + +(function testArrayHasOtherPrototype() { + function countArgs() { return arguments.length; } + var a = [1, 2, 3]; + var b = {}; + Object.defineProperty(b, Symbol.iterator, { + value: function*() { + yield 4; + }, + configurable: true + }); + + Object.setPrototypeOf(a, b); + + assertEquals(1, countArgs(...a)); +})(); + +(function testArrayIteratorPrototypeGetter() { + function countArgs() { return arguments.length; } + var a = [1, 2, 3]; + var ai = a[Symbol.iterator](); + var called = 0; + + var original_next = ai.__proto__["next"]; + + Object.defineProperty(ai.__proto__, "next", { + get: function() { + called++; + return original_next; + } + }); + + countArgs(...a); + + // should be called 4 times; 3 for the values, 1 for the final + // {value: undefined, done: true} pair + assertEquals(4, called); +})(); + +(function testArrayIteratorPrototypeModified() { + function countArgs() { return arguments.length; } + var a = [1,2,3]; + var ai = a[Symbol.iterator](); + Object.defineProperty(ai.__proto__, "next", { + value: function() { + return {value: undefined, done: true}; + }, + configurable: true + }); + + assertEquals(0, countArgs(...a)); + +})(); (function testCustomArrayPrototypeIterator() { var origIterator = @@ -370,3 +462,29 @@ Object.defineProperty(Array.prototype, Symbol.iterator, origIterator); })(); + +(function testGetPropertyIteratorCalledExactlyOnce() { + function countArgs() { return arguments.length; } + var a = [1, 2, 3]; + var called = 0; + + Object.defineProperty(Array.prototype, Symbol.iterator, { + value: function*() { + yield 1; + yield 2; + }, + configurable: true + }); + + var it = a[Symbol.iterator]; + Object.defineProperty(a, Symbol.iterator, { + get: function() { + called++; + return it; + } + }); + + countArgs(...a); + + assertEquals(1, called); +})(); diff --git a/deps/v8/test/mjsunit/es6/string-endswith.js b/deps/v8/test/mjsunit/es6/string-endswith.js index 4246f166a4..b776ccc4ba 100644 --- a/deps/v8/test/mjsunit/es6/string-endswith.js +++ b/deps/v8/test/mjsunit/es6/string-endswith.js @@ -34,6 +34,7 @@ assertFalse(testString.endsWith("world")); assertFalse(testString.endsWith("Hello World!")); assertFalse(testString.endsWith(null)); assertFalse(testString.endsWith(undefined)); +assertFalse(testString.endsWith()); assertTrue("null".endsWith(null)); assertTrue("undefined".endsWith(undefined)); diff --git a/deps/v8/test/mjsunit/es6/string-includes.js b/deps/v8/test/mjsunit/es6/string-includes.js index c825ffdc68..60a7ddd685 100644 --- a/deps/v8/test/mjsunit/es6/string-includes.js +++ b/deps/v8/test/mjsunit/es6/string-includes.js @@ -27,6 +27,11 @@ assertEquals(1, String.prototype.includes.length); +var s = 'a'; +assertFalse(s.includes(null)); +assertFalse(s.includes(undefined)); +assertFalse(s.includes()); + var reString = "asdf[a-z]+(asdf)?"; assertTrue(reString.includes("[a-z]+")); assertTrue(reString.includes("(asdf)?")); diff --git a/deps/v8/test/mjsunit/es6/string-startswith.js b/deps/v8/test/mjsunit/es6/string-startswith.js index f38f7b9cb8..449d07a56d 100644 --- a/deps/v8/test/mjsunit/es6/string-startswith.js +++ b/deps/v8/test/mjsunit/es6/string-startswith.js @@ -34,6 +34,7 @@ assertFalse(testString.startsWith("hello")); assertFalse(testString.startsWith("Hello World!")); assertFalse(testString.startsWith(null)); assertFalse(testString.startsWith(undefined)); +assertFalse(testString.startsWith()); assertTrue("null".startsWith(null)); assertTrue("undefined".startsWith(undefined)); diff --git a/deps/v8/test/mjsunit/es6/symbols.js b/deps/v8/test/mjsunit/es6/symbols.js index a21afb3770..d83e2174ec 100644 --- a/deps/v8/test/mjsunit/es6/symbols.js +++ b/deps/v8/test/mjsunit/es6/symbols.js @@ -353,7 +353,7 @@ function TestKeyDelete(obj) { } -var objs = [{}, [], Object.create(null), Object(1), new Map, function(){}] +var objs = [{}, [], Object.create({}), Object(1), new Map, function(){}] for (var i in objs) { var obj = objs[i] diff --git a/deps/v8/test/mjsunit/harmony/object-entries.js b/deps/v8/test/mjsunit/es8/object-entries.js index 101988a052..71f121b896 100644 --- a/deps/v8/test/mjsunit/harmony/object-entries.js +++ b/deps/v8/test/mjsunit/es8/object-entries.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. -// Flags: --harmony-object-values-entries // Flags: --allow-natives-syntax function TestMeta() { diff --git a/deps/v8/test/mjsunit/harmony/object-get-own-property-descriptors.js b/deps/v8/test/mjsunit/es8/object-get-own-property-descriptors.js index c71b20a226..f88840dba4 100644 --- a/deps/v8/test/mjsunit/harmony/object-get-own-property-descriptors.js +++ b/deps/v8/test/mjsunit/es8/object-get-own-property-descriptors.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. -// Flags: --harmony-object-own-property-descriptors // Flags: --allow-natives-syntax function DataDescriptor(value) { diff --git a/deps/v8/test/mjsunit/harmony/object-values.js b/deps/v8/test/mjsunit/es8/object-values.js index 141070db9c..ed200373a9 100644 --- a/deps/v8/test/mjsunit/harmony/object-values.js +++ b/deps/v8/test/mjsunit/es8/object-values.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. -// Flags: --harmony-object-values-entries // Flags: --allow-natives-syntax function TestMeta() { diff --git a/deps/v8/test/mjsunit/fixed-context-shapes-when-recompiling.js b/deps/v8/test/mjsunit/fixed-context-shapes-when-recompiling.js index bd64e3d168..6afc07a488 100644 --- a/deps/v8/test/mjsunit/fixed-context-shapes-when-recompiling.js +++ b/deps/v8/test/mjsunit/fixed-context-shapes-when-recompiling.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: --min-preparse-length 1 --allow-natives-syntax +// Flags: --min-preparse-length=1 --allow-natives-syntax --lazy-inner-functions // Test that the information on which variables to allocate in context doesn't // change when recompiling. @@ -50,6 +50,24 @@ } })(); +(function TestConstInInnerFunction() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + const a = 0; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + (function TestInnerFunctionParameter() { var a = 1; var b = 2; @@ -67,6 +85,23 @@ } })(); +(function TestInnerFunctionRestParameter() { + var a = 1; + var b = 2; + var c = 3; + function inner(...a) { + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + (function TestInnerInnerFunctionParameter() { var a = 1; var b = 2; @@ -84,6 +119,23 @@ } })(); +(function TestInnerInnerFunctionRestParameter() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + function innerinner(...a) { a; b; c; } + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + (function TestInnerArrowFunctionParameter() { var a = 1; var b = 2; @@ -101,6 +153,23 @@ } })(); +(function TestInnerArrowFunctionRestParameter() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + var f = (...a) => a + b + c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + (function TestInnerFunctionInnerFunction() { var a = 1; var b = 2; @@ -252,9 +321,171 @@ } })(); +(function TestInnerFunctionDestructuring1() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + var [a, a2] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring2() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + let [a, a2] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring3() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + const [a, a2] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring4() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + var [a2, ...a] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring5() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + let [a2, ...a] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring6() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + const [a2, ...a] = [1, 2]; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring7() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + var {a, a2} = {a: 1, a2: 2}; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring8() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + let {a, a2} = {a: 1, a2: 2}; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + +(function TestInnerFunctionDestructuring9() { + var a = 1; + var b = 2; + var c = 3; + function inner() { + const {a, a2} = {a: 1, a2: 2}; + a; b; c; + } + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + assertEquals(1, a); + assertEquals(2, b); + assertEquals(3, c); + } +})(); + // A cluster of similar tests where the inner function only declares a variable // whose name clashes with an outer function variable name, but doesn't use it. -(function TestRegress650969_1() { +(function TestRegress650969_1_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -266,67 +497,67 @@ } })(); -(function TestRegress650969_2() { +(function TestRegress650969_1_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); } var a; function inner() { - var a = 6; + let a; } } })(); -(function TestRegress650969_3() { +(function TestRegress650969_2_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); } var a; function inner() { - var a, b; + var a = 6; } } })(); -(function TestRegress650969_4() { +(function TestRegress650969_2_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); } var a; function inner() { - var a = 6, b; + let a = 6; } } })(); -(function TestRegress650969_5() { +(function TestRegress650969_2_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); } var a; function inner() { - let a; + const a = 6; } } })(); -(function TestRegress650969_6() { +(function TestRegress650969_3_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); } var a; function inner() { - let a = 6; + var a, b; } } })(); -(function TestRegress650969_7() { +(function TestRegress650969_3_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -338,7 +569,19 @@ } })(); -(function TestRegress650969_8() { +(function TestRegress650969_4_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var a = 6, b; + } + } +})(); + +(function TestRegress650969_4_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -350,6 +593,18 @@ } })(); +(function TestRegress650969_4_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const a = 0, b = 0; + } + } +})(); + (function TestRegress650969_9() { for (var i = 0; i < 3; ++i) { if (i == 1) { @@ -360,3 +615,307 @@ } } })(); + +(function TestRegress650969_10() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner(...a) { + } + } +})(); + +(function TestRegress650969_11_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var [a, b] = [1, 2]; + } + } +})(); + +(function TestRegress650969_11_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let [a, b] = [1, 2]; + } + } +})(); + +(function TestRegress650969_11_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const [a, b] = [1, 2]; + } + } +})(); + +(function TestRegress650969_12_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var [b, a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_12_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let [b, a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_12_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const [b, a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_13_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var [b, ...a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_13_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let [b, ...a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_13_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const [b, ...a] = [1, 2]; + } + } +})(); + +(function TestRegress650969_14_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var {a, b} = {a: 1, b: 2}; + } + } +})(); + +(function TestRegress650969_14_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let {a, b} = {a: 1, b: 2}; + } + } +})(); + +(function TestRegress650969_14_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const {a, b} = {a: 1, b: 2}; + } + } +})(); + +(function TestRegress650969_15_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_15_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_15_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_16_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + var {a: {b}, c} = {a: {b: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_16_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + let {a: {b}, c} = {a: {b: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_16_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + const {a: {b}, c} = {a: {b: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_17_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + for (var a = 0; 0 == 1; ) { } + } + } +})(); + +(function TestRegress650969_17_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + for (let a = 0; 0 == 1; ) { } + } + } +})(); + +(function TestRegress650969_17_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a; + function inner() { + for (const a = 0; 0 == 1; ) { } + } + } +})(); + +// Regression tests for an intermediate stage where unresolved references were +// discarded too aggressively. +(function TestRegress650969_sidetrack_var() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a = 0; + function inner() { + return a; + var {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_sidetrack_let() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a = 0; + function inner() { + return a; + let {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); + +(function TestRegress650969_sidetrack_const() { + for (var i = 0; i < 3; ++i) { + if (i == 1) { + %OptimizeOsr(); + } + var a = 0; + function inner() { + return a; + const {b: {a}, c} = {b: {a: 1}, c: 2}; + } + } +})(); diff --git a/deps/v8/test/mjsunit/for-in-opt.js b/deps/v8/test/mjsunit/for-in-opt.js deleted file mode 100644 index bc59a1b087..0000000000 --- a/deps/v8/test/mjsunit/for-in-opt.js +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -"use strict"; - -// Test non-JSObject receiver. -function f(o) { - var result = []; - for (var i in o) { - result.push(i); - } - return result; -} - -assertEquals(["0"], f("a")); -assertEquals(["0"], f("a")); - -%OptimizeFunctionOnNextCall(f); -assertEquals(["0","1","2"], f("bla")); - -// Test the lazy deopt points. -var keys = ["a", "b", "c", "d"]; -var property_descriptor_keys = []; -var deopt_enum = false; -var deopt_property_descriptor = false; - -var handler = { - ownKeys() { - if (deopt_enum) { - %DeoptimizeFunction(f2); - deopt_enum = false; - } - return keys; - }, - getOwnPropertyDescriptor(target, k) { - if (deopt_property_descriptor) { - %DeoptimizeFunction(f2); - deopt_property_descriptor = false; - } - property_descriptor_keys.push(k); - return { enumerable: true, configurable: true } - }, -}; - - -var proxy = new Proxy({}, handler); -var o = {__proto__: proxy}; - -function f2(o) { - var result = []; - for (var i in o) { - result.push(i); - } - return result; -} - -function check_f2() { - assertEquals(keys, f2(o)); - assertEquals(keys, property_descriptor_keys); - property_descriptor_keys.length = 0; -} - -check_f2(); -check_f2(); - -// Test lazy deopt after ForInEnumerate -%OptimizeFunctionOnNextCall(f2); -deopt_enum = true; -check_f2(); - -// Test lazy deopt after FILTER_KEY -%OptimizeFunctionOnNextCall(f2); -deopt_property_descriptor = true; -check_f2(); - - -function f3(o) { - for (var i in o) { - } -} - -f3({__proto__:{x:1}}); -f3({__proto__:{x:1}}); - -%OptimizeFunctionOnNextCall(f3); -f3(undefined); -f3(null); - -// Reliable repro for an issue previously flushed out by GC stress. -var p = {x: "x"} - -function f4(o, p) { - var result = []; - for (var i in o) { - var j = p.x + "str"; - result.push(i); - } - return result; -} - -function check_f4() { - assertEquals(keys, f4(o, p)); - assertEquals(keys, property_descriptor_keys); - property_descriptor_keys.length = 0; -} - -check_f4(); -check_f4(); - -%OptimizeFunctionOnNextCall(f4); - -p.y = "y"; // Change map, cause eager deopt. -check_f4(); - -// Repro for Turbofan equivalent. -var x; -var count = 0; - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - %DeoptimizeFunction(f5); - } -} - -var handler3 = { - ownKeys() { return ["a", "b"] }, - getOwnPropertyDescriptor(target, k) { - if (k == "a") count++; - if (x) %ScheduleBreak() - return { enumerable: true, configurable: true } - } -}; - -var proxy3 = new Proxy({}, handler3); -var o3 = {__proto__: proxy3}; - -function f5() { - for (var p in o3) { - print(p); - } -} - -x = false; - -f5(); f5(); f5(); -%OptimizeFunctionOnNextCall(f5); -x = true; -count = 0; -Debug.setListener(listener); -f5(); -Debug.setListener(null); -assertEquals(1, count); diff --git a/deps/v8/test/mjsunit/for-in.js b/deps/v8/test/mjsunit/for-in.js index 29d7445351..94b39cfd57 100644 --- a/deps/v8/test/mjsunit/for-in.js +++ b/deps/v8/test/mjsunit/for-in.js @@ -25,8 +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: --noharmony-for-in - function props(x) { var array = []; for (var p in x) array.push(p); @@ -141,6 +139,13 @@ function props(x) { (function forInInitialize() { for (var hest = 'hest' in {}) { } assertEquals('hest', hest, "empty-no-override"); + + // Lexical variables are disallowed + assertThrows("for (const x = 0 in {});", SyntaxError); + assertThrows("for (let x = 0 in {});", SyntaxError); + + // In strict mode, var is disallowed + assertThrows("'use strict'; for (var x = 0 in {});", SyntaxError); })(); (function forInObjects() { diff --git a/deps/v8/test/mjsunit/harmony/async-debug-basic.js b/deps/v8/test/mjsunit/harmony/async-debug-basic.js deleted file mode 100644 index a4909729c5..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-basic.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-async-await --allow-natives-syntax --expose-debug-as debug - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -listenerComplete = false; -breakPointCount = 0; - -async function f() { - await (async function() { var a = "a"; await 1; debugger; })(); - - var b = "b"; - - assertTrue(listenerDone); - assertFalse(exception); - assertEquals(1, breakpointCount); -} - -function listener(event, exec_state, event_data, data) { - try { - if (event != Debug.DebugEvent.Break) return; - - breakpointCount++; - listenerDone = true; - assertEquals("a", exec_state.frame(0).evaluate("a")); - assertEquals("b", exec_state.frame(1).evaluate("b")); - assertEquals("c", exec_state.frame(2).evaluate("c")); - } catch (e) { - exception = e; - }; -}; - -Debug.setListener(listener); - -var c = "c"; -f(); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases.js b/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases.js deleted file mode 100644 index 76296ef7f1..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases.js +++ /dev/null @@ -1,216 +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-async-await --expose-debug-as debug - -Debug = debug.Debug - -let events = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Exception) return; - events++; -} - -async function thrower() { - throw "a"; // Exception a -} - -var reject = () => Promise.reject("b"); // Exception b - -async function awaitReturn() { await 1; return; } - -async function scalar() { return 1; } - -function nothing() { return 1; } - -function rejectConstructor() { - return new Promise((resolve, reject) => reject("c")); // Exception c -} - -async function argThrower(x = (() => { throw "d"; })()) { } // Exception d - -async function awaitThrow() { - await undefined; - throw "e"; // Exception e -} - -function constructorThrow() { - return new Promise((resolve, reject) => - Promise.resolve().then(() => - reject("f") // Exception f - ) - ); -} - -function suppressThrow() { - return thrower(); -} - -async function caught(producer) { - try { - await producer(); - } catch (e) { - } -} - -async function uncaught(producer) { - await producer(); -} - -async function indirectUncaught(producer) { - await uncaught(producer); -} - -async function indirectCaught(producer) { - try { - await uncaught(producer); - } catch (e) { - } -} - -function dotCatch(producer) { - Promise.resolve(producer()).catch(() => {}); -} - -function indirectReturnDotCatch(producer) { - (async() => producer())().catch(() => {}); -} - -function indirectAwaitDotCatch(producer) { - (async() => await producer())().catch(() => {}); -} - -function nestedDotCatch(producer) { - Promise.resolve(producer()).then().catch(() => {}); -} - -async function indirectAwaitCatch(producer) { - try { - await (() => producer())(); - } catch (e) { - } -} - -function switchCatch(producer) { - let resolve; - let promise = new Promise(r => resolve = r); - async function localCaught() { - try { - await promise; // force switching to localUncaught and back - await producer(); - } catch (e) { } - } - async function localUncaught() { - await undefined; - resolve(); - } - localCaught(); - localUncaught(); -} - -function switchDotCatch(producer) { - let resolve; - let promise = new Promise(r => resolve = r); - async function localCaught() { - await promise; // force switching to localUncaught and back - await producer(); - } - async function localUncaught() { - await undefined; - resolve(); - } - localCaught().catch(() => {}); - localUncaught(); -} - -let catches = [caught, - indirectCaught, - indirectAwaitCatch, - switchCatch, - switchDotCatch]; -let noncatches = [uncaught, indirectUncaught]; -let lateCatches = [dotCatch, - indirectReturnDotCatch, - indirectAwaitDotCatch, - nestedDotCatch]; - -let throws = [thrower, reject, argThrower, suppressThrow]; -let nonthrows = [awaitReturn, scalar, nothing]; -let lateThrows = [awaitThrow, constructorThrow]; -let uncatchable = [rejectConstructor]; - -let cases = []; - -for (let producer of throws.concat(lateThrows)) { - for (let consumer of catches) { - cases.push({ producer, consumer, expectedEvents: 1, caught: true }); - cases.push({ producer, consumer, expectedEvents: 0, caught: false }); - } -} - -for (let producer of throws.concat(lateThrows)) { - for (let consumer of noncatches) { - cases.push({ producer, consumer, expectedEvents: 1, caught: true }); - cases.push({ producer, consumer, expectedEvents: 1, caught: false }); - } -} - -for (let producer of nonthrows) { - for (let consumer of catches.concat(noncatches, lateCatches)) { - cases.push({ producer, consumer, expectedEvents: 0, caught: true }); - cases.push({ producer, consumer, expectedEvents: 0, caught: false }); - } -} - -for (let producer of uncatchable) { - for (let consumer of catches.concat(noncatches, lateCatches)) { - cases.push({ producer, consumer, expectedEvents: 1, caught: true }); - cases.push({ producer, consumer, expectedEvents: 1, caught: false }); - } -} - -for (let producer of lateThrows) { - for (let consumer of lateCatches) { - cases.push({ producer, consumer, expectedEvents: 1, caught: true }); - cases.push({ producer, consumer, expectedEvents: 0, caught: false }); - } -} - -for (let producer of throws) { - for (let consumer of lateCatches) { - cases.push({ producer, consumer, expectedEvents: 1, caught: true }); - cases.push({ producer, consumer, expectedEvents: 1, caught: false }); - } -} - - -function runPart(n) { - let subcases = cases.slice(n * cases.length / 4, - ((n + 1) * cases.length) / 4); - for (let {producer, consumer, expectedEvents, caught} of subcases) { - Debug.setListener(listener); - if (caught) { - Debug.setBreakOnException(); - } else { - Debug.setBreakOnUncaughtException(); - } - - events = 0; - consumer(producer); - %RunMicrotasks(); - - Debug.setListener(null); - if (caught) { - Debug.clearBreakOnException(); - } else { - Debug.clearBreakOnUncaughtException(); - } - if (expectedEvents != events) { - print(`producer ${producer} consumer ${consumer} expectedEvents ` + - `${expectedEvents} caught ${caught} events ${events}`); - quit(1); - } - } -} diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases1.js b/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases1.js deleted file mode 100644 index dfafa5af26..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases1.js +++ /dev/null @@ -1,8 +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-async-await --expose-debug-as debug -// Files: test/mjsunit/harmony/async-debug-caught-exception-cases.js - -runPart(1); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception.js b/deps/v8/test/mjsunit/harmony/async-debug-caught-exception.js deleted file mode 100644 index 047b421d3d..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception.js +++ /dev/null @@ -1,144 +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-async-await --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var log; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Exception) return; - try { - var line = exec_state.frame(0).sourceLineText(); - var match = /Exception (\w)/.exec(line); - assertNotNull(match); - log.push(match[1]); - } catch (e) { - exception = e; - } -} - -async function thrower() { - throw "a"; // Exception a -} - -async function caught_throw() { - try { - await thrower(); - } catch (e) { - assertEquals("a", e); - } -} - - -// Caught throw, events on any exception. -log = []; -Debug.setListener(listener); -Debug.setBreakOnException(); -caught_throw(); -%RunMicrotasks(); -Debug.setListener(null); -Debug.clearBreakOnException(); -assertEquals(["a"], log); -assertNull(exception); - -// Caught throw, events on uncaught exception. -log = []; -Debug.setListener(listener); -Debug.setBreakOnUncaughtException(); -caught_throw(); -%RunMicrotasks(); -Debug.setListener(null); -Debug.clearBreakOnUncaughtException(); -assertEquals([], log); -assertNull(exception); - -var reject = Promise.reject("b"); - -async function caught_reject() { - try { - await reject; - } catch (e) { - assertEquals("b", e); - } -} - -// Caught reject, events on any exception. -log = []; -Debug.setListener(listener); -Debug.setBreakOnException(); -caught_reject(); -%RunMicrotasks(); -Debug.setListener(null); -Debug.clearBreakOnException(); -assertEquals([], log); -assertNull(exception); - -// Caught reject, events on uncaught exception. -log = []; -Debug.setListener(listener); -Debug.setBreakOnUncaughtException(); -caught_reject(); -%RunMicrotasks(); -Debug.setListener(null); -Debug.clearBreakOnUncaughtException(); -assertEquals([], log); -assertNull(exception); - -log = []; -Debug.setListener(listener); -Debug.setBreakOnException(); - -// "rethrown" uncaught exceptions in return don't cause another event -async function propagate_inner() { return thrower(); } -async function propagate_outer() { return propagate_inner(); } - -propagate_outer(); -%RunMicrotasks(); -assertEquals(["a"], log); -assertNull(exception); - -// Also don't propagate if an await interceded -log = []; -async function propagate_await() { await 1; return thrower(); } -async function propagate_await_outer() { return propagate_await(); } -propagate_await_outer(); -%RunMicrotasks(); -assertEquals(["a"], log); -assertNull(exception); - -Debug.clearBreakOnException(); -Debug.setBreakOnUncaughtException(); - -log = []; -Promise.resolve().then(() => Promise.reject()).catch(() => log.push("d")); // Exception c -%RunMicrotasks(); -assertEquals(["d"], log); -assertNull(exception); - -Debug.clearBreakOnUncaughtException(); -Debug.setListener(null); - -// If devtools is turned on in the middle, then catch prediction -// could be wrong (here, it mispredicts the exception as caught), -// but shouldn't crash. - -log = []; - -var resolve; -var turnOnListenerPromise = new Promise(r => resolve = r); -async function confused() { - await turnOnListenerPromise; - throw foo -} -confused(); -Promise.resolve().then(() => { - Debug.setListener(listener); - Debug.setBreakOnUncaughtException(); - resolve(); -}); - -assertEquals([], log); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-abort-at-break.js b/deps/v8/test/mjsunit/harmony/async-debug-step-abort-at-break.js deleted file mode 100644 index be1f8056a8..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-abort-at-break.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B3 StepOut - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B4 StepNext - g(); // B2 StepIn - return a; -} - -f(); - -// Starting a new step action at an intermediate break point -// means that we will abort the current async step. -debugger; // B5 StepNext - -late_resolve(3); // B6 Continue - -%RunMicrotasks(); - -assertEquals(7, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-continue-at-break.js b/deps/v8/test/mjsunit/harmony/async-debug-step-continue-at-break.js deleted file mode 100644 index 5099b2f53e..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-continue-at-break.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B3 StepOut - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B4 StepNext - g(); // B2 StepIn - return a; // B6 StepNext -} // B7 Continue - -f(); - -// Continuing at an intermediate break point means that we will -// carry on with the current async step. -debugger; // B5 Continue - -late_resolve(3); - -%RunMicrotasks(); - -assertEquals(8, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-in-and-out.js b/deps/v8/test/mjsunit/harmony/async-debug-step-in-and-out.js deleted file mode 100644 index 30fe2d6053..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-in-and-out.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B3 StepOut - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B4 StepNext - g(); // B2 StepIn - return a; // B5 StepNext -} // B6 Continue - -f(); - -late_resolve(3); - -%RunMicrotasks(); - -assertEquals(7, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-in-out-out.js b/deps/v8/test/mjsunit/harmony/async-debug-step-in-out-out.js deleted file mode 100644 index c2f34bb029..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-in-out-out.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B3 StepOut - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B4 StepOut - g(); // B2 StepIn - return a; -} - -f(); - -late_resolve(3); // B5 Continue - -%RunMicrotasks(); - -assertEquals(6, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-in.js b/deps/v8/test/mjsunit/harmony/async-debug-step-in.js deleted file mode 100644 index 0a7de1a2a3..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-in.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B3 StepIn - function(res, rej) { - late_resolve = res; // B4 StepIn - } // B5 StepIn - ); -} // B6 StepIn - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepIn - await // B7 StepIn - g(); // B2 StepIn - return a; // B8 StepIn -} // B9 Continue - -f().then(value => assertEquals(4, value)); - -late_resolve(3); - -%RunMicrotasks(); - -assertEquals(10, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-nested.js b/deps/v8/test/mjsunit/harmony/async-debug-step-nested.js deleted file mode 100644 index adf7a51432..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-nested.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( // B4 StepOut - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f1() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B6 StepNext - f2(); // B2 StepIn - return a; // B7 StepNext -} // B8 Continue - -async function f2() { - var b = - await // B5 StepOut - g(); // B3 StepIn - return b; -} - -f1(); - -late_resolve(3); - -%RunMicrotasks(); - -assertEquals(9, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-next-constant.js b/deps/v8/test/mjsunit/harmony/async-debug-step-next-constant.js deleted file mode 100644 index cea86d7a2f..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-next-constant.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B3 StepNext - 5; // B2 StepNext - return a; // B4 StepNext -} // B5 Continue - -f(); - -%RunMicrotasks(); - -assertEquals(6, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-next.js b/deps/v8/test/mjsunit/harmony/async-debug-step-next.js deleted file mode 100644 index 952d88dd85..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-next.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += // B1 StepNext - await // B3 StepNext - g(); // B2 StepNext - return a; // B4 StepNext -} // B5 Continue - -f(); - -late_resolve(3); - -%RunMicrotasks(); - -assertEquals(6, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-step-out.js b/deps/v8/test/mjsunit/harmony/async-debug-step-out.js deleted file mode 100644 index 41779acb54..0000000000 --- a/deps/v8/test/mjsunit/harmony/async-debug-step-out.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --harmony-async-await - -var Debug = debug.Debug; -var step_count = 0; - -function listener(event, execState, eventData, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var line = execState.frame(0).sourceLineText(); - print(line); - var [match, expected_count, step] = /\/\/ B(\d) (\w+)$/.exec(line); - assertEquals(step_count++, parseInt(expected_count)); - if (step != "Continue") execState.prepareStep(Debug.StepAction[step]); - } catch (e) { - print(e, e.stack); - quit(1); - } -} - -Debug.setListener(listener); - -var late_resolve; - -function g() { - return new Promise( - function(res, rej) { - late_resolve = res; - } - ); -} - -async function f() { - var a = 1; - debugger; // B0 StepNext - a += await g(); // B1 StepOut - return a; -} - -f(); - -late_resolve(3); // B2 Continue - -%RunMicrotasks(); - -assertEquals(3, step_count); diff --git a/deps/v8/test/mjsunit/harmony/async-function-debug-scopes.js b/deps/v8/test/mjsunit/harmony/async-function-debug-scopes.js index 3d72549d2a..b9b92841e7 100644 --- a/deps/v8/test/mjsunit/harmony/async-function-debug-scopes.js +++ b/deps/v8/test/mjsunit/harmony/async-function-debug-scopes.js @@ -6,8 +6,6 @@ var Debug = debug.Debug; -var AsyncFunction = (async function() {}).constructor; - async function thrower() { throw 'Exception'; } async function test(name, func, args, handler, continuation) { diff --git a/deps/v8/test/mjsunit/harmony/debug-async-break-on-stack.js b/deps/v8/test/mjsunit/harmony/debug-async-break-on-stack.js deleted file mode 100644 index d3d9d8bef6..0000000000 --- a/deps/v8/test/mjsunit/harmony/debug-async-break-on-stack.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug -// Flags: --harmony-async-await --allow-natives-syntax - -var Debug = debug.Debug; - -function assertEqualsAsync(expected, run, msg) { - var actual; - var hadValue = false; - var hadError = false; - var promise = run(); - - if (typeof promise !== "object" || typeof promise.then !== "function") { - throw new MjsUnitAssertionError( - "Expected " + run.toString() + - " to return a Promise, but it returned " + promise); - } - - promise.then(function(value) { hadValue = true; actual = value; }, - function(error) { hadError = true; actual = error; }); - - assertFalse(hadValue || hadError); - - %RunMicrotasks(); - - if (hadError) throw actual; - - assertTrue( - hadValue, "Expected '" + run.toString() + "' to produce a value"); - - assertEquals(expected, actual, msg); -} - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - print(line); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - - -async function g() { - setbreaks(); - throw 1; // B1 -} - -async function f() { - try { - await g(); - } catch (e) {} - return 2; // B2 -} - -function setbreaks() { - Debug.setListener(listener); - Debug.setBreakPoint(g, 2); - Debug.setBreakPoint(f, 4); -} - -f(); - -%RunMicrotasks(); - -assertEqualsAsync(2, async () => break_count); -assertEqualsAsync(null, async () => exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/harmony/debug-async-break.js b/deps/v8/test/mjsunit/harmony/debug-async-break.js deleted file mode 100644 index 3b6b71baca..0000000000 --- a/deps/v8/test/mjsunit/harmony/debug-async-break.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug -// Flags: --harmony-async-await --allow-natives-syntax - -var Debug = debug.Debug; - -function assertEqualsAsync(expected, run, msg) { - var actual; - var hadValue = false; - var hadError = false; - var promise = run(); - - if (typeof promise !== "object" || typeof promise.then !== "function") { - throw new MjsUnitAssertionError( - "Expected " + run.toString() + - " to return a Promise, but it returned " + promise); - } - - promise.then(function(value) { hadValue = true; actual = value; }, - function(error) { hadError = true; actual = error; }); - - assertFalse(hadValue || hadError); - - %RunMicrotasks(); - - if (hadError) throw actual; - - assertTrue( - hadValue, "Expected '" + run.toString() + "' to produce a value"); - - assertEquals(expected, actual, msg); -} - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -async function g() { - throw 1; -} - -async function f() { - try { - await g(); // B1 - } catch (e) {} - assertEquals(2, break_count); // B2 - return 1; // B3 -} - -Debug.setBreakPoint(f, 2); -Debug.setBreakPoint(f, 4); -Debug.setBreakPoint(f, 5); - -f(); - -%RunMicrotasks(); - -assertEqualsAsync(3, async () => break_count); -assertEqualsAsync(null, async () => exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/harmony/debug-async-function-async-task-event.js b/deps/v8/test/mjsunit/harmony/debug-async-function-async-task-event.js deleted file mode 100644 index 90e13d8659..0000000000 --- a/deps/v8/test/mjsunit/harmony/debug-async-function-async-task-event.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-async-await --expose-debug-as debug --allow-natives-syntax - -// The test observes the callbacks that async/await makes to the inspector -// to make accurate stack traces. The pattern is based on saving a stack once -// with enqueueRecurring and restoring it multiple times. - -// Additionally, the limited number of events is an indirect indication that -// we are not doing extra Promise processing that could be associated with memory -// leaks (v8:5380). In particular, no stacks are saved and restored for extra -// Promise handling on throwaway Promises. - -// TODO(littledan): Write a test that demonstrates that the memory leak in -// the exception case is fixed. - -Debug = debug.Debug; - -var base_id = -1; -var exception = null; -var expected = [ - 'enqueueRecurring #1', - 'willHandle #1', - 'then #1', - 'didHandle #1', - 'willHandle #1', - 'then #2', - 'cancel #1', - 'didHandle #1', -]; - -function assertLog(msg) { - print(msg); - assertTrue(expected.length > 0); - assertEquals(expected.shift(), msg); - if (!expected.length) { - Debug.setListener(null); - } -} - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.AsyncTaskEvent) return; - try { - if (base_id < 0) - base_id = event_data.id(); - var id = event_data.id() - base_id + 1; - assertTrue("async function" == event_data.name()); - assertLog(event_data.type() + " #" + id); - } catch (e) { - print(e + e.stack) - exception = e; - } -} - -Debug.setListener(listener); - -var resolver; -var p = new Promise(function(resolve, reject) { - resolver = resolve; -}); - -async function main() { - await p; - assertLog("then #1"); - await undefined; - assertLog("then #2"); -} -main(); -resolver(); - -%RunMicrotasks(); - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/harmony/for-in.js b/deps/v8/test/mjsunit/harmony/for-in.js deleted file mode 100644 index 58e343b903..0000000000 --- a/deps/v8/test/mjsunit/harmony/for-in.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --harmony-for-in - -assertThrows("for (var x = 0 in {});", SyntaxError); -assertThrows("for (const x = 0 in {});", SyntaxError); -assertThrows("for (let x = 0 in {});", SyntaxError); diff --git a/deps/v8/test/mjsunit/harmony/generators-turbo.js b/deps/v8/test/mjsunit/harmony/generators-turbo.js deleted file mode 100644 index 61334b93f8..0000000000 --- a/deps/v8/test/mjsunit/harmony/generators-turbo.js +++ /dev/null @@ -1,667 +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: --ignition --harmony-do-expressions -// Flags: --allow-natives-syntax --turbo --turbo-from-bytecode - - -// This file is identical to mjsunit/harmony/generators.js, except for its Flags -// lines. The purpose is to explicitly mention --turbo-from-bytecode such that -// Clusterfuzz can thoroughly test the new generators implementation. - - -function MaybeOptimizeOrDeoptimize(f) { - let x = Math.random(); // --random-seed makes this deterministic - if (x <= 0.33) { - %OptimizeFunctionOnNextCall(f); - } else if (x <= 0.66) { - %DeoptimizeFunction(f); - } -} - -function Next(generator, ...args) { - MaybeOptimizeOrDeoptimize(%GeneratorGetFunction(generator)); - return generator.next(...args); -} - -function Return(generator, ...args) { - MaybeOptimizeOrDeoptimize(%GeneratorGetFunction(generator)); - return generator.return(...args); -} - -function Throw(generator, ...args) { - MaybeOptimizeOrDeoptimize(%GeneratorGetFunction(generator)); - return generator.throw(...args); -} - - -{ // yield in try-catch - - let g = function*() { - try {yield 1} catch (error) {assertEquals("caught", error)} - }; - - assertThrowsEquals(() => Throw(g(), "not caught"), "not caught"); - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Throw(x, "caught")); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - assertThrowsEquals(() => Throw(x, "not caught"), "not caught"); - } -} - - -{ // return that doesn't close - let g = function*() { try {return 42} finally {yield 43} }; - - { - let x = g(); - assertEquals({value: 43, done: false}, Next(x)); - assertEquals({value: 42, done: true}, Next(x)); - } -} - - -{ // return that doesn't close - let x; - let g = function*() { try {return 42} finally {Throw(x, 666)} }; - - { - x = g(); - assertThrows(() => Next(x), TypeError); // still executing - } -} - - -{ // yield in try-finally, finally clause performs return - - let g = function*() { try {yield 42} finally {return 13} }; - - { // "return" closes at suspendedStart - let x = g(); - assertEquals({value: 666, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 42)); - assertThrowsEquals(() => Throw(x, 43), 43); - assertEquals({value: 42, done: true}, Return(x, 42)); - } - - { // "throw" closes at suspendedStart - let x = g(); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: undefined, done: true}, Next(x, 42)); - assertEquals({value: 43, done: true}, Return(x, 43)); - assertThrowsEquals(() => Throw(x, 44), 44); - } - - { // "next" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 13, done: true}, Next(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertThrowsEquals(() => Throw(x, 666), 666); - } - - { // "return" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 13, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertEquals({value: 666, done: true}, Return(x, 666)); - } - - { // "throw" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 13, done: true}, Throw(x, 666)); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: undefined, done: true}, Next(x, 666)); - } -} - - -{ // yield in try-finally, finally clause doesn't perform return - - let g = function*() { try {yield 42} finally {13} }; - - { // "return" closes at suspendedStart - let x = g(); - assertEquals({value: 666, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 42)); - assertThrowsEquals(() => Throw(x, 43), 43); - assertEquals({value: 42, done: true}, Return(x, 42)); - } - - { // "throw" closes at suspendedStart - let x = g(); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: undefined, done: true}, Next(x, 42)); - assertEquals({value: 43, done: true}, Return(x, 43)); - assertThrowsEquals(() => Throw(x, 44), 44); - } - - { // "next" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: 42, done: true}, Return(x, 42)); - } - - { // "return" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 666, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertThrowsEquals(() => Throw(x, 44), 44); - assertEquals({value: 42, done: true}, Return(x, 42)); - } - - { // "throw" closes at suspendedYield - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: undefined, done: true}, Next(x, 666)); - assertThrowsEquals(() => Throw(x, 666), 666); - assertEquals({value: 42, done: true}, Return(x, 42)); - } -} - - -{ // yield in try-finally, finally clause yields and performs return - - let g = function*() { try {yield 42} finally {yield 43; return 13} }; - - { - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Return(x, 666)); - assertEquals({value: 13, done: true}, Next(x)); - assertEquals({value: 666, done: true}, Return(x, 666)); - } - - { - let x = g(); - assertEquals({value: 666, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x)); - assertEquals({value: 666, done: true}, Return(x, 666)); - } -} - - -{ // yield in try-finally, finally clause yields and doesn't perform return - - let g = function*() { try {yield 42} finally {yield 43; 13} }; - - { - let x = g(); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Return(x, 666)); - assertEquals({value: 666, done: true}, Next(x)); - assertEquals({value: 5, done: true}, Return(x, 5)); - } - - { - let x = g(); - assertEquals({value: 666, done: true}, Return(x, 666)); - assertEquals({value: undefined, done: true}, Next(x)); - assertEquals({value: 666, done: true}, Return(x, 666)); - } -} - - -{ // yield*, finally clause performs return - - let h = function*() { try {yield 42} finally {yield 43; return 13} }; - let g = function*() { yield 1; yield yield* h(); }; - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Next(x, 666)); - assertEquals({value: 13, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Return(x, 666)); - assertEquals({value: 13, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Throw(x, 666)); - assertEquals({value: 13, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - } -} - - -{ // yield*, finally clause does not perform return - - let h = function*() { try {yield 42} finally {yield 43; 13} }; - let g = function*() { yield 1; yield yield* h(); }; - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Next(x, 666)); - assertEquals({value: undefined, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Return(x, 44)); - assertEquals({value: 44, done: false}, Next(x)); - assertEquals({value: undefined, done: true}, Next(x)); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 42, done: false}, Next(x)); - assertEquals({value: 43, done: false}, Throw(x, 666)); - assertThrowsEquals(() => Next(x), 666); - } -} - - -{ // yield*, .return argument is final result - - function* inner() { - yield 2; - } - - function* g() { - yield 1; - return yield* inner(); - } - - { - let x = g(); - assertEquals({value: 1, done: false}, Next(x)); - assertEquals({value: 2, done: false}, Next(x)); - assertEquals({value: 42, done: true}, Return(x, 42)); - } -} - - -// More or less random tests from here on. - - -{ - function* foo() { } - let g = foo(); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { return new.target } - let g = foo(); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { throw 666; return 42} - let g = foo(); - assertThrowsEquals(() => Next(g), 666); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo(a) { return a; } - let g = foo(42); - assertEquals({value: 42, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo(a) { a.iwashere = true; return a; } - let x = {}; - let g = foo(x); - assertEquals({value: {iwashere: true}, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let a = 42; - function* foo() { return a; } - let g = foo(); - assertEquals({value: 42, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let a = 40; - function* foo(b) { return a + b; } - let g = foo(2); - assertEquals({value: 42, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let a = 40; - function* foo(b) { a--; b++; return a + b; } - let g = foo(2); - assertEquals({value: 42, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let g; - function* foo() { Next(g) } - g = foo(); - assertThrows(() => Next(g), TypeError); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { yield 2; yield 3; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - - -{ - function* foo() { yield 2; if (true) { yield 3 }; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { yield 2; if (true) { yield 3; yield 4 } } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { yield 2; if (false) { yield 3 }; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { yield 2; while (true) { yield 3 }; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); -} - -{ - function* foo() { yield 2; (yield 3) + 42; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); -} - -{ - function* foo() { yield 2; (do {yield 3}) + 42; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); -} - -{ - function* foo() { yield 2; return (yield 3) + 42; yield 4 } - g = foo(); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 42, done: true}, Next(g, 0)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let x = 42; - function* foo() { - yield x; - for (let x in {a: 1, b: 2}) { - let i = 2; - yield x; - yield i; - do { - yield i; - } while (i-- > 0); - } - yield x; - return 5; - } - g = foo(); - assertEquals({value: 42, done: false}, Next(g)); - assertEquals({value: 'a', done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 1, done: false}, Next(g)); - assertEquals({value: 0, done: false}, Next(g)); - assertEquals({value: 'b', done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 1, done: false}, Next(g)); - assertEquals({value: 0, done: false}, Next(g)); - assertEquals({value: 42, done: false}, Next(g)); - assertEquals({value: 5, done: true}, Next(g)); -} - -{ - let a = 3; - function* foo() { - let b = 4; - yield 1; - { let c = 5; yield 2; yield a; yield b; yield c; } - } - g = foo(); - assertEquals({value: 1, done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 3, done: false}, Next(g)); - assertEquals({value: 4, done: false}, Next(g)); - assertEquals({value: 5, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - yield 42; - } - g = foo(); - for (let i = 0; i < 100; ++i) { - assertEquals({value: 42, done: false}, i%25 === 0 ? Next(g) : g.next()); - } - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - function* foo() { - for (let i = 0; i < 3; ++i) { - let j = 0 - yield i; - do { - yield (i + 10); - } while (++j < 2); - } - } - g = foo(); - assertEquals({value: 0, done: false}, Next(g)); - assertEquals({value: 10, done: false}, Next(g)); - assertEquals({value: 10, done: false}, Next(g)); - assertEquals({value: 1, done: false}, Next(g)); - assertEquals({value: 11, done: false}, Next(g)); - assertEquals({value: 11, done: false}, Next(g)); - assertEquals({value: 2, done: false}, Next(g)); - assertEquals({value: 12, done: false}, Next(g)); - assertEquals({value: 12, done: false}, Next(g)); - assertEquals({value: undefined, done: true}, Next(g)); -} - -{ - let foo = function*() { - while (true) { - if (true || false) yield 42; - continue; - } - } - g = foo(); - assertEquals({value: 42, done: false}, Next(g)); - assertEquals({value: 42, done: false}, Next(g)); - assertEquals({value: 42, done: false}, Next(g)); -} - -{ - let foo = function*() { - yield* (function*() { yield 42; }()); - assertUnreachable(); - } - g = foo(); - assertEquals({value: 42, done: false}, Next(g)); - assertEquals({value: 23, done: true}, Return(g, 23)); -} - -{ - let iterable = { - [Symbol.iterator]() { - return { next() { return {} } }; - } - }; - let foo = function*() { yield* iterable }; - g = foo(); - g.next(); - assertThrows(() => Throw(g), TypeError); -} diff --git a/deps/v8/test/mjsunit/harmony/private.js b/deps/v8/test/mjsunit/harmony/private.js index 7d34db40a8..cd65af1c70 100644 --- a/deps/v8/test/mjsunit/harmony/private.js +++ b/deps/v8/test/mjsunit/harmony/private.js @@ -295,7 +295,7 @@ function TestKeyDelete(obj) { } -var objs = [{}, [], Object.create(null), Object(1), new Map, function(){}] +var objs = [{}, [], Object.create({}), Object(1), new Map, function(){}] for (var i in objs) { var obj = objs[i] diff --git a/deps/v8/test/mjsunit/harmony/sloppy-implicit-block-function.js b/deps/v8/test/mjsunit/harmony/sloppy-implicit-block-function.js deleted file mode 100644 index 0702320864..0000000000 --- a/deps/v8/test/mjsunit/harmony/sloppy-implicit-block-function.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: --no-harmony-restrictive-declarations - -// ES#sec-functiondeclarations-in-ifstatement-statement-clauses -// Annex B 3.4 FunctionDeclarations in IfStatement Statement Clauses -// In sloppy mode, function declarations in if statements act like -// they have a block around them. Prohibited in strict mode. -(function() { - assertEquals(undefined, f); - if (false) function f() { }; - assertEquals(undefined, f); -})(); - -(function() { - assertEquals(undefined, f); - if (true) function f() { }; - assertEquals('function', typeof f); -})(); - -(function() { - assertEquals(undefined, f); - if (true) {} else function f() { }; - assertEquals(undefined, f); -})(); - -(function() { - assertEquals(undefined, f); - if (false) {} else function f() { }; - assertEquals('function', typeof f); -})(); - -// For legacy reasons, we also support these types of semantics as -// the body of a for or with statement. -(function() { - for (;false;) function f() { }; - assertEquals(undefined, f); -})(); - -(function() { - for (var x in {}) function f() { }; - assertEquals(undefined, f); -})(); - -(function() { - var x; - for (x in {}) function f() { }; - assertEquals(undefined, f); -})(); - -(function() { - for (var i = 0; i < 1; i++) function f() { }; - assertEquals('function', typeof f); -})(); - -(function() { - for (var x in {a: 1}) function f() { }; - assertEquals('function', typeof f); -})(); - -(function() { - var x; - for (x in {a: 1}) function f() { }; - assertEquals('function', typeof f); -})(); - -(function() { - with ({}) function f() { }; - assertEquals('function', typeof f); -})(); - -(function() { - do function f() {} while (0); - assertEquals('function', typeof f); -})(); - -// Labeled function declarations undergo the same hoisting/FiB semantics as if -// they were unalbeled. -(function() { - function bar() { - return f; - x: function f() {} - } - assertEquals('function', typeof bar()); -})(); - -(function() { - function bar() { - return f; - { - x: function f() {} - } - } - assertEquals(undefined, bar()); -})(); diff --git a/deps/v8/test/mjsunit/ignition/debug-break-mixed-stack.js b/deps/v8/test/mjsunit/ignition/debug-break-mixed-stack.js deleted file mode 100644 index 878a918d5c..0000000000 --- a/deps/v8/test/mjsunit/ignition/debug-break-mixed-stack.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug - -var exception = null; -var frame_depth = 10; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals(frame_depth, exec_state.frameCount()); - assertTrue(/\/\/ Break$/.test(exec_state.frame(0).sourceLineText())); - assertEquals(12 - frame_depth, exec_state.frame(0).evaluate("x").value()); - frame_depth--; - } catch (e) { - exception = e; - print(e + e.stack); - } -} - -function ChooseCode(f, x) { - if (x == 1) { - Debug.setBreakPoint(factorial, 4); - } - switch (x % 2) { - case 0: - %BaselineFunctionOnNextCall(f); - break; - case 1: - %InterpretFunctionOnNextCall(f); - break; - } -} - -function factorial(x) { - ChooseCode(factorial, x); - if (x == 1) return 1; - var factor = factorial(x - 1); - return x * factor; // Break -} - -Debug.setListener(listener); - -assertEquals(3628800, factorial(10)); - -Debug.setListener(null); -assertNull(exception); -assertEquals(1, frame_depth); diff --git a/deps/v8/test/mjsunit/ignition/debug-break-on-stack.js b/deps/v8/test/mjsunit/ignition/debug-break-on-stack.js deleted file mode 100644 index d2577b38de..0000000000 --- a/deps/v8/test/mjsunit/ignition/debug-break-on-stack.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - print(line); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - - -function g() { - setbreaks(); - throw 1; // B1 -} - -function f() { - try { - g(); - } catch (e) {} - return 2; // B2 -} - -function setbreaks() { - Debug.setListener(listener); - Debug.setBreakPoint(g, 2, 0); - Debug.setBreakPoint(f, 4, 0); -} - -f(); - -assertEquals(2, break_count); -assertNull(exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/ignition/debug-break.js b/deps/v8/test/mjsunit/ignition/debug-break.js deleted file mode 100644 index 8237d4a552..0000000000 --- a/deps/v8/test/mjsunit/ignition/debug-break.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -var break_count = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_count++; - var line = exec_state.frame(0).sourceLineText(); - assertTrue(line.indexOf(`B${break_count}`) > 0); - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function g() { - throw 1; -} - -function f() { - try { - g(); // B1 - } catch (e) {} - assertEquals(2, break_count); // B2 - return 1; // B3 -} - -Debug.setBreakPoint(f, 2, 0); -Debug.setBreakPoint(f, 4, 1); -Debug.setBreakPoint(f, 5, 1); - -f(); - -assertEquals(3, break_count); -assertNull(exception); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/ignition/debug-scope-on-return.js b/deps/v8/test/mjsunit/ignition/debug-scope-on-return.js deleted file mode 100644 index 5be6de6e65..0000000000 --- a/deps/v8/test/mjsunit/ignition/debug-scope-on-return.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -// Check that the we are still in function context when we break on return. - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - // Access scope details to check the context is correct. - var scope_count = exec_state.frame().scopeCount(); - // Do steps until we reach the global scope again. - exec_state.prepareStep(Debug.StepAction.StepIn); - } -} - -Debug.setListener(listener); - -function f() { - debugger; - - L: with ({x:12}) { - break L; - } - - return; -} -f(); diff --git a/deps/v8/test/mjsunit/ignition/debug-step-mixed-stack.js b/deps/v8/test/mjsunit/ignition/debug-step-mixed-stack.js deleted file mode 100644 index 6566431175..0000000000 --- a/deps/v8/test/mjsunit/ignition/debug-step-mixed-stack.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug - -var exception = null; -var frame_depth = 11; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals(frame_depth, exec_state.frameCount()); - assertTrue(/\/\/ Break$/.test(exec_state.frame(0).sourceLineText())); - assertEquals(12 - frame_depth, exec_state.frame(0).evaluate("x").value()); - if (frame_depth > 2) exec_state.prepareStep(Debug.StepAction.StepOut); - frame_depth--; - } catch (e) { - exception = e; - print(e + e.stack); - } -} - -function ChooseCode(f, x) { - switch (x % 2) { - case 0: - %BaselineFunctionOnNextCall(f); - break; - case 1: - %InterpretFunctionOnNextCall(f); - break; - } -} - -function factorial(x) { - ChooseCode(factorial, x); - if (x == 1) { - debugger; // Break - return 1; - } - var factor = factorial(x - 1); - return x * factor; // Break -} - -Debug.setListener(listener); - -assertEquals(3628800, factorial(10)); - -Debug.setListener(null); -assertNull(exception); -assertEquals(1, frame_depth); diff --git a/deps/v8/test/mjsunit/ignition/debugger-statement.js b/deps/v8/test/mjsunit/ignition/debugger-statement.js deleted file mode 100644 index 9c2204e4d2..0000000000 --- a/deps/v8/test/mjsunit/ignition/debugger-statement.js +++ /dev/null @@ -1,31 +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: --ignition-filter=f --expose-debug-as debug - -var Debug = debug.Debug; - -var break_count = 0; - -function f() { - debugger; -} - -function listener(event, exec_data) { - if (event != Debug.DebugEvent.Break) return; - break_count++; -} - -f(); -assertEquals(0, break_count); - -Debug.setListener(listener); - -f(); -assertEquals(1, break_count); - -Debug.setListener(null); - -f(); -assertEquals(1, break_count); diff --git a/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js b/deps/v8/test/mjsunit/ignition/osr-from-bytecode.js index d4f40bad79..8f9c1be3af 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 --turbo-from-bytecode +// Flags: --allow-natives-syntax --ignition --ignition-osr function f() { for (var i = 0; i < 10; i++) { diff --git a/deps/v8/test/mjsunit/ignition/regress-662418.js b/deps/v8/test/mjsunit/ignition/regress-662418.js new file mode 100644 index 0000000000..5ac3ff1952 --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/regress-662418.js @@ -0,0 +1,18 @@ +// 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. + +var valueof_calls = 0; + +var v = { + toString: function() { + var z = w++; + } +}; +var w = { + valueOf: function() { + valueof_calls++; + } +}; +var x = { [v]: 'B' }; +assertTrue(valueof_calls == 1); diff --git a/deps/v8/test/mjsunit/ignition/regress-664146.js b/deps/v8/test/mjsunit/ignition/regress-664146.js new file mode 100644 index 0000000000..415713a92f --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/regress-664146.js @@ -0,0 +1,27 @@ +// 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. + +var foo_call_count = 0; +function foo() { foo_call_count++; } + +// These || and && combinations shouldn't call foo(). +(true || foo()) ? 1 : 2; +assertTrue(foo_call_count == 0); +(false && foo()) ? 1 : 2; +assertTrue(foo_call_count == 0); + +// These || and && combinations should all call foo(). +(foo() || true) ? 1 : 2; +assertTrue(foo_call_count == 1); +(false || foo()) ? 1 : 2; +assertTrue(foo_call_count == 2); +(foo() || false) ? 1 : 2; +assertTrue(foo_call_count == 3); + +(true && foo()) ? 1 : 2; +assertTrue(foo_call_count == 4); +(foo() && true) ? 1 : 2; +assertTrue(foo_call_count == 5); +(foo() && false) ? 1 : 2; +assertTrue(foo_call_count == 6); diff --git a/deps/v8/test/mjsunit/ignition/regress-672027.js b/deps/v8/test/mjsunit/ignition/regress-672027.js new file mode 100644 index 0000000000..b0182675cf --- /dev/null +++ b/deps/v8/test/mjsunit/ignition/regress-672027.js @@ -0,0 +1,17 @@ +// 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: --max-old-space-size=100 + +(function() { + var source = "[]" + for (var i = 0; i < 300; i++) { + source += ".concat(["; + for (var j = 0; j < 1000; j++) { + source += "0,"; + } + source += "0])" + } + eval(source); +})(); diff --git a/deps/v8/test/mjsunit/invalid-lhs.js b/deps/v8/test/mjsunit/invalid-lhs.js index d28dc9ccf8..92929b68e5 100644 --- a/deps/v8/test/mjsunit/invalid-lhs.js +++ b/deps/v8/test/mjsunit/invalid-lhs.js @@ -33,7 +33,7 @@ assertThrows("12 = 12", ReferenceError); assertThrows("x++ = 12", ReferenceError); assertThrows("eval('var x') = 12", ReferenceError); assertThrows("if (false) 12 = 12", ReferenceError); -assertDoesNotThrow("if (false) eval('var x') = 12", ReferenceError); +assertDoesNotThrow("if (false) eval('var x') = 12"); // Pre- and post-fix operations: assertThrows("12++", ReferenceError); @@ -46,20 +46,20 @@ assertThrows("if (false) 12++", ReferenceError); assertThrows("if (false) 12--", ReferenceError); assertThrows("if (false) ++12", ReferenceError); assertThrows("if (false) --12", ReferenceError); -assertDoesNotThrow("if (false) ++(eval('12'))", ReferenceError); -assertDoesNotThrow("if (false) (eval('12'))++", ReferenceError); +assertDoesNotThrow("if (false) ++(eval('12'))"); +assertDoesNotThrow("if (false) (eval('12'))++"); // For in: assertThrows("for (12 in [1]) print(12);", SyntaxError); assertThrows("for (eval('var x') in [1]) print(12);", ReferenceError); assertThrows("if (false) for (12 in [1]) print(12);", SyntaxError); -assertDoesNotThrow("if (false) for (eval('0') in [1]) print(12);", ReferenceError); +assertDoesNotThrow("if (false) for (eval('0') in [1]) print(12);"); // For: assertThrows("for (12 = 1;;) print(12);", ReferenceError); assertThrows("for (eval('var x') = 1;;) print(12);", ReferenceError); assertThrows("if (false) for (12 = 1;;) print(12);", ReferenceError); -assertDoesNotThrow("if (false) for (eval('var x') = 1;;) print(12);", ReferenceError); +assertDoesNotThrow("if (false) for (eval('var x') = 1;;) print(12);"); // Assignments to 'this'. assertThrows("this = 42", ReferenceError); diff --git a/deps/v8/test/mjsunit/lazy-inner-functions.js b/deps/v8/test/mjsunit/lazy-inner-functions.js index 127d349b1b..dfcd6db853 100644 --- a/deps/v8/test/mjsunit/lazy-inner-functions.js +++ b/deps/v8/test/mjsunit/lazy-inner-functions.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: --min-preparse-length 1 +// Flags: --min-preparse-length=1 (function TestLazyInnerFunctionCallsEval() { var i = (function eager_outer() { diff --git a/deps/v8/test/mjsunit/math-floor-part2.js b/deps/v8/test/mjsunit/math-floor-part2.js index eab3ab3a2b..658979841a 100644 --- a/deps/v8/test/mjsunit/math-floor-part2.js +++ b/deps/v8/test/mjsunit/math-floor-part2.js @@ -109,6 +109,7 @@ function test() { // Test in a loop to cover the custom IC and GC-related issues. -for (var i = 0; i < 100; i++) { +for (var i = 0; i < 10; i++) { test(); + new Array(i * 10000); } diff --git a/deps/v8/test/mjsunit/math-floor-part3.js b/deps/v8/test/mjsunit/math-floor-part3.js index 6a536657ac..4ce645ea0d 100644 --- a/deps/v8/test/mjsunit/math-floor-part3.js +++ b/deps/v8/test/mjsunit/math-floor-part3.js @@ -111,6 +111,7 @@ function test() { // Test in a loop to cover the custom IC and GC-related issues. -for (var i = 0; i < 100; i++) { +for (var i = 0; i < 10; i++) { test(); + new Array(i * 10000); } diff --git a/deps/v8/test/mjsunit/math-floor-part4.js b/deps/v8/test/mjsunit/math-floor-part4.js index 9ae83d87c6..499200288e 100644 --- a/deps/v8/test/mjsunit/math-floor-part4.js +++ b/deps/v8/test/mjsunit/math-floor-part4.js @@ -93,11 +93,11 @@ function test() { // Test in a loop to cover the custom IC and GC-related issues. -for (var i = 0; i < 100; i++) { +for (var i = 0; i < 10; i++) { test(); + new Array(i * 10000); } - // Regression test for a bug where a negative zero coming from Math.floor // was not properly handled by other operations. function floorsum(i, n) { diff --git a/deps/v8/test/mjsunit/mirror-script.js b/deps/v8/test/mjsunit/mirror-script.js index 635c658ac3..74f37f80bb 100644 --- a/deps/v8/test/mjsunit/mirror-script.js +++ b/deps/v8/test/mjsunit/mirror-script.js @@ -83,7 +83,6 @@ function testScriptMirror(f, file_name, file_lines, type, compilation_type, // Test the script mirror for different functions. -testScriptMirror(function(){}, 'mirror-script.js', 90, 2, 0); -testScriptMirror(Math.random, 'native math.js', -1, 0, 0); -testScriptMirror(eval('(function(){})'), null, 1, 2, 1, '(function(){})', 87); -testScriptMirror(eval('(function(){\n })'), null, 2, 2, 1, '(function(){\n })', 88); +testScriptMirror(function(){}, 'mirror-script.js', 89, 2, 0); +testScriptMirror(eval('(function(){})'), null, 1, 2, 1, '(function(){})', 86); +testScriptMirror(eval('(function(){\n })'), null, 2, 2, 1, '(function(){\n })', 87); diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 6a7c2da9e4..d4759a281f 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -117,6 +117,9 @@ var assertUnoptimized; // Assert that a string contains another expected substring. var assertContains; +// Assert that a string matches a given regex. +var assertMatches; + (function () { // Scope for utility functions. @@ -201,6 +204,11 @@ var assertContains; } + function failWithMessage(message) { + throw new MjsUnitAssertionError(message); + } + + function fail(expectedText, found, name_opt) { var message = "Fail" + "ure"; if (name_opt) { @@ -208,8 +216,12 @@ var assertContains; message += " (" + name_opt + ")"; } - message += ": expected <" + expectedText + - "> found <" + PrettyPrint(found) + ">"; + var foundText = PrettyPrint(found); + if (expectedText.length <= 40 && foundText.length <= 40) { + message += ": expected <" + expectedText + "> found <" + foundText + ">"; + } else { + message += ":\nexpected:\n" + expectedText + "\nfound:\n" + foundText; + } throw new MjsUnitAssertionError(message); } @@ -361,7 +373,7 @@ var assertContains; if (typeof type_opt === 'function') { assertInstanceof(e, type_opt); } else if (type_opt !== void 0) { - fail("invalid use of assertThrows, maybe you want assertThrowsEquals"); + failWithMessage("invalid use of assertThrows, maybe you want assertThrowsEquals"); } if (arguments.length >= 3) { assertEquals(e.type, cause_opt); @@ -369,7 +381,7 @@ var assertContains; // Success. return; } - throw new MjsUnitAssertionError("Did not throw exception"); + failWithMessage("Did not throw exception"); }; @@ -380,7 +392,7 @@ var assertContains; assertEquals(val, e); return; } - throw new MjsUnitAssertionError("Did not throw exception"); + failWithMessage("Did not throw exception"); }; @@ -391,9 +403,9 @@ var assertContains; if (typeof actualConstructor === "function") { actualTypeName = actualConstructor.name || String(actualConstructor); } - fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" + + failWithMessage("Object <" + PrettyPrint(obj) + "> is not an instance of <" + (type.name || type) + ">" + - (actualTypeName ? " but of < " + actualTypeName + ">" : "")); + (actualTypeName ? " but of <" + actualTypeName + ">" : "")); } }; @@ -406,7 +418,7 @@ var assertContains; eval(code); } } catch (e) { - fail("threw an exception: ", e.message || e, name_opt); + failWithMessage("threw an exception: " + (e.message || e)); } }; @@ -416,7 +428,7 @@ var assertContains; if (name_opt) { message += " - " + name_opt; } - throw new MjsUnitAssertionError(message); + failWithMessage(message); }; assertContains = function(sub, value, name_opt) { @@ -425,6 +437,15 @@ var assertContains; } }; + assertMatches = function(regexp, str, name_opt) { + if (!(regexp instanceof RegExp)) { + regexp = new RegExp(regexp); + } + if (!str.match(regexp)) { + fail("should match '" + regexp + "'", str, name_opt); + } + }; + var OptimizationStatusImpl = undefined; var OptimizationStatus = function(fun, sync_opt) { diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index aa653e73a5..983bfe5ffd 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -27,6 +27,10 @@ [ [ALWAYS, { + # Modules which are only meant to be imported from by other tests, not to be + # tested standalone. + 'modules-skip*': [SKIP], + # All tests in the bug directory are expected to fail. 'bugs/*': [FAIL], @@ -55,9 +59,9 @@ 'es6/debug-promises/reject-with-undefined-reject': [FAIL], 'es6/debug-promises/reject-with-invalid-reject': [FAIL], - # Issue 3660: Replacing activated TurboFan frames by unoptimized code does - # not work, but we expect it to not crash. - 'debug-step-turbofan': [PASS, FAIL], + # Issue 5587: The eval'ed code is piped through Ignition and fails when being + # live edited. This needs investigation. + 'debug-liveedit-double-call': [SKIP], ############################################################################## # Too slow in debug mode with --stress-opt mode. @@ -154,22 +158,9 @@ 'numops-fuzz-part*': [PASS, ['mode == debug', SLOW]], 'readonly': [PASS, SLOW], 'regress/regress-1200351': [PASS, SLOW], - 'regress/regress-crbug-474297': [PASS, ['mode == debug', SLOW]], + 'regress/regress-crbug-474297': [PASS, ['gc_stress == False', SKIP]], 'es6/tail-call-megatest*': [PASS, SLOW, FAST_VARIANTS, ['tsan', SKIP]], - # TODO(titzer): ASM->WASM tests on these platforms - 'wasm/asm-wasm': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - # TODO(branelson): Figure out why ignition + asm-wasm-stdlib fails. - # TODO(branelson): The old status entry was misconfigured as it added - # "or ignition == True". This was deprecated at some point and was never - # true. Essentially the next lines skip the tests for a bunch of - # architectures. - 'wasm/asm-wasm-stdlib': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - 'wasm/asm-wasm-literals': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - 'wasm/asm-wasm-copy': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - 'wasm/asm-wasm-deopt': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - 'wasm/asm-wasm-switch': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], - # case-insensitive unicode regexp relies on case mapping provided by ICU. 'es6/unicode-regexp-ignore-case': [PASS, ['no_i18n == True', FAIL]], 'es6/unicode-regexp-ignore-case-noi18n': [FAIL, ['no_i18n == True', PASS]], @@ -177,13 +168,12 @@ # desugaring regexp property class relies on ICU. 'harmony/regexp-property-*': [PASS, ['no_i18n == True', FAIL]], + # Allocates a large array buffer, which TSAN sometimes cannot handle. + 'regress/regress-599717': [PASS, ['tsan', SKIP]], + # TODO(bmeurer): Flaky timeouts (sometimes <1s, sometimes >3m). 'unicodelctest': [PASS, NO_VARIANTS], 'unicodelctest-no-optimization': [PASS, NO_VARIANTS], - - # TODO(rmcilroy,5038): Crashes in Deoptimizer::PatchCodeForDeoptimization on - # nosnap builds when --stress-opt and --turbo-from-bytecode is enabled. - 'harmony/generators-turbo': [PASS, FAST_VARIANTS], }], # ALWAYS ['novfp3 == True', { @@ -215,7 +205,6 @@ 'regress/regress-4121': [SKIP], 'compare-known-objects-slow': [SKIP], # Tests taking too long - 'debug-stepout-scope-part8': [SKIP], 'mirror-object': [SKIP], 'packed-elements': [SKIP], 'regress/regress-1122': [SKIP], @@ -230,10 +219,6 @@ # Async function tests taking too long # https://bugs.chromium.org/p/v8/issues/detail?id=5411 'harmony/async-function-debug-scopes': [SKIP], - 'harmony/async-debug-caught-exception-cases0': [SKIP], - 'harmony/async-debug-caught-exception-cases1': [SKIP], - 'harmony/async-debug-caught-exception-cases2': [SKIP], - 'harmony/async-debug-caught-exception-cases3': [SKIP], # TODO(mstarzinger): Takes too long with TF. 'array-sort': [PASS, NO_VARIANTS], @@ -250,9 +235,6 @@ # Too slow for gc stress. 'asm/embenchen/box2d': [SKIP], - # Issue 3723. - 'regress/regress-3717': [SKIP], - # BUG(v8:4237) 'regress/regress-3976': [SKIP], @@ -268,8 +250,8 @@ # BUG(v8:4779): Crashes flakily with stress mode on arm64. 'array-splice': [PASS, SLOW, ['arch == arm64', FAST_VARIANTS]], - # BUG(v8:5053). - 'wasm/embenchen/fasta': [PASS, FAST_VARIANTS], + # BUG(chromium:664490) + 'debug-scopes': [SKIP], }], # 'gc_stress == True' ############################################################################## @@ -576,12 +558,21 @@ # Too slow. 'es6/tail-call-megatest*': [SKIP], + # Forced optimisation path tests. + 'shared-function-tier-up-default': [SKIP], + 'shared-function-tier-up-ignition': [SKIP], + 'shared-function-tier-up-turbo': [SKIP], + # Ongoing implementation of modules. # https://bugs.chromium.org/p/v8/issues/detail?id=1569 # The deopt fuzzer currently does not respect the 'variant != ignition' rule # further down in this file, so we have to duplicate this here. # https://bugs.chromium.org/p/v8/issues/detail?id=5374 'modules-*': [SKIP], + + # Fails deopt_fuzzer due to --deopt_every_n_times or + # deopt_every_n_garbage_collections + 'es6/array-iterator-turbo': [SKIP] }], # 'deopt_fuzzer == True' ############################################################################## @@ -608,30 +599,25 @@ }], # 'arch == ppc64' ############################################################################## +['variant == nocrankshaft', { + 'es6/array-iterator-turbo': [SKIP], +}], # variant == nocranshaft + +############################################################################## ['variant == stress', { - 'debug-evaluate-locals-optimized': [FAIL], - 'debug-evaluate-locals-optimized-double': [FAIL], + 'es6/array-iterator-turbo': [SKIP], + 'ignition/regress-599001-verifyheap': [SKIP], 'unicode-test': [SKIP], }], # variant == stress ############################################################################## -['variant == turbofan', { - - # Assumptions about optimization need investigation in TurboFan. - 'regress-sync-optimized-lists': [FAIL], - -}], # variant == turbofan - -############################################################################## ['variant == turbofan_opt', { + 'es6/array-iterator-turbo': [SKIP], # TODO(jarin/mstarzinger): Investigate debugger issues with TurboFan. - 'debug-evaluate-closure': [FAIL], 'debug-evaluate-locals': [FAIL], 'debug-set-variable-value': [FAIL], - 'debug-evaluate-locals-optimized': [FAIL], - 'debug-evaluate-locals-optimized-double': [FAIL], 'debug-liveedit-double-call': [FAIL], 'es6/debug-evaluate-blockscopes': [FAIL], @@ -646,99 +632,20 @@ }], # variant == turbofan_opt ############################################################################## -['variant == ignition', { +['variant == ignition or variant == ignition_staging', { + # TODO(5587): fails to liveedit evaled code. 'debug-liveedit-double-call': [FAIL], - 'regress-sync-optimized-lists': [FAIL], - - # Might trigger stack overflow. - 'unicode-test': [SKIP], - - # TODO(4680): Test doesn't know about three tier compiler pipeline. - 'assert-opt-and-deopt': [SKIP], - - # Fails because concurrent compilation is not triggered on bytecode. - # Check in Runtime_OptimizeFunctionOnNextCall. - 'compiler/manual-concurrent-recompile': [FAIL], - 'regress/regress-embedded-cons-string': [FAIL], - 'regress/regress-prepare-break-while-recompile': [FAIL], - - # BUG(v8:5451): Flaky crashes. - 'wasm/asm-wasm': [PASS, ['gc_stress', SKIP]], }], # variant == ignition -['variant == ignition and arch == arm64', { - # TODO(rmcilroy,4680): Arm64 specific timeouts. - 'asm/construct-double': [SKIP], - 'compiler/osr-one': [SKIP], - 'compiler/osr-two': [SKIP], - 'wasm/asm-wasm-i32': [SKIP], - 'wasm/asm-wasm-u32': [SKIP], -}], # variant == ignition and arch == arm64 - -['variant == ignition and arch == arm', { - # TODO(rmcilroy,4680): Arm specific timeouts. - 'compiler/osr-one': [SKIP], - 'compiler/osr-two': [SKIP], - 'regress/regress-1257': [SKIP], -}], # variant == ignition and arch == arm - -['variant == ignition and msan', { - # TODO(mythria,4680): All of these tests have large loops and hence slow - # and timeout. - 'compiler/osr-big': [SKIP], - 'compiler/osr-nested': [SKIP], - 'regress/regress-298269': [SKIP], - 'regress/regress-crbug-319860': [SKIP], - 'regress/regress-deep-proto': [SKIP], - 'try': [SKIP], - # Too slow for interpreter and msan. - 'es6/tail-call-megatest*': [SKIP], -}], # variant == ignition and msan - -############################################################################## -['variant == ignition_staging', { - 'assert-opt-and-deopt': [SKIP], - 'debug-liveedit-double-call': [FAIL], - 'regress-sync-optimized-lists': [FAIL], - - # Fails because concurrent compilation is not triggered on bytecode. - # Check in Runtime_OptimizeFunctionOnNextCall. - 'compiler/manual-concurrent-recompile': [FAIL], - 'regress/regress-embedded-cons-string': [FAIL], - 'regress/regress-prepare-break-while-recompile': [FAIL], - - # Flaky. - 'asm/int32div': [SKIP], - 'asm/int32mod': [SKIP], - 'compiler/uint32': [SKIP], - 'regress/regress-454725': [SKIP], - - # Might trigger stack overflow. - 'unicode-test': [SKIP], - - # BUG(v8:5451): Flaky crashes. - 'wasm/asm-wasm': [PASS, ['gc_stress', SKIP]], -}], # variant == ignition_staging - ############################################################################## ['variant == ignition_turbofan', { + # TODO(5587): fails to liveedit evaled code. 'debug-liveedit-double-call': [FAIL], - # Might trigger stack overflow. - 'unicode-test': [SKIP], - - 'wasm/asm-wasm-f32': [PASS, ['arch in [arm64]', SKIP]], - 'wasm/asm-wasm-f64': [PASS, ['arch in [arm64]', SKIP]], - # TODO(rmcilroy,titzer): Times out after # https://codereview.chromium.org/1951013002 . 'regress/regress-599717': [PASS, ['tsan', SKIP]], - # TODO(rmcilroy,5038): Crashes in Deoptimizer::PatchCodeForDeoptimization on - # nosnap builds when --stress-opt and --turbo-from-bytecode is enabled. - 'harmony/generators-turbo': [PASS, FAST_VARIANTS], - 'regress/regress-crbug-352058': [SKIP], - # TODO(jarin): No truncations on CheckFloat64Hole. 'getters-on-elements': [SKIP], @@ -746,47 +653,7 @@ 'unicodelctest-no-optimization': [SKIP], }], # variant == ignition_turbofan -['variant == ignition_turbofan and arch == arm64', { - # TODO(rmcilroy,4680): Arm64 specific timeouts. - 'asm/construct-double': [SKIP], - 'compiler/osr-one': [SKIP], - 'compiler/osr-two': [SKIP], - 'wasm/asm-wasm-i32': [SKIP], - 'wasm/asm-wasm-u32': [SKIP], -}], # variant == ignition_turbofan and arch == arm64 - -['variant == ignition_turbofan and arch == arm', { - # TODO(rmcilroy,4680): Arm specific timeouts. - 'compiler/osr-one': [SKIP], - 'compiler/osr-two': [SKIP], - 'regress/regress-1257': [SKIP], -}], # variant == ignition_turbofan and arch == arm - -['variant == ignition_turbofan and msan', { - # TODO(mythria,4680): All of these tests have large loops and hence slow - # and timeout. - 'compiler/osr-big': [SKIP], - 'compiler/osr-nested': [SKIP], - 'regress/regress-298269': [SKIP], - 'regress/regress-crbug-319860': [SKIP], - 'regress/regress-deep-proto': [SKIP], - 'try': [SKIP], - # Too slow for interpreter and msan. - 'es6/tail-call-megatest*': [SKIP], -}], # variant == ignition_turbofan and msan - ############################################################################## -['variant == ignition or variant == ignition_staging or variant == ignition_turbofan', { - # Modules for which execution must fail (e.g. because of unresolved imports). - # Eventually we should test for the precise error message, but for now we only - # ensure that there is an error. - 'modules-fail*': [FAIL], - - # Modules which are only meant to be imported from by other tests, not to be - # tested standalone. - 'modules-skip*': [SKIP], -}], # variant == ignition or variant == ignition_staging or variant == ignition_turbofan - ['variant != ignition and variant != ignition_staging and variant != ignition_turbofan', { # Ongoing implementation of modules. # https://bugs.chromium.org/p/v8/issues/detail?id=1569 @@ -803,6 +670,12 @@ }], # 'gcov_coverage' ############################################################################## +['variant == stress or variant == turbofan_opt', { + # BUG(v8:5553). + 'wasm/grow-memory': [SKIP], +}], # variant == stress or variant == turbofan_opt + +############################################################################## ['variant == asm_wasm', { # Skip stuff uninteresting for asm.js 'bugs/*': [SKIP], @@ -821,13 +694,4 @@ 'whitespaces': [SKIP], }], # variant == asm_wasm -############################################################################## -# 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 - ] diff --git a/deps/v8/test/mjsunit/modules-debug-scopes1.js b/deps/v8/test/mjsunit/modules-debug-scopes1.js new file mode 100644 index 0000000000..02de75510e --- /dev/null +++ b/deps/v8/test/mjsunit/modules-debug-scopes1.js @@ -0,0 +1,897 @@ +// 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. + +// MODULE +// Flags: --expose-debug-as debug --allow-natives-syntax + +// These tests are copied from mjsunit/debug-scopes.js and adapted for modules. + + +var Debug = debug.Debug; + +var test_name; +var listener_delegate; +var listener_called; +var exception; +var begin_test_count = 0; +var end_test_count = 0; +var break_count = 0; + + +// Debug event listener which delegates. +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + break_count++; + listener_called = true; + listener_delegate(exec_state); + } + } catch (e) { + exception = e; + } +} + +// Add the debug event listener. +Debug.setListener(listener); + + +// Initialize for a new test. +function BeginTest(name) { + test_name = name; + listener_delegate = null; + listener_called = false; + exception = null; + begin_test_count++; +} + + +// Check result of a test. +function EndTest() { + assertTrue(listener_called, "listener not called for " + test_name); + assertNull(exception, test_name + " / " + exception); + end_test_count++; +} + + +// Check that two scope are the same. +function assertScopeMirrorEquals(scope1, scope2) { + assertEquals(scope1.scopeType(), scope2.scopeType()); + assertEquals(scope1.frameIndex(), scope2.frameIndex()); + assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); + assertPropertiesEqual(scope1.scopeObject().value(), scope2.scopeObject().value()); +} + +function CheckFastAllScopes(scopes, exec_state) +{ + var fast_all_scopes = exec_state.frame().allScopes(true); + var length = fast_all_scopes.length; + assertTrue(scopes.length >= length); + for (var i = 0; i < scopes.length && i < length; i++) { + var scope = fast_all_scopes[length - i - 1]; + assertTrue(scope.isScope()); + assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); + } +} + + +// Check that the scope chain contains the expected types of scopes. +function CheckScopeChain(scopes, exec_state) { + var all_scopes = exec_state.frame().allScopes(); + assertEquals(scopes.length, exec_state.frame().scopeCount()); + assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length"); + for (var i = 0; i < scopes.length; i++) { + var scope = exec_state.frame().scope(i); + assertTrue(scope.isScope()); + assertEquals(scopes[i], scope.scopeType()); + assertScopeMirrorEquals(all_scopes[i], scope); + } + CheckFastAllScopes(scopes, exec_state); + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); + + // Send a scopes request and check the result. + var json; + var request_json = '{"seq":0,"type":"request","command":"scopes"}'; + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scopes.length, response.body.scopes.length); + for (var i = 0; i < scopes.length; i++) { + assertEquals(i, response.body.scopes[i].index); + assertEquals(scopes[i], response.body.scopes[i].type); + if (scopes[i] == debug.ScopeType.Local || + scopes[i] == debug.ScopeType.Script || + scopes[i] == debug.ScopeType.Closure) { + assertTrue(response.body.scopes[i].object.ref < 0); + } else { + assertTrue(response.body.scopes[i].object.ref >= 0); + } + var found = false; + for (var j = 0; j < response.refs.length && !found; j++) { + found = response.refs[j].handle == response.body.scopes[i].object.ref; + } + assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " not found"); + } +} + + +// Check that the scope chain contains the expected names of scopes. +function CheckScopeChainNames(names, exec_state) { + var all_scopes = exec_state.frame().allScopes(); + assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); + for (var i = 0; i < names.length; i++) { + var scope = exec_state.frame().scope(i); + assertTrue(scope.isScope()); + assertEquals(names[i], scope.details().name()) + } +} + + +// Check that the scope contains at least minimum_content. For functions just +// check that there is a function. +function CheckScopeContent(minimum_content, number, exec_state) { + var scope = exec_state.frame().scope(number); + var minimum_count = 0; + for (var p in minimum_content) { + var property_mirror = scope.scopeObject().property(p); + assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); + if (typeof(minimum_content[p]) === 'function') { + assertTrue(property_mirror.value().isFunction()); + } else { + assertEquals(minimum_content[p], property_mirror.value().value(), 'property ' + p + ' has unexpected value'); + } + minimum_count++; + } + + // 'arguments' and might be exposed in the local and closure scope. Just + // ignore this. + var scope_size = scope.scopeObject().properties().length; + if (!scope.scopeObject().property('arguments').isUndefined()) { + scope_size--; + } + // Ditto for 'this'. + if (!scope.scopeObject().property('this').isUndefined()) { + scope_size--; + } + // Temporary variables introduced by the parser have not been materialized. + assertTrue(scope.scopeObject().property('').isUndefined()); + + if (scope_size < minimum_count) { + print('Names found in scope:'); + var names = scope.scopeObject().propertyNames(); + for (var i = 0; i < names.length; i++) { + print(names[i]); + } + } + assertTrue(scope_size >= minimum_count); + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); + + // Send a scope request for information on a single scope and check the + // result. + var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"number":'; + request_json += scope.scopeIndex(); + request_json += '}}'; + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scope.scopeType(), response.body.type); + assertEquals(number, response.body.index); + if (scope.scopeType() == debug.ScopeType.Local || + scope.scopeType() == debug.ScopeType.Script || + scope.scopeType() == debug.ScopeType.Closure) { + assertTrue(response.body.object.ref < 0); + } else { + assertTrue(response.body.object.ref >= 0); + } + var found = false; + for (var i = 0; i < response.refs.length && !found; i++) { + found = response.refs[i].handle == response.body.object.ref; + } + assertTrue(found, "Scope object " + response.body.object.ref + " not found"); +} + +// Check that the scopes have positions as expected. +function CheckScopeChainPositions(positions, exec_state) { + var all_scopes = exec_state.frame().allScopes(); + assertTrue(positions.length <= all_scopes.length, "FrameMirror.allScopes length"); + for (var i = 0; i < positions.length; i++) { + var scope = exec_state.frame().scope(i); + assertTrue(scope.isScope()); + var position = positions[i]; + if (!position) + continue; + + print(`Checking position.start = ${position.start}, .end = ${position.end}`); + assertEquals(position.start, scope.details().startPosition()) + assertEquals(position.end, scope.details().endPosition()) + } +} + +// Simple empty local scope. +BeginTest("Local 1"); + +function local_1() { + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +}; +local_1(); +EndTest(); + + +// Local scope with a parameter. +BeginTest("Local 2"); + +function local_2(a) { + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 0, exec_state); +}; +local_2(1); +EndTest(); + + +// Local scope with a parameter and a local variable. +BeginTest("Local 3"); + +function local_3(a) { + var x = 3; + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,x:3}, 0, exec_state); +}; +local_3(1); +EndTest(); + + +// Local scope with parameters and local variables. +BeginTest("Local 4"); + +function local_4(a, b) { + var x = 3; + var y = 4; + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); +}; +local_4(1, 2); +EndTest(); + + +// Empty local scope with use of eval. +BeginTest("Local 5"); + +function local_5() { + eval(''); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +}; +local_5(); +EndTest(); + + +// Local introducing local variable using eval. +BeginTest("Local 6"); + +function local_6() { + eval('var i = 5'); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); +}; +local_6(); +EndTest(); + + +// Local scope with parameters and local variables. +BeginTest("Local 7"); + +function local_7(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + debugger; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state); +}; +local_7(1, 2); +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. +BeginTest("Closure 1"); + +function closure_1(a) { + function f() { + debugger; + return a; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 1, exec_state); + CheckScopeChainNames(["f", "closure_1", undefined, undefined, undefined], exec_state) +}; +closure_1(1)(); +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Due to VM optimizations parts of the actual closure is +// missing from the debugger information. +BeginTest("Closure 2"); + +function closure_2(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + return a + x; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,x:3}, 1, exec_state); + CheckScopeChainNames(["f", "closure_2", undefined, undefined, undefined], exec_state) +}; +closure_2(1, 2)(); +EndTest(); + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Using all arguments and locals from the outer function +// in the inner function makes these part of the debugger information on the +// closure. +BeginTest("Closure 3"); + +function closure_3(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + return a + b + x + y; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); + CheckScopeChainNames(["f", "closure_3", undefined, undefined, undefined], exec_state) +}; +closure_3(1, 2)(); +EndTest(); + + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. Using all arguments and locals from the outer function +// in the inner function makes these part of the debugger information on the +// closure. Use the inner function as well... +BeginTest("Closure 4"); + +function closure_4(a, b) { + var x = a + 2; + var y = b + 2; + function f() { + debugger; + if (f) { + return a + b + x + y; + } + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); + CheckScopeChainNames(["f", "closure_4", undefined, undefined, undefined], exec_state) +}; +closure_4(1, 2)(); +EndTest(); + + + +// Simple closure formed by returning an inner function referering the outer +// functions arguments. In the presence of eval all arguments and locals +// (including the inner function itself) from the outer function becomes part of +// the debugger infformation on the closure. +BeginTest("Closure 5"); + +function closure_5(a, b) { + var x = 3; + var y = 4; + function f() { + eval(''); + debugger; + return 1; + }; + return f; +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); + CheckScopeChainNames(["f", "closure_5", undefined, undefined, undefined], exec_state) +}; +closure_5(1, 2)(); +EndTest(); + + +// Two closures. Due to optimizations only the parts actually used are provided +// through the debugger information. +BeginTest("Closure 6"); +let some_global; +function closure_6(a, b) { + function f(a, b) { + var x = 3; + var y = 4; + return function() { + var x = 3; + var y = 4; + debugger; + some_global = a; + return f; + }; + } + return f(a, b); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({a:1}, 1, exec_state); + CheckScopeContent({f:function(){}}, 2, exec_state); + CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined, undefined], exec_state) +}; +closure_6(1, 2)(); +EndTest(); + + +// Two closures. In the presence of eval all information is provided as the +// compiler cannot determine which parts are used. +BeginTest("Closure 7"); +function closure_7(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + function f(a, b) { + var x = 3; + var y = 4; + eval('var i = 5'); + eval('var j = 6'); + return function() { + debugger; + some_global = a; + return f; + }; + } + return f(a, b); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Closure, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 0, exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); + CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 2, exec_state); + CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined, undefined], exec_state) +}; +closure_7(1, 2)(); +EndTest(); + + +// Closure that may be optimized out. +BeginTest("Closure 8"); +function closure_8() { + (function inner(x) { + debugger; + })(2); +} + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x: 2}, 0, exec_state); + CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state) +}; +closure_8(); +EndTest(); + + +BeginTest("Closure 9"); +let closure_9 = Function(' \ + eval("var y = 1;"); \ + eval("var z = 1;"); \ + (function inner(x) { \ + y++; \ + z++; \ + debugger; \ + })(2); \ +') + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Closure, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state) +}; +closure_9(); +EndTest(); + + +// Test global scope. +BeginTest("Global"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Module, debug.ScopeType.Script, debug.ScopeType.Global], exec_state); + CheckScopeChainNames([undefined, undefined, undefined], exec_state) +}; +debugger; +EndTest(); + + +BeginTest("Catch block 1"); +function catch_block_1() { + try { + throw 'Exception'; + } catch (e) { + debugger; + } +}; + + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Catch, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({e:'Exception'}, 0, exec_state); + CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined, undefined], exec_state) +}; +catch_block_1(); +EndTest(); + + +BeginTest("Catch block 3"); +function catch_block_3() { + eval("var y = 78;"); + try { + throw 'Exception'; + } catch (e) { + debugger; + } +}; + + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Catch, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({e:'Exception'}, 0, exec_state); + CheckScopeContent({}, 1, exec_state); + CheckScopeChainNames(["catch_block_3", "catch_block_3", undefined, undefined, undefined], exec_state) +}; +catch_block_3(); +EndTest(); + + +// Test catch in global scope. +BeginTest("Catch block 5"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Catch, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({e:'Exception'}, 0, exec_state); + CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state) +}; + +try { + throw 'Exception'; +} catch (e) { + debugger; +} + +EndTest(); + + +// Closure inside catch in global code. +BeginTest("Catch block 6"); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Catch, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({x: 2}, 0, exec_state); + CheckScopeContent({e:'Exception'}, 1, exec_state); + CheckScopeChainNames([undefined, undefined, undefined, undefined, undefined], exec_state) +}; + +try { + throw 'Exception'; +} catch (e) { + (function(x) { + debugger; + })(2); +} +EndTest(); + + +// Catch block in function that is marked for optimization while being executed. +BeginTest("Catch block 7"); +function catch_block_7() { + %OptimizeFunctionOnNextCall(catch_block_7); + try { + throw 'Exception'; + } catch (e) { + debugger; + } +}; + + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Catch, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({e:'Exception'}, 0, exec_state); + CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined, undefined], exec_state) +}; +catch_block_7(); +EndTest(); + + +BeginTest("Classes and methods 1"); + +listener_delegate = function(exec_state) { + "use strict" + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent({}, 1, exec_state); + CheckScopeChainNames(["m", undefined, undefined, undefined], exec_state) +}; + +(function() { + "use strict"; + class C1 { + m() { + debugger; + } + } + new C1().m(); +})(); + +EndTest(); + +BeginTest("Scope positions"); +var code1 = "function f() { \n" + + " var a = 1; \n" + + " function b() { \n" + + " debugger; \n" + + " return a + 1; \n" + + " } \n" + + " b(); \n" + + "} \n" + + "f(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChainPositions([{start: 58, end: 118}, {start: 10, end: 162}], exec_state); +} +eval(code1); +EndTest(); + + +BeginTest("Scope positions in for statement"); +var code3 = "function for_statement() { \n" + + " for (let i = 0; i < 1; i++) { \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 52, end: 111}, {start: 22, end: 145}], exec_state); +} +eval(code3); +EndTest(); + +BeginTest("Scope positions in for statement with lexical block"); +var code4 = "function for_statement() { \n" + + " for (let i = 0; i < 1; i++) { \n" + + " let j; \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 66, end: 147}, {start: 52, end: 147}, {start: 22, end: 181}], exec_state); +} +eval(code4); +EndTest(); + +BeginTest("Scope positions in lexical for each statement"); +var code5 = "function for_each_statement() { \n" + + " for (let i of [0]) { \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_each_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 55, end: 111}, {start: 27, end: 145}], exec_state); +} +eval(code5); +EndTest(); + +BeginTest("Scope positions in lexical for each statement with lexical block"); +var code6 = "function for_each_statement() { \n" + + " for (let i of [0]) { \n" + + " let j; \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_each_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 57, end: 147}, {start: 55, end: 147}, {start: 27, end: 181}], exec_state); +} +eval(code6); +EndTest(); + +BeginTest("Scope positions in non-lexical for each statement"); +var code7 = "function for_each_statement() { \n" + + " var i; \n" + + " for (i of [0]) { \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_each_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 27, end: 181}], exec_state); +} +eval(code7); +EndTest(); + +BeginTest("Scope positions in non-lexical for each statement with lexical block"); +var code8 = "function for_each_statement() { \n" + + " var i; \n" + + " for (i of [0]) { \n" + + " let j; \n" + + " debugger; \n" + + " } \n" + + "} \n" + + "for_each_statement(); \n"; + +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Block, + debug.ScopeType.Local, + debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}], exec_state); +} +eval(code8); +EndTest(); + +assertEquals(begin_test_count, break_count, + 'one or more tests did not enter the debugger'); +assertEquals(begin_test_count, end_test_count, + 'one or more tests did not have its result checked'); diff --git a/deps/v8/test/mjsunit/modules-debug-scopes2.js b/deps/v8/test/mjsunit/modules-debug-scopes2.js new file mode 100644 index 0000000000..ffe712f5d0 --- /dev/null +++ b/deps/v8/test/mjsunit/modules-debug-scopes2.js @@ -0,0 +1,239 @@ +// 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. + +// MODULE +// Flags: --expose-debug-as debug + + +var Debug = debug.Debug; + +var test_name; +var listener_delegate; +var listener_called; +var exception; +var begin_test_count = 0; +var end_test_count = 0; +var break_count = 0; + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + break_count++; + listener_called = true; + listener_delegate(exec_state); + } + } catch (e) { + exception = e; + } +} + +Debug.setListener(listener); + + +function BeginTest(name) { + test_name = name; + listener_delegate = null; + listener_called = false; + exception = null; + begin_test_count++; +} + +function EndTest() { + assertTrue(listener_called, "listener not called for " + test_name); + assertNull(exception, test_name + " / " + exception); + end_test_count++; +} + + +// Check that two scope are the same. +function assertScopeMirrorEquals(scope1, scope2) { + assertEquals(scope1.scopeType(), scope2.scopeType()); + assertEquals(scope1.frameIndex(), scope2.frameIndex()); + assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); + assertPropertiesEqual(scope1.scopeObject().value(), scope2.scopeObject().value()); +} + +function CheckFastAllScopes(scopes, exec_state) +{ + var fast_all_scopes = exec_state.frame().allScopes(true); + var length = fast_all_scopes.length; + assertTrue(scopes.length >= length); + for (var i = 0; i < scopes.length && i < length; i++) { + var scope = fast_all_scopes[length - i - 1]; + assertTrue(scope.isScope()); + assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); + } +} + + +// Check that the scope chain contains the expected types of scopes. +function CheckScopeChain(scopes, exec_state) { + var all_scopes = exec_state.frame().allScopes(); + assertEquals(scopes.length, exec_state.frame().scopeCount()); + assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length"); + for (var i = 0; i < scopes.length; i++) { + var scope = exec_state.frame().scope(i); + assertTrue(scope.isScope()); + assertEquals(scopes[i], scope.scopeType()); + assertScopeMirrorEquals(all_scopes[i], scope); + } + CheckFastAllScopes(scopes, exec_state); + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); + + // Send a scopes request and check the result. + var json; + var request_json = '{"seq":0,"type":"request","command":"scopes"}'; + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scopes.length, response.body.scopes.length); + for (var i = 0; i < scopes.length; i++) { + assertEquals(i, response.body.scopes[i].index); + assertEquals(scopes[i], response.body.scopes[i].type); + if (scopes[i] == debug.ScopeType.Local || + scopes[i] == debug.ScopeType.Script || + scopes[i] == debug.ScopeType.Closure) { + assertTrue(response.body.scopes[i].object.ref < 0); + } else { + assertTrue(response.body.scopes[i].object.ref >= 0); + } + var found = false; + for (var j = 0; j < response.refs.length && !found; j++) { + found = response.refs[j].handle == response.body.scopes[i].object.ref; + } + assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " not found"); + } +} + + +function CheckScopeDoesNotHave(properties, number, exec_state) { + var scope = exec_state.frame().scope(number); + for (var p of properties) { + var property_mirror = scope.scopeObject().property(p); + assertTrue(property_mirror.isUndefined(), 'property ' + p + ' found in scope'); + } +} + + +// Check that the scope contains at least minimum_content. For functions just +// check that there is a function. +function CheckScopeContent(minimum_content, number, exec_state) { + var scope = exec_state.frame().scope(number); + var minimum_count = 0; + for (var p in minimum_content) { + var property_mirror = scope.scopeObject().property(p); + assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); + if (typeof(minimum_content[p]) === 'function') { + assertTrue(property_mirror.value().isFunction()); + } else { + assertEquals(minimum_content[p], property_mirror.value().value(), 'property ' + p + ' has unexpected value'); + } + minimum_count++; + } + + // 'arguments' and might be exposed in the local and closure scope. Just + // ignore this. + var scope_size = scope.scopeObject().properties().length; + if (!scope.scopeObject().property('arguments').isUndefined()) { + scope_size--; + } + // Ditto for 'this'. + if (!scope.scopeObject().property('this').isUndefined()) { + scope_size--; + } + // Temporary variables introduced by the parser have not been materialized. + assertTrue(scope.scopeObject().property('').isUndefined()); + + if (scope_size < minimum_count) { + print('Names found in scope:'); + var names = scope.scopeObject().propertyNames(); + for (var i = 0; i < names.length; i++) { + print(names[i]); + } + } + assertTrue(scope_size >= minimum_count); + + // Get the debug command processor. + var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); + + // Send a scope request for information on a single scope and check the + // result. + var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"number":'; + request_json += scope.scopeIndex(); + request_json += '}}'; + var response_json = dcp.processDebugJSONRequest(request_json); + var response = JSON.parse(response_json); + assertEquals(scope.scopeType(), response.body.type); + assertEquals(number, response.body.index); + if (scope.scopeType() == debug.ScopeType.Local || + scope.scopeType() == debug.ScopeType.Script || + scope.scopeType() == debug.ScopeType.Closure) { + assertTrue(response.body.object.ref < 0); + } else { + assertTrue(response.body.object.ref >= 0); + } + var found = false; + for (var i = 0; i < response.refs.length && !found; i++) { + found = response.refs[i].handle == response.body.object.ref; + } + assertTrue(found, "Scope object " + response.body.object.ref + " not found"); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Actual tests. +//////////////////////////////////////////////////////////////////////////////// + + +BeginTest(); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent( + {local_var: undefined, exported_var: undefined, imported_var: undefined}, + 0, exec_state); + CheckScopeDoesNotHave( + ["doesnotexist", "local_let", "exported_let", "imported_let"], + 0, exec_state); +}; +debugger; +EndTest(); + +let local_let = 1; +var local_var = 2; +export let exported_let = 3; +export var exported_var = 4; +import {exported_let as imported_let} from "modules-debug-scopes2.js"; +import {exported_var as imported_var} from "modules-debug-scopes2.js"; + +BeginTest(); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent( + {local_let: 1, local_var: 2, exported_let: 3, exported_var: 4, + imported_let: 3, imported_var: 4}, 0, exec_state); +}; +debugger; +EndTest(); + +local_let += 10; +local_var += 10; +exported_let += 10; +exported_var += 10; + +BeginTest(); +listener_delegate = function(exec_state) { + CheckScopeChain([debug.ScopeType.Module, + debug.ScopeType.Script, + debug.ScopeType.Global], exec_state); + CheckScopeContent( + {local_let: 11, local_var: 12, exported_let: 13, exported_var: 14, + imported_let: 13, imported_var: 14}, 0, exec_state); +}; +debugger; +EndTest(); diff --git a/deps/v8/test/mjsunit/modules-fail-5.js b/deps/v8/test/mjsunit/modules-fail-5.js deleted file mode 100644 index 046275b2d3..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-5.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// MODULE - -import {a as b} from "modules-fail-5.js"; -export {c as a} from "modules-fail-5.js"; -import {c} from "modules-fail-5.js"; diff --git a/deps/v8/test/mjsunit/modules-fail-6.js b/deps/v8/test/mjsunit/modules-fail-6.js deleted file mode 100644 index 766cf43852..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-6.js +++ /dev/null @@ -1,8 +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. -// -// MODULE - -// Star exports do not propagate a default export. -import a from "modules-skip-4.js"; diff --git a/deps/v8/test/mjsunit/modules-fail-7.js b/deps/v8/test/mjsunit/modules-fail-7.js deleted file mode 100644 index 766cf43852..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-7.js +++ /dev/null @@ -1,8 +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. -// -// MODULE - -// Star exports do not propagate a default export. -import a from "modules-skip-4.js"; diff --git a/deps/v8/test/mjsunit/modules-fail-8.js b/deps/v8/test/mjsunit/modules-fail-8.js deleted file mode 100644 index bc9c101301..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-8.js +++ /dev/null @@ -1,7 +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. -// -// MODULE - -import {a} from "modules-skip-7.js"; diff --git a/deps/v8/test/mjsunit/modules-fail-cyclic-1.js b/deps/v8/test/mjsunit/modules-fail-cyclic-1.js deleted file mode 100644 index 5156a57cd9..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-cyclic-1.js +++ /dev/null @@ -1,8 +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. -// -// MODULE - -import {a} from "modules-fail-cyclic-1.js"; -export {a}; diff --git a/deps/v8/test/mjsunit/modules-fail-cyclic-2.js b/deps/v8/test/mjsunit/modules-fail-cyclic-2.js deleted file mode 100644 index f6a7cecec1..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-cyclic-2.js +++ /dev/null @@ -1,8 +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. -// -// MODULE - -import {a} from "modules-skip-cyclic.js"; -export {a as b}; diff --git a/deps/v8/test/mjsunit/modules-fail-cyclic-3.js b/deps/v8/test/mjsunit/modules-fail-cyclic-3.js deleted file mode 100644 index a216569fff..0000000000 --- a/deps/v8/test/mjsunit/modules-fail-cyclic-3.js +++ /dev/null @@ -1,8 +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. -// -// MODULE - -export {a as x} from "modules-skip-cyclic-3.js"; -export {b as y} from "modules-skip-cyclic-3.js"; diff --git a/deps/v8/test/mjsunit/modules-init3.js b/deps/v8/test/mjsunit/modules-init3.js index 36ff1e8ffa..e8b46106f7 100644 --- a/deps/v8/test/mjsunit/modules-init3.js +++ b/deps/v8/test/mjsunit/modules-init3.js @@ -11,6 +11,11 @@ assertThrows(() => x, ReferenceError); assertThrows(() => y, ReferenceError); assertThrows(() => z, ReferenceError); +assertEquals(23, w = 23); +assertThrows(() => x = 666, ReferenceError); +assertThrows(() => y = 666, ReferenceError); +assertThrows(() => z = 666, TypeError); + export function* v() { return 40 } export var w = 41; export let x = 42; diff --git a/deps/v8/test/mjsunit/modules-namespace1.js b/deps/v8/test/mjsunit/modules-namespace1.js new file mode 100644 index 0000000000..227b9c8a4c --- /dev/null +++ b/deps/v8/test/mjsunit/modules-namespace1.js @@ -0,0 +1,107 @@ +// 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. +// +// MODULE + +let ja = 42; +export {ja as yo}; +export const bla = "blaa"; +export {foo as foo_again}; +// See further below for the actual star import that declares "foo". + +// The object itself. +assertEquals("object", typeof foo); +assertThrows(() => foo = 666, TypeError); +assertFalse(Reflect.isExtensible(foo)); +assertTrue(Reflect.preventExtensions(foo)); +assertThrows(() => Reflect.apply(foo, {}, [])); +assertThrows(() => Reflect.construct(foo, {}, [])); +assertSame(null, Reflect.getPrototypeOf(foo)); +// TODO(neis): The next one should be False. +assertTrue(Reflect.setPrototypeOf(foo, null)); +assertFalse(Reflect.setPrototypeOf(foo, {})); +assertSame(null, Reflect.getPrototypeOf(foo)); +assertEquals( + ["bla", "foo_again", "yo", Symbol.toStringTag, Symbol.iterator], + Reflect.ownKeys(foo)); + +// Its "yo" property. +assertEquals( + {value: 42, enumerable: true, configurable: false, writable: true}, + Reflect.getOwnPropertyDescriptor(foo, "yo")); +assertFalse(Reflect.deleteProperty(foo, "yo")); +assertTrue(Reflect.has(foo, "yo")); +assertFalse(Reflect.set(foo, "yo", true)); +// TODO(neis): The next two should be False. +assertTrue(Reflect.defineProperty(foo, "yo", + Reflect.getOwnPropertyDescriptor(foo, "yo"))); +assertTrue(Reflect.defineProperty(foo, "yo", {})); +assertFalse(Reflect.defineProperty(foo, "yo", {get() {return 1}})); +assertEquals(42, Reflect.get(foo, "yo")); +assertEquals(43, (ja++, foo.yo)); + +// Its "foo_again" property. +assertSame(foo, foo.foo_again); + +// Its @@toStringTag property. +assertTrue(Reflect.has(foo, Symbol.toStringTag)); +assertEquals("string", typeof Reflect.get(foo, Symbol.toStringTag)); +assertEquals( + {value: "Module", configurable: true, writable: false, enumerable: false}, + Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag)); + +// Its @@iterator property. +assertTrue(Reflect.has(foo, Symbol.iterator)); +assertEquals("function", typeof Reflect.get(foo, Symbol.iterator)); +assertEquals("[Symbol.iterator]", foo[Symbol.iterator].name); +assertEquals(0, foo[Symbol.iterator].length); +assertSame(Function.prototype, foo[Symbol.iterator].__proto__); +assertEquals( + {value: foo[Symbol.iterator], + configurable: true, writable: true, enumerable: false}, + Reflect.getOwnPropertyDescriptor(foo, Symbol.iterator)); +assertEquals(["bla", "foo_again", "yo"], [...foo]); +assertThrows(() => (42, foo[Symbol.iterator])(), TypeError); +{ + let it = foo[Symbol.iterator](); + assertSame(it.__proto__, ([][Symbol.iterator]()).__proto__.__proto__); + assertEquals(["next"], Reflect.ownKeys(it)); + assertEquals( + {value: it.next, configurable: true, writable: true, enumerable: false}, + Reflect.getOwnPropertyDescriptor(it, "next")); + assertEquals("function", typeof it.next); + assertEquals("next", it.next.name); + assertEquals(0, it.next.length); + assertSame(Function.prototype, it.next.__proto__); + assertFalse(it === foo[Symbol.iterator]()); + assertFalse(it.next === foo[Symbol.iterator]().next); + assertThrows(() => (42, it.next)(), TypeError); + assertThrows(() => it.next.call(foo[Symbol.iterator]()), TypeError); + let next = it.next; + assertEquals(42, (it.next = 42, it.next)); + assertEquals(43, (it.bla = 43, it.bla)); + assertTrue(delete it.next); + assertThrows(() => next.call(foo[Symbol.iterator]()), TypeError); +} + +// TODO(neis): Clarify spec w.r.t. other symbols. + +// Nonexistant properties. +let nonexistant = ["gaga", 123, Symbol('')]; +for (let key of nonexistant) { + assertSame(undefined, Reflect.getOwnPropertyDescriptor(foo, key)); + assertTrue(Reflect.deleteProperty(foo, key)); + assertFalse(Reflect.set(foo, key, true)); + assertSame(undefined, Reflect.get(foo, key)); + assertFalse(Reflect.defineProperty(foo, key, {get() {return 1}})); + assertFalse(Reflect.has(foo, key)); +} + +// The actual star import that we are testing. Namespace imports are +// initialized before evaluation. +import * as foo from "modules-namespace1.js"; + +// There can be only one namespace object. +import * as bar from "modules-namespace1.js"; +assertSame(foo, bar); diff --git a/deps/v8/test/mjsunit/modules-namespace2.js b/deps/v8/test/mjsunit/modules-namespace2.js new file mode 100644 index 0000000000..43529b916d --- /dev/null +++ b/deps/v8/test/mjsunit/modules-namespace2.js @@ -0,0 +1,22 @@ +// 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. +// +// MODULE + +assertEquals( + ["b", "c", "get_a", "ns2", "set_a", "zzz", + Symbol.toStringTag, Symbol.iterator], + Reflect.ownKeys(ns)); +assertEquals(["b", "c", "get_a", "ns2", "set_a", "zzz"], [...ns]); + +import * as foo from "modules-skip-1.js"; +assertSame(foo.a, ns.b); +assertSame(foo.a, ns.c); +assertSame(foo.get_a, ns.get_a); +assertSame(foo.set_a, ns.set_a); +assertEquals(123, ns.zzz); + +assertSame(ns, ns.ns2.ns); +import * as ns from "modules-skip-namespace.js"; +export {ns}; diff --git a/deps/v8/test/mjsunit/modules-namespace3.js b/deps/v8/test/mjsunit/modules-namespace3.js new file mode 100644 index 0000000000..df9ef7806b --- /dev/null +++ b/deps/v8/test/mjsunit/modules-namespace3.js @@ -0,0 +1,11 @@ +// 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. +// +// MODULE + +import * as foo from "modules-namespace3.js"; +export * from "modules-namespace3.js"; +export var bar; +assertEquals(["bar", "default"], Object.getOwnPropertyNames(foo)); +export default function() {}; diff --git a/deps/v8/test/mjsunit/modules-namespace4.js b/deps/v8/test/mjsunit/modules-namespace4.js new file mode 100644 index 0000000000..ef508d5fb8 --- /dev/null +++ b/deps/v8/test/mjsunit/modules-namespace4.js @@ -0,0 +1,59 @@ +// 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. +// +// MODULE + +import * as foo from "modules-namespace4.js"; + +assertSame(undefined, a); +assertThrows(() => b, ReferenceError); +assertThrows(() => B, ReferenceError); +assertThrows(() => c, ReferenceError); +assertEquals(45, d()); + +assertSame(undefined, foo.a); +assertThrows(() => foo.b, ReferenceError); +assertThrows(() => foo.B, ReferenceError); +assertThrows(() => foo.c, ReferenceError); +assertEquals(45, foo.d()); +assertThrows(() => foo.default, ReferenceError); +assertSame(undefined, foo.doesnotexist); + +Function("Foo", " \ + with (Foo) { \ + assertEquals(undefined, a); \ + assertThrows(() => b, ReferenceError); \ + assertThrows(() => B, ReferenceError); \ + assertThrows(() => c, ReferenceError); \ + assertEquals(45, d()); \ + }")(foo); + +export var a = 42; +export let b = 43; +export {b as B}; +export const c = 44; +export function d() { return 45 }; +export default 46; + +assertEquals(42, a); +assertEquals(43, b); +assertEquals(44, c); +assertEquals(45, d()); + +assertEquals(42, foo.a); +assertEquals(43, foo.b); +assertEquals(43, foo.B); +assertEquals(44, foo.c); +assertEquals(45, foo.d()); +assertEquals(46, foo.default); +assertSame(undefined, foo.doesnotexist); + +Function("Foo", " \ + with (Foo) { \ + assertEquals(42, a); \ + assertEquals(43, b); \ + assertEquals(43, B); \ + assertEquals(44, c); \ + assertEquals(45, d()); \ + }")(foo); diff --git a/deps/v8/test/mjsunit/modules-fail-star-exports-conflict.js b/deps/v8/test/mjsunit/modules-relative-path.js index 6e2b219342..7e6a37ac1c 100644 --- a/deps/v8/test/mjsunit/modules-fail-star-exports-conflict.js +++ b/deps/v8/test/mjsunit/modules-relative-path.js @@ -4,7 +4,11 @@ // // MODULE -export * from "modules-skip-star-exports-conflict.js"; -export * from "modules-skip-6.js"; +import {x as y} from "./modules-relative-path.js"; +export let x = 0; -import {a} from "modules-fail-star-exports-conflict.js"; +assertEquals(0, x); +assertEquals(x, y); +x++; +assertEquals(1, x); +assertEquals(x, y); diff --git a/deps/v8/test/mjsunit/modules-skip-2.js b/deps/v8/test/mjsunit/modules-skip-2.js index fdd576a988..d5ff578b49 100644 --- a/deps/v8/test/mjsunit/modules-skip-2.js +++ b/deps/v8/test/mjsunit/modules-skip-2.js @@ -5,3 +5,4 @@ export {a as b, default} from "modules-skip-1.js"; import {a as tmp} from "modules-skip-1.js"; export {tmp as c}; +export const zzz = 999; diff --git a/deps/v8/test/mjsunit/modules-skip-cyclic-3.js b/deps/v8/test/mjsunit/modules-skip-cyclic-3.js deleted file mode 100644 index ced96270b1..0000000000 --- a/deps/v8/test/mjsunit/modules-skip-cyclic-3.js +++ /dev/null @@ -1,6 +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. - -export {y as a} from "modules-fail-cyclic-3.js"; -export {x as b} from "modules-fail-cyclic-3.js"; diff --git a/deps/v8/test/mjsunit/modules-skip-init3.js b/deps/v8/test/mjsunit/modules-skip-init3.js index eac1ae172b..589b2cfb16 100644 --- a/deps/v8/test/mjsunit/modules-skip-init3.js +++ b/deps/v8/test/mjsunit/modules-skip-init3.js @@ -10,6 +10,12 @@ assertThrows(() => x, ReferenceError); assertThrows(() => y, ReferenceError); assertThrows(() => z, ReferenceError); +assertThrows(() => v = 666, TypeError); +assertThrows(() => w = 666, TypeError); +assertThrows(() => x = 666, TypeError); +assertThrows(() => y = 666, TypeError); +assertThrows(() => z = 666, TypeError); + export function check() { assertEquals({value: 40, done: true}, v().next()); assertEquals(41, w); diff --git a/deps/v8/test/mjsunit/modules-skip-namespace.js b/deps/v8/test/mjsunit/modules-skip-namespace.js new file mode 100644 index 0000000000..ff6a7b81d3 --- /dev/null +++ b/deps/v8/test/mjsunit/modules-skip-namespace.js @@ -0,0 +1,13 @@ +// 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. + +//assertEquals( +// ["ns", Symbol.toStringTag, Symbol.iterator], Reflect.ownKeys(ns2)); +//assertEquals(["ns"], [...ns2]); + +export * from "modules-skip-4.js"; +export * from "modules-skip-5.js"; +export var zzz = 123; +export {ns2}; +import * as ns2 from "modules-namespace2.js"; diff --git a/deps/v8/test/mjsunit/modules-turbo.js b/deps/v8/test/mjsunit/modules-turbo.js new file mode 100644 index 0000000000..7c31682a5b --- /dev/null +++ b/deps/v8/test/mjsunit/modules-turbo.js @@ -0,0 +1,14 @@ +// 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. + +// MODULE +// Flags: --allow-natives-syntax + +export let x = 0; +function foo() { x++ }; +foo(); +%OptimizeFunctionOnNextCall(foo); +foo(); +assertOptimized(foo); +assertEquals(2, x); diff --git a/deps/v8/test/mjsunit/object-create.js b/deps/v8/test/mjsunit/object-create.js index d8385842a3..d2f676e77c 100644 --- a/deps/v8/test/mjsunit/object-create.js +++ b/deps/v8/test/mjsunit/object-create.js @@ -49,6 +49,27 @@ try { assertTrue(/Object or null/.test(e)); } +try { + Object.create(null, this); + assertTrue(false); +} catch(e) { + assertTrue(/Property description/.test(e)) +} + +try { + Object.create(null, [1, 2, 3]); + assertTrue(false); +} catch(e) { + assertTrue(/Property description/.test(e)) +} + +try { + Object.create(null, new Proxy([1, 2, 3], {})); + assertTrue(false); +} catch(e) { + assertTrue(/Property description/.test(e)) +} + var ctr = 0; var ctr2 = 0; var ctr3 = 0; @@ -248,3 +269,14 @@ for (x in sonOfTricky) { sum += sonOfTricky[x]; } assertEquals(16, sum); + + +(function createWithEmptyProtoInfoCreateMap() { + var proto = {a:1}; + var instance = {__proto__: proto }; + // Try force creation of prototype info on proto by loading a proto property. + assertEquals(instance.a, 1); + var result = Object.create(proto, {}); + assertEquals(result.a, 1); + assertEquals(result.__proto__, proto); +})() diff --git a/deps/v8/test/mjsunit/preparse-toplevel-strict-eval.js b/deps/v8/test/mjsunit/preparse-toplevel-strict-eval.js new file mode 100644 index 0000000000..6d99ac755e --- /dev/null +++ b/deps/v8/test/mjsunit/preparse-toplevel-strict-eval.js @@ -0,0 +1,13 @@ +// 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: --min-preparse-length=0 + +"use strict"; +var x = 1; +var g = eval("var y = 100; function h(s) { if (s) x = s; return x+y; }; h"); + +assertEquals(101, g()); +assertEquals(102, g(2)); +assertEquals(102, g(2)); diff --git a/deps/v8/test/mjsunit/print.js b/deps/v8/test/mjsunit/print.js new file mode 100644 index 0000000000..1ec3383e47 --- /dev/null +++ b/deps/v8/test/mjsunit/print.js @@ -0,0 +1,6 @@ +// 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. + +assertEquals("function", typeof print, "print should be defined"); +assertEquals("function", typeof printErr, "printErr should be defined"); diff --git a/deps/v8/test/mjsunit/prototype-non-existing.js b/deps/v8/test/mjsunit/prototype-non-existing.js new file mode 100644 index 0000000000..367a59f547 --- /dev/null +++ b/deps/v8/test/mjsunit/prototype-non-existing.js @@ -0,0 +1,92 @@ +// 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 + +// Dictionary object in the prototype chain. +(function() { + function A() { + this.z = "a"; + } + var a = new A(); + + function B() { + this.b = "b"; + } + B.prototype = a; + var b = new B(); + + // Ensure b stays slow. + for (var i = 0; i < 1200; i++) { + b["b"+i] = 0; + } + assertFalse(%HasFastProperties(b)); + + function C() { + this.c = "c"; + } + C.prototype = b; + var c = new C(); + + function f(expected) { + assertFalse(%HasFastProperties(b)); + var result = c.z; + assertEquals(expected, result); + } + f("a"); + f("a"); + f("a"); + %OptimizeFunctionOnNextCall(f); + f("a"); + + a.z = "z"; + f("z"); + f("z"); + f("z"); + + b.z = "bz"; + f("bz"); + f("bz"); + f("bz"); +})(); + + +// Global object in the prototype chain. +(function() { + var global = this; + + function A() { + this.z = "a"; + } + A.prototype = global.__proto__; + var a = new A(); + + global.__proto__ = a; + + function C() { + this.c = "c"; + } + C.prototype = global; + var c = new C(); + + function f(expected) { + var result = c.z; + assertEquals(expected, result); + } + f("a"); + f("a"); + f("a"); + %OptimizeFunctionOnNextCall(f); + f("a"); + + a.z = "z"; + f("z"); + f("z"); + f("z"); + + global.z = "bz"; + f("bz"); + f("bz"); + f("bz"); +})(); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases2.js b/deps/v8/test/mjsunit/regexp-regexpexec.js index 0bfefae4b8..bfc42b6a16 100644 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases2.js +++ b/deps/v8/test/mjsunit/regexp-regexpexec.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-async-await --expose-debug-as debug -// Files: test/mjsunit/harmony/async-debug-caught-exception-cases.js - -runPart(2); +// Test that the fallback path in RegExpExec executes the default exec +// implementation. +delete RegExp.prototype.exec; +assertEquals("b", "aba".replace(/a/g, "")); diff --git a/deps/v8/test/mjsunit/regexp.js b/deps/v8/test/mjsunit/regexp.js index ddaf022d19..04c723665a 100644 --- a/deps/v8/test/mjsunit/regexp.js +++ b/deps/v8/test/mjsunit/regexp.js @@ -731,3 +731,36 @@ assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)/.exec("aabcacbc")); // \u{daff}\u{e000} is not a surrogate pair, while \u{daff}\u{dfff} is. assertEquals(["\u{daff}", "\u{e000}"], "\u{daff}\u{e000}".split(/[a-z]{0,1}/u)); assertEquals(["\u{daff}\u{dfff}"], "\u{daff}\u{dfff}".split(/[a-z]{0,1}/u)); + +// Test that changing a property on RegExp.prototype results in us taking the +// slow path, which executes RegExp.prototype.exec instead of our +// RegExpExecStub. +const RegExpPrototypeExec = RegExp.prototype.exec; +RegExp.prototype.exec = function() { throw new Error(); } +assertThrows(() => "abc".replace(/./, "")); +RegExp.prototype.exec = RegExpPrototypeExec; + +// Test the code path in RE.proto[@@search] when previousLastIndex is a receiver +// but can't be converted to a primitive. This exposed a crash in an older +// C++ implementation of @@search which a) still relied on Object::Equals, +// and b) incorrectly returned isolate->pending_exception() on error. + +var re = /./; +re.lastIndex = { [Symbol.toPrimitive]: 42 }; +try { "abc".search(re); } catch (_) {} // Ensure we don't crash. + +// Test lastIndex values of -0.0 and NaN (since @@search uses SameValue). + +var re = /./; +re.exec = function(str) { assertEquals(0, re.lastIndex); return []; } +re.lastIndex = -0.0; +assertEquals(-0, re.lastIndex); +"abc".search(re); +assertEquals(-0, re.lastIndex); + +var re = /./; +re.exec = function(str) { assertEquals(0, re.lastIndex); return []; } +re.lastIndex = NaN; +assertEquals(NaN, re.lastIndex); +"abc".search(re); +assertEquals(NaN, re.lastIndex); diff --git a/deps/v8/test/mjsunit/regress-3225.js b/deps/v8/test/mjsunit/regress-3225.js deleted file mode 100644 index 51fac89bf6..0000000000 --- a/deps/v8/test/mjsunit/regress-3225.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var debug_step = 0; -var failure = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - if (debug_step == 0) { - assertEquals(1, exec_state.frame(0).evaluate('a').value()); - assertEquals(3, exec_state.frame(0).evaluate('b').value()); - exec_state.frame(0).evaluate("a = 4").value(); - debug_step++; - } else { - assertEquals(4, exec_state.frame(0).evaluate('a').value()); - assertEquals(3, exec_state.frame(0).evaluate('b').value()); - exec_state.frame(0).evaluate("set_a_to_5()"); - exec_state.frame(0).evaluate("b = 5").value(); - } - } catch (e) { - failure = e; - } -} - -Debug.setListener(listener); - -function* generator(a, b) { - function set_a_to_5() { a = 5 } - var b = 3; // Shadows a parameter. - debugger; - yield a; - yield b; - debugger; - yield a; - return b; -} - -var foo = generator(1, 2); - -assertEquals(4, foo.next().value); -assertEquals(3, foo.next().value); -assertEquals(5, foo.next().value); -assertEquals(5, foo.next().value); -assertNull(failure); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress-3456.js b/deps/v8/test/mjsunit/regress-3456.js index 498953b807..3636de3011 100644 --- a/deps/v8/test/mjsunit/regress-3456.js +++ b/deps/v8/test/mjsunit/regress-3456.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: --min-preparse-length 1 +// Flags: --min-preparse-length=1 // Arrow function parsing (commit r22366) changed the flags stored in // PreParserExpression, and IsValidReferenceExpression() would return diff --git a/deps/v8/test/mjsunit/regress-604044.js b/deps/v8/test/mjsunit/regress-604044.js index 58ccfbed99..882fd5644f 100644 --- a/deps/v8/test/mjsunit/regress-604044.js +++ b/deps/v8/test/mjsunit/regress-604044.js @@ -2,6 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --min-preparse-length 1 +// Flags: --min-preparse-length=1 (function(_ = function() {}){}) diff --git a/deps/v8/test/mjsunit/regress-sync-optimized-lists.js b/deps/v8/test/mjsunit/regress-sync-optimized-lists.js index 0f7eeba0d3..9297c2df54 100644 --- a/deps/v8/test/mjsunit/regress-sync-optimized-lists.js +++ b/deps/v8/test/mjsunit/regress-sync-optimized-lists.js @@ -29,11 +29,9 @@ f1(new Ctor(), false); // Kick off concurrent recompilation and OSR. var o = new Ctor(); f1(o, true); -assertOptimized(f1, "no sync"); // Flush the optimizing compiler's queue. %NotifyContextDisposed(); -assertUnoptimized(f1, "no sync"); // Trigger deopt. o.c = 2.2; diff --git a/deps/v8/test/mjsunit/regress/debug-prepare-step-in.js b/deps/v8/test/mjsunit/regress/debug-prepare-step-in.js deleted file mode 100644 index 93474da695..0000000000 --- a/deps/v8/test/mjsunit/regress/debug-prepare-step-in.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 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: --expose-debug-as debug --allow-natives-syntax --expose-gc -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -function breakListener(event, exec_state, event_data, data) { - exec_state.prepareStep(Debug.StepAction.StepIn); -} - -Debug.setListener(breakListener); - -var o = {x:function() { return 10; }}; - -function f(o) { - var m = "x"; - o[m](); -} - -Debug.setBreakPoint(f, 2, 0); - -f(o); - -%NotifyContextDisposed(); -function g() { - gc(); -} - -g(); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-1170187.js b/deps/v8/test/mjsunit/regress/regress-1170187.js deleted file mode 100644 index 6aa2896751..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-1170187.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug - -// Make sure that the retreival of local variables are performed correctly even -// when an adapter frame is present. - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -listenerCalled = false; -exception = false; - - -function checkName(name) { - assertTrue(name == 'a' || name == 'b' || name == 'c'); -} - - -function checkValue(value) { - assertEquals(void 0, value); -} - - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - var local0Name = exec_state.frame(0).localName(0); - var local1Name = exec_state.frame(0).localName(1); - var local2Name = exec_state.frame(0).localName(2); - checkName(local0Name); - checkName(local1Name); - checkName(local2Name); - var local0Value = exec_state.frame(0).localValue(0).value(); - var local1Value = exec_state.frame(0).localValue(1).value(); - var local2Value = exec_state.frame(0).localValue(2).value(); - checkValue(local0Value); - checkValue(local1Value); - checkValue(local2Value); - listenerCalled = true; - } - } catch (e) { - exception = e; - }; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -// Call a function with local variables passing a different number parameters -// that the number of arguments. -(function(x,y){var a,b,c; debugger; return 3})() - -// Make sure that the debug event listener vas invoked (again). -assertTrue(listenerCalled); -assertFalse(exception, "exception in listener") diff --git a/deps/v8/test/mjsunit/regress/regress-131994.js b/deps/v8/test/mjsunit/regress/regress-131994.js deleted file mode 100644 index 7f600959da..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-131994.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug - -// Test that a variable in the local scope that shadows a context-allocated -// variable is correctly resolved when being evaluated in the debugger. - -Debug = debug.Debug; - -var exception = false; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - var breakpoint = exec_state.frame(0); - try { - // Assert correct break point. - assertTrue(breakpoint.sourceLineText().indexOf("// Break") > -1); - // Assert correct value. - assertEquals(3, breakpoint.evaluate('x').value()); - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function h() { - var x; // Context-allocated due to g(). - - var g = function g() { - x = -7; - }; - - var f = function f() { - var x = 3; // Allocated in the local scope. - debugger; // Break. - }; - - f(); -} - -h(); - -assertFalse(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-1387.js b/deps/v8/test/mjsunit/regress/regress-1387.js index d171d381ad..0d58eab499 100644 --- a/deps/v8/test/mjsunit/regress/regress-1387.js +++ b/deps/v8/test/mjsunit/regress/regress-1387.js @@ -26,13 +26,13 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Tests that we always return the same type error function when trying to -// access strict mode caller and callee. +// access or set strict mode callee. function foo() { 'use strict'; return arguments; } -var get1 = Object.getOwnPropertyDescriptor(foo(), "caller").get; -var get2 = Object.getOwnPropertyDescriptor(foo(), "callee").get; -assertEquals(get1, get2); +var get = Object.getOwnPropertyDescriptor(foo(), "callee").get; +var set = Object.getOwnPropertyDescriptor(foo(), "callee").set; +assertEquals(get, set); diff --git a/deps/v8/test/mjsunit/regress/regress-147497.js b/deps/v8/test/mjsunit/regress/regress-147497.js deleted file mode 100644 index f61d0c664d..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-147497.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2013 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: --expose-debug-as debug - -Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - exec_state.prepareStep(Debug.StepAction.StepNext); - } -}; - -Debug.setListener(listener); - -var statement = ""; -for (var i = 0; i < 1024; i++) statement += "z"; -statement = 'with(0)' + statement + '=function foo(){}'; - -debugger; -eval(statement); diff --git a/deps/v8/test/mjsunit/regress/regress-1523.js b/deps/v8/test/mjsunit/regress/regress-1523.js deleted file mode 100644 index 30b3d59eec..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-1523.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 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. - -// See: http://code.google.com/p/v8/issues/detail?id=1523 - -// Flags: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. - -Debug = debug.Debug - -var listenerCalled = false; -var result = -1; - -function listener(event, exec_state, event_data, data) { - listenerCalled = true; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function test_and(x) { - if (x && (bar === this.baz)) - return 0; - return 1; -} - -function test_or(x) { - if (x || (bar === this.baz)) - return 0; - return 1; -} - -// Set a break points and call each function to invoke the debug event listener. -Debug.setBreakPoint(test_and, 0, 0); -Debug.setBreakPoint(test_or, 0, 0); - -listenerCalled = false; -result = test_and(false); -assertEquals(1, result); -assertTrue(listenerCalled); - -listenerCalled = false; -result = test_or(true); -assertEquals(0, result); -assertTrue(listenerCalled); diff --git a/deps/v8/test/mjsunit/regress/regress-1586.js b/deps/v8/test/mjsunit/regress/regress-1586.js deleted file mode 100644 index 9c805a7a4b..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-1586.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug - -// Test debug evaluation for functions without local context, but with -// nested catch contexts. - -function f() { - var i = 1; // Line 1. - { // Line 2. - try { // Line 3. - throw 'stuff'; // Line 4. - } catch (e) { // Line 5. - x = 2; // Line 6. - } - } -}; - -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - result = exec_state.frame().evaluate("i").value(); - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -//Set breakpoint on line 6. -var bp = Debug.setBreakPoint(f, 6); - -result = -1; -f(); -assertEquals(1, result); - -// Clear breakpoint. -Debug.clearBreakPoint(bp); -// Get rid of the debug event listener. -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-220.js b/deps/v8/test/mjsunit/regress/regress-220.js deleted file mode 100644 index cd38a478cc..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-220.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2009 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: --no-harmony-restrictive-declarations - -function foo(f) { eval(f); } - -// Ensure that compiling a declaration of a function does not crash. -foo("(function (x) { with ({x: []}) function x(){} })"); diff --git a/deps/v8/test/mjsunit/regress/regress-2296.js b/deps/v8/test/mjsunit/regress/regress-2296.js index c00f14f172..b81e8ee784 100644 --- a/deps/v8/test/mjsunit/regress/regress-2296.js +++ b/deps/v8/test/mjsunit/regress/regress-2296.js @@ -30,7 +30,11 @@ Debug = debug.Debug function listener(event, exec_state, event_data, data) { - event_data.script().setSource(1); + try { + event_data.script().setSource(1); + } catch (e) { + assertTrue(String(e).indexOf("Source is not a string") > 0); + } }; Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/regress/regress-2318.js b/deps/v8/test/mjsunit/regress/regress-2318.js index 771d195212..6f184302eb 100644 --- a/deps/v8/test/mjsunit/regress/regress-2318.js +++ b/deps/v8/test/mjsunit/regress/regress-2318.js @@ -25,11 +25,10 @@ // (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: --expose-debug-as debug --nostack-trace-on-abort --stack-size=150 +// Flags: --expose-debug-as debug --stack-size=150 function f() { var i = 0; - // Stack-allocate to reach the end of stack quickly. var _A0 = 00; var _A1 = 01; var _A2 = 02; var _A3 = 03; var _A4 = 04; var _B0 = 05; var _B1 = 06; var _B2 = 07; var _B3 = 08; var _B4 = 09; @@ -58,10 +57,16 @@ function f() { Debug = debug.Debug; function listener(event, exec_state, event_data, data) { - result = exec_state.frame().evaluate("i").value(); + if (event != Debug.DebugEvent.Break) return; + try { + exec_state.frame(0).evaluate("i"); + } catch (e) { + } }; Debug.setListener(listener); -var bp = Debug.setBreakPoint(f, 0); +var bp = Debug.setBreakPoint(f, 1); assertThrows(function() { f(); }, RangeError); + +Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-252797.js b/deps/v8/test/mjsunit/regress/regress-252797.js index 379205f599..ac776a17d8 100644 --- a/deps/v8/test/mjsunit/regress/regress-252797.js +++ b/deps/v8/test/mjsunit/regress/regress-252797.js @@ -31,11 +31,17 @@ // starting with a negative lookup. // Create a holder in fast mode. -var holder = Object.create(null, { +var holder = Object.create({}, { holderMethod: {value: function() {}} }); assertTrue(%HasFastProperties(holder)); +// We assume dict usage for null prototype. +var holder = Object.create(null, { + holderMethod: {value: function() {}} +}); +assertFalse(%HasFastProperties(holder)); + // Create a receiver into dictionary mode. var receiver = Object.create(holder, { killMe: {value: 0, configurable: true}, diff --git a/deps/v8/test/mjsunit/regress/regress-2618.js b/deps/v8/test/mjsunit/regress/regress-2618.js index 2634c80c66..faffc5bf47 100644 --- a/deps/v8/test/mjsunit/regress/regress-2618.js +++ b/deps/v8/test/mjsunit/regress/regress-2618.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: --use-osr --allow-natives-syntax --ignition-osr --turbo-from-bytecode +// Flags: --use-osr --allow-natives-syntax --ignition-osr function f() { do { diff --git a/deps/v8/test/mjsunit/regress/regress-269.js b/deps/v8/test/mjsunit/regress/regress-269.js deleted file mode 100644 index ce165e0abf..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-269.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function g() { -} - -function f() { - debugger; - g.apply(null, ['']); -} - -f() diff --git a/deps/v8/test/mjsunit/regress/regress-2825.js b/deps/v8/test/mjsunit/regress/regress-2825.js deleted file mode 100644 index 6ffd8ec150..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-2825.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -// Do not edit this file with an editor that replaces \r with \r\n. -// Variable definitions for i0 through i3 are each terminated with \r. -function f() { - var i0 = 0;
var i1 = 1;
var i2 = 2;
var i3 = 3;
- var j0 = 0; - var j1 = 1; - var j2 = 2; - var j3 = 3; -} - -Debug = debug.Debug; -var exception = null; -var break_point_hit = false; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - break_point_hit = true; - assertEquals(" var i2 = 2;", exec_state.frame(0).sourceLineText()); - } catch (e) { - print(e + e.stack); - exception = e; - } -} - -Debug.setListener(listener); - -Debug.setBreakPoint(f, 3, 0); - -f(); - -Debug.setListener(null); -assertTrue(break_point_hit); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-325676.js b/deps/v8/test/mjsunit/regress/regress-325676.js deleted file mode 100644 index 6c23d0a6bc..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-325676.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2013 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: --expose-debug-as debug - -// If a function parameter is forced to be context allocated, -// debug evaluate need to resolve it to a context slot instead of -// parameter slot on the stack. - -var Debug = debug.Debug; - -var expected; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals(expected, exec_state.frame(0).evaluate('arg').value()); - exec_state.frame(0).evaluate('arg = "evaluated";'); // no effect - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function f(arg) { - expected = arg; - debugger; - assertEquals("evaluated", arg); - - arg = "value"; - expected = arg; - debugger; - assertEquals("evaluated", arg); - - // Forces arg to be context allocated even though a parameter. - function g() { arg; } -} - -f(); -f(1); -f(1, 2); - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-3717.js b/deps/v8/test/mjsunit/regress/regress-3717.js deleted file mode 100644 index 1f7bc7d126..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-3717.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --no-lazy - -Debug = debug.Debug; -var exception = null; -var break_count = 0; - -function f() { - function g(p) { - return 1; - } - g(1); -}; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) break_count++; - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); -var bp = Debug.setBreakPoint(f, 2); -f(); -Debug.clearBreakPoint(bp); -Debug.setListener(null); - -assertEquals(1, break_count); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-392114.js b/deps/v8/test/mjsunit/regress/regress-392114.js deleted file mode 100644 index e5cf1cde37..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-392114.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 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: --expose-debug-as debug --allow-natives-syntax - -Debug = debug.Debug; - -function dummy(x) { - return x + 100; -} - -function create_closure() { - var f = function(arg) { - if (arg) { %DeoptimizeFunction(f); } - var a = Array(10); - for (var i = 0; i < a.length; i++) { - a[i] = i; - } - } - return f; -} - -var c = create_closure(); -c(); - -// c CallIC state now has custom Array handler installed. - -// Turn on the debugger. -Debug.setListener(function () {}); - -var d = create_closure(); -%OptimizeFunctionOnNextCall(d); -// Thanks to the debugger, we recreate the full code too. We deopt and run -// it, stomping on the unexpected AllocationSite in the type vector slot. -d(true); - -// CallIC in c misinterprets type vector slot contents as an AllocationSite, -// corrupting the heap. -c(); - -// CallIC MISS - crash due to corruption. -dummy(); diff --git a/deps/v8/test/mjsunit/regress/regress-4309-1.js b/deps/v8/test/mjsunit/regress/regress-4309-1.js deleted file mode 100644 index a13fd43a4a..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-4309-1.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; - -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var scopes = exec_state.frame().allScopes(); - assertEquals(3, scopes.length); - assertEquals(debug.ScopeType.Local, scopes[0].scopeType()); - assertEquals(debug.ScopeType.Script, scopes[1].scopeType()); - assertEquals(debug.ScopeType.Global, scopes[2].scopeType()); - } catch (e) { - exception = e; - } -} - -function f() { - eval(''); - debugger; -} - -f(); -f(); - -%OptimizeFunctionOnNextCall(f); -Debug.setListener(listener); - -f(); - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-4309-3.js b/deps/v8/test/mjsunit/regress/regress-4309-3.js deleted file mode 100644 index 687dd4c44a..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-4309-3.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; - -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var scopes = exec_state.frame().allScopes(); - assertEquals(4, scopes.length); - assertEquals(debug.ScopeType.With, scopes[0].scopeType()); - assertEquals(debug.ScopeType.Local, scopes[1].scopeType()); - assertEquals(debug.ScopeType.Script, scopes[2].scopeType()); - assertEquals(debug.ScopeType.Global, scopes[3].scopeType()); - } catch (e) { - exception = e; - } -} - -function f() { - with({}) { - debugger; - } -} - -f(); -f(); - -%OptimizeFunctionOnNextCall(f); -Debug.setListener(listener); - -f(); - -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-4320.js b/deps/v8/test/mjsunit/regress/regress-4320.js deleted file mode 100644 index df6a99b28f..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-4320.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -var Debug = debug.Debug; - -function f() { g(); } - -function g() { } - -f(); -f(); -%OptimizeFunctionOnNextCall(f); -f(); - -Debug.setListener(function() {}); -Debug.setBreakPoint(g, 0); - -f(); diff --git a/deps/v8/test/mjsunit/regress/regress-4703.js b/deps/v8/test/mjsunit/regress/regress-4703.js deleted file mode 100644 index dad8a97874..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-4703.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var all_scopes = exec_state.frame().allScopes(); - assertEquals([ debug.ScopeType.Block, - debug.ScopeType.Local, - debug.ScopeType.Script, - debug.ScopeType.Global ], - all_scopes.map(scope => scope.scopeType())); - } catch (e) { - exception = e; - } -} - -debug.Debug.setListener(listener); - -(function(arg, ...rest) { - var one = 1; - function inner() { - one; - arg; - } - debugger; -})(); diff --git a/deps/v8/test/mjsunit/regress/regress-491536.js b/deps/v8/test/mjsunit/regress/regress-491536.js deleted file mode 100644 index 6e6e0c6e14..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-491536.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -if (this["debug"]) debug.Debug.setListener(function() {}); -var source = "var outer = 0; function test() {'use strict'; outer = 1; } test(); print('ok');"; -function test_function() { eval(source); } -assertDoesNotThrow(test_function); diff --git a/deps/v8/test/mjsunit/regress/regress-5071.js b/deps/v8/test/mjsunit/regress/regress-5071.js deleted file mode 100644 index 41c1250031..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-5071.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - assertEquals(2, exec_state.frameCount()); - assertEquals("a", exec_state.frame(0).localName(0)); - assertEquals("1", exec_state.frame(0).localValue(0).value()); - assertEquals(1, exec_state.frame(0).localCount()); -} - -Debug.setListener(listener); - -function f() { - var a = 1; - { - let b = 2; - debugger; - } -} - -f(); diff --git a/deps/v8/test/mjsunit/regress/regress-514362.js b/deps/v8/test/mjsunit/regress/regress-514362.js deleted file mode 100644 index f69cfecebe..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-514362.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -function bar(x) { debugger; } -function foo() { bar(arguments[0]); } -function wrap() { return foo(1); } - -wrap(); -wrap(); -%OptimizeFunctionOnNextCall(wrap); - -var Debug = debug.Debug; -Debug.setListener(function(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - for (var i = 0; i < exec_state.frameCount(); i++) exec_state.frame(i); -}); - -wrap(); diff --git a/deps/v8/test/mjsunit/regress/regress-5252.js b/deps/v8/test/mjsunit/regress/regress-5252.js index 682d3193ea..c645416982 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 --turbo-from-bytecode +// Flags: --allow-natives-syntax --ignition --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 394bb49ca5..0b54b80623 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 --turbo-from-bytecode --allow-natives-syntax +// Flags: --ignition --ignition-osr --allow-natives-syntax function g() { return 23 } function h() { return 42 } diff --git a/deps/v8/test/mjsunit/regress/regress-5279.js b/deps/v8/test/mjsunit/regress/regress-5279.js deleted file mode 100644 index 847f5df054..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-5279.js +++ /dev/null @@ -1,16 +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 --expose-debug-as debug - -var Debug = debug.Debug; - -Debug.setListener(() => undefined); - -const myObj = {}; - -for (let i = 0; i < 10; i++) { - %OptimizeOsr(); - %ScheduleBreak(); -} diff --git a/deps/v8/test/mjsunit/regress/regress-536751.js b/deps/v8/test/mjsunit/regress/regress-536751.js deleted file mode 100644 index a63fae3957..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-536751.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --no-harmony-restrictive-declarations - -// At some point, this code led to DCHECK errors in debug mode - -for (; false;) function foo() {}; - -for (x in []) function foo() {}; diff --git a/deps/v8/test/mjsunit/regress/regress-542099.js b/deps/v8/test/mjsunit/regress/regress-542099.js deleted file mode 100644 index 6345fd468a..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-542099.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --no-harmony-restrictive-declarations - -// Previously, this caused a CHECK fail in debug mode -// https://code.google.com/p/chromium/issues/detail?id=542099 - -var foo = {}; -var bar = foo; -for (foo.x in {a: 1}) function foo() { return foo; } -assertEquals("object", typeof bar); -assertEquals("a", bar.x); -assertEquals("function", typeof foo); -assertEquals("function", typeof foo()); -assertSame(foo, foo()); -assertEquals(undefined, foo.x); diff --git a/deps/v8/test/mjsunit/regress/regress-542100.js b/deps/v8/test/mjsunit/regress/regress-542100.js deleted file mode 100644 index c16e6284fa..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-542100.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --no-harmony-restrictive-declarations - -(function() { - var x = {a: 1} - assertEquals("undefined", typeof f); - with (x) - function f() { return a; } - assertEquals("function", typeof f); - assertEquals(1, f()); - x.a = 2; - assertEquals(2, f()); -})(); - -var y = {b: 1} -assertEquals("undefined", typeof g); -with (y) - function g() { return b; } -assertEquals("function", typeof g); -assertEquals(1, g()); -y.b = 2; -assertEquals(2, g()); diff --git a/deps/v8/test/mjsunit/regress/regress-5434.js b/deps/v8/test/mjsunit/regress/regress-5434.js new file mode 100644 index 0000000000..8c45a96079 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5434.js @@ -0,0 +1,42 @@ +// 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. + +// Ensure that we have the correct number of accesses to exec in split, and +// that exec is called at the correct point in time. + +var lastIndexHasBeenSet = false; +var countOfExecGets = 0; + +// Force the slow path and make sure the created splitter object has our +// overwritten exec method (@@split does not call exec on the original regexp +// but on a newly-created splitter which is guaranteed to be sticky). +class ObservableExecRegExp extends RegExp { + constructor(pattern, flags) { + super(pattern, flags); + this.lastIndex = 42; + + const re = this; + Object.defineProperty(this, "exec", { + get: function() { + // Ensure exec is first accessed after lastIndex has been reset to + // satisfy the spec. + assertTrue(re.lastIndex != 42); + countOfExecGets++; + return RegExp.prototype.exec; + } + }); + } +} + + + +var re = new ObservableExecRegExp(/x/); + +assertEquals(42, re.lastIndex); +assertEquals(0, countOfExecGets); + +var result = "axbxc".split(re); + +assertEquals(5, countOfExecGets); +assertEquals(["a", "b", "c"], result); diff --git a/deps/v8/test/mjsunit/regress/regress-5476.js b/deps/v8/test/mjsunit/regress/regress-5476.js new file mode 100644 index 0000000000..5d18cebf7a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5476.js @@ -0,0 +1,16 @@ +// 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. +'use strict' + +class LeakyPromise extends Promise { + constructor(executor) { + super((resolve, reject) => { resolve();}); + this.resolve = function() {assertEquals(this, undefined); }; + this.reject = function() {assertEquals(this, undefined); }; + executor(this.resolve, this.reject); + } +} + +const p1 = new LeakyPromise((r) => r()); +const p2 = new LeakyPromise((_, r) => r()); diff --git a/deps/v8/test/mjsunit/regress/regress-5559.js b/deps/v8/test/mjsunit/regress/regress-5559.js deleted file mode 100644 index c6f32575f5..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-5559.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug - -var exception = null; -var break_count = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - print(event_data.sourceLineText()); - assertTrue( - event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); - exec_state.prepareStep(Debug.StepAction.StepOut); - } catch (e) { - exception = e; - } -}; - -function thrower() { - try { - debugger; // Break 0. - throw 'error'; - } catch (err) { - } -} - - -Debug.setListener(listener); -thrower(); -Debug.setListener(null); // Break 1. - -assertNull(exception); -assertEquals(2, break_count); diff --git a/deps/v8/test/mjsunit/regress/regress-5566.js b/deps/v8/test/mjsunit/regress/regress-5566.js new file mode 100644 index 0000000000..98e1f07208 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5566.js @@ -0,0 +1,26 @@ +// 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. + +// https://github.com/tc39/proposal-regexp-legacy-features#additional-properties-of-the-regexp-constructor + +const props = [ "input", "$_" + , "lastMatch", "$&" + , "lastParen", "$+" + , "leftContext", "$`" + , "rightContext", "$'" + , "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9" + ]; + +for (let i = 0; i < props.length; i++) { + const prop = props[i]; + const desc = Object.getOwnPropertyDescriptor(RegExp, prop); + assertTrue(desc.configurable, prop); + assertFalse(desc.enumerable, prop); + assertTrue(desc.get !== undefined, prop); + + // TODO(jgruber): Although the spec proposal specifies setting setters to + // undefined, we are not sure that this change would be web-compatible, and + // we are intentionally sticking with the old behavior for now. + assertTrue(desc.set !== undefined, prop); +} diff --git a/deps/v8/test/mjsunit/regress/regress-568765.js b/deps/v8/test/mjsunit/regress/regress-568765.js deleted file mode 100644 index 9efd8599a5..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-568765.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-gc --gc-interval=216 -// Flags: --nonative-context-specialization - -function PrettyPrint() { return ""; } -function fail() { } -assertSame = function assertSame() { if (found === expected) { if (1 / found) return; } else if ((expected !== expected) && (found !== found)) { return; }; }; assertEquals = function assertEquals(expected, found, name_opt) { if ( expected) { fail(PrettyPrint()); } }; -assertTrue = function assertTrue() { assertEquals(); }; -assertThrows = function assertThrows(code, type_opt, cause_opt) { var threwException = true; try { if (typeof code == 'function') { code(); } else {; } threwException = false; } catch (e) { if (typeof type_opt == 'function') {; } if (arguments.length >= 3) {; } return; } }; -assertInstanceof = function assertInstanceof() { if (obj instanceof type) { var actualTypeName = null; var actualConstructor = Object.getPrototypeOf().constructor; if (typeof actualConstructor == "function") {; }; } }; -function modifyPropertyOrValue() { var names; try {; } catch(e) {; return; } if(!names) return; name = names[rand_value % names.length]; if (isNaN()); } -function nop() {} -var __v_5 = {}; -var __v_12 = {}; -var __v_13 = {}; -var __v_16 = {}; -function __f_0() { -} -(function (){ - function __f_6() { - } - a = __f_6(); - b = __f_6(); - name = "Array"; -})(); -(function (){ - function __f_1() { - assertTrue(); - } - __f_1(); -})(); -__v_10 = { -} -__v_11 = new Object(); -tailee1 = function() { - "use strict"; - if (__v_12-- == 0) { - } - return nop(); -}; -%OptimizeFunctionOnNextCall(tailee1); -assertEquals(__v_10, tailee1.call()); -__v_14 = 100000; -gc(); -tailee2 = function() { - "use strict"; - __v_14 = ((__v_14 | 0) - 1) | 0; - if ((__v_14 | 0) === 0) { - } -}; -%OptimizeFunctionOnNextCall(tailee2); -assertEquals(__v_11, tailee2.call()); -__v_13 = 999999; -tailee3 = function() { - "use strict"; - if (__v_13-- == 0) { - } -}; -%OptimizeFunctionOnNextCall(tailee3); -assertEquals(__v_9, tailee3.call(__v_11, __v_9)); -tailee4 = function(px) { - return nop(tailee4, this, px, undefined); -}; -%OptimizeFunctionOnNextCall(tailee4); -assertThrows(function() { tailee4.call(); }); -tailee5 = function() { - return nop(); -}; -%OptimizeFunctionOnNextCall(tailee5); -assertThrows(function() { tailee5.call(); }); -tailee6 = function() { -} -tailee7 = function( py, pz, pa, pb, pc) { - return nop(); -}; -%OptimizeFunctionOnNextCall(tailee7); - tailee7.call(); - -(function() { - Number.prototype[0] = "a"; - Number.prototype[1] = "b"; - Object.defineProperty(Number.prototype, 2, { - get: function() { - } - }); - Number.prototype.length = 3; -Array.prototype.includes.call(5); -})(); -var __v_9 = -8; -var __v_20 = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-575364.js b/deps/v8/test/mjsunit/regress/regress-575364.js index 8671aec06b..34957a23c1 100644 --- a/deps/v8/test/mjsunit/regress/regress-575364.js +++ b/deps/v8/test/mjsunit/regress/regress-575364.js @@ -8,5 +8,4 @@ function f() { "use asm"; } -assertFalse(Wasm == undefined); assertTrue(%IsNotAsmWasmCode(f)); diff --git a/deps/v8/test/mjsunit/regress/regress-5763-1.js b/deps/v8/test/mjsunit/regress/regress-5763-1.js new file mode 100644 index 0000000000..50ad4035ae --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5763-1.js @@ -0,0 +1,11 @@ +// 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 + +try { + var TA = Object.getPrototypeOf(Int8Array); + var obj = Reflect.construct(TA, [], Int8Array); + Int8Array.prototype.values.call(obj).next(); +} catch (e) {} diff --git a/deps/v8/test/mjsunit/regress/regress-5763-2.js b/deps/v8/test/mjsunit/regress/regress-5763-2.js new file mode 100644 index 0000000000..0964b7f8e6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5763-2.js @@ -0,0 +1,11 @@ +// 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 + +try { + var TA = Object.getPrototypeOf(Int8Array); + var obj = Reflect.construct(TA, [], Int8Array); + new Int8Array(4).set(obj); +} catch (e) {} diff --git a/deps/v8/test/mjsunit/regress/regress-5790.js b/deps/v8/test/mjsunit/regress/regress-5790.js new file mode 100644 index 0000000000..7790db5ea9 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5790.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 foo(a) { + "use strict"; + if (a) return arguments[1]; +} + +foo(false); +foo(false); +%OptimizeFunctionOnNextCall(foo); +foo(true, 1); +foo(true, 1); +%OptimizeFunctionOnNextCall(foo); +foo(false); +foo(true, 1); +assertOptimized(foo); diff --git a/deps/v8/test/mjsunit/regress/regress-5802.js b/deps/v8/test/mjsunit/regress/regress-5802.js new file mode 100644 index 0000000000..6a84c09851 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5802.js @@ -0,0 +1,117 @@ +// 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 eq(a, b) { return a == b; } + + var o = { [Symbol.toPrimitive]: () => "o" }; + + assertTrue(eq(o, o)); + %BaselineFunctionOnNextCall(eq); + assertTrue(eq(o, o)); + %OptimizeFunctionOnNextCall(eq); + assertTrue(eq(o, o)); + assertTrue(eq("o", o)); + assertTrue(eq(o, "o")); + %OptimizeFunctionOnNextCall(eq); + assertTrue(eq(o, o)); + assertTrue(eq("o", o)); + assertTrue(eq(o, "o")); + assertOptimized(eq); +})(); + +(function() { + function ne(a, b) { return a != b; } + + var o = { [Symbol.toPrimitive]: () => "o" }; + + assertFalse(ne(o, o)); + %BaselineFunctionOnNextCall(ne); + assertFalse(ne(o, o)); + %OptimizeFunctionOnNextCall(ne); + assertFalse(ne(o, o)); + assertFalse(ne("o", o)); + assertFalse(ne(o, "o")); + %OptimizeFunctionOnNextCall(ne); + assertFalse(ne(o, o)); + assertFalse(ne("o", o)); + assertFalse(ne(o, "o")); + assertOptimized(ne); +})(); + +(function() { + function eq(a, b) { return a == b; } + + var a = {}; + var b = {b}; + var u = %GetUndetectable(); + + assertTrue(eq(a, a)); + assertTrue(eq(b, b)); + assertFalse(eq(a, b)); + assertFalse(eq(b, a)); + %BaselineFunctionOnNextCall(eq); + assertTrue(eq(a, a)); + assertTrue(eq(b, b)); + assertFalse(eq(a, b)); + assertFalse(eq(b, a)); + %OptimizeFunctionOnNextCall(eq); + assertTrue(eq(a, a)); + assertTrue(eq(b, b)); + assertFalse(eq(a, b)); + assertFalse(eq(b, a)); + assertTrue(eq(null, u)); + assertTrue(eq(undefined, u)); + assertTrue(eq(u, null)); + assertTrue(eq(u, undefined)); + %OptimizeFunctionOnNextCall(eq); + assertTrue(eq(a, a)); + assertTrue(eq(b, b)); + assertFalse(eq(a, b)); + assertFalse(eq(b, a)); + assertTrue(eq(null, u)); + assertTrue(eq(undefined, u)); + assertTrue(eq(u, null)); + assertTrue(eq(u, undefined)); + assertOptimized(eq); +})(); + +(function() { + function ne(a, b) { return a != b; } + + var a = {}; + var b = {b}; + var u = %GetUndetectable(); + + assertFalse(ne(a, a)); + assertFalse(ne(b, b)); + assertTrue(ne(a, b)); + assertTrue(ne(b, a)); + %BaselineFunctionOnNextCall(ne); + assertFalse(ne(a, a)); + assertFalse(ne(b, b)); + assertTrue(ne(a, b)); + assertTrue(ne(b, a)); + %OptimizeFunctionOnNextCall(ne); + assertFalse(ne(a, a)); + assertFalse(ne(b, b)); + assertTrue(ne(a, b)); + assertTrue(ne(b, a)); + assertFalse(ne(null, u)); + assertFalse(ne(undefined, u)); + assertFalse(ne(u, null)); + assertFalse(ne(u, undefined)); + %OptimizeFunctionOnNextCall(ne); + assertFalse(ne(a, a)); + assertFalse(ne(b, b)); + assertTrue(ne(a, b)); + assertTrue(ne(b, a)); + assertFalse(ne(null, u)); + assertFalse(ne(undefined, u)); + assertFalse(ne(u, null)); + assertFalse(ne(u, undefined)); + assertOptimized(ne); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-617882.js b/deps/v8/test/mjsunit/regress/regress-617882.js deleted file mode 100644 index acc332c59b..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-617882.js +++ /dev/null @@ -1,29 +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: --invoke-weak-callbacks --omit-quit --gc-interval=355 --expose-debug-as=debug - -var __v_33 = {}; -__v_4 = 70000; -function __f_18() { - if ((__v_7 % 50) != 0) { - } else { - return __v_33 + 0.5; - } -} -function __f_17(a) { - for (var __v_7= 0; __v_7 < __v_4; ++__v_7 ) { - a[__v_7] = __f_18(); - } -} -for (var __v_7= 0; __v_7 < __v_4; __v_7 += 500 ) { -} -__v_9 = new Array(); -__f_17(__v_9); -__v_9.length = 100; -Debug = debug.Debug -function __f_26() { - } -__v_29 = "(function() {\ - })()"; diff --git a/deps/v8/test/mjsunit/regress/regress-632289.js b/deps/v8/test/mjsunit/regress/regress-632289.js index 65a22558de..3f3059b2d4 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 --turbo-from-bytecode --always-opt --allow-natives-syntax +// Flags: --ignition --always-opt --allow-natives-syntax try { } catch(e) {; } diff --git a/deps/v8/test/mjsunit/regress/regress-653407.js b/deps/v8/test/mjsunit/regress/regress-653407.js new file mode 100644 index 0000000000..6dc28a9fd0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-653407.js @@ -0,0 +1,26 @@ +// 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 --ignition --turbo + +// This is to test if 'this' gets correctly initialized when inlining +// constructors in turbofan. + +class superClass { + constructor () {} +} + +class subClass extends superClass { + constructor () { + super(); + } +} + +function f() { + new subClass(); +} + +f(); // We need this to collect feedback, so that subClass gets inlined in f. +%OptimizeFunctionOnNextCall(f) +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-662845.js b/deps/v8/test/mjsunit/regress/regress-662845.js new file mode 100644 index 0000000000..7740ed10ff --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-662845.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(x) { + (function() { x = 1; })() + return arguments[0]; +} + +assertEquals(1, foo(42)); +assertEquals(1, foo(42)); +%OptimizeFunctionOnNextCall(foo); +assertEquals(1, foo(42)); diff --git a/deps/v8/test/mjsunit/regress/regress-662904.js b/deps/v8/test/mjsunit/regress/regress-662904.js new file mode 100644 index 0000000000..00ab1cd65f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-662904.js @@ -0,0 +1,19 @@ +// 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(a) { + var sum = 0; + var a = [0, "a"]; + for (var i in a) { + sum += a[i]; + } + return sum; +} + +assertEquals("0a", foo()); +assertEquals("0a", foo()); +%OptimizeFunctionOnNextCall(foo); +assertEquals("0a", foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-662935.js b/deps/v8/test/mjsunit/regress/regress-662935.js deleted file mode 100644 index b15f83a1e9..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-662935.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug -function overflow() { - return new Promise(function foo() { foo() }); -} - -function listener(event, exec_state, event_data, data) { } - -Debug.setListener(listener); - -assertEquals(Promise, overflow().constructor); diff --git a/deps/v8/test/mjsunit/regress/regress-664087.js b/deps/v8/test/mjsunit/regress/regress-664087.js new file mode 100644 index 0000000000..6739167930 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-664087.js @@ -0,0 +1,21 @@ +// 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 g() { + throw 1; +} + +var v = { valueOf : g }; + +function foo(v) { + v++; +} + +%NeverOptimizeFunction(g); +assertThrows(function () { foo(v); }); +assertThrows(function () { foo(v); }); +%OptimizeFunctionOnNextCall(foo); +assertThrows(function () { foo(v); }); diff --git a/deps/v8/test/mjsunit/regress/regress-94873.js b/deps/v8/test/mjsunit/regress/regress-94873.js deleted file mode 100644 index b61bc0c15d..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-94873.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2011 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug; - -function sendCommand(state, cmd) { - // Get the debug command processor in paused state. - var dcp = state.debugCommandProcessor(false); - var request = JSON.stringify(cmd); - var response = dcp.processDebugJSONRequest(request); - return JSON.parse(response); -} - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - var line = event_data.sourceLineText(); - print('break: ' + line); - - var frame = sendCommand(exec_state, { - seq: 0, - type: "request", - command: "frame" - }); - - sendCommand(exec_state, { - seq: 0, - type: "request", - command: "evaluate", - arguments: { - expression: "obj.x.toString()", - additional_context: [{ - name: "obj", - handle: frame.body.receiver.ref - }] - } - }); - } - } catch (e) { - print(e); - } -} - -Debug.setListener(listener); - -function a(x, y) { - this.x = x; - this.y = y; -} - -Debug.setBreakPoint(a, 0, 0); -new a(1, 2); diff --git a/deps/v8/test/mjsunit/regress/regress-998565.js b/deps/v8/test/mjsunit/regress/regress-998565.js deleted file mode 100644 index 840c045c0c..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-998565.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2008 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: --expose-debug-as debug -// Get the Debug object exposed from the debug context global object. -Debug = debug.Debug - -listenerCalled = false; - -function listener(event, exec_state, event_data, data) { - listenerCalled = true; - throw 1; -}; - -// Add the debug event listener. -Debug.setListener(listener); - -function f() { - a=1 -}; - -// Set a break point and call to invoke the debug event listener. -Debug.setBreakPoint(f, 0, 0); -f(); - -// Make sure that the debug event listener vas invoked. -assertTrue(listenerCalled); diff --git a/deps/v8/test/mjsunit/regress/regress-abort-preparsing-params.js b/deps/v8/test/mjsunit/regress/regress-abort-preparsing-params.js index d2bdc5084d..d535321795 100644 --- a/deps/v8/test/mjsunit/regress/regress-abort-preparsing-params.js +++ b/deps/v8/test/mjsunit/regress/regress-abort-preparsing-params.js @@ -4,7 +4,7 @@ var outer_a; -function f(a) { +function f(a, b, a) { outer_a = a; x = 1; x = 1; @@ -942,5 +942,5 @@ function f(a) { x = 1; x = 1; } -f(1); +f(1, 2, 1); assertEquals(1, outer_a); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-107996.js b/deps/v8/test/mjsunit/regress/regress-crbug-107996.js deleted file mode 100644 index dfe07e59de..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-107996.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 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: --expose-debug-as debug - -Debug = debug.Debug; - -Debug.setListener(listener); - -var fourteen; -var four_in_debugger = []; - -function listener(event, exec_state, event_data, data) { - if (event == Debug.DebugEvent.Break) { - for (var i = 0; i < exec_state.frameCount(); i++) { - var frame = exec_state.frame(i); - four_in_debugger[i] = frame.evaluate("four", false).value(); - } - } -} - -function f1() { - var three = 3; - var four = 4; - (function f2() { - var seven = 7; - (function f3() { - debugger; - fourteen = three + four + seven; - })(); - })(); -} - -f1(); -assertEquals(14, fourteen); -assertEquals(4, four_in_debugger[0]); -assertEquals(4, four_in_debugger[1]); -assertEquals(4, four_in_debugger[2]); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-323936.js b/deps/v8/test/mjsunit/regress/regress-crbug-323936.js deleted file mode 100644 index ca543b068a..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-323936.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug; - -var step = 0; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - if (step == 0) { - assertEquals("error", exec_state.frame(0).evaluate("e").value()); - exec_state.frame(0).evaluate("write_0('foo')"); - exec_state.frame(0).evaluate("write_1('modified')"); - } else { - assertEquals("argument", exec_state.frame(0).evaluate("e").value()); - exec_state.frame(0).evaluate("write_2('bar')"); - } - step++; - } catch (e) { - print(e + e.stack); - exception = e; - } -} - -Debug.setListener(listener); - -function f(e, x) { - try { - throw "error"; - } catch(e) { - // In ES2015 hoisting semantics, 'x' binds to the argument - // and 'e' binds to the exception. - function write_0(v) { e = v } - function write_1(v) { x = v } - debugger; - assertEquals("foo", e); // overwritten by the debugger - } - assertEquals("argument", e); // debugger did not overwrite - function write_2(v) { e = v } - debugger; - assertEquals("bar", e); - assertEquals("modified", x); -} - -f("argument") -assertNull(exception); -assertEquals(2, step); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-387599.js b/deps/v8/test/mjsunit/regress/regress-crbug-387599.js deleted file mode 100644 index 753dcfa3a6..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-387599.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -Debug = debug.Debug; -Debug.setListener(function() {}); - -function f() { - for (var i = 0; i < 100; i++) %OptimizeOsr(); -} - -Debug.setBreakPoint(f, 0, 0); -f(); -f(); -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-401915.js b/deps/v8/test/mjsunit/regress/regress-crbug-401915.js deleted file mode 100644 index 96dce04868..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-401915.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -Debug = debug.Debug; -Debug.setListener(function() {}); -Debug.setBreakOnException(); - -try { - try { - %DebugPushPromise(new Promise(function() {})); - } catch (e) { - } - throw new Error(); -} catch (e) { -} - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-405491.js b/deps/v8/test/mjsunit/regress/regress-crbug-405491.js deleted file mode 100644 index b63378113f..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-405491.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as 1 diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-405922.js b/deps/v8/test/mjsunit/regress/regress-crbug-405922.js deleted file mode 100644 index 31b432de19..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-405922.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --allow-natives-syntax --expose-debug-as debug - -Debug = debug.Debug -var exception = null; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - exec_state.prepareStep(Debug.StepAction.StepIn); - } - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -function f(x) { - if (x > 0) %_Call(f, null, x-1); -} - -debugger; -f(2); - -Debug.setListener(null); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-409614.js b/deps/v8/test/mjsunit/regress/regress-crbug-409614.js deleted file mode 100644 index 1a9a77746a..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-409614.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug; -var exception = null; -var error_count = 0; - -function f() { - return 0; // Break -} // Break - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - if (exec_state.frame(0).sourceLineText().indexOf("Break") <0) { - error_count++; - } - exec_state.prepareStep(Debug.StepAction.StepIn); - f(); // We should not break in this call of f(). - } catch (e) { - print(e + e.stack); - exception = e; - } -} - -Debug.setListener(listener); - -debugger; // Break -f(); // Break - -Debug.setListener(null); // Break - -assertNull(exception); -assertEquals(0, error_count); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-467180.js b/deps/v8/test/mjsunit/regress/regress-crbug-467180.js deleted file mode 100644 index a07c6a6466..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-467180.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -function f() { - for (var i = 10; i < 14; i++) { // 1 - i; // 2 - } -} // 3 - -var state = "conditional"; -var log = []; -var exception = null; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var label = +exec_state.frame(0).sourceLineText().substr(-1); - log.push(label); - if (label == 2) log.push(exec_state.frame(0).evaluate("i").value()); - exec_state.prepareStep(Debug.StepAction.StepNext); - } catch (e) { - exception = e; - print("Caught something. " + e + " " + e.stack); - }; -}; - - -var Debug = debug.Debug; -Debug.setListener(listener); - -Debug.setBreakPoint(f, 2, 0, "i == 12"); - -f(); - -Debug.setListener(null); // 4 - -assertEquals([2,12,1,1,2,13,1,1,3,4], log); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-568477-1.js b/deps/v8/test/mjsunit/regress/regress-crbug-568477-1.js deleted file mode 100644 index ed269a9d7d..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-568477-1.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var expected = ["debugger;", "var x = y;", "debugger;", "var x = y;"]; -var log = []; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - log.push(exec_state.frame(0).sourceLineText().trimLeft()); - exec_state.prepareStep(Debug.StepAction.StepNext); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setListener(listener); - -function f() { - var a = 1; - debugger; - var x = y; - print(x); -} - -function call_f_with_deeper_stack() { - (() => () => () => f())()()(); -} - -Promise.resolve().then(f).catch(call_f_with_deeper_stack); - -// Schedule microtask to check against expectation at the end. -function testDone(iteration) { - function checkResult() { - try { - assertTrue(iteration < 10); - if (expected.length == log.length) { - assertEquals(expected, log); - } else { - testDone(iteration + 1); - } - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } - } - - %EnqueueMicrotask(checkResult); -} - -testDone(0); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-568477-3.js b/deps/v8/test/mjsunit/regress/regress-crbug-568477-3.js deleted file mode 100644 index 812db2b8f7..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-568477-3.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var expected = ["debugger;", "var x = y;", "debugger;", "var x = y;"]; -var log = []; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - log.push(exec_state.frame(0).sourceLineText().trimLeft()); - exec_state.prepareStep(Debug.StepAction.StepNext); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setListener(listener); - -function f() { - var a = 1; - debugger; - var x = y; - print(x); -} - -function call_f_with_deeper_stack() { - (() => () => () => f())()()(); -} - -var p = Promise.resolve(); -p.then(f); -p.then(call_f_with_deeper_stack); - -// Schedule microtask to check against expectation at the end. -function testDone(iteration) { - function checkResult() { - try { - assertTrue(iteration < 10); - if (expected.length == log.length) { - assertEquals(expected, log); - } else { - testDone(iteration + 1); - } - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } - } - - %EnqueueMicrotask(checkResult); -} - -testDone(0); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-568477-4.js b/deps/v8/test/mjsunit/regress/regress-crbug-568477-4.js deleted file mode 100644 index f0e3e901db..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-568477-4.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax - -var Debug = debug.Debug; -var expected = - ["debugger;", "var x = y;", "var b = 2;", "Debug.setListener(null);"]; -var log = []; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - log.push(exec_state.frame(0).sourceLineText().trimLeft()); - exec_state.prepareStep(Debug.StepAction.StepNext); - } catch (e) { - %AbortJS(e + "\n" + e.stack); - } -} - -Debug.setListener(listener); - -function f() { - var a = 1; - debugger; - var x = y; - print(x); -} - -try { - %Call(f, {}); -} catch (e) { - var b = 2; -} - -Debug.setListener(null); - -assertEquals(expected, log); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-582048.js b/deps/v8/test/mjsunit/regress/regress-crbug-582048.js deleted file mode 100644 index 6d98f488e3..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-582048.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - var frame_count = exec_state.frameCount(); - for (var i = 0; i < frame_count; i++) { - var frame = exec_state.frame(i); - var scope_count = frame.scopeCount(); - for (var j = 0; j < scope_count; j++) { - var scope = frame.scope(j); - assertTrue(scope.scopeObject().property('').isUndefined()); - } - } - } catch (e) { - print(e, e.stack); - exception = e; - } -} - -Debug.setListener(listener); - -(function(a = 1) { debugger; })(); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-582051.js b/deps/v8/test/mjsunit/regress/regress-crbug-582051.js deleted file mode 100644 index 93f4e70dfb..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-582051.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -var test_y = false; - -function foo(a = 1) { - var x = 2; - debugger; - eval("var y = 3"); - test_y = true; - debugger; -} - -var exception = null; -var break_count = 0; -var Debug = debug.Debug; -var ScopeType = debug.ScopeType; - -function listener(event, exec_state) { - if (event != Debug.DebugEvent.Break) return; - try { - var scopes = exec_state.frame(0).allScopes(); - var expectation = [ ScopeType.Block, - ScopeType.Local, - ScopeType.Script, - ScopeType.Global ]; - assertEquals(expectation, scopes.map(x => x.scopeType())); - assertEquals(2, scopes[0].scopeObject().value().x); - if (test_y) assertEquals(3, scopes[0].scopeObject().value().y); - assertEquals(1, scopes[1].scopeObject().value().a); - break_count++; - } catch (e) { - print(e); - exception = e; - } -} -Debug.setListener(listener); -foo(); - -assertNull(exception); -assertEquals(2, break_count); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-609046.js b/deps/v8/test/mjsunit/regress/regress-crbug-609046.js deleted file mode 100644 index 10b63af3e3..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-609046.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -// Test that hidden scopes are correctly walked in the scope chain. - -var Debug = debug.Debug; -var exception = null; -var delegate = null; -var done = false; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals([ debug.ScopeType.Block, - debug.ScopeType.Script, - debug.ScopeType.Global ], - exec_state.frame(0).allScopes().map(s => s.scopeType())); - done = true; - } catch (e) { - exception = e; - } -} - -Debug.setListener(listener); - -for(let a = 0; a < 3; a++) { - debugger; - eval(); // Force context-allocation of everything. -} - -Debug.setListener(null); -assertNull(exception); -assertTrue(done); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-632800.js b/deps/v8/test/mjsunit/regress/regress-crbug-632800.js index 6296572c17..a4c2301217 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 --turbo-from-bytecode +// Flags: --ignition --ignition-osr function osr() { for (var i = 0; i < 50000; ++i) Math.random(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-633999.js b/deps/v8/test/mjsunit/regress/regress-crbug-633999.js deleted file mode 100644 index 3f16908610..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-crbug-633999.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug --allow-natives-syntax --noturbo - -var Debug = debug.Debug -var exception = null; -var step = 0; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Exception) return; - try { - step++; - } catch (e) { - exception = e; - } -} - -Debug.setBreakOnException(); -Debug.setListener(listener); - -(function () { - "use asm"; - function f() { - try { - throw 666; - } catch (e) { - } - } - f(); - f(); - %OptimizeFunctionOnNextCall(f); - f(); - assertOptimized(f); -})(); - -Debug.setListener(null); -assertNull(exception); -assertEquals(3, step); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-635923.js b/deps/v8/test/mjsunit/regress/regress-crbug-635923.js index aea5e3a97c..5b697d74ad 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-from-bytecode --turbo-filter=f +// Flags: --allow-natives-syntax --ignition --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-644631.js b/deps/v8/test/mjsunit/regress/regress-crbug-644631.js index 5e649a4946..bf845c7aee 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-644631.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-644631.js @@ -2,11 +2,12 @@ // 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: --allow-natives-syntax --turbo --always-opt function f() { - new Int8Array(new ArrayBuffer(2147483648)); + var obj = Object.freeze({}); + %_CreateDataProperty(obj, "foo", "bar"); } // Should not crash -assertThrows(f, RangeError); +assertThrows(f, TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-656275.js b/deps/v8/test/mjsunit/regress/regress-crbug-656275.js new file mode 100644 index 0000000000..74b29c1458 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-656275.js @@ -0,0 +1,14 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var a = 1; + +function foo(x) { a = Math.fround(x + 1); } + +foo(1); +foo(1); +%OptimizeFunctionOnNextCall(foo); +foo(1.3); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-658185.js b/deps/v8/test/mjsunit/regress/regress-crbug-658185.js new file mode 100644 index 0000000000..60de8d6458 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-658185.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: --allow-natives-syntax --turbo-escape + +var t = 0; +function foo() { + var o = {x:1}; + var p = {y:2.5, x:0}; + o = []; + for (var i = 0; i < 2; ++i) { + t = o.x; + o = p; + } +} +foo(); +foo(); +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/modules-fail-1.js b/deps/v8/test/mjsunit/regress/regress-crbug-658528.js index 3e28647514..a6b07482b7 100644 --- a/deps/v8/test/mjsunit/modules-fail-1.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-658528.js @@ -1,7 +1,10 @@ // 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. -// -// MODULE -import {a} from "modules-fail-1.js"; +function f() { + eval("var x = 1"); + const x = 2; +} + +assertThrows(f, SyntaxError); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-658691.js b/deps/v8/test/mjsunit/regress/regress-crbug-658691.js new file mode 100644 index 0000000000..fee95f1eb3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-658691.js @@ -0,0 +1,24 @@ +// 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 --ignition --turbo + +// The {f} function is compiled using TurboFan. +// 1) The call to {Reflect.set} has no arguments adaptation. +// 2) The call to {Reflect.set} is in tail position. +function f(a, b, c) { + "use strict"; + return Reflect.set({}); +} + +// The {g} function is compiled using Ignition. +// 1) The call to {f} requires arguments adaptation. +// 2) The call to {f} is not in tail position. +function g() { + return f() + "-no-tail"; +} + +assertEquals("true-no-tail", g()); +%OptimizeFunctionOnNextCall(f); +assertEquals("true-no-tail", g()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-659915a.js b/deps/v8/test/mjsunit/regress/regress-crbug-659915a.js new file mode 100644 index 0000000000..ef672b187f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-659915a.js @@ -0,0 +1,24 @@ +// 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 --min-preparse-length=10 + +let x; +function f(a) { + x += a; +} +function g(a) { + f(a); return x; +} +function h(a) { + x = a; return x; +} + +function boom() { return g(1) } + +assertEquals(1, h(1)); +assertEquals(2, boom()); +assertEquals(3, boom()); +%OptimizeFunctionOnNextCall(boom); +assertEquals(4, boom()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-659915b.js b/deps/v8/test/mjsunit/regress/regress-crbug-659915b.js new file mode 100644 index 0000000000..cc47f03bb1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-659915b.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: --allow-natives-syntax --min-preparse-length=10 + +(function() { + var x = 23; + function f() { return x; } + function g() { [x] = [x + 1]; } + function h() { g(); return x; } + + function boom() { return h() } + + assertEquals(24, boom()); + assertEquals(25, boom()); + assertEquals(26, boom()); + %OptimizeFunctionOnNextCall(boom); + assertEquals(27, boom()); +})(); diff --git a/deps/v8/test/mjsunit/modules-skip-cyclic.js b/deps/v8/test/mjsunit/regress/regress-crbug-659967.js index ad5d80608e..654f00de60 100644 --- a/deps/v8/test/mjsunit/modules-skip-cyclic.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-659967.js @@ -2,4 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export {b as a} from "modules-fail-cyclic-2.js"; +function f() { null >> arguments; } + +f(); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-660379.js b/deps/v8/test/mjsunit/regress/regress-crbug-660379.js new file mode 100644 index 0000000000..84634628d6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-660379.js @@ -0,0 +1,42 @@ +// 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 InlinedThrowAtEndOfTry() { + function g() { + %DeoptimizeFunction(f); + throw "boom"; + } + function f() { + try { + g(); // Right at the end of try. + } catch (e) { + assertEquals("boom", e) + } + } + assertDoesNotThrow(f); + assertDoesNotThrow(f); + %OptimizeFunctionOnNextCall(f); + assertDoesNotThrow(f); +})(); + +(function InlinedThrowInFrontOfTry() { + function g() { + %DeoptimizeFunction(f); + throw "boom"; + } + function f() { + g(); // Right in front of try. + try { + Math.random(); + } catch (e) { + assertUnreachable(); + } + } + assertThrows(f); + assertThrows(f); + %OptimizeFunctionOnNextCall(f); + assertThrows(f); +})(); diff --git a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases3.js b/deps/v8/test/mjsunit/regress/regress-crbug-661949.js index 6fc7eab0cf..e083cae349 100644 --- a/deps/v8/test/mjsunit/harmony/async-debug-caught-exception-cases3.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-661949.js @@ -2,7 +2,14 @@ // 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-async-await --expose-debug-as debug -// Files: test/mjsunit/harmony/async-debug-caught-exception-cases.js +// Flags: --allow-natives-syntax -runPart(3); +var foo = (function() { + 'use asm'; + function foo() { ''[0]; } + return foo; +})(); + +foo(); +%OptimizeFunctionOnNextCall(foo); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-662367.js b/deps/v8/test/mjsunit/regress/regress-crbug-662367.js new file mode 100644 index 0000000000..8e1eafa30a --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-662367.js @@ -0,0 +1,37 @@ +// 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 --fold-constants + +var zero = 0; + +(function ConstantFoldZeroDivZero() { + function f() { + return 0 / zero; + } + assertTrue(isNaN(f())); + assertTrue(isNaN(f())); + %OptimizeFunctionOnNextCall(f); + assertTrue(isNaN(f())); +})(); + +(function ConstantFoldMinusZeroDivZero() { + function f() { + return -0 / zero; + } + assertTrue(isNaN(f())); + assertTrue(isNaN(f())); + %OptimizeFunctionOnNextCall(f); + assertTrue(isNaN(f())); +})(); + +(function ConstantFoldNaNDivZero() { + function f() { + return NaN / 0; + } + assertTrue(isNaN(f())); + assertTrue(isNaN(f())); + %OptimizeFunctionOnNextCall(f); + assertTrue(isNaN(f())); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-662410.js b/deps/v8/test/mjsunit/regress/regress-crbug-662410.js new file mode 100644 index 0000000000..f1cbc6b824 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-662410.js @@ -0,0 +1,21 @@ +// 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 g(v) { return v.constructor; } + +g({}); +g({}); + +function f() { + var i = 0; + do { + i = i + 1; + g(i); + } while (i < 1); +} + +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-662830.js b/deps/v8/test/mjsunit/regress/regress-crbug-662830.js new file mode 100644 index 0000000000..3126978d7d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-662830.js @@ -0,0 +1,19 @@ +// 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 f() { + %_DeoptimizeNow(); + throw 1; +} + +function g() { + try { f(); } catch(e) { } + for (var i = 0; i < 3; ++i) if (i === 1) %OptimizeOsr(); + %_DeoptimizeNow(); +} + +%OptimizeFunctionOnNextCall(g); +g(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-663750.js b/deps/v8/test/mjsunit/regress/regress-crbug-663750.js new file mode 100644 index 0000000000..ba758e77e4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-663750.js @@ -0,0 +1,26 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var v = 0; +function foo(a) { + v = a; +} +this.x = 0; +delete x; + +foo(1); +foo(2); +%OptimizeFunctionOnNextCall(foo); +foo(3); +assertEquals(3, v); + +Object.freeze(this); + +foo(4); +foo(5); +%OptimizeFunctionOnNextCall(foo); +foo(6); +assertEquals(3, v); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-664084.js b/deps/v8/test/mjsunit/regress/regress-crbug-664084.js new file mode 100644 index 0000000000..79e221e495 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664084.js @@ -0,0 +1,14 @@ +// 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() { + return +({} + 1); +} + +assertEquals(NaN, foo()); +assertEquals(NaN, foo()); +%OptimizeFunctionOnNextCall(foo); +assertEquals(NaN, foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-664469.js b/deps/v8/test/mjsunit/regress/regress-crbug-664469.js new file mode 100644 index 0000000000..e163391112 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664469.js @@ -0,0 +1,21 @@ +// 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. + +function f(a, i) { + a[i] = "object"; +} + +f("make it generic", 0); + +// Nearly kMaxRegularHeapObjectSize's worth of doubles. +var kLength = 500000 / 8; +var kValue = 0.1; +var a = new Array(kLength); +for (var i = 0; i < kLength; i++) { + a[i] = kValue; +} +f(a, 0); +for (var i = 1; i < kLength; i++) { + assertEquals(kValue, a[i]); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-664506.js b/deps/v8/test/mjsunit/regress/regress-crbug-664506.js new file mode 100644 index 0000000000..b0bf5e7591 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664506.js @@ -0,0 +1,11 @@ +// 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 --predictable --random-seed=-1109634722 + +gc(); +gc(); +assertEquals("[object Object]", Object.prototype.toString.call({})); +gc(); +assertEquals("[object Array]", Object.prototype.toString.call([])); diff --git a/deps/v8/test/mjsunit/modules-fail-2.js b/deps/v8/test/mjsunit/regress/regress-crbug-664802.js index e7dd683ced..3395f4c676 100644 --- a/deps/v8/test/mjsunit/modules-fail-2.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664802.js @@ -1,7 +1,10 @@ // 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. -// -// MODULE -import {a as b} from "modules-fail-2.js"; +var o = {}; +o.__proto__ = new Proxy({}, {}); + +var m = new Map(); +m.set({}); +m.set(o); diff --git a/deps/v8/test/mjsunit/modules-fail-4.js b/deps/v8/test/mjsunit/regress/regress-crbug-664942.js index ec9edda909..3b76990511 100644 --- a/deps/v8/test/mjsunit/modules-fail-4.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664942.js @@ -1,8 +1,12 @@ // 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. -// -// MODULE -import {a as b} from "modules-fail-4.js"; -export {c as a} from "modules-fail-4.js"; +// Flags: --allow-natives-syntax + +function foo() { + return 'x'[0]; +} +foo(); +%OptimizeFunctionOnNextCall(foo); +assertEquals("x", foo()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-664974.js b/deps/v8/test/mjsunit/regress/regress-crbug-664974.js new file mode 100644 index 0000000000..37ad4f9dc2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664974.js @@ -0,0 +1,13 @@ +// 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. + +for (var i = 0; i < 2000; i++) { + Object.prototype['X'+i] = true; +} + +var m = new Map(); +m.set(Object.prototype, 23); + +var o = {}; +m.set(o, 42); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-665886.js b/deps/v8/test/mjsunit/regress/regress-crbug-665886.js new file mode 100644 index 0000000000..b3309c249f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-665886.js @@ -0,0 +1,14 @@ +// 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. + +[1].toLocaleString(); +delete Number.prototype.toLocaleString; +[1].toLocaleString(); +var o = {}; +o.__proto__ = { toString: Array.prototype.toString }; +o.toString(); +Number.prototype.arrayToString = Array.prototype.toString; +(42).arrayToString(); +var a = [7]; +a.toLocaleString(); diff --git a/deps/v8/test/mjsunit/regress/regress-409533.js b/deps/v8/test/mjsunit/regress/regress-crbug-679202.js index e51065e4bf..e4350224fd 100644 --- a/deps/v8/test/mjsunit/regress/regress-409533.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-679202.js @@ -1,12 +1,13 @@ -// Copyright 2014 the V8 project authors. All rights reserved. +// 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() { - %_RegExpConstructResult(0, {}, {}); -} +var x = Object.prototype; + +function f() { return x <= x; } + f(); f(); %OptimizeFunctionOnNextCall(f); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-682194.js b/deps/v8/test/mjsunit/regress/regress-crbug-682194.js new file mode 100644 index 0000000000..62a4347eef --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-682194.js @@ -0,0 +1,35 @@ +// 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 + +var proxy = new Proxy([], { + defineProperty() { + w.length = 1; // shorten the array so the backstore pointer is relocated + gc(); // force gc to move the array's elements backstore + return Object.defineProperty.apply(this, arguments); + } +}); + +class MyArray extends Array { + // custom constructor which returns a proxy object + static get[Symbol.species](){ + return function() { + return proxy; + } + }; +} + +var w = new MyArray(100); +w[1] = 0.1; +w[2] = 0.1; + +var result = Array.prototype.concat.call(w); + +assertEquals(undefined, result[0]); +assertEquals(0.1, result[1]); + +for (var i = 2; i < 200; i++) { + assertEquals(undefined, result[i]); +} diff --git a/deps/v8/test/mjsunit/regress/regress-debug-code-recompilation.js b/deps/v8/test/mjsunit/regress/regress-debug-code-recompilation.js deleted file mode 100644 index 2f81d0cb54..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-debug-code-recompilation.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2012 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 --hydrogen-filter=Debug.setBreakPoint -// Flags: --expose-debug-as debug - -Debug = debug.Debug -Debug.setListener(function(){}); - -function f() {a=1;b=2}; -function g() { - a=1; - b=2; -} - -bp = Debug.setBreakPoint(f, 0, 0); -Debug.clearBreakPoint(bp); -%OptimizeFunctionOnNextCall(Debug.setBreakPoint); -bp = Debug.setBreakPoint(f, 0, 0); -Debug.clearBreakPoint(bp); -bp = Debug.setBreakPoint(f, 0, 0); -Debug.clearBreakPoint(bp); -%OptimizeFunctionOnNextCall(Debug.setBreakPoint); -bp = Debug.setBreakPoint(f, 0, 0); -Debug.clearBreakPoint(bp); - -Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-debug-context-load.js b/deps/v8/test/mjsunit/regress/regress-debug-context-load.js deleted file mode 100644 index 0b3c275f99..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-debug-context-load.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-debug-as debug - -Debug = debug.Debug; -Debug.setListener(null); 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 b08a94257c..57028b0cef 100644 --- a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js +++ b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js @@ -36,6 +36,7 @@ if (!%IsConcurrentRecompilationSupported()) { function test(fun) { fun(); + %BaselineFunctionOnNextCall(fun); fun(); // Mark for concurrent optimization. %OptimizeFunctionOnNextCall(fun, "concurrent"); diff --git a/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js b/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js deleted file mode 100644 index c637be5497..0000000000 --- a/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2013 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: --expose-debug-as debug --allow-natives-syntax -// Flags: --concurrent-recompilation --block-concurrent-recompilation - -if (!%IsConcurrentRecompilationSupported()) { - print("Concurrent recompilation is disabled. Skipping this test."); - quit(); -} - -Debug = debug.Debug; - -function listener(event, exec_state, event_data, data) { - if (event != Debug.DebugEvent.Break) return; - try { - assertEquals("foo", exec_state.frame(0).evaluate("a").value()); - } catch (e) { - exception = e; - }; - listened++; -}; - -var exception = null; -var listened = 0; - -var f = function() { - var a = "foo"; - var b = a.substring("1"); - [a, b].sort(); - return a; -} - -f(); -f(); -%OptimizeFunctionOnNextCall(f, "concurrent"); // Mark with builtin. -f(); // Kick off concurrent recompilation. - -// After compile graph has been created... -Debug.setListener(listener); // Activate debugger. -Debug.setBreakPoint(f, 2, 0); // Force deopt. - -// At this point, concurrent recompilation is still being blocked. -assertUnoptimized(f, "no sync"); -// Let concurrent recompilation proceed. -%UnblockConcurrentRecompilation(); -// Sync with optimization thread. But no optimized code is installed. -assertUnoptimized(f, "sync"); - -f(); // Trigger break point. -assertEquals(1, listened); -assertNull(exception); diff --git a/deps/v8/test/mjsunit/regress/regress-prepare-break-while-recompile.js b/deps/v8/test/mjsunit/regress/regress-prepare-break-while-recompile.js index 0673220e4a..528f517148 100644 --- a/deps/v8/test/mjsunit/regress/regress-prepare-break-while-recompile.js +++ b/deps/v8/test/mjsunit/regress/regress-prepare-break-while-recompile.js @@ -46,6 +46,8 @@ function bar() { } foo(); +%BaselineFunctionOnNextCall(foo); +foo(); // Mark and kick off recompilation. %OptimizeFunctionOnNextCall(foo, "concurrent"); foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js b/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js new file mode 100644 index 0000000000..12baca0918 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-trap-allocation-memento.js @@ -0,0 +1,50 @@ +// 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 --noalways-opt + +var elements_kind = { + fast_smi_only : 'fast smi only elements', + fast : 'fast elements', + fast_double : 'fast double elements', + dictionary : 'dictionary elements', +} + +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 (%HasDictionaryElements(obj)) return elements_kind.dictionary; +} + +function assertKind(expected, obj, name_opt) { + assertEquals(expected, getKind(obj), name_opt); +} + +(function() { + function make1() { return new Array(); } + function make2() { return new Array(); } + function make3() { return new Array(); } + function foo(a, i) { a[0] = i; } + + function run_test(maker_function) { + var one = maker_function(); + assertKind(elements_kind.fast_smi_only, one); + // Use memento to pre-transition allocation site to DOUBLE elements. + foo(one, 1.5); + // Newly created arrays should now have DOUBLE elements right away. + var two = maker_function(); + assertKind(elements_kind.fast_double, two); + } + + // Initialize the KeyedStoreIC in foo; the actual operation will be done + // in the runtime. + run_test(make1); + // Run again; the IC optimistically assumed to only see the transitioned + // (double-elements) map again, so this will make it polymorphic. + // The actual operation will again be done in the runtime. + run_test(make2); + // Finally, check if the initialized IC honors the allocation memento. + run_test(make3); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/loop-stack-check.js b/deps/v8/test/mjsunit/regress/wasm/loop-stack-check.js new file mode 100644 index 0000000000..a76ad017d9 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/loop-stack-check.js @@ -0,0 +1,19 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addFunction("foo", kSig_i_ii) + .addBody([ + kExprLoop, 00, + kExprBrTable, 0xfb, 0xff, 0xff, 0xff, + ]) + .exportFunc(); + assertThrows(function() { builder.instantiate(); }); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js b/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js new file mode 100644 index 0000000000..032a02684b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-02256b.js @@ -0,0 +1,502 @@ +// 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: --random-seed=891196975 --expose-gc --allow-natives-syntax +// Flags: --gc-interval=207 --stress-compaction --validate-asm +// +// /v8/test/mjsunit/wasm/grow-memory.js +// /v8/test/mjsunit/regress/regress-540.js +// /v8/test/mjsunit/regress/wasm/regression-02862.js +// /v8/test/mjsunit/regress/regress-2813.js +// /v8/test/mjsunit/regress/regress-323845.js +// Begin stripped down and modified version of mjsunit.js for easy minimization in CF. + +function MjsUnitAssertionError(message) {} +MjsUnitAssertionError.prototype.toString = function() { + return this.message; +}; +var assertSame; +var assertEquals; +var assertEqualsDelta; +var assertArrayEquals; +var assertPropertiesEqual; +var assertToStringEquals; +var assertTrue; +var assertFalse; +var triggerAssertFalse; +var assertNull; +var assertNotNull; +var assertThrows; +var assertDoesNotThrow; +var assertInstanceof; +var assertUnreachable; +var assertOptimized; +var assertUnoptimized; + +function classOf(object) { + var string = Object.prototype.toString.call(object); + return string.substring(8, string.length - 1); +} + +function PrettyPrint(value) { + return ""; +} + +function PrettyPrintArrayElement(value, index, array) { + return ""; +} + +function fail(expectedText, found, name_opt) {} + +function deepObjectEquals(a, b) { + var aProps = Object.keys(a); + aProps.sort(); + var bProps = Object.keys(b); + bProps.sort(); + if (!deepEquals(aProps, bProps)) { + return false; + } + for (var i = 0; i < aProps.length; i++) { + if (!deepEquals(a[aProps[i]], b[aProps[i]])) { + return false; + } + } + return true; +} + +function deepEquals(a, b) { + if (a === b) { + if (a === 0) return (1 / a) === (1 / b); + return true; + } + if (typeof a != typeof b) return false; + if (typeof a == "number") return isNaN(a) && isNaN(b); + if (typeof a !== "object" && typeof a !== "function") return false; + var objectClass = classOf(a); + if (objectClass !== classOf(b)) return false; + if (objectClass === "RegExp") { + return (a.toString() === b.toString()); + } + if (objectClass === "Function") return false; + if (objectClass === "Array") { + var elementCount = 0; + if (a.length != b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + if (!deepEquals(a[i], b[i])) return false; + } + return true; + } + if (objectClass == "String" || objectClass == "Number" || objectClass == "Boolean" || objectClass == "Date") { + if (a.valueOf() !== b.valueOf()) return false; + } + return deepObjectEquals(a, b); +} +assertSame = function assertSame(expected, found, name_opt) { + if (found === expected) { + if (expected !== 0 || (1 / expected) == (1 / found)) return; + } else if ((expected !== expected) && (found !== found)) { + return; + } + fail(PrettyPrint(expected), found, name_opt); +}; +assertEquals = function assertEquals(expected, found, name_opt) { + if (!deepEquals(found, expected)) { + fail(PrettyPrint(expected), found, name_opt); + } +}; +assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt) { + assertTrue(Math.abs(expected - found) <= delta, name_opt); +}; +assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { + var start = ""; + if (name_opt) { + start = name_opt + " - "; + } + assertEquals(expected.length, found.length, start + "array length"); + if (expected.length == found.length) { + for (var i = 0; i < expected.length; ++i) { + assertEquals(expected[i], found[i], start + "array element at index " + i); + } + } +}; +assertPropertiesEqual = function assertPropertiesEqual(expected, found, name_opt) { + if (!deepObjectEquals(expected, found)) { + fail(expected, found, name_opt); + } +}; +assertToStringEquals = function assertToStringEquals(expected, found, name_opt) { + if (expected != String(found)) { + fail(expected, found, name_opt); + } +}; +assertTrue = function assertTrue(value, name_opt) { + assertEquals(true, value, name_opt); +}; +assertFalse = function assertFalse(value, name_opt) { + assertEquals(false, value, name_opt); +}; +assertNull = function assertNull(value, name_opt) { + if (value !== null) { + fail("null", value, name_opt); + } +}; +assertNotNull = function assertNotNull(value, name_opt) { + if (value === null) { + fail("not null", value, name_opt); + } +}; +assertThrows = function assertThrows(code, type_opt, cause_opt) { + var threwException = true; + try { + if (typeof code == 'function') { + code(); + } else { + eval(code); + } + threwException = false; + } catch (e) { + if (typeof type_opt == 'function') { + assertInstanceof(e, type_opt); + } + if (arguments.length >= 3) { + assertEquals(e.type, cause_opt); + } + return; + } +}; +assertInstanceof = function assertInstanceof(obj, type) { + if (!(obj instanceof type)) { + var actualTypeName = null; + var actualConstructor = Object.getPrototypeOf(obj).constructor; + if (typeof actualConstructor == "function") { + actualTypeName = actualConstructor.name || String(actualConstructor); + } + fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" + (type.name || type) + ">" + (actualTypeName ? " but of < " + actualTypeName + ">" : "")); + } +}; +assertDoesNotThrow = function assertDoesNotThrow(code, name_opt) { + try { + if (typeof code == 'function') { + code(); + } else { + eval(code); + } + } catch (e) { + fail("threw an exception: ", e.message || e, name_opt); + } +}; +assertUnreachable = function assertUnreachable(name_opt) { + var message = "Fail" + "ure: unreachable"; + if (name_opt) { + message += " - " + name_opt; + } +}; +var OptimizationStatus = function() {} +assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { + if (sync_opt === undefined) sync_opt = ""; + assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); +} +assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { + if (sync_opt === undefined) sync_opt = ""; + assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); +} +triggerAssertFalse = function() {} +try { + console.log; + print = console.log; + alert = console.log; +} catch (e) {} + +function runNearStackLimit(f) { + function t() { + try { + t(); + } catch (e) { + f(); + } + }; + try { + t(); + } catch (e) {} +} + +function quit() {} + +function nop() {} +try { + gc; +} catch (e) { + gc = nop; +} + +function getRandomProperty(v, rand) { + var properties = Object.getOwnPropertyNames(v); + var proto = Object.getPrototypeOf(v); + if (proto) { + properties = properties.concat(Object.getOwnPropertyNames(proto)); + } + if (properties.includes("constructor") && v.constructor.hasOwnProperty("__proto__")) { + properties = properties.concat(Object.getOwnPropertyNames(v.constructor.__proto__)); + } + if (properties.length == 0) { + return "0"; + } + return properties[rand % properties.length]; +} +// End stripped down and modified version of mjsunit.js. + +var __v_0 = {}; +var __v_1 = {}; +var __v_2 = {}; +var __v_3 = {}; +var __v_4 = -1073741824; +var __v_5 = {}; +var __v_6 = 1; +var __v_7 = 1073741823; +var __v_8 = {}; +var __v_9 = {}; +var __v_10 = 4294967295; +var __v_11 = this; +var __v_12 = {}; +var __v_13 = {}; + + +function __f_18(__f_17, y) { + eval(__f_17); + return y(); +} +try { + var __v_17 = __f_18("function y() { return 1; }", function() { + return 0; + }) + assertEquals(1, __v_17); + gc(); + __v_17 = + (function(__f_17) { + function __f_17() { + return 3; + } + return __f_17(); + })(function() { + return 2; + }); + assertEquals(3, __v_17); + __v_17 = + (function(__f_17) { + function __f_17() { + return 5; + } + return arguments[0](); + })(function() { + return -1073741825; + }); + assertEquals(5, __v_17); +} catch (e) { + print("Caught: " + e); +} + +function __f_27() {} +try { + var __v_24 = {}; + var __v_21 = {}; + var __v_22 = {}; + var __v_20 = {}; + __v_58 = { + instantiateModuleFromAsm: function(text, ffi, heap) { + var __v_21 = eval('(' + text + ')'); + if (__f_27()) { + throw "validate failure"; + } + var __v_20 = __v_21(); + if (__f_27()) { + throw "bad module args"; + } + } + }; + __f_21 = function __f_21() { + if (found === expected) { + if (1 / expected) return; + } else if ((expected !== expected) && (found !== found)) { + return; + }; + }; + __f_28 = function __f_28() { + if (!__f_23()) { + __f_125(__f_69(), found, name_opt); + } + }; + __f_24 = function __f_24(code, type_opt, cause_opt) { + var __v_24 = true; + try { + if (typeof code == 'function') { + code(); + } else { + eval(); + } + __v_24 = false; + } catch (e) { + if (typeof type_opt == 'function') { + __f_22(); + } + if (arguments.length >= 3) { + __f_28(); + } + return; + } + }; + __f_22 = function __f_22() { + if (obj instanceof type) { + obj.constructor; + if (typeof __v_57 == "function") {; + }; + } + }; + try { + __f_28(); + __v_82.__p_750895751 = __v_82[getRandomProperty()]; + } catch (e) { + "Caught: " + e; + } + __f_19(); + gc(); + __f_19(19, __f_24); + __f_19(); + __f_19(); + __f_24(function() { + __v_58.instantiateModuleFromAsm(__f_28.toString()).__f_20(); + }); +} catch (e) { + print("Caught: " + e); +} + +function __f_19() { + "use asm"; + + function __f_20() {} + return { + __f_20: __f_20 + }; +} +try { + __f_19(); + __f_19(); + __f_19(); +} catch (e) { + print("Caught: " + e); +} + +function __f_29() {} +try { + __f_19(); + try { + __f_19(); + gc(); + __f_25(); + } catch (e) { + "Caught: " + e; + } + __f_19(); + __f_19(); + __f_19(); +} catch (e) { + print("Caught: " + e); +} + +function __f_23() { + "use asm"; + + function __f_20() {} + return { + __f_20: __f_20 + }; +} +try { + __f_19(); + __f_19(); + __f_19(); + __f_19(); + gc(); + __f_19(); + __f_19(); + __f_19(); +} catch (e) { + print("Caught: " + e); +} + +function __f_26(stdlib) { + "use asm"; + var __v_2 = new stdlib.Int32Array(); + __v_22[4294967295] | 14 + 1 | 14; + return { + __f_20: __f_20 + }; +} + +function __f_25() { + var __v_19 = new ArrayBuffer(); + var __v_23 = new Int32Array(__v_19); + var module = __v_58.instantiateModuleFromAsm(__f_26.toString()); + __f_28(); + gc(); +} +try { + (function() {})(); + (function() {})(); + try { + (function() { + __v_23.__defineGetter__(getRandomProperty(__v_23, 580179357), function() { + gc(); + return __f_25(__v_23); + }); + var __v_23 = 0x87654321; + __v_19.__f_89(); + })(); + } catch (e) {; + } +} catch (e) { + print("Caught: " + e); +} + +function __f_30(x) { + var __v_30 = x + 1; + var __v_31 = x + 2; + if (x != 0) { + if (x > 0 & x < 100) { + return __v_30; + } + } + return 0; +} +try { + assertEquals(0, __f_30(0)); + assertEquals(0, __f_30(0)); + %OptimizeFunctionOnNextCall(__f_30); + assertEquals(3, __f_30(2)); +} catch (e) { + print("Caught: " + e); +} + +function __f_31() { + __f_32.arguments; +} + +function __f_32(x) { + __f_31(); +} + +function __f_33() { + __f_32({}); +} +try { + __f_33(); + __f_33(); + __f_33(); + %OptimizeFunctionOnNextCall(__f_33); + __f_33(); + gc(); +} catch (e) { + print("Caught: " + e); +} diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-5531.js b/deps/v8/test/mjsunit/regress/wasm/regression-5531.js new file mode 100644 index 0000000000..9c1c092519 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-5531.js @@ -0,0 +1,22 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.addFunction("foo", kSig_i_v) + .addBody([ + kExprI32Const, 0x00, + kExprI8Const, 0xcb, + kExprI8Const, 0xff, + kExprBrTable, 0xcb, 0xcb, 0xcb, 0x00, 0x00, 0xcb, 0x00 // entries=1238475 + ]) + .exportFunc(); + assertThrows(function() { builder.instantiate(); }); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-648079.js b/deps/v8/test/mjsunit/regress/wasm/regression-648079.js new file mode 100644 index 0000000000..e9d14175e4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-648079.js @@ -0,0 +1,324 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { +"use asm"; +var builder = new WasmModuleBuilder(); +builder.addFunction("regression_648079", kSig_s_v) + .addBody([ + // locals: + 0x00, + // body: + kExprI64RemU, + kExprI64Ctz, + kExprI64LeU, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprI64Ctz, + kExprI64Ne, + kExprI64ShrS, + kExprI64GtS, + kExprI64RemU, + kExprUnreachable, + kExprI64RemU, + kExprI32Eqz, + kExprI64LeU, + kExprDrop, + kExprF32Add, + kExprI64Ior, + kExprF32CopySign, + kExprI64Ne, + kExprI64GeS, + kExprUnreachable, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprIf, 10, // @32 + kExprBlock, 00, // @34 + kExprBr, // depth=109 + kExprI64Shl, + kExprI64LeU, + kExprI64GeS, + kExprI64Clz, + kExprF32Min, + kExprF32Eq, + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprI32Const, + kExprUnreachable, + kExprBr, // depth=101 + kExprF32Div, + kExprI64GtU, + kExprI64GeS, + kExprI64Clz, + kExprSelect, + kExprI64GtS, + kExprI64RemU, + kExprI64LeU, + kExprI64Shl, + kExprI64Ctz, + kExprLoop, 01, // @63 i32 + kExprElse, // @65 + kExprI64LeU, + kExprI64RemU, + kExprI64Ne, + kExprI64GeS, + kExprI32Const, + kExprI64GtS, + kExprI64LoadMem32U, + kExprI64Clz, + kExprI64Shl, + kExprI64Ne, + kExprI64ShrS, + kExprI64GtS, + kExprI64DivU, + kExprI64Ne, + kExprI64GtS, + kExprI64Ne, + kExprI64Popcnt, + kExprI64DivU, + kExprI64DivU, + kExprSelect, + kExprI64Ctz, + kExprI64Popcnt, + kExprI64RemU, + kExprI64Clz, + kExprF64Sub, + kExprF32Trunc, + kExprF32Trunc, + kExprI64RemU, + kExprI64Ctz, + kExprI64LeU, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprBrIf, // depth=116 + kExprF32Min, + kExprI64GtU, + kExprBlock, 01, // @107 i32 + kExprTeeLocal, + kExprBlock, 01, // @111 i32 + kExprBlock, 01, // @113 i32 + kExprBlock, 01, // @115 i32 + kExprBlock, 01, // @117 i32 + kExprBlock, 01, // @119 i32 + kExprBlock, 01, // @121 i32 + kExprBlock, 01, // @123 i32 + kExprBlock, 88, // @125 + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprLoop, 40, // @131 + kExprUnreachable, + kExprUnreachable, + kExprI32Add, + kExprBlock, 05, // @136 + kExprUnreachable, + kExprIf, 02, // @139 i64 + kExprBlock, 01, // @141 i32 + kExprBrIf, // depth=16 + kExprLoop, 00, // @145 + kExprUnreachable, + kExprUnreachable, + kExprReturn, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprI64LoadMem16U, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprNop, + kExprBr, // depth=1 + kExprElse, // @164 + kExprF32Trunc, + kExprI32Add, + kExprCallIndirect, // sig #1 + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprBlock, 00, // @172 + kExprI64RemU, + kExprI64Ctz, + kExprI64LeU, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprDrop, + kExprI64Popcnt, + kExprF32Min, + kExprUnreachable, + kExprF64Sub, + kExprI32Const, + kExprUnreachable, + kExprGetLocal, + kExprI64LoadMem32U, + kExprUnreachable, + kExprI64RemU, + kExprI32Eqz, + kExprI64LeU, + kExprDrop, + kExprF32Add, + kExprI64Ior, + kExprF32CopySign, + kExprI64Ne, + kExprI64GeS, + kExprUnreachable, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprIf, 10, // @216 + kExprBlock, 00, // @218 + kExprBr, // depth=109 + kExprI64Shl, + kExprI64LeU, + kExprI64GeS, + kExprI64Clz, + kExprF32Min, + kExprF32Eq, + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprF64Min, + kExprI32Const, + kExprBr, // depth=101 + kExprF32Div, + kExprI64GtU, + kExprI64GeS, + kExprI64Clz, + kExprI64Popcnt, + kExprF64Lt, + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprLoop, 01, // @247 i32 + kExprElse, // @249 + kExprI64LeU, + kExprI64RemU, + kExprI64Ne, + kExprI64GeS, + kExprI32Const, + kExprBlock, 01, // @256 i32 + kExprBlock, 01, // @258 i32 + kExprBlock, 01, // @260 i32 + kExprBlock, 01, // @262 i32 + kExprBlock, 01, // @264 i32 + kExprF32Ge, + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprLoop, 40, // @271 + kExprUnreachable, + kExprUnreachable, + kExprI32Add, + kExprBlock, 01, // @276 i32 + kExprUnreachable, + kExprIf, 02, // @279 i64 + kExprBlock, 00, // @281 + kExprBrIf, // depth=16 + kExprLoop, 00, // @285 + kExprUnreachable, + kExprUnreachable, + kExprReturn, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprI64LoadMem16U, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprNop, + kExprBr, // depth=1 + kExprElse, // @304 + kExprF32Trunc, + kExprI32Add, + kExprCallIndirect, // sig #1 + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprBlock, 00, // @312 + kExprI64RemU, + kExprI64Ctz, + kExprI64LeU, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprDrop, + kExprI64Popcnt, + kExprF32Min, + kExprUnreachable, + kExprF64Sub, + kExprI32Const, + kExprUnreachable, + kExprGetLocal, + kExprI64LoadMem32U, + kExprUnreachable, + kExprUnreachable, + kExprNop, + kExprBr, // depth=1 + kExprElse, // @348 + kExprF32Trunc, + kExprI32Add, + kExprCallIndirect, // sig #1 + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprBlock, 00, // @356 + kExprI64RemU, + kExprI64Ctz, + kExprI64LeU, + kExprUnreachable, + kExprUnreachable, + kExprUnreachable, + kExprDrop, + kExprI64Popcnt, + kExprF32Min, + kExprUnreachable, + kExprF64Sub, + kExprI32Const, + kExprUnreachable, + kExprGetLocal, + kExprI64LoadMem32U, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF32Trunc, + kExprF32Trunc, + kExprF32Trunc, + kExprUnreachable, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + kExprF64Min, + ]) + .exportFunc(); +assertThrows(function() { builder.instantiate(); }); +})(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-651961.js b/deps/v8/test/mjsunit/regress/wasm/regression-651961.js index abdec98358..30f6565d32 100644 --- a/deps/v8/test/mjsunit/regress/wasm/regression-651961.js +++ b/deps/v8/test/mjsunit/regress/wasm/regression-651961.js @@ -9,12 +9,12 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function() { var builder = new WasmModuleBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, 32, false); builder.addFunction("foo", kSig_i_v) .addBody([ - kExprMemorySize, + kExprMemorySize, kMemoryZero, kExprI32Const, 0x10, - kExprGrowMemory, + kExprGrowMemory, kMemoryZero, kExprI32Mul, ]) .exportFunc(); diff --git a/deps/v8/test/mjsunit/regress/wasm/regression-654377.js b/deps/v8/test/mjsunit/regress/wasm/regression-654377.js new file mode 100644 index 0000000000..871da72114 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/wasm/regression-654377.js @@ -0,0 +1,23 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function() { + var builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.addFunction("foo", kSig_i_v) + .addBody([ + kExprI32Const, 00, + kExprMemorySize, + kExprBrIf, 00, + kExprMemorySize, + kExprBr, 0xe7, 0xd2, 0xf2, 0xff, 0x1d + ]) + .exportFunc(); + assertThrows(function() { builder.instantiate(); }); +})(); diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-default.js b/deps/v8/test/mjsunit/shared-function-tier-up-default.js new file mode 100644 index 0000000000..09c5f8e7fe --- /dev/null +++ b/deps/v8/test/mjsunit/shared-function-tier-up-default.js @@ -0,0 +1,32 @@ +// 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: --mark-shared-functions-for-tier-up --allow-natives-syntax --no-ignition --no-ignition-staging --no-turbo + +(function() { + var sum = 0; + var i = 0; + for (var i = 0; i < 3; ++i) { + var f = function(x) { + return 2 * x; + } + sum += f(i); + + if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { + // If we are always or never optimizing f, just exit, this test is useless. + return; + } + + if (i == 1) { + // f must be baseline code. + assertEquals(2, %GetOptimizationStatus(f)); + + // Run twice (i = 0, 1), then tier-up. + %OptimizeFunctionOnNextCall(f); + } else if (i == 2) { + // Tier-up at i = 2 should go up to crankshaft. + assertEquals(1, %GetOptimizationStatus(f)); + } + } +})() diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js b/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js new file mode 100644 index 0000000000..607c2e1e04 --- /dev/null +++ b/deps/v8/test/mjsunit/shared-function-tier-up-ignition.js @@ -0,0 +1,41 @@ +// 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: --mark-shared-functions-for-tier-up --allow-natives-syntax --ignition-staging --no-turbo + +(function() { + var sum = 0; + var i = 0; + for (var i = 0; i < 5; ++i) { + var f = function(x) { + return 2 * x; + } + sum += f(i); + + if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { + // If we are always or never optimizing f, just exit, this test is useless. + return; + } + + if (i == 1) { + // f must be interpreted code. + assertEquals(8, %GetOptimizationStatus(f)); + + // Allow it to run twice (i = 0, 1), then tier-up to baseline. + %BaselineFunctionOnNextCall(f); + } else if (i == 2) { + // Tier-up at i = 2 should only go up to baseline. + assertEquals(2, %GetOptimizationStatus(f)); + } else if (i == 3) { + // Now f must be baseline code. + assertEquals(2, %GetOptimizationStatus(f)); + + // Run two more times (i = 2, 3), then tier-up to optimized. + %OptimizeFunctionOnNextCall(f); + } else if (i == 4) { + // Tier-up at i = 4 should now go up to crankshaft. + assertEquals(1, %GetOptimizationStatus(f)); + } + } +})() diff --git a/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js new file mode 100644 index 0000000000..aed30e8150 --- /dev/null +++ b/deps/v8/test/mjsunit/shared-function-tier-up-turbo.js @@ -0,0 +1,32 @@ +// 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: --mark-shared-functions-for-tier-up --allow-natives-syntax --ignition-staging --turbo + +(function() { + var sum = 0; + var i = 0; + for (var i = 0; i < 3; ++i) { + var f = function(x) { + return 2 * x; + } + sum += f(i); + + if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { + // If we are always or never optimizing f, just exit, this test is useless. + return; + } + + if (i == 1) { + // f must be interpreted code. + assertEquals(8, %GetOptimizationStatus(f)); + + // Run twice (i = 0, 1), then tier-up. + %OptimizeFunctionOnNextCall(f); + } else if (i == 2) { + // Tier-up at i = 2 should go up to turbofan. + assertEquals(7, %GetOptimizationStatus(f)); + } + } +})() diff --git a/deps/v8/test/mjsunit/strict-mode.js b/deps/v8/test/mjsunit/strict-mode.js index f7f95da88c..736ff1b9f1 100644 --- a/deps/v8/test/mjsunit/strict-mode.js +++ b/deps/v8/test/mjsunit/strict-mode.js @@ -1111,14 +1111,14 @@ function CheckArgumentsPillDescriptor(func, name) { } var args = strict(); - CheckArgumentsPillDescriptor(args, "caller"); + assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller")); CheckArgumentsPillDescriptor(args, "callee"); args = strict(17, "value", strict); assertEquals(17, args[0]) assertEquals("value", args[1]) assertEquals(strict, args[2]); - CheckArgumentsPillDescriptor(args, "caller"); + assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller")); CheckArgumentsPillDescriptor(args, "callee"); function outer() { @@ -1130,14 +1130,14 @@ function CheckArgumentsPillDescriptor(func, name) { } var args = outer()(); - CheckArgumentsPillDescriptor(args, "caller"); + assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller")); CheckArgumentsPillDescriptor(args, "callee"); args = outer()(17, "value", strict); assertEquals(17, args[0]) assertEquals("value", args[1]) assertEquals(strict, args[2]); - CheckArgumentsPillDescriptor(args, "caller"); + assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller")); CheckArgumentsPillDescriptor(args, "callee"); })(); diff --git a/deps/v8/test/mjsunit/tools/profviz-test.default b/deps/v8/test/mjsunit/tools/profviz-test.default index bff249d651..040afb4217 100644 --- a/deps/v8/test/mjsunit/tools/profviz-test.default +++ b/deps/v8/test/mjsunit/tools/profviz-test.default @@ -1,5 +1,5 @@ [ - "set yrange [0:25.5]", + "set yrange [0:24.5]", "set xlabel \"execution time in ms\"", "set xrange [2.4204999999999997:141.1669999999999]", "set style fill pattern 2 bo 1", @@ -17,7 +17,7 @@ "set object 6 rect from 57.242999999999974, 7 to 57.329716562499975, 6.766323024054983 fc rgb \"#9944CC\"", "set object 7 rect from 58.751499999999965, 7 to 58.838216562499966, 6.766323024054983 fc rgb \"#9944CC\"", "set object 8 rect from 60.72499999999996, 7 to 60.81171656249996, 6.766323024054983 fc rgb \"#9944CC\"", - "set ytics out nomirror (\"execution (59.6%%)\" 12.5, \"external (0.2%%)\" 13.5, \"compile unopt (3.1%%)\" 14.5, \"recompile sync (6.6%%)\" 15.5, \"recompile async (11.6%%)\" 16.5, \"compile eval (0.0%%)\" 17.5, \"ic miss (0.0%%)\" 18.5, \"parse (9.9%%)\" 19.5, \"preparse (0.6%%)\" 20.5, \"lazy parse (2.9%%)\" 21.5, \"gc scavenge (1.6%%)\" 22.5, \"gc compaction (3.3%%)\" 23.5, \"gc context (0.0%%)\" 24.5, \"code kind color coding\" 11, \"code kind in execution\" 10, \"top 8 js stack frames\" 9, \"pause times\" 0, \"max deopt size: 9.1 kB\" 7)", + "set ytics out nomirror (\"execution (59.6%%)\" 12.5, \"external (0.2%%)\" 13.5, \"compile unopt (3.1%%)\" 14.5, \"recompile sync (6.6%%)\" 15.5, \"recompile async (11.6%%)\" 16.5, \"compile eval (0.0%%)\" 17.5, \"parse (9.9%%)\" 18.5, \"preparse (0.6%%)\" 19.5, \"lazy parse (2.9%%)\" 20.5, \"gc scavenge (1.6%%)\" 21.5, \"gc compaction (3.3%%)\" 22.5, \"gc context (0.0%%)\" 23.5, \"code kind color coding\" 11, \"code kind in execution\" 10, \"top 8 js stack frames\" 9, \"pause times\" 0, \"max deopt size: 9.1 kB\" 7)", "set object 9 rect from 42.11000000000001, 12.83 to 42.28050000000001, 12.17 fc rgb \"#000000\"", "set object 10 rect from 42.298000000000016, 12.83 to 42.30000000000002, 12.17 fc rgb \"#000000\"", "set object 11 rect from 42.31450000000002, 12.83 to 42.62700000000002, 12.17 fc rgb \"#000000\"", @@ -448,232 +448,232 @@ "set object 436 rect from 108.1159999999999, 16.83 to 110.07649999999991, 16.17 fc rgb \"#CC4499\"", "set object 437 rect from 131.1424999999999, 16.83 to 133.02899999999988, 16.17 fc rgb \"#CC4499\"", "set object 438 rect from 141.13349999999986, 16.83 to 141.1669999999999, 16.17 fc rgb \"#CC4499\"", - "set object 439 rect from 22.2675, 19.83 to 22.3815, 19.17 fc rgb \"#00CC00\"", - "set object 440 rect from 22.665, 19.83 to 23.1135, 19.17 fc rgb \"#00CC00\"", - "set object 441 rect from 27.951000000000004, 19.83 to 27.972500000000004, 19.17 fc rgb \"#00CC00\"", - "set object 442 rect from 27.993000000000002, 19.83 to 28.013500000000004, 19.17 fc rgb \"#00CC00\"", - "set object 443 rect from 28.043000000000003, 19.83 to 28.063500000000005, 19.17 fc rgb \"#00CC00\"", - "set object 444 rect from 28.085000000000004, 19.83 to 28.087500000000002, 19.17 fc rgb \"#00CC00\"", - "set object 445 rect from 28.115000000000002, 19.83 to 28.139500000000005, 19.17 fc rgb \"#00CC00\"", - "set object 446 rect from 28.154000000000007, 19.83 to 28.260000000000005, 19.17 fc rgb \"#00CC00\"", - "set object 447 rect from 28.309500000000003, 19.83 to 28.374000000000006, 19.17 fc rgb \"#00CC00\"", - "set object 448 rect from 28.383500000000005, 19.83 to 28.385000000000005, 19.17 fc rgb \"#00CC00\"", - "set object 449 rect from 28.396500000000003, 19.83 to 28.445000000000007, 19.17 fc rgb \"#00CC00\"", - "set object 450 rect from 28.459500000000006, 19.83 to 28.463000000000005, 19.17 fc rgb \"#00CC00\"", - "set object 451 rect from 28.489500000000007, 19.83 to 28.499000000000006, 19.17 fc rgb \"#00CC00\"", - "set object 452 rect from 28.512500000000006, 19.83 to 28.516000000000005, 19.17 fc rgb \"#00CC00\"", - "set object 453 rect from 28.529500000000006, 19.83 to 28.533000000000005, 19.17 fc rgb \"#00CC00\"", - "set object 454 rect from 28.554500000000004, 19.83 to 28.557000000000006, 19.17 fc rgb \"#00CC00\"", - "set object 455 rect from 28.573500000000006, 19.83 to 28.579000000000008, 19.17 fc rgb \"#00CC00\"", - "set object 456 rect from 28.59950000000001, 19.83 to 28.602000000000007, 19.17 fc rgb \"#00CC00\"", - "set object 457 rect from 28.623500000000007, 19.83 to 28.625000000000007, 19.17 fc rgb \"#00CC00\"", - "set object 458 rect from 28.637500000000006, 19.83 to 28.647000000000006, 19.17 fc rgb \"#00CC00\"", - "set object 459 rect from 28.657500000000006, 19.83 to 28.669000000000008, 19.17 fc rgb \"#00CC00\"", - "set object 460 rect from 28.682500000000005, 19.83 to 28.686000000000007, 19.17 fc rgb \"#00CC00\"", - "set object 461 rect from 28.695500000000006, 19.83 to 28.701000000000008, 19.17 fc rgb \"#00CC00\"", - "set object 462 rect from 28.72450000000001, 19.83 to 28.811000000000007, 19.17 fc rgb \"#00CC00\"", - "set object 463 rect from 28.83250000000001, 19.83 to 28.907500000000006, 19.17 fc rgb \"#00CC00\"", - "set object 464 rect from 28.97100000000001, 19.83 to 28.97450000000001, 19.17 fc rgb \"#00CC00\"", - "set object 465 rect from 28.99600000000001, 19.83 to 28.99850000000001, 19.17 fc rgb \"#00CC00\"", - "set object 466 rect from 29.01200000000001, 19.83 to 29.01350000000001, 19.17 fc rgb \"#00CC00\"", - "set object 467 rect from 29.02600000000001, 19.83 to 29.056500000000007, 19.17 fc rgb \"#00CC00\"", - "set object 468 rect from 29.06900000000001, 19.83 to 29.159500000000012, 19.17 fc rgb \"#00CC00\"", - "set object 469 rect from 29.17100000000001, 19.83 to 29.18450000000001, 19.17 fc rgb \"#00CC00\"", - "set object 470 rect from 29.19400000000001, 19.83 to 41.84850000000001, 19.17 fc rgb \"#00CC00\"", - "set object 471 rect from 41.87900000000001, 19.83 to 41.88650000000001, 19.17 fc rgb \"#00CC00\"", - "set object 472 rect from 27.972500000000004, 20.83 to 28.053000000000004, 20.17 fc rgb \"#44CC00\"", - "set object 473 rect from 28.063500000000005, 20.83 to 28.169000000000004, 20.17 fc rgb \"#44CC00\"", - "set object 474 rect from 28.260000000000005, 20.83 to 28.489500000000007, 20.17 fc rgb \"#44CC00\"", - "set object 475 rect from 28.499000000000006, 20.83 to 28.761500000000005, 20.17 fc rgb \"#44CC00\"", - "set object 476 rect from 28.78900000000001, 20.83 to 28.847500000000007, 20.17 fc rgb \"#44CC00\"", - "set object 477 rect from 28.907500000000006, 20.83 to 29.047000000000008, 20.17 fc rgb \"#44CC00\"", - "set object 478 rect from 29.056500000000007, 20.83 to 29.111000000000008, 20.17 fc rgb \"#44CC00\"", - "set object 479 rect from 29.12350000000001, 20.83 to 29.21900000000001, 20.17 fc rgb \"#44CC00\"", - "set object 480 rect from 41.82650000000001, 20.83 to 41.83500000000001, 20.17 fc rgb \"#44CC00\"", - "set object 481 rect from 41.84850000000001, 20.83 to 41.87900000000001, 20.17 fc rgb \"#44CC00\"", - "set object 482 rect from 16.737, 21.83 to 16.9595, 21.17 fc rgb \"#00CC44\"", - "set object 483 rect from 17.8715, 21.83 to 18.017000000000003, 21.17 fc rgb \"#00CC44\"", - "set object 484 rect from 18.992, 21.83 to 19.0685, 21.17 fc rgb \"#00CC44\"", - "set object 485 rect from 20.52, 21.83 to 20.5975, 21.17 fc rgb \"#00CC44\"", - "set object 486 rect from 21.109, 21.83 to 21.1335, 21.17 fc rgb \"#00CC44\"", - "set object 487 rect from 21.212, 21.83 to 21.2695, 21.17 fc rgb \"#00CC44\"", - "set object 488 rect from 21.4595, 21.83 to 21.49, 21.17 fc rgb \"#00CC44\"", - "set object 489 rect from 21.566499999999998, 21.83 to 21.588, 21.17 fc rgb \"#00CC44\"", - "set object 490 rect from 21.6535, 21.83 to 21.727, 21.17 fc rgb \"#00CC44\"", - "set object 491 rect from 22.445, 21.83 to 22.4625, 21.17 fc rgb \"#00CC44\"", - "set object 492 rect from 22.502000000000002, 21.83 to 22.5165, 21.17 fc rgb \"#00CC44\"", - "set object 493 rect from 22.553, 21.83 to 22.5645, 21.17 fc rgb \"#00CC44\"", - "set object 494 rect from 23.233, 21.83 to 23.336000000000002, 21.17 fc rgb \"#00CC44\"", - "set object 495 rect from 23.4255, 21.83 to 23.506, 21.17 fc rgb \"#00CC44\"", - "set object 496 rect from 23.5895, 21.83 to 23.613, 21.17 fc rgb \"#00CC44\"", - "set object 497 rect from 23.870500000000003, 21.83 to 23.907, 21.17 fc rgb \"#00CC44\"", - "set object 498 rect from 24.393, 21.83 to 24.430500000000002, 21.17 fc rgb \"#00CC44\"", - "set object 499 rect from 24.470000000000002, 21.83 to 24.504500000000004, 21.17 fc rgb \"#00CC44\"", - "set object 500 rect from 25.267500000000002, 21.83 to 25.283, 21.17 fc rgb \"#00CC44\"", - "set object 501 rect from 25.4195, 21.83 to 25.427, 21.17 fc rgb \"#00CC44\"", - "set object 502 rect from 25.519500000000004, 21.83 to 25.526000000000003, 21.17 fc rgb \"#00CC44\"", - "set object 503 rect from 42.28050000000001, 21.83 to 42.298000000000016, 21.17 fc rgb \"#00CC44\"", - "set object 504 rect from 42.62700000000002, 21.83 to 42.656500000000015, 21.17 fc rgb \"#00CC44\"", - "set object 505 rect from 42.747000000000014, 21.83 to 42.763500000000015, 21.17 fc rgb \"#00CC44\"", - "set object 506 rect from 42.80300000000001, 21.83 to 42.81050000000001, 21.17 fc rgb \"#00CC44\"", - "set object 507 rect from 42.844000000000015, 21.83 to 42.858500000000014, 21.17 fc rgb \"#00CC44\"", - "set object 508 rect from 43.60550000000001, 21.83 to 43.62000000000002, 21.17 fc rgb \"#00CC44\"", - "set object 509 rect from 44.796000000000014, 21.83 to 44.81150000000002, 21.17 fc rgb \"#00CC44\"", - "set object 510 rect from 44.84500000000001, 21.83 to 44.87150000000002, 21.17 fc rgb \"#00CC44\"", - "set object 511 rect from 44.996000000000016, 21.83 to 45.00850000000001, 21.17 fc rgb \"#00CC44\"", - "set object 512 rect from 45.04700000000001, 21.83 to 45.06450000000002, 21.17 fc rgb \"#00CC44\"", - "set object 513 rect from 45.09600000000001, 21.83 to 45.107500000000016, 21.17 fc rgb \"#00CC44\"", - "set object 514 rect from 45.14400000000002, 21.83 to 45.16150000000002, 21.17 fc rgb \"#00CC44\"", - "set object 515 rect from 45.32050000000002, 21.83 to 45.33700000000002, 21.17 fc rgb \"#00CC44\"", - "set object 516 rect from 45.38750000000002, 21.83 to 45.402000000000015, 21.17 fc rgb \"#00CC44\"", - "set object 517 rect from 45.43250000000002, 21.83 to 45.442000000000014, 21.17 fc rgb \"#00CC44\"", - "set object 518 rect from 45.46050000000002, 21.83 to 45.46500000000002, 21.17 fc rgb \"#00CC44\"", - "set object 519 rect from 45.47750000000001, 21.83 to 45.48300000000001, 21.17 fc rgb \"#00CC44\"", - "set object 520 rect from 45.49750000000001, 21.83 to 45.55900000000001, 21.17 fc rgb \"#00CC44\"", - "set object 521 rect from 45.66050000000001, 21.83 to 45.70300000000001, 21.17 fc rgb \"#00CC44\"", - "set object 522 rect from 45.79350000000001, 21.83 to 45.81700000000001, 21.17 fc rgb \"#00CC44\"", - "set object 523 rect from 45.86950000000001, 21.83 to 45.92300000000001, 21.17 fc rgb \"#00CC44\"", - "set object 524 rect from 45.99450000000001, 21.83 to 46.060500000000005, 21.17 fc rgb \"#00CC44\"", - "set object 525 rect from 46.18500000000001, 21.83 to 46.28150000000001, 21.17 fc rgb \"#00CC44\"", - "set object 526 rect from 46.550000000000004, 21.83 to 46.5915, 21.17 fc rgb \"#00CC44\"", - "set object 527 rect from 46.65500000000001, 21.83 to 46.691500000000005, 21.17 fc rgb \"#00CC44\"", - "set object 528 rect from 46.861000000000004, 21.83 to 46.8935, 21.17 fc rgb \"#00CC44\"", - "set object 529 rect from 47.039500000000004, 21.83 to 47.049, 21.17 fc rgb \"#00CC44\"", - "set object 530 rect from 47.0765, 21.83 to 47.135000000000005, 21.17 fc rgb \"#00CC44\"", - "set object 531 rect from 47.4125, 21.83 to 47.465, 21.17 fc rgb \"#00CC44\"", - "set object 532 rect from 49.454499999999996, 21.83 to 49.467, 21.17 fc rgb \"#00CC44\"", - "set object 533 rect from 49.6855, 21.83 to 49.726, 21.17 fc rgb \"#00CC44\"", - "set object 534 rect from 49.799499999999995, 21.83 to 49.812999999999995, 21.17 fc rgb \"#00CC44\"", - "set object 535 rect from 49.841499999999996, 21.83 to 49.849999999999994, 21.17 fc rgb \"#00CC44\"", - "set object 536 rect from 49.894499999999994, 21.83 to 49.9695, 21.17 fc rgb \"#00CC44\"", - "set object 537 rect from 50.083999999999996, 21.83 to 50.14149999999999, 21.17 fc rgb \"#00CC44\"", - "set object 538 rect from 50.29299999999999, 21.83 to 50.31249999999999, 21.17 fc rgb \"#00CC44\"", - "set object 539 rect from 50.36699999999999, 21.83 to 50.39849999999999, 21.17 fc rgb \"#00CC44\"", - "set object 540 rect from 50.520999999999994, 21.83 to 50.528499999999994, 21.17 fc rgb \"#00CC44\"", - "set object 541 rect from 50.54899999999999, 21.83 to 50.62049999999999, 21.17 fc rgb \"#00CC44\"", - "set object 542 rect from 51.27549999999999, 21.83 to 51.29099999999999, 21.17 fc rgb \"#00CC44\"", - "set object 543 rect from 51.52249999999999, 21.83 to 51.56899999999999, 21.17 fc rgb \"#00CC44\"", - "set object 544 rect from 51.87299999999998, 21.83 to 51.89049999999999, 21.17 fc rgb \"#00CC44\"", - "set object 545 rect from 52.115999999999985, 21.83 to 52.13449999999999, 21.17 fc rgb \"#00CC44\"", - "set object 546 rect from 52.286999999999985, 21.83 to 52.300499999999985, 21.17 fc rgb \"#00CC44\"", - "set object 547 rect from 52.326999999999984, 21.83 to 52.33049999999999, 21.17 fc rgb \"#00CC44\"", - "set object 548 rect from 52.362999999999985, 21.83 to 52.404499999999985, 21.17 fc rgb \"#00CC44\"", - "set object 549 rect from 54.566499999999984, 21.83 to 54.64299999999998, 21.17 fc rgb \"#00CC44\"", - "set object 550 rect from 55.49149999999998, 21.83 to 55.53099999999998, 21.17 fc rgb \"#00CC44\"", - "set object 551 rect from 56.64049999999998, 21.83 to 56.64999999999998, 21.17 fc rgb \"#00CC44\"", - "set object 552 rect from 56.750999999999976, 21.83 to 56.76449999999998, 21.17 fc rgb \"#00CC44\"", - "set object 553 rect from 57.039499999999975, 21.83 to 57.076499999999974, 21.17 fc rgb \"#00CC44\"", - "set object 554 rect from 57.885999999999974, 21.83 to 57.893499999999975, 21.17 fc rgb \"#00CC44\"", - "set object 555 rect from 57.97749999999997, 21.83 to 57.99099999999997, 21.17 fc rgb \"#00CC44\"", - "set object 556 rect from 58.04499999999997, 21.83 to 58.055499999999974, 21.17 fc rgb \"#00CC44\"", - "set object 557 rect from 58.14549999999997, 21.83 to 58.15399999999997, 21.17 fc rgb \"#00CC44\"", - "set object 558 rect from 58.17549999999997, 21.83 to 58.18399999999997, 21.17 fc rgb \"#00CC44\"", - "set object 559 rect from 58.40999999999997, 21.83 to 58.431499999999964, 21.17 fc rgb \"#00CC44\"", - "set object 560 rect from 58.51699999999997, 21.83 to 58.53049999999997, 21.17 fc rgb \"#00CC44\"", - "set object 561 rect from 58.590999999999966, 21.83 to 58.60049999999997, 21.17 fc rgb \"#00CC44\"", - "set object 562 rect from 59.65599999999996, 21.83 to 59.669499999999964, 21.17 fc rgb \"#00CC44\"", - "set object 563 rect from 60.05149999999996, 21.83 to 60.060999999999964, 21.17 fc rgb \"#00CC44\"", - "set object 564 rect from 60.176999999999964, 21.83 to 60.19499999999996, 21.17 fc rgb \"#00CC44\"", - "set object 565 rect from 60.26949999999996, 21.83 to 60.27999999999996, 21.17 fc rgb \"#00CC44\"", - "set object 566 rect from 60.31149999999996, 21.83 to 60.34699999999996, 21.17 fc rgb \"#00CC44\"", - "set object 567 rect from 60.471499999999956, 21.83 to 60.48399999999996, 21.17 fc rgb \"#00CC44\"", - "set object 568 rect from 60.508499999999955, 21.83 to 60.51999999999996, 21.17 fc rgb \"#00CC44\"", - "set object 569 rect from 60.92099999999996, 21.83 to 60.98249999999996, 21.17 fc rgb \"#00CC44\"", - "set object 570 rect from 63.15199999999995, 21.83 to 63.228499999999954, 21.17 fc rgb \"#00CC44\"", - "set object 571 rect from 67.34999999999994, 21.83 to 67.36349999999995, 21.17 fc rgb \"#00CC44\"", - "set object 572 rect from 67.40699999999995, 21.83 to 67.41249999999995, 21.17 fc rgb \"#00CC44\"", - "set object 573 rect from 67.45699999999994, 21.83 to 67.46599999999995, 21.17 fc rgb \"#00CC44\"", - "set object 574 rect from 69.11299999999994, 21.83 to 69.12949999999995, 21.17 fc rgb \"#00CC44\"", - "set object 575 rect from 69.19199999999995, 21.83 to 69.22649999999994, 21.17 fc rgb \"#00CC44\"", - "set object 576 rect from 69.30799999999994, 21.83 to 69.31949999999995, 21.17 fc rgb \"#00CC44\"", - "set object 577 rect from 69.34699999999995, 21.83 to 69.35749999999994, 21.17 fc rgb \"#00CC44\"", - "set object 578 rect from 69.38399999999996, 21.83 to 69.40549999999995, 21.17 fc rgb \"#00CC44\"", - "set object 579 rect from 69.45099999999994, 21.83 to 69.46349999999994, 21.17 fc rgb \"#00CC44\"", - "set object 580 rect from 70.31749999999994, 21.83 to 70.33949999999994, 21.17 fc rgb \"#00CC44\"", - "set object 581 rect from 74.41449999999995, 21.83 to 74.43899999999994, 21.17 fc rgb \"#00CC44\"", - "set object 582 rect from 74.52049999999994, 21.83 to 74.54499999999993, 21.17 fc rgb \"#00CC44\"", - "set object 583 rect from 74.59549999999994, 21.83 to 74.60899999999995, 21.17 fc rgb \"#00CC44\"", - "set object 584 rect from 84.09999999999994, 21.83 to 84.15349999999994, 21.17 fc rgb \"#00CC44\"", - "set object 585 rect from 84.26099999999994, 21.83 to 84.27549999999994, 21.17 fc rgb \"#00CC44\"", - "set object 586 rect from 84.31099999999992, 21.83 to 84.31949999999993, 21.17 fc rgb \"#00CC44\"", - "set object 587 rect from 84.34199999999993, 21.83 to 84.35349999999993, 21.17 fc rgb \"#00CC44\"", - "set object 588 rect from 84.37299999999993, 21.83 to 84.40149999999993, 21.17 fc rgb \"#00CC44\"", - "set object 589 rect from 84.43999999999994, 21.83 to 84.46149999999993, 21.17 fc rgb \"#00CC44\"", - "set object 590 rect from 84.53049999999993, 21.83 to 84.60099999999994, 21.17 fc rgb \"#00CC44\"", - "set object 591 rect from 84.68049999999992, 21.83 to 84.69199999999992, 21.17 fc rgb \"#00CC44\"", - "set object 592 rect from 84.71649999999993, 21.83 to 84.72799999999992, 21.17 fc rgb \"#00CC44\"", - "set object 593 rect from 84.92199999999994, 21.83 to 84.93849999999993, 21.17 fc rgb \"#00CC44\"", - "set object 594 rect from 84.99799999999993, 21.83 to 85.01049999999992, 21.17 fc rgb \"#00CC44\"", - "set object 595 rect from 85.03599999999992, 21.83 to 85.04449999999993, 21.17 fc rgb \"#00CC44\"", - "set object 596 rect from 85.06199999999993, 21.83 to 85.07249999999993, 21.17 fc rgb \"#00CC44\"", - "set object 597 rect from 85.09499999999994, 21.83 to 85.10249999999992, 21.17 fc rgb \"#00CC44\"", - "set object 598 rect from 85.38399999999993, 21.83 to 85.43999999999994, 21.17 fc rgb \"#00CC44\"", - "set object 599 rect from 85.59949999999992, 21.83 to 85.61599999999993, 21.17 fc rgb \"#00CC44\"", - "set object 600 rect from 85.63749999999993, 21.83 to 85.65899999999993, 21.17 fc rgb \"#00CC44\"", - "set object 601 rect from 85.69649999999993, 21.83 to 85.70599999999993, 21.17 fc rgb \"#00CC44\"", - "set object 602 rect from 85.73249999999993, 21.83 to 85.76899999999992, 21.17 fc rgb \"#00CC44\"", - "set object 603 rect from 85.86549999999993, 21.83 to 85.87599999999992, 21.17 fc rgb \"#00CC44\"", - "set object 604 rect from 85.91149999999992, 21.83 to 85.92499999999993, 21.17 fc rgb \"#00CC44\"", - "set object 605 rect from 102.74599999999992, 21.83 to 102.80749999999992, 21.17 fc rgb \"#00CC44\"", - "set object 606 rect from 107.5244999999999, 21.83 to 107.57199999999992, 21.17 fc rgb \"#00CC44\"", - "set object 607 rect from 107.62449999999991, 21.83 to 107.6389999999999, 21.17 fc rgb \"#00CC44\"", - "set object 608 rect from 107.6674999999999, 21.83 to 107.6759999999999, 21.17 fc rgb \"#00CC44\"", - "set object 609 rect from 107.69849999999991, 21.83 to 107.70999999999992, 21.17 fc rgb \"#00CC44\"", - "set object 610 rect from 107.7294999999999, 21.83 to 107.7469999999999, 21.17 fc rgb \"#00CC44\"", - "set object 611 rect from 107.7834999999999, 21.83 to 107.79299999999992, 21.17 fc rgb \"#00CC44\"", - "set object 612 rect from 107.82049999999991, 21.83 to 107.8529999999999, 21.17 fc rgb \"#00CC44\"", - "set object 613 rect from 107.9294999999999, 21.83 to 107.94099999999992, 21.17 fc rgb \"#00CC44\"", - "set object 614 rect from 107.9654999999999, 21.83 to 107.97599999999991, 21.17 fc rgb \"#00CC44\"", - "set object 615 rect from 130.5489999999999, 21.83 to 130.5954999999999, 21.17 fc rgb \"#00CC44\"", - "set object 616 rect from 130.6469999999999, 21.83 to 130.6614999999999, 21.17 fc rgb \"#00CC44\"", - "set object 617 rect from 130.68999999999988, 21.83 to 130.6994999999999, 21.17 fc rgb \"#00CC44\"", - "set object 618 rect from 130.7219999999999, 21.83 to 130.7324999999999, 21.17 fc rgb \"#00CC44\"", - "set object 619 rect from 130.7519999999999, 21.83 to 130.76949999999988, 21.17 fc rgb \"#00CC44\"", - "set object 620 rect from 130.8059999999999, 21.83 to 130.8154999999999, 21.17 fc rgb \"#00CC44\"", - "set object 621 rect from 130.84299999999988, 21.83 to 130.87549999999987, 21.17 fc rgb \"#00CC44\"", - "set object 622 rect from 130.95199999999988, 21.83 to 130.9644999999999, 21.17 fc rgb \"#00CC44\"", - "set object 623 rect from 130.99099999999987, 21.83 to 131.00249999999988, 21.17 fc rgb \"#00CC44\"", - "set object 624 rect from 140.86699999999988, 21.83 to 140.8814999999999, 21.17 fc rgb \"#00CC44\"", - "set object 625 rect from 140.9319999999999, 21.83 to 140.9574999999999, 21.17 fc rgb \"#00CC44\"", - "set object 626 rect from 141.0299999999999, 21.83 to 141.03849999999989, 21.17 fc rgb \"#00CC44\"", - "set object 627 rect from 55.79999999999998, 22.83 to 56.198999999999984, 22.17 fc rgb \"#0044CC\"", - "set object 628 rect from 62.16149999999996, 22.83 to 62.548999999999964, 22.17 fc rgb \"#0044CC\"", - "set object 629 rect from 65.56449999999995, 22.83 to 65.61699999999995, 22.17 fc rgb \"#0044CC\"", - "set object 630 rect from 68.70599999999996, 22.83 to 68.76649999999995, 22.17 fc rgb \"#0044CC\"", - "set object 631 rect from 72.22199999999995, 22.83 to 72.28049999999995, 22.17 fc rgb \"#0044CC\"", - "set object 632 rect from 75.41849999999994, 22.83 to 75.46799999999995, 22.17 fc rgb \"#0044CC\"", - "set object 633 rect from 78.16449999999993, 22.83 to 78.23649999999994, 22.17 fc rgb \"#0044CC\"", - "set object 634 rect from 80.90399999999994, 22.83 to 80.95049999999993, 22.17 fc rgb \"#0044CC\"", - "set object 635 rect from 83.58349999999993, 22.83 to 83.63999999999993, 22.17 fc rgb \"#0044CC\"", - "set object 636 rect from 88.75199999999992, 22.83 to 88.82299999999992, 22.17 fc rgb \"#0044CC\"", - "set object 637 rect from 91.90999999999991, 22.83 to 91.96649999999993, 22.17 fc rgb \"#0044CC\"", - "set object 638 rect from 94.55599999999993, 22.83 to 94.6054999999999, 22.17 fc rgb \"#0044CC\"", - "set object 639 rect from 97.20749999999991, 22.83 to 97.26099999999992, 22.17 fc rgb \"#0044CC\"", - "set object 640 rect from 99.86649999999992, 22.83 to 99.92199999999991, 22.17 fc rgb \"#0044CC\"", - "set object 641 rect from 102.56049999999992, 22.83 to 102.61199999999991, 22.17 fc rgb \"#0044CC\"", - "set object 642 rect from 105.88099999999991, 22.83 to 105.93349999999991, 22.17 fc rgb \"#0044CC\"", - "set object 643 rect from 109.2659999999999, 22.83 to 109.38599999999991, 22.17 fc rgb \"#0044CC\"", - "set object 644 rect from 109.4024999999999, 22.83 to 109.41799999999989, 22.17 fc rgb \"#0044CC\"", - "set object 645 rect from 112.6029999999999, 22.83 to 112.6564999999999, 22.17 fc rgb \"#0044CC\"", - "set object 646 rect from 115.36399999999989, 22.83 to 115.4124999999999, 22.17 fc rgb \"#0044CC\"", - "set object 647 rect from 118.1434999999999, 22.83 to 118.19199999999991, 22.17 fc rgb \"#0044CC\"", - "set object 648 rect from 120.9194999999999, 22.83 to 121.0104999999999, 22.17 fc rgb \"#0044CC\"", - "set object 649 rect from 121.0259999999999, 22.83 to 121.0314999999999, 22.17 fc rgb \"#0044CC\"", - "set object 650 rect from 123.77499999999989, 22.83 to 123.8254999999999, 22.17 fc rgb \"#0044CC\"", - "set object 651 rect from 126.55149999999989, 22.83 to 126.59899999999989, 22.17 fc rgb \"#0044CC\"", - "set object 652 rect from 129.3344999999999, 22.83 to 129.4124999999999, 22.17 fc rgb \"#0044CC\"", - "set object 653 rect from 129.4249999999999, 22.83 to 129.48849999999987, 22.17 fc rgb \"#0044CC\"", - "set object 654 rect from 132.8659999999999, 22.83 to 132.92249999999987, 22.17 fc rgb \"#0044CC\"", - "set object 655 rect from 136.14449999999988, 22.83 to 136.19799999999987, 22.17 fc rgb \"#0044CC\"", - "set object 656 rect from 138.9289999999999, 22.83 to 138.98049999999986, 22.17 fc rgb \"#0044CC\"", - "set object 657 rect from 2.4204999999999997, 23.83 to 3.7920000000000003, 23.17 fc rgb \"#4444CC\"", - "set object 658 rect from 3.8075, 23.83 to 3.8129999999999997, 23.17 fc rgb \"#4444CC\"", - "set object 659 rect from 6.2695, 23.83 to 7.373, 23.17 fc rgb \"#4444CC\"", - "set object 660 rect from 7.3865, 23.83 to 7.3919999999999995, 23.17 fc rgb \"#4444CC\"", - "set object 661 rect from 9.2915, 23.83 to 10.405000000000001, 23.17 fc rgb \"#4444CC\"", - "set object 662 rect from 10.4235, 23.83 to 10.43, 23.17 fc rgb \"#4444CC\"", - "set object 663 rect from 12.8765, 23.83 to 13.897, 23.17 fc rgb \"#4444CC\"", - "set object 664 rect from 13.910499999999999, 23.83 to 13.915999999999999, 23.17 fc rgb \"#4444CC\"", + "set object 439 rect from 22.2675, 18.83 to 22.3815, 18.17 fc rgb \"#00CC00\"", + "set object 440 rect from 22.665, 18.83 to 23.1135, 18.17 fc rgb \"#00CC00\"", + "set object 441 rect from 27.951000000000004, 18.83 to 27.972500000000004, 18.17 fc rgb \"#00CC00\"", + "set object 442 rect from 27.993000000000002, 18.83 to 28.013500000000004, 18.17 fc rgb \"#00CC00\"", + "set object 443 rect from 28.043000000000003, 18.83 to 28.063500000000005, 18.17 fc rgb \"#00CC00\"", + "set object 444 rect from 28.085000000000004, 18.83 to 28.087500000000002, 18.17 fc rgb \"#00CC00\"", + "set object 445 rect from 28.115000000000002, 18.83 to 28.139500000000005, 18.17 fc rgb \"#00CC00\"", + "set object 446 rect from 28.154000000000007, 18.83 to 28.260000000000005, 18.17 fc rgb \"#00CC00\"", + "set object 447 rect from 28.309500000000003, 18.83 to 28.374000000000006, 18.17 fc rgb \"#00CC00\"", + "set object 448 rect from 28.383500000000005, 18.83 to 28.385000000000005, 18.17 fc rgb \"#00CC00\"", + "set object 449 rect from 28.396500000000003, 18.83 to 28.445000000000007, 18.17 fc rgb \"#00CC00\"", + "set object 450 rect from 28.459500000000006, 18.83 to 28.463000000000005, 18.17 fc rgb \"#00CC00\"", + "set object 451 rect from 28.489500000000007, 18.83 to 28.499000000000006, 18.17 fc rgb \"#00CC00\"", + "set object 452 rect from 28.512500000000006, 18.83 to 28.516000000000005, 18.17 fc rgb \"#00CC00\"", + "set object 453 rect from 28.529500000000006, 18.83 to 28.533000000000005, 18.17 fc rgb \"#00CC00\"", + "set object 454 rect from 28.554500000000004, 18.83 to 28.557000000000006, 18.17 fc rgb \"#00CC00\"", + "set object 455 rect from 28.573500000000006, 18.83 to 28.579000000000008, 18.17 fc rgb \"#00CC00\"", + "set object 456 rect from 28.59950000000001, 18.83 to 28.602000000000007, 18.17 fc rgb \"#00CC00\"", + "set object 457 rect from 28.623500000000007, 18.83 to 28.625000000000007, 18.17 fc rgb \"#00CC00\"", + "set object 458 rect from 28.637500000000006, 18.83 to 28.647000000000006, 18.17 fc rgb \"#00CC00\"", + "set object 459 rect from 28.657500000000006, 18.83 to 28.669000000000008, 18.17 fc rgb \"#00CC00\"", + "set object 460 rect from 28.682500000000005, 18.83 to 28.686000000000007, 18.17 fc rgb \"#00CC00\"", + "set object 461 rect from 28.695500000000006, 18.83 to 28.701000000000008, 18.17 fc rgb \"#00CC00\"", + "set object 462 rect from 28.72450000000001, 18.83 to 28.811000000000007, 18.17 fc rgb \"#00CC00\"", + "set object 463 rect from 28.83250000000001, 18.83 to 28.907500000000006, 18.17 fc rgb \"#00CC00\"", + "set object 464 rect from 28.97100000000001, 18.83 to 28.97450000000001, 18.17 fc rgb \"#00CC00\"", + "set object 465 rect from 28.99600000000001, 18.83 to 28.99850000000001, 18.17 fc rgb \"#00CC00\"", + "set object 466 rect from 29.01200000000001, 18.83 to 29.01350000000001, 18.17 fc rgb \"#00CC00\"", + "set object 467 rect from 29.02600000000001, 18.83 to 29.056500000000007, 18.17 fc rgb \"#00CC00\"", + "set object 468 rect from 29.06900000000001, 18.83 to 29.159500000000012, 18.17 fc rgb \"#00CC00\"", + "set object 469 rect from 29.17100000000001, 18.83 to 29.18450000000001, 18.17 fc rgb \"#00CC00\"", + "set object 470 rect from 29.19400000000001, 18.83 to 41.84850000000001, 18.17 fc rgb \"#00CC00\"", + "set object 471 rect from 41.87900000000001, 18.83 to 41.88650000000001, 18.17 fc rgb \"#00CC00\"", + "set object 472 rect from 27.972500000000004, 19.83 to 28.053000000000004, 19.17 fc rgb \"#44CC00\"", + "set object 473 rect from 28.063500000000005, 19.83 to 28.169000000000004, 19.17 fc rgb \"#44CC00\"", + "set object 474 rect from 28.260000000000005, 19.83 to 28.489500000000007, 19.17 fc rgb \"#44CC00\"", + "set object 475 rect from 28.499000000000006, 19.83 to 28.761500000000005, 19.17 fc rgb \"#44CC00\"", + "set object 476 rect from 28.78900000000001, 19.83 to 28.847500000000007, 19.17 fc rgb \"#44CC00\"", + "set object 477 rect from 28.907500000000006, 19.83 to 29.047000000000008, 19.17 fc rgb \"#44CC00\"", + "set object 478 rect from 29.056500000000007, 19.83 to 29.111000000000008, 19.17 fc rgb \"#44CC00\"", + "set object 479 rect from 29.12350000000001, 19.83 to 29.21900000000001, 19.17 fc rgb \"#44CC00\"", + "set object 480 rect from 41.82650000000001, 19.83 to 41.83500000000001, 19.17 fc rgb \"#44CC00\"", + "set object 481 rect from 41.84850000000001, 19.83 to 41.87900000000001, 19.17 fc rgb \"#44CC00\"", + "set object 482 rect from 16.737, 20.83 to 16.9595, 20.17 fc rgb \"#00CC44\"", + "set object 483 rect from 17.8715, 20.83 to 18.017000000000003, 20.17 fc rgb \"#00CC44\"", + "set object 484 rect from 18.992, 20.83 to 19.0685, 20.17 fc rgb \"#00CC44\"", + "set object 485 rect from 20.52, 20.83 to 20.5975, 20.17 fc rgb \"#00CC44\"", + "set object 486 rect from 21.109, 20.83 to 21.1335, 20.17 fc rgb \"#00CC44\"", + "set object 487 rect from 21.212, 20.83 to 21.2695, 20.17 fc rgb \"#00CC44\"", + "set object 488 rect from 21.4595, 20.83 to 21.49, 20.17 fc rgb \"#00CC44\"", + "set object 489 rect from 21.566499999999998, 20.83 to 21.588, 20.17 fc rgb \"#00CC44\"", + "set object 490 rect from 21.6535, 20.83 to 21.727, 20.17 fc rgb \"#00CC44\"", + "set object 491 rect from 22.445, 20.83 to 22.4625, 20.17 fc rgb \"#00CC44\"", + "set object 492 rect from 22.502000000000002, 20.83 to 22.5165, 20.17 fc rgb \"#00CC44\"", + "set object 493 rect from 22.553, 20.83 to 22.5645, 20.17 fc rgb \"#00CC44\"", + "set object 494 rect from 23.233, 20.83 to 23.336000000000002, 20.17 fc rgb \"#00CC44\"", + "set object 495 rect from 23.4255, 20.83 to 23.506, 20.17 fc rgb \"#00CC44\"", + "set object 496 rect from 23.5895, 20.83 to 23.613, 20.17 fc rgb \"#00CC44\"", + "set object 497 rect from 23.870500000000003, 20.83 to 23.907, 20.17 fc rgb \"#00CC44\"", + "set object 498 rect from 24.393, 20.83 to 24.430500000000002, 20.17 fc rgb \"#00CC44\"", + "set object 499 rect from 24.470000000000002, 20.83 to 24.504500000000004, 20.17 fc rgb \"#00CC44\"", + "set object 500 rect from 25.267500000000002, 20.83 to 25.283, 20.17 fc rgb \"#00CC44\"", + "set object 501 rect from 25.4195, 20.83 to 25.427, 20.17 fc rgb \"#00CC44\"", + "set object 502 rect from 25.519500000000004, 20.83 to 25.526000000000003, 20.17 fc rgb \"#00CC44\"", + "set object 503 rect from 42.28050000000001, 20.83 to 42.298000000000016, 20.17 fc rgb \"#00CC44\"", + "set object 504 rect from 42.62700000000002, 20.83 to 42.656500000000015, 20.17 fc rgb \"#00CC44\"", + "set object 505 rect from 42.747000000000014, 20.83 to 42.763500000000015, 20.17 fc rgb \"#00CC44\"", + "set object 506 rect from 42.80300000000001, 20.83 to 42.81050000000001, 20.17 fc rgb \"#00CC44\"", + "set object 507 rect from 42.844000000000015, 20.83 to 42.858500000000014, 20.17 fc rgb \"#00CC44\"", + "set object 508 rect from 43.60550000000001, 20.83 to 43.62000000000002, 20.17 fc rgb \"#00CC44\"", + "set object 509 rect from 44.796000000000014, 20.83 to 44.81150000000002, 20.17 fc rgb \"#00CC44\"", + "set object 510 rect from 44.84500000000001, 20.83 to 44.87150000000002, 20.17 fc rgb \"#00CC44\"", + "set object 511 rect from 44.996000000000016, 20.83 to 45.00850000000001, 20.17 fc rgb \"#00CC44\"", + "set object 512 rect from 45.04700000000001, 20.83 to 45.06450000000002, 20.17 fc rgb \"#00CC44\"", + "set object 513 rect from 45.09600000000001, 20.83 to 45.107500000000016, 20.17 fc rgb \"#00CC44\"", + "set object 514 rect from 45.14400000000002, 20.83 to 45.16150000000002, 20.17 fc rgb \"#00CC44\"", + "set object 515 rect from 45.32050000000002, 20.83 to 45.33700000000002, 20.17 fc rgb \"#00CC44\"", + "set object 516 rect from 45.38750000000002, 20.83 to 45.402000000000015, 20.17 fc rgb \"#00CC44\"", + "set object 517 rect from 45.43250000000002, 20.83 to 45.442000000000014, 20.17 fc rgb \"#00CC44\"", + "set object 518 rect from 45.46050000000002, 20.83 to 45.46500000000002, 20.17 fc rgb \"#00CC44\"", + "set object 519 rect from 45.47750000000001, 20.83 to 45.48300000000001, 20.17 fc rgb \"#00CC44\"", + "set object 520 rect from 45.49750000000001, 20.83 to 45.55900000000001, 20.17 fc rgb \"#00CC44\"", + "set object 521 rect from 45.66050000000001, 20.83 to 45.70300000000001, 20.17 fc rgb \"#00CC44\"", + "set object 522 rect from 45.79350000000001, 20.83 to 45.81700000000001, 20.17 fc rgb \"#00CC44\"", + "set object 523 rect from 45.86950000000001, 20.83 to 45.92300000000001, 20.17 fc rgb \"#00CC44\"", + "set object 524 rect from 45.99450000000001, 20.83 to 46.060500000000005, 20.17 fc rgb \"#00CC44\"", + "set object 525 rect from 46.18500000000001, 20.83 to 46.28150000000001, 20.17 fc rgb \"#00CC44\"", + "set object 526 rect from 46.550000000000004, 20.83 to 46.5915, 20.17 fc rgb \"#00CC44\"", + "set object 527 rect from 46.65500000000001, 20.83 to 46.691500000000005, 20.17 fc rgb \"#00CC44\"", + "set object 528 rect from 46.861000000000004, 20.83 to 46.8935, 20.17 fc rgb \"#00CC44\"", + "set object 529 rect from 47.039500000000004, 20.83 to 47.049, 20.17 fc rgb \"#00CC44\"", + "set object 530 rect from 47.0765, 20.83 to 47.135000000000005, 20.17 fc rgb \"#00CC44\"", + "set object 531 rect from 47.4125, 20.83 to 47.465, 20.17 fc rgb \"#00CC44\"", + "set object 532 rect from 49.454499999999996, 20.83 to 49.467, 20.17 fc rgb \"#00CC44\"", + "set object 533 rect from 49.6855, 20.83 to 49.726, 20.17 fc rgb \"#00CC44\"", + "set object 534 rect from 49.799499999999995, 20.83 to 49.812999999999995, 20.17 fc rgb \"#00CC44\"", + "set object 535 rect from 49.841499999999996, 20.83 to 49.849999999999994, 20.17 fc rgb \"#00CC44\"", + "set object 536 rect from 49.894499999999994, 20.83 to 49.9695, 20.17 fc rgb \"#00CC44\"", + "set object 537 rect from 50.083999999999996, 20.83 to 50.14149999999999, 20.17 fc rgb \"#00CC44\"", + "set object 538 rect from 50.29299999999999, 20.83 to 50.31249999999999, 20.17 fc rgb \"#00CC44\"", + "set object 539 rect from 50.36699999999999, 20.83 to 50.39849999999999, 20.17 fc rgb \"#00CC44\"", + "set object 540 rect from 50.520999999999994, 20.83 to 50.528499999999994, 20.17 fc rgb \"#00CC44\"", + "set object 541 rect from 50.54899999999999, 20.83 to 50.62049999999999, 20.17 fc rgb \"#00CC44\"", + "set object 542 rect from 51.27549999999999, 20.83 to 51.29099999999999, 20.17 fc rgb \"#00CC44\"", + "set object 543 rect from 51.52249999999999, 20.83 to 51.56899999999999, 20.17 fc rgb \"#00CC44\"", + "set object 544 rect from 51.87299999999998, 20.83 to 51.89049999999999, 20.17 fc rgb \"#00CC44\"", + "set object 545 rect from 52.115999999999985, 20.83 to 52.13449999999999, 20.17 fc rgb \"#00CC44\"", + "set object 546 rect from 52.286999999999985, 20.83 to 52.300499999999985, 20.17 fc rgb \"#00CC44\"", + "set object 547 rect from 52.326999999999984, 20.83 to 52.33049999999999, 20.17 fc rgb \"#00CC44\"", + "set object 548 rect from 52.362999999999985, 20.83 to 52.404499999999985, 20.17 fc rgb \"#00CC44\"", + "set object 549 rect from 54.566499999999984, 20.83 to 54.64299999999998, 20.17 fc rgb \"#00CC44\"", + "set object 550 rect from 55.49149999999998, 20.83 to 55.53099999999998, 20.17 fc rgb \"#00CC44\"", + "set object 551 rect from 56.64049999999998, 20.83 to 56.64999999999998, 20.17 fc rgb \"#00CC44\"", + "set object 552 rect from 56.750999999999976, 20.83 to 56.76449999999998, 20.17 fc rgb \"#00CC44\"", + "set object 553 rect from 57.039499999999975, 20.83 to 57.076499999999974, 20.17 fc rgb \"#00CC44\"", + "set object 554 rect from 57.885999999999974, 20.83 to 57.893499999999975, 20.17 fc rgb \"#00CC44\"", + "set object 555 rect from 57.97749999999997, 20.83 to 57.99099999999997, 20.17 fc rgb \"#00CC44\"", + "set object 556 rect from 58.04499999999997, 20.83 to 58.055499999999974, 20.17 fc rgb \"#00CC44\"", + "set object 557 rect from 58.14549999999997, 20.83 to 58.15399999999997, 20.17 fc rgb \"#00CC44\"", + "set object 558 rect from 58.17549999999997, 20.83 to 58.18399999999997, 20.17 fc rgb \"#00CC44\"", + "set object 559 rect from 58.40999999999997, 20.83 to 58.431499999999964, 20.17 fc rgb \"#00CC44\"", + "set object 560 rect from 58.51699999999997, 20.83 to 58.53049999999997, 20.17 fc rgb \"#00CC44\"", + "set object 561 rect from 58.590999999999966, 20.83 to 58.60049999999997, 20.17 fc rgb \"#00CC44\"", + "set object 562 rect from 59.65599999999996, 20.83 to 59.669499999999964, 20.17 fc rgb \"#00CC44\"", + "set object 563 rect from 60.05149999999996, 20.83 to 60.060999999999964, 20.17 fc rgb \"#00CC44\"", + "set object 564 rect from 60.176999999999964, 20.83 to 60.19499999999996, 20.17 fc rgb \"#00CC44\"", + "set object 565 rect from 60.26949999999996, 20.83 to 60.27999999999996, 20.17 fc rgb \"#00CC44\"", + "set object 566 rect from 60.31149999999996, 20.83 to 60.34699999999996, 20.17 fc rgb \"#00CC44\"", + "set object 567 rect from 60.471499999999956, 20.83 to 60.48399999999996, 20.17 fc rgb \"#00CC44\"", + "set object 568 rect from 60.508499999999955, 20.83 to 60.51999999999996, 20.17 fc rgb \"#00CC44\"", + "set object 569 rect from 60.92099999999996, 20.83 to 60.98249999999996, 20.17 fc rgb \"#00CC44\"", + "set object 570 rect from 63.15199999999995, 20.83 to 63.228499999999954, 20.17 fc rgb \"#00CC44\"", + "set object 571 rect from 67.34999999999994, 20.83 to 67.36349999999995, 20.17 fc rgb \"#00CC44\"", + "set object 572 rect from 67.40699999999995, 20.83 to 67.41249999999995, 20.17 fc rgb \"#00CC44\"", + "set object 573 rect from 67.45699999999994, 20.83 to 67.46599999999995, 20.17 fc rgb \"#00CC44\"", + "set object 574 rect from 69.11299999999994, 20.83 to 69.12949999999995, 20.17 fc rgb \"#00CC44\"", + "set object 575 rect from 69.19199999999995, 20.83 to 69.22649999999994, 20.17 fc rgb \"#00CC44\"", + "set object 576 rect from 69.30799999999994, 20.83 to 69.31949999999995, 20.17 fc rgb \"#00CC44\"", + "set object 577 rect from 69.34699999999995, 20.83 to 69.35749999999994, 20.17 fc rgb \"#00CC44\"", + "set object 578 rect from 69.38399999999996, 20.83 to 69.40549999999995, 20.17 fc rgb \"#00CC44\"", + "set object 579 rect from 69.45099999999994, 20.83 to 69.46349999999994, 20.17 fc rgb \"#00CC44\"", + "set object 580 rect from 70.31749999999994, 20.83 to 70.33949999999994, 20.17 fc rgb \"#00CC44\"", + "set object 581 rect from 74.41449999999995, 20.83 to 74.43899999999994, 20.17 fc rgb \"#00CC44\"", + "set object 582 rect from 74.52049999999994, 20.83 to 74.54499999999993, 20.17 fc rgb \"#00CC44\"", + "set object 583 rect from 74.59549999999994, 20.83 to 74.60899999999995, 20.17 fc rgb \"#00CC44\"", + "set object 584 rect from 84.09999999999994, 20.83 to 84.15349999999994, 20.17 fc rgb \"#00CC44\"", + "set object 585 rect from 84.26099999999994, 20.83 to 84.27549999999994, 20.17 fc rgb \"#00CC44\"", + "set object 586 rect from 84.31099999999992, 20.83 to 84.31949999999993, 20.17 fc rgb \"#00CC44\"", + "set object 587 rect from 84.34199999999993, 20.83 to 84.35349999999993, 20.17 fc rgb \"#00CC44\"", + "set object 588 rect from 84.37299999999993, 20.83 to 84.40149999999993, 20.17 fc rgb \"#00CC44\"", + "set object 589 rect from 84.43999999999994, 20.83 to 84.46149999999993, 20.17 fc rgb \"#00CC44\"", + "set object 590 rect from 84.53049999999993, 20.83 to 84.60099999999994, 20.17 fc rgb \"#00CC44\"", + "set object 591 rect from 84.68049999999992, 20.83 to 84.69199999999992, 20.17 fc rgb \"#00CC44\"", + "set object 592 rect from 84.71649999999993, 20.83 to 84.72799999999992, 20.17 fc rgb \"#00CC44\"", + "set object 593 rect from 84.92199999999994, 20.83 to 84.93849999999993, 20.17 fc rgb \"#00CC44\"", + "set object 594 rect from 84.99799999999993, 20.83 to 85.01049999999992, 20.17 fc rgb \"#00CC44\"", + "set object 595 rect from 85.03599999999992, 20.83 to 85.04449999999993, 20.17 fc rgb \"#00CC44\"", + "set object 596 rect from 85.06199999999993, 20.83 to 85.07249999999993, 20.17 fc rgb \"#00CC44\"", + "set object 597 rect from 85.09499999999994, 20.83 to 85.10249999999992, 20.17 fc rgb \"#00CC44\"", + "set object 598 rect from 85.38399999999993, 20.83 to 85.43999999999994, 20.17 fc rgb \"#00CC44\"", + "set object 599 rect from 85.59949999999992, 20.83 to 85.61599999999993, 20.17 fc rgb \"#00CC44\"", + "set object 600 rect from 85.63749999999993, 20.83 to 85.65899999999993, 20.17 fc rgb \"#00CC44\"", + "set object 601 rect from 85.69649999999993, 20.83 to 85.70599999999993, 20.17 fc rgb \"#00CC44\"", + "set object 602 rect from 85.73249999999993, 20.83 to 85.76899999999992, 20.17 fc rgb \"#00CC44\"", + "set object 603 rect from 85.86549999999993, 20.83 to 85.87599999999992, 20.17 fc rgb \"#00CC44\"", + "set object 604 rect from 85.91149999999992, 20.83 to 85.92499999999993, 20.17 fc rgb \"#00CC44\"", + "set object 605 rect from 102.74599999999992, 20.83 to 102.80749999999992, 20.17 fc rgb \"#00CC44\"", + "set object 606 rect from 107.5244999999999, 20.83 to 107.57199999999992, 20.17 fc rgb \"#00CC44\"", + "set object 607 rect from 107.62449999999991, 20.83 to 107.6389999999999, 20.17 fc rgb \"#00CC44\"", + "set object 608 rect from 107.6674999999999, 20.83 to 107.6759999999999, 20.17 fc rgb \"#00CC44\"", + "set object 609 rect from 107.69849999999991, 20.83 to 107.70999999999992, 20.17 fc rgb \"#00CC44\"", + "set object 610 rect from 107.7294999999999, 20.83 to 107.7469999999999, 20.17 fc rgb \"#00CC44\"", + "set object 611 rect from 107.7834999999999, 20.83 to 107.79299999999992, 20.17 fc rgb \"#00CC44\"", + "set object 612 rect from 107.82049999999991, 20.83 to 107.8529999999999, 20.17 fc rgb \"#00CC44\"", + "set object 613 rect from 107.9294999999999, 20.83 to 107.94099999999992, 20.17 fc rgb \"#00CC44\"", + "set object 614 rect from 107.9654999999999, 20.83 to 107.97599999999991, 20.17 fc rgb \"#00CC44\"", + "set object 615 rect from 130.5489999999999, 20.83 to 130.5954999999999, 20.17 fc rgb \"#00CC44\"", + "set object 616 rect from 130.6469999999999, 20.83 to 130.6614999999999, 20.17 fc rgb \"#00CC44\"", + "set object 617 rect from 130.68999999999988, 20.83 to 130.6994999999999, 20.17 fc rgb \"#00CC44\"", + "set object 618 rect from 130.7219999999999, 20.83 to 130.7324999999999, 20.17 fc rgb \"#00CC44\"", + "set object 619 rect from 130.7519999999999, 20.83 to 130.76949999999988, 20.17 fc rgb \"#00CC44\"", + "set object 620 rect from 130.8059999999999, 20.83 to 130.8154999999999, 20.17 fc rgb \"#00CC44\"", + "set object 621 rect from 130.84299999999988, 20.83 to 130.87549999999987, 20.17 fc rgb \"#00CC44\"", + "set object 622 rect from 130.95199999999988, 20.83 to 130.9644999999999, 20.17 fc rgb \"#00CC44\"", + "set object 623 rect from 130.99099999999987, 20.83 to 131.00249999999988, 20.17 fc rgb \"#00CC44\"", + "set object 624 rect from 140.86699999999988, 20.83 to 140.8814999999999, 20.17 fc rgb \"#00CC44\"", + "set object 625 rect from 140.9319999999999, 20.83 to 140.9574999999999, 20.17 fc rgb \"#00CC44\"", + "set object 626 rect from 141.0299999999999, 20.83 to 141.03849999999989, 20.17 fc rgb \"#00CC44\"", + "set object 627 rect from 55.79999999999998, 21.83 to 56.198999999999984, 21.17 fc rgb \"#0044CC\"", + "set object 628 rect from 62.16149999999996, 21.83 to 62.548999999999964, 21.17 fc rgb \"#0044CC\"", + "set object 629 rect from 65.56449999999995, 21.83 to 65.61699999999995, 21.17 fc rgb \"#0044CC\"", + "set object 630 rect from 68.70599999999996, 21.83 to 68.76649999999995, 21.17 fc rgb \"#0044CC\"", + "set object 631 rect from 72.22199999999995, 21.83 to 72.28049999999995, 21.17 fc rgb \"#0044CC\"", + "set object 632 rect from 75.41849999999994, 21.83 to 75.46799999999995, 21.17 fc rgb \"#0044CC\"", + "set object 633 rect from 78.16449999999993, 21.83 to 78.23649999999994, 21.17 fc rgb \"#0044CC\"", + "set object 634 rect from 80.90399999999994, 21.83 to 80.95049999999993, 21.17 fc rgb \"#0044CC\"", + "set object 635 rect from 83.58349999999993, 21.83 to 83.63999999999993, 21.17 fc rgb \"#0044CC\"", + "set object 636 rect from 88.75199999999992, 21.83 to 88.82299999999992, 21.17 fc rgb \"#0044CC\"", + "set object 637 rect from 91.90999999999991, 21.83 to 91.96649999999993, 21.17 fc rgb \"#0044CC\"", + "set object 638 rect from 94.55599999999993, 21.83 to 94.6054999999999, 21.17 fc rgb \"#0044CC\"", + "set object 639 rect from 97.20749999999991, 21.83 to 97.26099999999992, 21.17 fc rgb \"#0044CC\"", + "set object 640 rect from 99.86649999999992, 21.83 to 99.92199999999991, 21.17 fc rgb \"#0044CC\"", + "set object 641 rect from 102.56049999999992, 21.83 to 102.61199999999991, 21.17 fc rgb \"#0044CC\"", + "set object 642 rect from 105.88099999999991, 21.83 to 105.93349999999991, 21.17 fc rgb \"#0044CC\"", + "set object 643 rect from 109.2659999999999, 21.83 to 109.38599999999991, 21.17 fc rgb \"#0044CC\"", + "set object 644 rect from 109.4024999999999, 21.83 to 109.41799999999989, 21.17 fc rgb \"#0044CC\"", + "set object 645 rect from 112.6029999999999, 21.83 to 112.6564999999999, 21.17 fc rgb \"#0044CC\"", + "set object 646 rect from 115.36399999999989, 21.83 to 115.4124999999999, 21.17 fc rgb \"#0044CC\"", + "set object 647 rect from 118.1434999999999, 21.83 to 118.19199999999991, 21.17 fc rgb \"#0044CC\"", + "set object 648 rect from 120.9194999999999, 21.83 to 121.0104999999999, 21.17 fc rgb \"#0044CC\"", + "set object 649 rect from 121.0259999999999, 21.83 to 121.0314999999999, 21.17 fc rgb \"#0044CC\"", + "set object 650 rect from 123.77499999999989, 21.83 to 123.8254999999999, 21.17 fc rgb \"#0044CC\"", + "set object 651 rect from 126.55149999999989, 21.83 to 126.59899999999989, 21.17 fc rgb \"#0044CC\"", + "set object 652 rect from 129.3344999999999, 21.83 to 129.4124999999999, 21.17 fc rgb \"#0044CC\"", + "set object 653 rect from 129.4249999999999, 21.83 to 129.48849999999987, 21.17 fc rgb \"#0044CC\"", + "set object 654 rect from 132.8659999999999, 21.83 to 132.92249999999987, 21.17 fc rgb \"#0044CC\"", + "set object 655 rect from 136.14449999999988, 21.83 to 136.19799999999987, 21.17 fc rgb \"#0044CC\"", + "set object 656 rect from 138.9289999999999, 21.83 to 138.98049999999986, 21.17 fc rgb \"#0044CC\"", + "set object 657 rect from 2.4204999999999997, 22.83 to 3.7920000000000003, 22.17 fc rgb \"#4444CC\"", + "set object 658 rect from 3.8075, 22.83 to 3.8129999999999997, 22.17 fc rgb \"#4444CC\"", + "set object 659 rect from 6.2695, 22.83 to 7.373, 22.17 fc rgb \"#4444CC\"", + "set object 660 rect from 7.3865, 22.83 to 7.3919999999999995, 22.17 fc rgb \"#4444CC\"", + "set object 661 rect from 9.2915, 22.83 to 10.405000000000001, 22.17 fc rgb \"#4444CC\"", + "set object 662 rect from 10.4235, 22.83 to 10.43, 22.17 fc rgb \"#4444CC\"", + "set object 663 rect from 12.8765, 22.83 to 13.897, 22.17 fc rgb \"#4444CC\"", + "set object 664 rect from 13.910499999999999, 22.83 to 13.915999999999999, 22.17 fc rgb \"#4444CC\"", "set object 665 rect from 18.803, 10.2 to 19.803, 9.8 fc rgb \"#000000\"", "set object 666 rect from 19.8815, 10.2 to 20.8815, 9.8 fc rgb \"#000000\"", "set object 667 rect from 20.910999999999998, 10.2 to 21.910999999999998, 9.8 fc rgb \"#000000\"", @@ -1371,7 +1371,7 @@ "set label \"1 ms\" at 14.3305828125,1 font \"Helvetica,7'\"", "set label \"0 ms\" at 18.204082812499998,1 font \"Helvetica,7'\"", "set label \"0 ms\" at 85.27908281249994,1 font \"Helvetica,7'\"", - "set y2range [0:62.076318181818216]", + "set y2range [0:59.54259090909095]", "plot '-' using 1:2 axes x1y2 with impulses ls 1", "41.88650000000001 13.935500000000008", "3.7920000000000003 1.3375000000000004", @@ -1563,4 +1563,4 @@ "# start: 2.4204999999999997", "# end: 141.1669999999999", "# objects: 1547" -]
\ No newline at end of file +] diff --git a/deps/v8/test/mjsunit/tools/profviz.js b/deps/v8/test/mjsunit/tools/profviz.js index 3a14f4e6be..6ff0e2cb9e 100644 --- a/deps/v8/test/mjsunit/tools/profviz.js +++ b/deps/v8/test/mjsunit/tools/profviz.js @@ -78,6 +78,5 @@ var create_baseline = false; if (create_baseline) { print(JSON.stringify(output_lines, null, 2)); } else { - assertArrayEquals(output_lines, - JSON.parse(read(reference_file))); + assertArrayEquals(JSON.parse(read(reference_file)), output_lines); } diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm-stack.js b/deps/v8/test/mjsunit/wasm/asm-wasm-stack.js new file mode 100644 index 0000000000..be728394ea --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/asm-wasm-stack.js @@ -0,0 +1,105 @@ +// 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: --validate-asm --allow-natives-syntax + +var filename = '(?:[^ ]+/)?test/mjsunit/wasm/asm-wasm-stack.js'; +filename = filename.replace(/\//g, '[/\\\\]'); + +function checkPreformattedStack(e, expected_lines) { + print('preformatted stack: ' + e.stack); + var lines = e.stack.split('\n'); + assertEquals(expected_lines.length, lines.length); + for (var i = 0; i < lines.length; ++i) { + assertMatches(expected_lines[i], lines[i], 'line ' + i); + } +} + +function checkFunctionsOnCallsites(e, locations) { + var stack = e.stack; + print('callsite objects (size ' + stack.length + '):'); + for (var i = 0; i < stack.length; ++i) { + var s = stack[i]; + print( + ' [' + i + '] ' + s.getFunctionName() + ' (' + s.getFileName() + ':' + + s.getLineNumber() + ':' + s.getColumnNumber() + ')'); + } + assertEquals(locations.length, stack.length, 'stack size'); + for (var i = 0; i < locations.length; ++i) { + var cs = stack[i]; + assertMatches('^' + filename + '$', cs.getFileName(), 'file name at ' + i); + assertEquals( + locations[i][0], cs.getFunctionName(), 'function name at ' + i); + assertEquals(locations[i][1], cs.getLineNumber(), 'line number at ' + i); + assertEquals( + locations[i][2], cs.getColumnNumber(), 'column number at ' + i); + assertNotNull(cs.getThis(), 'receiver should be global'); + assertEquals(stack[0].getThis(), cs.getThis(), 'receiver should be global'); + } +} + +function throwException() { + throw new Error('exception from JS'); +} + +function generateWasmFromAsmJs(stdlib, foreign, heap) { + 'use asm'; + var throwFunc = foreign.throwFunc; + function callThrow() { + throwFunc(); + } + function redirectFun(i) { + i = i|0; + switch (i|0) { + case 0: callThrow(); break; + case 1: redirectFun(0); break; + case 2: redirectFun(1); break; + } + } + return redirectFun; +} + +(function PreformattedStackTraceFromJS() { + var fun = generateWasmFromAsmJs(this, {throwFunc: throwException}, undefined); + var e = null; + try { + fun(0); + } catch (ex) { + e = ex; + } + assertInstanceof(e, Error, 'exception should have been thrown'); + checkPreformattedStack(e, [ + '^Error: exception from JS$', + '^ *at throwException \\(' + filename + ':43:9\\)$', + '^ *at callThrow \\(' + filename + ':50:5\\)$', + '^ *at redirectFun \\(' + filename + ':55:15\\)$', + '^ *at PreformattedStackTraceFromJS \\(' + filename + ':67:5\\)$', + '^ *at ' + filename + ':80:3$' + ]); +})(); + +// Now collect the Callsite objects instead of just a string. +Error.prepareStackTrace = function(error, frames) { + return frames; +}; + +(function CallsiteObjectsFromJS() { + var fun = generateWasmFromAsmJs(this, {throwFunc: throwException}, undefined); + var e = null; + try { + fun(2); + } catch (ex) { + e = ex; + } + assertInstanceof(e, Error, 'exception should have been thrown'); + checkFunctionsOnCallsites(e, [ + ['throwException', 43, 9], // -- + ['callThrow', 50, 5], // -- + ['redirectFun', 55, 15], // -- + ['redirectFun', 56, 15], // -- + ['redirectFun', 57, 15], // -- + ['CallsiteObjectsFromJS', 91, 5], // -- + [null, 105, 3] + ]); +})(); diff --git a/deps/v8/test/mjsunit/wasm/compiled-module-management.js b/deps/v8/test/mjsunit/wasm/compiled-module-management.js index a1bd2ce3c8..8c4c3b32af 100644 --- a/deps/v8/test/mjsunit/wasm/compiled-module-management.js +++ b/deps/v8/test/mjsunit/wasm/compiled-module-management.js @@ -2,49 +2,70 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO (mtrofin): re-enable ignition (v8:5345) -// Flags: --no-ignition --no-ignition-staging // Flags: --expose-wasm --expose-gc --allow-natives-syntax load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); +// Use global variables for all values where the test wants to maintain strict +// control over value lifetime. Using local variables would not give sufficient +// guarantees of the value lifetime. +var module; +var instance1; +var instance2; +var instance3; +var instance4; -(function CompiledModuleInstancesAreGCed() { +(function CompiledModuleInstancesInitialize1to3() { var builder = new WasmModuleBuilder(); builder.addMemory(1,1, true); - builder.addImport("getValue", kSig_i); - builder.addFunction("f", kSig_i) + builder.addImport("getValue", kSig_i_v); + builder.addFunction("f", kSig_i_v) .addBody([ kExprCallFunction, 0 ]).exportFunc(); - var module = new WebAssembly.Module(builder.toBuffer()); + module = new WebAssembly.Module(builder.toBuffer()); %ValidateWasmModuleState(module); %ValidateWasmInstancesChain(module, 0); - var i1 = new WebAssembly.Instance(module, {getValue: () => 1}); + instance1 = new WebAssembly.Instance(module, {getValue: () => 1}); %ValidateWasmInstancesChain(module, 1); - var i2 = new WebAssembly.Instance(module, {getValue: () => 2}); + instance2 = new WebAssembly.Instance(module, {getValue: () => 2}); %ValidateWasmInstancesChain(module, 2); - var i3 = new WebAssembly.Instance(module, {getValue: () => 3}); + instance3 = new WebAssembly.Instance(module, {getValue: () => 3}); %ValidateWasmInstancesChain(module, 3); +})(); - assertEquals(1, i1.exports.f()); - i1 = null; - gc(); - %ValidateWasmInstancesChain(module, 2); - assertEquals(3, i3.exports.f()); - i3 = null; - gc(); - %ValidateWasmInstancesChain(module, 1); - assertEquals(2, i2.exports.f()); - i2 = null; - gc(); - %ValidateWasmModuleState(module); - var i4 = new WebAssembly.Instance(module, {getValue: () => 4}); - assertEquals(4, i4.exports.f()); +(function CompiledModuleInstancesClear1() { + assertEquals(1, instance1.exports.f()); + instance1 = null; +})(); + +gc(); +%ValidateWasmInstancesChain(module, 2); + +(function CompiledModuleInstancesClear3() { + assertEquals(3, instance3.exports.f()); + instance3 = null; +})(); + +gc(); +%ValidateWasmInstancesChain(module, 1); + +(function CompiledModuleInstancesClear2() { + assertEquals(2, instance2.exports.f()); + instance2 = null; +})(); + +gc(); +%ValidateWasmModuleState(module); + +(function CompiledModuleInstancesInitialize4AndClearModule() { + instance4 = new WebAssembly.Instance(module, {getValue: () => 4}); + assertEquals(4, instance4.exports.f()); module = null; - gc(); - %ValidateWasmOrphanedInstance(i4); })(); + +gc(); +%ValidateWasmOrphanedInstance(instance4); diff --git a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js index aa36b71882..eb6534d0a8 100644 --- a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js +++ b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js @@ -12,7 +12,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); builder.addMemory(1,1, true); var kSig_v_i = makeSig([kAstI32], []); var signature = builder.addType(kSig_v_i); - builder.addImport("some_value", kSig_i); + builder.addImport("some_value", kSig_i_v); builder.addImport("writer", signature); builder.addFunction("main", kSig_i_i) @@ -20,7 +20,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); kExprGetLocal, 0, kExprI32LoadMem, 0, 0, kExprI32Const, 1, - kExprCallIndirect, signature, + kExprCallIndirect, signature, kTableZero, kExprGetLocal,0, kExprI32LoadMem,0, 0, kExprCallFunction, 0, @@ -35,15 +35,15 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); kExprCallFunction, 1]); builder.appendToTable([2, 3]); - - var module = new WebAssembly.Module(builder.toBuffer()); + var wire_bytes = builder.toBuffer(); + var module = new WebAssembly.Module(wire_bytes); var buff = %SerializeWasmModule(module); module = null; gc(); - module = %DeserializeWasmModule(buff); + module = %DeserializeWasmModule(buff, wire_bytes); - var mem_1 = new ArrayBuffer(4); - var view_1 = new Int32Array(mem_1); + var mem_1 = new WebAssembly.Memory({initial: 1}); + var view_1 = new Int32Array(mem_1.buffer); view_1[0] = 42; @@ -59,19 +59,20 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function DeserializeInvalidObject() { var invalid_buffer = new ArrayBuffer(10); - module = %DeserializeWasmModule(invalid_buffer); + module = %DeserializeWasmModule(invalid_buffer, invalid_buffer); assertEquals(module, undefined); })(); (function RelationBetweenModuleAndClone() { let builder = new WasmModuleBuilder(); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([kExprI8Const, 42]) .exportFunc(); - var compiled_module = new WebAssembly.Module(builder.toBuffer()); + var wire_bytes = builder.toBuffer(); + var compiled_module = new WebAssembly.Module(wire_bytes); var serialized = %SerializeWasmModule(compiled_module); - var clone = %DeserializeWasmModule(serialized); + var clone = %DeserializeWasmModule(serialized, wire_bytes); assertNotNull(clone); assertFalse(clone == undefined); @@ -81,15 +82,16 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function SerializeAfterInstantiation() { let builder = new WasmModuleBuilder(); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([kExprI8Const, 42]) .exportFunc(); - var compiled_module = new WebAssembly.Module(builder.toBuffer()); + var wire_bytes = builder.toBuffer() + var compiled_module = new WebAssembly.Module(wire_bytes); var instance1 = new WebAssembly.Instance(compiled_module); var instance2 = new WebAssembly.Instance(compiled_module); var serialized = %SerializeWasmModule(compiled_module); - var clone = %DeserializeWasmModule(serialized); + var clone = %DeserializeWasmModule(serialized, wire_bytes); assertNotNull(clone); assertFalse(clone == undefined); diff --git a/deps/v8/test/mjsunit/wasm/data-segments.js b/deps/v8/test/mjsunit/wasm/data-segments.js new file mode 100644 index 0000000000..8cff5e1756 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/data-segments.js @@ -0,0 +1,66 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +var debug = false; + +function SimpleDataSegmentTest(offset) { + print("SimpleDataSegmentTest(" + offset + ")..."); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.addFunction("load", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportAs("load"); + builder.addDataSegment(offset, [9, 9, 9, 9]); + + var buffer = builder.toBuffer(debug); + var instance = new WebAssembly.Instance(new WebAssembly.Module(buffer)); + for (var i = offset - 20; i < offset + 20; i += 4) { + if (i < 0) continue; + var expected = (i == offset) ? 151587081 : 0; + assertEquals(expected, instance.exports.load(i)); + } +} + +SimpleDataSegmentTest(0); +SimpleDataSegmentTest(4); +SimpleDataSegmentTest(12); +SimpleDataSegmentTest(1064); + +function GlobalImportedInitTest(pad) { + print("GlobaleImportedInitTest(" + pad + ")..."); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + + while (pad-- > 0) builder.addGlobal(kAstI32); // pad + + var g = builder.addImportedGlobal("offset", undefined, kAstI32); + + while (pad-- > 0) builder.addGlobal(kAstI32); // pad + + builder.addFunction("load", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportAs("load"); + builder.addDataSegment(g.index, [5, 5, 5, 5], true); + + var buffer = builder.toBuffer(debug); + var module = new WebAssembly.Module(buffer); + + for (var offset of [0, 12, 192, 1024]) { + var instance = new WebAssembly.Instance(module, {offset: offset}); + for (var i = offset - 20; i < offset + 20; i += 4) { + if (i < 0) continue; + var expected = i == offset ? 84215045 : 0; + assertEquals(expected, instance.exports.load(i)); + } + } +} + +GlobalImportedInitTest(0); +GlobalImportedInitTest(1); +GlobalImportedInitTest(4); diff --git a/deps/v8/test/mjsunit/wasm/debug-disassembly.js b/deps/v8/test/mjsunit/wasm/debug-disassembly.js deleted file mode 100644 index ac09d4af96..0000000000 --- a/deps/v8/test/mjsunit/wasm/debug-disassembly.js +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-wasm --expose-debug-as debug - -load("test/mjsunit/wasm/wasm-constants.js"); -load("test/mjsunit/wasm/wasm-module-builder.js"); - -Debug = debug.Debug - -// Initialized in setup(). -var exception; -var break_count; -var num_wasm_scripts; -var module; - -function listener(event, exec_state, event_data, data) { - try { - if (event == Debug.DebugEvent.Break) { - ++break_count; - // Request frame details. This should trigger creation of the Script - // objects for all frames on the stack. - var num_frames = exec_state.frameCount(); - for (var i = 0; i < num_frames; ++i) { - var frame = exec_state.frame(i); - var details = frame.details(); - var script = details.script(); - if (script.type == Debug.ScriptType.Wasm) { - var pos = frame.sourcePosition(); - var name = script.nameOrSourceURL(); - var disassembly = Debug.disassembleWasmFunction(script.id); - var offset_table = Debug.getWasmFunctionOffsetTable(script.id); - assertEquals(0, offset_table.length % 3); - var lineNr = null; - var columnNr = null; - for (var p = 0; p < offset_table.length; p += 3) { - if (offset_table[p] != pos) continue; - lineNr = offset_table[p+1]; - columnNr = offset_table[p+2]; - } - assertNotNull(lineNr, "position should occur in offset table"); - assertNotNull(columnNr, "position should occur in offset table"); - var line = disassembly.split("\n")[lineNr]; - assertTrue(!!line, "line number must occur in disassembly"); - assertTrue(line.length > columnNr, "column number must be valid"); - var expected_string; - if (name.endsWith("/1")) { - // Function 0 calls the imported function. - expected_string = "kExprCallFunction,"; - } else if (name.endsWith("/2")) { - // Function 1 calls function 0. - expected_string = "kExprCallFunction,"; - } else { - assertTrue(false, "Unexpected wasm script: " + name); - } - assertTrue(line.substr(columnNr).startsWith(expected_string), - "offset " + columnNr + " should start with '" + expected_string - + "': " + line); - } - } - } else if (event == Debug.DebugEvent.AfterCompile) { - var script = event_data.script(); - if (script.scriptType() == Debug.ScriptType.Wasm) { - ++num_wasm_scripts; - } - } - } catch (e) { - print("exception: " + e); - exception = e; - } -}; - -var builder = new WasmModuleBuilder(); - -builder.addImport("func", kSig_v_v); - -builder.addFunction("call_import", kSig_v_v) - .addBody([kExprCallFunction, 0]) - .exportFunc(); - -// Add a bit of unneccessary code to increase the byte offset. -builder.addFunction("call_call_import", kSig_v_v) - .addLocals({i32_count: 2}) - .addBody([ - kExprI32Const, 27, kExprSetLocal, 0, - kExprI32Const, (-7 & 0x7f), kExprSetLocal, 1, - kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add, kExprI64UConvertI32, - kExprI64Const, 0, - kExprI64Ne, kExprIf, kAstStmt, - kExprCallFunction, 1, - kExprEnd - ]) - .exportFunc(); - -function call_debugger() { - debugger; -} - -function setup() { - module = builder.instantiate({func: call_debugger}); - exception = null; - break_count = 0; - num_wasm_scripts = 0; -} - -(function testRegisteredWasmScripts1() { - setup(); - Debug.setListener(listener); - // Call the "call_import" function -> 1 script. - module.exports.call_import(); - module.exports.call_import(); - module.exports.call_call_import(); - Debug.setListener(null); - - assertEquals(3, break_count); - if (exception) throw exception; -})(); - -(function testRegisteredWasmScripts2() { - setup(); - Debug.setListener(listener); - module.exports.call_call_import(); - Debug.setListener(null); - - assertEquals(1, break_count); - if (exception) throw exception; -})(); diff --git a/deps/v8/test/mjsunit/wasm/errors.js b/deps/v8/test/mjsunit/wasm/errors.js new file mode 100644 index 0000000000..97ce89998b --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/errors.js @@ -0,0 +1,134 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +'use strict'; + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function module(bytes) { + let buffer = bytes; + if (typeof buffer === 'string') { + buffer = new ArrayBuffer(bytes.length); + let view = new Uint8Array(buffer); + for (let i = 0; i < bytes.length; ++i) { + view[i] = bytes.charCodeAt(i); + } + } + return new WebAssembly.Module(buffer); +} + +function instance(bytes, imports = {}) { + return new WebAssembly.Instance(module(bytes), imports); +} + +function builder() { + return new WasmModuleBuilder; +} + +function assertCompileError(bytes) { + assertThrows(() => module(bytes), WebAssembly.CompileError); +} + +function assertLinkError(bytes, imports = {}) { + assertThrows(() => instance(bytes, imports), TypeError); +} + +function assertRuntimeError(bytes, imports = {}) { + assertThrows(() => instance(bytes, imports).exports.run(), + WebAssembly.RuntimeError); +} + +function assertConversionError(bytes, imports = {}) { + assertThrows(() => instance(bytes, imports).exports.run(), TypeError); +} + +(function TestDecodingError() { + assertCompileError(""); + assertCompileError("X"); + assertCompileError("\0x00asm"); +})(); + +(function TestValidationError() { + assertCompileError(builder().addFunction("f", kSig_i_v).end().toBuffer()); + assertCompileError(builder().addFunction("f", kSig_i_v).addBody([ + kExprReturn + ]).end().toBuffer()); + assertCompileError(builder().addFunction("f", kSig_v_v).addBody([ + kExprGetLocal, 0 + ]).end().toBuffer()); + assertCompileError(builder().addStart(0).toBuffer()); +})(); + +(function TestLinkingError() { + let b; + + b = builder(); + b.addImportWithModule("foo", "bar", kSig_v_v); + assertLinkError(b.toBuffer(), {}); + b = builder(); + b.addImportWithModule("foo", "bar", kSig_v_v); + assertLinkError(b.toBuffer(), {foo: {}}); + b = builder(); + b.addImportWithModule("foo", "bar", kSig_v_v); + assertLinkError(b.toBuffer(), {foo: {bar: 9}}); + + b = builder(); + b.addImportedGlobal("foo", "bar", kAstI32); + assertLinkError(b.toBuffer(), {}); + // TODO(titzer): implement stricter import checks for globals. + // b = builder(); + // b.addImportedGlobal("foo", "bar", kAstI32); + // assertLinkError(b.toBuffer(), {foo: {}}); + // b = builder(); + // b.addImportedGlobal("foo", "bar", kAstI32); + // assertLinkError(b.toBuffer(), {foo: {bar: ""}}); + // b = builder(); + // b.addImportedGlobal("foo", "bar", kAstI32); + // assertLinkError(b.toBuffer(), {foo: {bar: () => 9}}); + + b = builder(); + b.addImportedMemory("foo", "bar"); + assertLinkError(b.toBuffer(), {}); + b = builder(); + b.addImportedMemory("foo", "bar"); + assertLinkError(b.toBuffer(), {foo: {}}); + // TODO(titzer): implement stricter import checks for globals. + // b = builder(); + // b.addImportedMemory("foo", "bar", 1); + // assertLinkError(b.toBuffer(), + // {foo: {bar: new WebAssembly.Memory({initial: 0})}}); +})(); + +(function TestTrapError() { + assertRuntimeError(builder().addFunction("run", kSig_v_v).addBody([ + kExprUnreachable + ]).exportFunc().end().toBuffer()); + + assertRuntimeError(builder().addFunction("run", kSig_v_v).addBody([ + kExprI32Const, 1, + kExprI32Const, 0, + kExprI32DivS, + kExprDrop + ]).exportFunc().end().toBuffer()); + + assertRuntimeError(builder().addFunction("run", kSig_v_v).addBody([ + ]).exportFunc().end(). + addFunction("start", kSig_v_v).addBody([ + kExprUnreachable + ]).end().addStart(1).toBuffer()); +})(); + +(function TestConversionError() { + let b = builder(); + b.addImportWithModule("foo", "bar", kSig_v_l); + assertConversionError(b.addFunction("run", kSig_v_v).addBody([ + kExprI64Const, 0, kExprCallFunction, 0 + ]).exportFunc().end().toBuffer()); + assertConversionError(builder().addFunction("run", kSig_l_v).addBody([ + kExprI64Const, 0 + ]).exportFunc().end().toBuffer()); +})(); diff --git a/deps/v8/test/mjsunit/wasm/exceptions.js b/deps/v8/test/mjsunit/wasm/exceptions.js index 71bd5f18ed..d02e34b9d0 100644 --- a/deps/v8/test/mjsunit/wasm/exceptions.js +++ b/deps/v8/test/mjsunit/wasm/exceptions.js @@ -106,7 +106,7 @@ var test_catch = (function () { } var kJSThrowLarge = builder.addImport("throw_large", sig_index); - // Helper function for throwing from Wasm. + // Helper function for throwing from WebAssembly. var kWasmThrowFunction = builder.addFunction("throw", kSig_v_i) .addBody([ diff --git a/deps/v8/test/mjsunit/wasm/export-table.js b/deps/v8/test/mjsunit/wasm/export-table.js index 6d21cf5790..4e9f1314e3 100644 --- a/deps/v8/test/mjsunit/wasm/export-table.js +++ b/deps/v8/test/mjsunit/wasm/export-table.js @@ -8,10 +8,11 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); (function testExportedMain() { + print("TestExportedMain..."); var kReturnValue = 88; var builder = new WasmModuleBuilder(); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([ kExprI8Const, kReturnValue, @@ -28,11 +29,12 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); })(); (function testExportedTwice() { + print("TestExportedTwice..."); var kReturnValue = 99; var builder = new WasmModuleBuilder(); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([ kExprI8Const, kReturnValue, @@ -49,15 +51,17 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertEquals(kReturnValue, module.exports.foo()); assertEquals(kReturnValue, module.exports.blah()); + assertSame(module.exports.blah, module.exports.foo); })(); (function testNumericName() { + print("TestNumericName..."); var kReturnValue = 93; var builder = new WasmModuleBuilder(); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([ kExprI8Const, kReturnValue, @@ -74,6 +78,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); })(); (function testExportNameClash() { + print("TestExportNameClash..."); var builder = new WasmModuleBuilder(); builder.addFunction("one", kSig_v_v).addBody([kExprNop]).exportAs("main"); @@ -87,3 +92,23 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertContains("Duplicate export", e.toString()); } })(); + + +(function testExportMultipleIdentity() { + print("TestExportMultipleIdentity..."); + var builder = new WasmModuleBuilder(); + + builder.addFunction("one", kSig_v_v).addBody([kExprNop]) + .exportAs("a") + .exportAs("b") + .exportAs("c"); + + let instance = builder.instantiate(); + let e = instance.exports; + assertEquals("function", typeof e.a); + assertEquals("function", typeof e.b); + assertEquals("function", typeof e.c); + assertSame(e.a, e.b); + assertSame(e.a, e.c); + assertEquals("a", e.a.name); +})(); diff --git a/deps/v8/test/mjsunit/wasm/ffi.js b/deps/v8/test/mjsunit/wasm/ffi.js index 5966ec8c5e..4b503efce4 100644 --- a/deps/v8/test/mjsunit/wasm/ffi.js +++ b/deps/v8/test/mjsunit/wasm/ffi.js @@ -94,7 +94,7 @@ print("Native function"); var builder = new WasmModuleBuilder(); - var sig_index = builder.addType(kSig_d); + var sig_index = builder.addType(kSig_d_v); builder.addImport("func", sig_index); builder.addFunction("main", sig_index) .addBody([ diff --git a/deps/v8/test/mjsunit/wasm/frame-inspection.js b/deps/v8/test/mjsunit/wasm/frame-inspection.js index 9d45239e4a..01f9142d3a 100644 --- a/deps/v8/test/mjsunit/wasm/frame-inspection.js +++ b/deps/v8/test/mjsunit/wasm/frame-inspection.js @@ -12,10 +12,14 @@ Debug = debug.Debug var exception = null; var break_count = 0; -const expected_num_frames = 5; -const expected_wasm_frames = [false, true, true, false, false]; -const expected_wasm_positions = [0, 1, 2, 0, 0]; -const expected_function_names = ["call_debugger", "wasm_2", "wasm_1", "testFrameInspection", ""]; +const expected_frames = [ + // func-name; wasm?; pos; line; col + ['call_debugger', false], // -- + ['wasm_2', true, 56, 2, 1], // -- + ['wasm_1', true, 52, 1, 2], // -- + ['testFrameInspection', false], // -- + ['', false] +]; function listener(event, exec_state, event_data, data) { if (event != Debug.DebugEvent.Break) return; @@ -23,20 +27,24 @@ function listener(event, exec_state, event_data, data) { try { var break_id = exec_state.break_id; var frame_count = exec_state.frameCount(); - assertEquals(expected_num_frames, frame_count); + assertEquals(expected_frames.length, frame_count, 'frame count'); for (var i = 0; i < frame_count; ++i) { var frame = exec_state.frame(i); + assertEquals(expected_frames[i][0], frame.func().name(), 'name at ' + i); // wasm frames have unresolved function, others resolved ones. - assertEquals(expected_wasm_frames[i], !frame.func().resolved()); - assertEquals(expected_function_names[i], frame.func().name()); - if (expected_wasm_frames[i]) { + assertEquals( + expected_frames[i][1], !frame.func().resolved(), 'resolved at ' + i); + if (expected_frames[i][1]) { // wasm frame? var script = frame.details().script(); - assertNotNull(script); - assertEquals(expected_wasm_positions[i], frame.details().sourcePosition()); + assertNotNull(script, 'script at ' + i); + assertEquals( + expected_frames[i][2], frame.details().sourcePosition(), + 'source pos at ' + i); var loc = script.locationFromPosition(frame.details().sourcePosition()); - assertEquals(expected_wasm_positions[i], loc.column); - assertEquals(expected_wasm_positions[i], loc.position); + assertEquals(expected_frames[i][2], loc.position, 'pos at ' + i); + assertEquals(expected_frames[i][3], loc.line, 'line at ' + i); + assertEquals(expected_frames[i][4], loc.column, 'column at ' + i); } } } catch (e) { @@ -49,14 +57,13 @@ var builder = new WasmModuleBuilder(); // wasm_1 calls wasm_2 on offset 2. // wasm_2 calls call_debugger on offset 1. -builder.addImport("func", kSig_v_v); +builder.addImport('func', kSig_v_v); -builder.addFunction("wasm_1", kSig_v_v) - .addBody([kExprNop, kExprCallFunction, 2]) - .exportAs("main"); +builder.addFunction('wasm_1', kSig_v_v) + .addBody([kExprNop, kExprCallFunction, 2]) + .exportAs('main'); -builder.addFunction("wasm_2", kSig_v_v) - .addBody([kExprCallFunction, 0]); +builder.addFunction('wasm_2', kSig_v_v).addBody([kExprCallFunction, 0]); function call_debugger() { debugger; diff --git a/deps/v8/test/mjsunit/wasm/function-prototype.js b/deps/v8/test/mjsunit/wasm/function-prototype.js index 25339adea7..fdf788f773 100644 --- a/deps/v8/test/mjsunit/wasm/function-prototype.js +++ b/deps/v8/test/mjsunit/wasm/function-prototype.js @@ -10,7 +10,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function TestFunctionPrototype() { var builder = new WasmModuleBuilder(); - builder.addFunction("nine", kSig_i) + builder.addFunction("nine", kSig_i_v) .addBody([kExprI8Const, 9]) .exportFunc(); diff --git a/deps/v8/test/mjsunit/wasm/gc-buffer.js b/deps/v8/test/mjsunit/wasm/gc-buffer.js new file mode 100644 index 0000000000..d33695532a --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/gc-buffer.js @@ -0,0 +1,42 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm --stress-gc --expose-gc + +load("test/mjsunit/wasm/wasm-constants.js"); +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). + var module = (() => { + var builder = new WasmModuleBuilder(); + builder.addImport("the_name_of_my_import", kSig_i_i); + builder.addFunction("main", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprCallFunction, 0]) + .exportAs("main"); + print("module"); + return new WebAssembly.Module(builder.toBuffer()); + })(); + + gc(); + for (var i = 0; i < 10; i++) { + print(" instance " + i); + var instance = new WebAssembly.Instance(module, {the_name_of_my_import: f}); + var g = instance.exports.main; + assertEquals("function", typeof g); + for (var j = 0; j < 10; j++) { + assertEquals(f(j), g(j)); + } + } +} + +(function test() { + for (var i = 0; i < 3; i++) { + run(x => (x + 19)); + run(x => (x - 18)); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/gc-stress.js b/deps/v8/test/mjsunit/wasm/gc-stress.js new file mode 100644 index 0000000000..468be105cc --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/gc-stress.js @@ -0,0 +1,37 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm --stress-gc + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function run(f) { + var builder = new WasmModuleBuilder(); + builder.addImport("f", kSig_i_i); + builder.addFunction("main", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprCallFunction, 0]) + .exportAs("main"); + + print("module"); + var module = new WebAssembly.Module(builder.toBuffer()); + + for (var i = 0; i < 10; i++) { + print(" instance " + i); + var instance = new WebAssembly.Instance(module, {f: f}); + var g = instance.exports.main; + for (var j = 0; j < 10; j++) { + assertEquals(f(j), g(j)); + } + } +} + +(function test() { + for (var i = 0; i < 100; i++) { + run(x => (x + 19)); + run(x => (x - 18)); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/globals.js b/deps/v8/test/mjsunit/wasm/globals.js new file mode 100644 index 0000000000..ca421477a2 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/globals.js @@ -0,0 +1,88 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function TestImported(type, val, expected) { + print("TestImported " + type + "(" + val +")" + " = " + expected); + var builder = new WasmModuleBuilder(); + var sig = makeSig([], [type]); + var g = builder.addImportedGlobal("foo", undefined, type); + builder.addFunction("main", sig) + .addBody([kExprGetGlobal, g.index]) + .exportAs("main"); + builder.addGlobal(kAstI32); // pad + + var instance = builder.instantiate({foo: val}); + assertEquals(expected, instance.exports.main()); +} + +TestImported(kAstI32, 300.1, 300); +TestImported(kAstF32, 87234.87238, Math.fround(87234.87238)); +TestImported(kAstF64, 77777.88888, 77777.88888); +TestImported(kAstF64, "89", 89); + + +function TestExported(type, val, expected) { + print("TestExported " + type + "(" + val +")" + " = " + expected); + var builder = new WasmModuleBuilder(); + var sig = makeSig([type], []); + builder.addGlobal(kAstI32); // pad + var g = builder.addGlobal(type, false) + .exportAs("foo"); + g.init = val; + builder.addGlobal(kAstI32); // pad + + var instance = builder.instantiate(); + assertEquals(expected, instance.exports.foo); +} + +TestExported(kAstI32, 455.5, 455); +TestExported(kAstF32, -999.34343, Math.fround(-999.34343)); +TestExported(kAstF64, 87347.66666, 87347.66666); + + +function TestImportedExported(type, val, expected) { + print("TestImportedExported " + type + "(" + val +")" + " = " + expected); + var builder = new WasmModuleBuilder(); + var sig = makeSig([type], []); + var i = builder.addImportedGlobal("foo", undefined, type); + builder.addGlobal(kAstI32); // pad + var o = builder.addGlobal(type, false) + .exportAs("bar"); + o.init_index = i; + builder.addGlobal(kAstI32); // pad + + var instance = builder.instantiate({foo: val}); + assertEquals(expected, instance.exports.bar); +} + +TestImportedExported(kAstI32, 415.5, 415); +TestImportedExported(kAstF32, -979.34343, Math.fround(-979.34343)); +TestImportedExported(kAstF64, 81347.66666, 81347.66666); + +function TestGlobalIndexSpace(type, val) { + print("TestGlobalIndexSpace(" + val + ") = " + val); + var builder = new WasmModuleBuilder(); + var im = builder.addImportedGlobal("foo", undefined, type); + assertEquals(0, im); + var def = builder.addGlobal(type, false); + assertEquals(1, def.index); + def.init_index = im; + + var sig = makeSig([], [type]); + builder.addFunction("main", sig) + .addBody([kExprGetGlobal, def.index]) + .exportAs("main"); + + var instance = builder.instantiate({foo: val}); + assertEquals(val, instance.exports.main()); +} + +TestGlobalIndexSpace(kAstI32, 123); +TestGlobalIndexSpace(kAstF32, 54321.125); +TestGlobalIndexSpace(kAstF64, 12345.678); diff --git a/deps/v8/test/mjsunit/wasm/grow-memory.js b/deps/v8/test/mjsunit/wasm/grow-memory.js index ecc105ee0d..37289a5b77 100644 --- a/deps/v8/test/mjsunit/wasm/grow-memory.js +++ b/deps/v8/test/mjsunit/wasm/grow-memory.js @@ -2,17 +2,18 @@ // 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 --stress-compaction +// Flags: --expose-wasm --stress-compaction load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); var kPageSize = 0x10000; +var kV8MaxPages = 16384; function genGrowMemoryBuilder() { var builder = new WasmModuleBuilder(); builder.addFunction("grow_memory", kSig_i_i) - .addBody([kExprGetLocal, 0, kExprGrowMemory]) + .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) .exportFunc(); builder.addFunction("load", kSig_i_i) .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) @@ -38,9 +39,11 @@ function genGrowMemoryBuilder() { return builder; } +// TODO(gdeepti): Generate tests programatically for all the sizes instead of +// current implementation. function testGrowMemoryReadWrite32() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset; function peek() { return module.exports.load(offset); } @@ -87,7 +90,7 @@ testGrowMemoryReadWrite32(); function testGrowMemoryReadWrite16() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset; function peek() { return module.exports.load16(offset); } @@ -134,7 +137,7 @@ testGrowMemoryReadWrite16(); function testGrowMemoryReadWrite8() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset; function peek() { return module.exports.load8(offset); } @@ -197,15 +200,96 @@ function testGrowMemoryZeroInitialSize() { assertEquals(20, peek()); } - //TODO(gdeepti): Fix tests with correct write boundaries - //when runtime function is fixed. - for(offset = kPageSize; offset <= kPageSize + 5; offset++) { + for(offset = kPageSize - 3; offset <= kPageSize + 5; offset++) { assertTraps(kTrapMemOutOfBounds, peek); } + + offset = 3*kPageSize; + for (var i = 1; i < 4; i++) { + assertTraps(kTrapMemOutOfBounds, poke); + assertEquals(i, growMem(1)); + } + poke(20); + assertEquals(20, peek()); } testGrowMemoryZeroInitialSize(); +function testGrowMemoryZeroInitialSize32() { + var builder = genGrowMemoryBuilder(); + var module = builder.instantiate(); + var offset; + 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); } + + assertTraps(kTrapMemOutOfBounds, peek); + assertTraps(kTrapMemOutOfBounds, poke); + + assertEquals(0, growMem(1)); + + for(offset = 0; offset <= kPageSize - 4; offset++) { + poke(20); + assertEquals(20, peek()); + } + + for(offset = kPageSize - 3; offset <= kPageSize + 5; offset++) { + assertTraps(kTrapMemOutOfBounds, peek); + } +} + +testGrowMemoryZeroInitialSize32(); + +function testGrowMemoryZeroInitialSize16() { + var builder = genGrowMemoryBuilder(); + var module = builder.instantiate(); + var offset; + function peek() { return module.exports.load16(offset); } + function poke(value) { return module.exports.store16(offset, value); } + function growMem(pages) { return module.exports.grow_memory(pages); } + + assertTraps(kTrapMemOutOfBounds, peek); + assertTraps(kTrapMemOutOfBounds, poke); + + assertEquals(0, growMem(1)); + + for(offset = 0; offset <= kPageSize - 2; offset++) { + poke(20); + assertEquals(20, peek()); + } + + for(offset = kPageSize - 1; offset <= kPageSize + 5; offset++) { + assertTraps(kTrapMemOutOfBounds, peek); + } +} + +testGrowMemoryZeroInitialSize16(); + +function testGrowMemoryZeroInitialSize8() { + var builder = genGrowMemoryBuilder(); + var module = builder.instantiate(); + var offset; + function peek() { return module.exports.load8(offset); } + function poke(value) { return module.exports.store8(offset, value); } + function growMem(pages) { return module.exports.grow_memory(pages); } + + assertTraps(kTrapMemOutOfBounds, peek); + assertTraps(kTrapMemOutOfBounds, poke); + + assertEquals(0, growMem(1)); + + for(offset = 0; offset <= kPageSize - 1; offset++) { + poke(20); + assertEquals(20, peek()); + } + + for(offset = kPageSize; offset <= kPageSize + 5; offset++) { + assertTraps(kTrapMemOutOfBounds, peek); + } +} + +testGrowMemoryZeroInitialSize8(); + function testGrowMemoryTrapMaxPagesZeroInitialMemory() { var builder = genGrowMemoryBuilder(); var module = builder.instantiate(); @@ -240,9 +324,9 @@ testGrowMemoryTrapsWithNonSmiInput(); function testGrowMemoryCurrentMemory() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); builder.addFunction("memory_size", kSig_i_v) - .addBody([kExprMemorySize]) + .addBody([kExprMemorySize, kMemoryZero]) .exportFunc(); var module = builder.instantiate(); function growMem(pages) { return module.exports.grow_memory(pages); } @@ -256,7 +340,7 @@ testGrowMemoryCurrentMemory(); function testGrowMemoryPreservesDataMemOp32() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset, val; function peek() { return module.exports.load(offset); } @@ -279,7 +363,7 @@ testGrowMemoryPreservesDataMemOp32(); function testGrowMemoryPreservesDataMemOp16() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset, val; function peek() { return module.exports.load16(offset); } @@ -302,7 +386,7 @@ testGrowMemoryPreservesDataMemOp16(); function testGrowMemoryPreservesDataMemOp8() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset, val = 0; function peek() { return module.exports.load8(offset); } @@ -329,7 +413,7 @@ testGrowMemoryPreservesDataMemOp8(); function testGrowMemoryOutOfBoundsOffset() { var builder = genGrowMemoryBuilder(); - builder.addMemory(1, 1, false); + builder.addMemory(1, kV8MaxPages, false); var module = builder.instantiate(); var offset, val; function peek() { return module.exports.load(offset); } @@ -358,3 +442,48 @@ function testGrowMemoryOutOfBoundsOffset() { } testGrowMemoryOutOfBoundsOffset(); + +function testGrowMemoryOutOfBoundsOffset2() { + var builder = new WasmModuleBuilder(); + builder.addMemory(16, 128, false); + builder.addFunction("main", kSig_v_v) + .addBody([ + kExprI32Const, 20, + kExprI32Const, 29, + kExprGrowMemory, kMemoryZero, + kExprI32StoreMem, 0, 0xFF, 0xFF, 0xFF, 0x3a + ]) + .exportAs("main"); + var module = builder.instantiate(); + assertTraps(kTrapMemOutOfBounds, module.exports.main); +} + +testGrowMemoryOutOfBoundsOffset2(); + +function testGrowMemoryDeclaredMaxTraps() { + var builder = genGrowMemoryBuilder(); + builder.addMemory(1, 16, false); + var module = builder.instantiate(); + function growMem(pages) { return module.exports.grow_memory(pages); } + assertEquals(1, growMem(5)); + assertEquals(6, growMem(5)); + assertEquals(-1, growMem(6)); +} + +testGrowMemoryDeclaredMaxTraps(); + +function testGrowMemoryDeclaredSpecMaxTraps() { + // The spec maximum is higher than the internal V8 maximum. This test only + // checks that grow_memory does not grow past the internally defined maximum + // to reflect the currentl implementation. + var builder = genGrowMemoryBuilder(); + var kSpecMaxPages = 65535; + builder.addMemory(1, kSpecMaxPages, false); + var module = builder.instantiate(); + function poke(value) { return module.exports.store(offset, value); } + function growMem(pages) { return module.exports.grow_memory(pages); } + assertEquals(1, growMem(20)); + assertEquals(-1, growMem(kV8MaxPages - 20)); +} + +testGrowMemoryDeclaredSpecMaxTraps(); diff --git a/deps/v8/test/mjsunit/wasm/import-memory.js b/deps/v8/test/mjsunit/wasm/import-memory.js new file mode 100644 index 0000000000..845da91d1d --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/import-memory.js @@ -0,0 +1,231 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +(function TestOne() { + print("TestOne"); + let memory = new WebAssembly.Memory({initial: 1}); + assertEquals(kPageSize, memory.buffer.byteLength); + let i32 = new Int32Array(memory.buffer); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("mine"); + builder.addFunction("main", kSig_i_v) + .addBody([ + kExprI32Const, 0, + kExprI32LoadMem, 0, 0]) + .exportAs("main"); + + let main = builder.instantiate({mine: memory}).exports.main; + assertEquals(0, main()); + + i32[0] = 993377; + + assertEquals(993377, main()); +})(); + +(function TestIdentity() { + print("TestIdentity"); + let memory = new WebAssembly.Memory({initial: 1}); + let i32 = new Int32Array(memory.buffer); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("garg"); + builder.exportMemoryAs("daggle"); + + let instance = builder.instantiate({garg: memory}); + assertSame(memory, instance.exports.daggle); +})(); + + +(function TestImportExport() { + print("TestImportExport"); + var i1; + { + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.exportMemoryAs("exported_mem"); + builder.addFunction("foo", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprI32LoadMem, 0, 0]) + .exportAs("foo"); + i1 = builder.instantiate(); + } + + var i2; + { + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.addImportedMemory("imported_mem"); + builder.addFunction("bar", kSig_i_i) + .addBody([ + kExprGetLocal, 0, + kExprI32LoadMem, 0, 0]) + .exportAs("bar"); + i2 = builder.instantiate({imported_mem: i1.exports.exported_mem}); + } + + let i32 = new Int32Array(i1.exports.exported_mem.buffer); + + for (var i = 0; i < 1e11; i = i * 3 + 5) { + for (var j = 0; j < 10; j++) { + var val = i + 99077 + j; + i32[j] = val; + assertEquals(val | 0, i1.exports.foo(j * 4)); + assertEquals(val | 0, i2.exports.bar(j * 4)); + } + } +})(); + +(function ValidateBoundsCheck() { + print("ValidateBoundsCheck"); + let memory = new WebAssembly.Memory({initial: 1, maximum: 5}); + assertEquals(kPageSize, memory.buffer.byteLength); + let i32 = new Int32Array(memory.buffer); + let builder = new WasmModuleBuilder(); + // builder.addImportedMemory("mine"); + builder.addImportedMemory("mine"); + builder.addFunction("load", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportFunc(); + builder.addFunction("store", kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, + kExprGetLocal, 1]) + .exportFunc(); + var offset; + let instance = builder.instantiate({mine: memory}); + function load() { return instance.exports.load(offset); } + function store(value) { return instance.exports.store(offset, value); } + + for (offset = 0; offset < kPageSize - 3; offset+=4) { + store(offset); + } + for (offset = 0; offset < kPageSize - 3; offset+=4) { + assertEquals(offset, load()); + } + for (offset = kPageSize - 3; offset < kPageSize + 4; offset++) { + assertTraps(kTrapMemOutOfBounds, load); + } +})(); + +(function TestGrowMemoryMaxDesc() { + print("MaximumDescriptor"); + let memory = new WebAssembly.Memory({initial: 1, maximum: 5}); + assertEquals(kPageSize, memory.buffer.byteLength); + let i32 = new Int32Array(memory.buffer); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("mine", "", 0, 20); + builder.addFunction("load", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportFunc(); + builder.addFunction("store", kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, + kExprGetLocal, 1]) + .exportFunc(); + var offset; + let instance = builder.instantiate({mine: memory}); + function load() { return instance.exports.load(offset); } + function store(value) { return instance.exports.store(offset, value); } + + for (var i = 1; i < 5; i++) { + for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset+=4) { + store(offset * 2); + } + assertEquals(i, memory.grow(1)); + assertEquals((i + 1) * kPageSize, memory.buffer.byteLength); + } + for (offset = 4 * kPageSize; offset < 5 * kPageSize - 3; offset+=4) { + store(offset * 2); + } + for (offset = 0; offset < 5 * kPageSize - 3; offset+=4) { + assertEquals(offset * 2, load()); + } + for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { + assertThrows(load); + } + assertThrows(() => memory.grow(1)); +})(); + +(function TestGrowMemoryZeroInitialMemory() { + print("ZeroInitialMemory"); + let memory = new WebAssembly.Memory({initial: 0}); + assertEquals(0, memory.buffer.byteLength); + let i32 = new Int32Array(memory.buffer); + let builder = new WasmModuleBuilder(); + builder.addImportedMemory("mine"); + builder.addFunction("load", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) + .exportFunc(); + builder.addFunction("store", kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, + kExprGetLocal, 1]) + .exportFunc(); + var offset; + let instance = builder.instantiate({mine: memory}); + function load() { return instance.exports.load(offset); } + function store(value) { return instance.exports.store(offset, value); } + + for (var i = 1; i < 5; i++) { + assertEquals(i - 1, memory.grow(1)); + assertEquals(i * kPageSize, memory.buffer.byteLength); + for (offset = (i - 1) * kPageSize; offset < i * kPageSize - 3; offset++) { + store(offset * 2); + } + } + for (offset = 5 * kPageSize; offset < 5 * kPageSize + 4; offset++) { + assertThrows(load); + } + assertThrows(() => memory.grow(16381)); +})(); + +(function ImportedMemoryBufferLength() { + print("ImportedMemoryBufferLength"); + let memory = new WebAssembly.Memory({initial: 2, maximum: 10}); + assertEquals(2*kPageSize, memory.buffer.byteLength); + let builder = new WasmModuleBuilder(); + builder.addFunction("grow", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) + .exportFunc(); + builder.addImportedMemory("mine"); + let instance = builder.instantiate({mine: memory}); + function grow(pages) { return instance.exports.grow(pages); } + assertEquals(2, grow(3)); + assertEquals(5*kPageSize, memory.buffer.byteLength); + assertEquals(5, grow(5)); + assertEquals(10*kPageSize, memory.buffer.byteLength); + assertThrows(() => memory.grow(1)); +})(); + +(function TestGrowMemoryExportedMaximum() { + print("TestGrowMemoryExportedMaximum"); + let initial_size = 1, maximum_size = 10; + var exp_instance; + { + let builder = new WasmModuleBuilder(); + builder.addMemory(initial_size, maximum_size, true); + builder.exportMemoryAs("exported_mem"); + exp_instance = builder.instantiate(); + } + var instance; + { + var builder = new WasmModuleBuilder(); + builder.addImportedMemory("imported_mem"); + builder.addFunction("mem_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + builder.addFunction("grow", kSig_i_i) + .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) + .exportFunc(); + instance = builder.instantiate({ + imported_mem: exp_instance.exports.exported_mem}); + } + for (var i = initial_size; i < maximum_size; i++) { + assertEquals(i, instance.exports.grow(1)); + assertEquals((i+1), instance.exports.mem_size()); + } + assertEquals(-1, instance.exports.grow(1)); +})(); diff --git a/deps/v8/test/mjsunit/wasm/import-table.js b/deps/v8/test/mjsunit/wasm/import-table.js index aa836d6eac..e00e533ae1 100644 --- a/deps/v8/test/mjsunit/wasm/import-table.js +++ b/deps/v8/test/mjsunit/wasm/import-table.js @@ -266,9 +266,9 @@ testCallPrint(); function testCallImport2(foo, bar, expected) { var builder = new WasmModuleBuilder(); - builder.addImport("foo", kSig_i); - builder.addImport("bar", kSig_i); - builder.addFunction("main", kSig_i) + builder.addImport("foo", kSig_i_v); + builder.addImport("bar", kSig_i_v); + builder.addFunction("main", kSig_i_v) .addBody([ kExprCallFunction, 0, // -- kExprCallFunction, 1, // -- diff --git a/deps/v8/test/mjsunit/wasm/incrementer.wasm b/deps/v8/test/mjsunit/wasm/incrementer.wasm Binary files differindex 30b51c2e1b..4ab5a90448 100644 --- a/deps/v8/test/mjsunit/wasm/incrementer.wasm +++ b/deps/v8/test/mjsunit/wasm/incrementer.wasm diff --git a/deps/v8/test/mjsunit/wasm/indirect-calls.js b/deps/v8/test/mjsunit/wasm/indirect-calls.js index 26021bb74d..ac4fa54e6d 100644 --- a/deps/v8/test/mjsunit/wasm/indirect-calls.js +++ b/deps/v8/test/mjsunit/wasm/indirect-calls.js @@ -27,7 +27,7 @@ var module = (function () { kExprGetLocal, 1, kExprGetLocal, 2, kExprGetLocal, 0, - kExprCallIndirect, sig_index + kExprCallIndirect, sig_index, kTableZero ]) .exportFunc() builder.appendToTable([1, 2, 3]); @@ -54,27 +54,27 @@ module = (function () { var sig_i_ii = builder.addType(kSig_i_ii); var sig_i_i = builder.addType(kSig_i_i); - builder.addImport("mul", sig_i_ii); - builder.addFunction("add", sig_i_ii) + var mul = builder.addImport("mul", sig_i_ii); + var add = builder.addFunction("add", sig_i_ii) .addBody([ kExprGetLocal, 0, // -- kExprGetLocal, 1, // -- kExprI32Add // -- ]); - builder.addFunction("popcnt", sig_i_i) + var popcnt = builder.addFunction("popcnt", sig_i_i) .addBody([ kExprGetLocal, 0, // -- kExprI32Popcnt // -- ]); - builder.addFunction("main", kSig_i_iii) + var main = builder.addFunction("main", kSig_i_iii) .addBody([ kExprGetLocal, 1, kExprGetLocal, 2, kExprGetLocal, 0, - kExprCallIndirect, sig_i_ii + kExprCallIndirect, sig_i_ii, kTableZero ]) - .exportFunc() - builder.appendToTable([0, 1, 2, 3]); + .exportFunc(); + builder.appendToTable([mul.index, add.index, popcnt.index, main.index]); return builder.instantiate({mul: function(a, b) { return a * b | 0; }}); })(); @@ -84,3 +84,125 @@ assertEquals(99, module.exports.main(1, 22, 77)); assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); assertTraps(kTrapFuncSigMismatch, "module.exports.main(3, 12, 33)"); assertTraps(kTrapFuncInvalid, "module.exports.main(4, 12, 33)"); + +function AddFunctions(builder) { + var mul = builder.addFunction("mul", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Mul // -- + ]); + var add = builder.addFunction("add", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Add // -- + ]); + var sub = builder.addFunction("sub", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Sub // -- + ]); + return {mul: mul, add: add, sub: sub}; +} + + +module = (function () { + var builder = new WasmModuleBuilder(); + + var f = AddFunctions(builder); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + builder.appendToTable([f.mul.index, f.add.index, f.sub.index]); + + return builder.instantiate(); +})(); + +assertEquals(33, module.exports.main(1, 0)); +assertEquals(66, module.exports.main(2, 0)); +assertEquals(34, module.exports.main(1, 1)); +assertEquals(35, module.exports.main(2, 1)); +assertEquals(32, module.exports.main(1, 2)); +assertEquals(31, module.exports.main(2, 2)); +assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)"); + +(function ConstBaseTest() { + print("ConstBaseTest..."); + function instanceWithTable(base, length) { + var builder = new WasmModuleBuilder(); + + var f = AddFunctions(builder); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableLength(length); + builder.addFunctionTableInit(base, false, [f.add.index, f.sub.index, f.mul.index]); + + return builder.instantiate(); + } + + for (var i = 0; i < 5; i++) { + print(" base = " + i); + var module = instanceWithTable(i, 10); + main = module.exports.main; + for (var j = 0; j < i; j++) { + assertTraps(kTrapFuncSigMismatch, "main(12, " + j + ")"); + } + assertEquals(34, main(1, i + 0)); + assertEquals(35, main(2, i + 0)); + assertEquals(32, main(1, i + 1)); + assertEquals(31, main(2, i + 1)); + assertEquals(33, main(1, i + 2)); + assertEquals(66, main(2, i + 2)); + assertTraps(kTrapFuncInvalid, "main(12, 10)"); + } +})(); + +(function GlobalBaseTest() { + print("GlobalBaseTest..."); + + var builder = new WasmModuleBuilder(); + + var f = AddFunctions(builder); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableLength(10); + var g = builder.addImportedGlobal("base", undefined, kAstI32); + builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, f.sub.index]); + + var module = new WebAssembly.Module(builder.toBuffer()); + + for (var i = 0; i < 5; i++) { + print(" base = " + i); + var instance = new WebAssembly.Instance(module, {base: i}); + main = instance.exports.main; + for (var j = 0; j < i; j++) { + assertTraps(kTrapFuncSigMismatch, "main(12, " + j + ")"); + } + assertEquals(33, main(1, i + 0)); + assertEquals(66, main(2, i + 0)); + assertEquals(34, main(1, i + 1)); + assertEquals(35, main(2, i + 1)); + assertEquals(32, main(1, i + 2)); + assertEquals(31, main(2, i + 2)); + assertTraps(kTrapFuncInvalid, "main(12, 10)"); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/indirect-tables.js b/deps/v8/test/mjsunit/wasm/indirect-tables.js new file mode 100644 index 0000000000..62b900586c --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/indirect-tables.js @@ -0,0 +1,377 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function AddFunctions(builder) { + let sig_index = builder.addType(kSig_i_ii); + let mul = builder.addFunction("mul", sig_index) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Mul // -- + ]); + let add = builder.addFunction("add", sig_index) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Add // -- + ]); + let sub = builder.addFunction("sub", sig_index) + .addBody([ + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprI32Sub // -- + ]); + return {mul: mul, add: add, sub: sub}; +} + +function js_div(a, b) { return (a / b) | 0; } + +(function ExportedTableTest() { + print("ExportedTableTest..."); + + let builder = new WasmModuleBuilder(); + + let d = builder.addImport("js_div", kSig_i_ii); + let f = AddFunctions(builder); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + f.add.exportAs("blarg"); + + builder.setFunctionTableLength(10); + let g = builder.addImportedGlobal("base", undefined, kAstI32); + builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, + f.sub.index, + d]); + builder.addExportOfKind("table", kExternalTable, 0); + + let module = new WebAssembly.Module(builder.toBuffer()); + + for (let i = 0; i < 5; i++) { + print(" base = " + i); + let instance = new WebAssembly.Instance(module, {base: i, js_div: js_div}); + main = instance.exports.main; + let table = instance.exports.table; + assertTrue(table instanceof WebAssembly.Table); + assertEquals(10, table.length); + for (let j = 0; j < i; j++) { + assertSame(null, table.get(j)); + } + let mul = table.get(i+0); + let add = table.get(i+1); + let sub = table.get(i+2); + + print(" mul=" + mul); + print(" add=" + add); + print(" sub=" + sub); + assertEquals("function", typeof mul); + assertEquals("function", typeof add); + assertEquals("function", typeof sub); + assertEquals(2, mul.length); + assertEquals(2, add.length); + assertEquals(2, sub.length); + assertEquals("blarg", add.name); + + let exp_div = table.get(i+3); + assertEquals("function", typeof exp_div); + print(" js_div=" + exp_div); + // Should have a new, wrapped version of the import. + assertFalse(js_div == exp_div); + + + for (let j = i + 4; j < 10; j++) { + assertSame(null, table.get(j)); + } + + assertEquals(-33, mul(-11, 3)); + assertEquals(4444444, add(3333333, 1111111)); + assertEquals(-9999, sub(1, 10000)); + assertEquals(-44, exp_div(-88.1, 2)); + } +})(); + + +(function ImportedTableTest() { + let kTableSize = 10; + print("ImportedTableTest..."); + var builder = new WasmModuleBuilder(); + + let d = builder.addImport("js_div", kSig_i_ii); + let f = AddFunctions(builder); + builder.setFunctionTableLength(kTableSize); + let g = builder.addImportedGlobal("base", undefined, kAstI32); + builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, + f.sub.index, + d]); + builder.addExportOfKind("table", kExternalTable, 0); + + let m1 = new WebAssembly.Module(builder.toBuffer()); + + var builder = new WasmModuleBuilder(); + + builder.addImportedTable("table", undefined, kTableSize, kTableSize); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + let m2 = new WebAssembly.Module(builder.toBuffer()); + + // Run 5 trials at different table bases. + for (let i = 0; i < 5; i++) { + print(" base = " + i); + let i1 = new WebAssembly.Instance(m1, {base: i, js_div: js_div}); + let table = i1.exports.table; + assertEquals(10, table.length); + let i2 = new WebAssembly.Instance(m2, {table: table}); + let main = i2.exports.main; + + for (var j = 0; j < i; j++) { + assertThrows(() => main(0, j)); + assertSame(null, table.get(j)); + } + + // mul + assertEquals("function", typeof table.get(i+0)); + assertEquals(0, main(0, i+0)); + assertEquals(66, main(2, i+0)); + + // add + assertEquals("function", typeof table.get(i+1)); + assertEquals(33, main(0, i+1)); + assertEquals(38, main(5, i+1)); + + // sub + assertEquals("function", typeof table.get(i+2)); + assertEquals(32, main(1, i+2)); + assertEquals(28, main(5, i+2)); + + // div + assertEquals("function", typeof table.get(i+3)); + assertEquals(8, main(4, i+3)); + assertEquals(3, main(11, i+3)); + + for (var j = i + 4; j < (kTableSize + 5); j++) { + assertThrows(x => main(0, j)); + if (j < kTableSize) assertSame(null, table.get(j)); + } + } +})(); + +(function ImportedTableTest() { + let kTableSize = 10; + print("ManualTableTest..."); + + var builder = new WasmModuleBuilder(); + + let d = builder.addImport("js_div", kSig_i_ii); + builder.addImportedTable("table", undefined, kTableSize, kTableSize); + let g = builder.addImportedGlobal("base", undefined, kAstI32); + let f = AddFunctions(builder); + builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, + f.sub.index, + d]); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 55, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + let m2 = new WebAssembly.Module(builder.toBuffer()); + + // Run 5 trials at different table bases. + for (let i = 0; i < 5; i++) { + print(" base = " + i); + let table = new WebAssembly.Table({element: "anyfunc", + initial: kTableSize}); + assertEquals(10, table.length); + let i2 = new WebAssembly.Instance(m2, {base: i, table: table, + js_div: js_div}); + let main = i2.exports.main; + + for (var j = 0; j < i; j++) { + assertThrows(() => main(0, j)); + assertSame(null, table.get(j)); + } + + // mul + assertEquals("function", typeof table.get(i+0)); + assertEquals(0, main(0, i+0)); + assertEquals(110, main(2, i+0)); + + // add + assertEquals("function", typeof table.get(i+1)); + assertEquals(55, main(0, i+1)); + assertEquals(60, main(5, i+1)); + + // sub + assertEquals("function", typeof table.get(i+2)); + assertEquals(54, main(1, i+2)); + assertEquals(50, main(5, i+2)); + + // div + assertEquals("function", typeof table.get(i+3)); + assertEquals(13, main(4, i+3)); + assertEquals(5, main(11, i+3)); + + for (var j = i + 4; j < (kTableSize + 5); j++) { + assertThrows(x => main(0, j)); + if (j < kTableSize) assertSame(null, table.get(j)); + } + } +})(); + + +(function CumulativeTest() { + print("CumulativeTest..."); + + let kTableSize = 10; + let table = new WebAssembly.Table({element: "anyfunc", initial: 10}); + + var builder = new WasmModuleBuilder(); + + builder.addImportedTable("table", undefined, kTableSize, kTableSize); + let g = builder.addImportedGlobal("base", undefined, kAstI32); + let sig_index = builder.addType(kSig_i_v); + builder.addFunction("g", sig_index) + .addBody([ + kExprGetGlobal, g + ]); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, + kExprCallIndirect, sig_index, kTableZero]) // -- + .exportAs("main"); + builder.addFunctionTableInit(g, true, [g]); + + let module = new WebAssembly.Module(builder.toBuffer()); + + for (var i = 0; i < kTableSize; i++) { + print(" base = " + i); + let instance = new WebAssembly.Instance(module, {base: i, table: table}); + + for (var j = 0; j < kTableSize; j++) { + let func = table.get(j); + if (j > i) { + assertSame(null, func); + assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(j)); + } else { + assertEquals("function", typeof func); + assertEquals(j, func()); + assertEquals(j, instance.exports.main(j)); + } + } + } +})(); + +(function TwoWayTest() { + print("TwoWayTest..."); + let kTableSize = 3; + + // Module {m1} defines the table and exports it. + var builder = new WasmModuleBuilder(); + builder.addType(kSig_i_i); + builder.addType(kSig_i_ii); + var sig_index1 = builder.addType(kSig_i_v); + var f1 = builder.addFunction("f1", sig_index1) + .addBody([kExprI32Const, 11]); + + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_index1, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableLength(kTableSize); + builder.addFunctionTableInit(0, false, [f1.index]); + builder.addExportOfKind("table", kExternalTable, 0); + + var m1 = new WebAssembly.Module(builder.toBuffer()); + + // Module {m2} imports the table and adds {f2}. + var builder = new WasmModuleBuilder(); + builder.addType(kSig_i_ii); + var sig_index2 = builder.addType(kSig_i_v); + var f2 = builder.addFunction("f2", sig_index2) + .addBody([kExprI32Const, 22]); + + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_index2, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableLength(kTableSize); + builder.addFunctionTableInit(1, false, [f2.index]); + builder.addImportedTable("table", undefined, kTableSize, kTableSize); + + var m2 = new WebAssembly.Module(builder.toBuffer()); + + assertFalse(sig_index1 == sig_index2); + + var i1 = new WebAssembly.Instance(m1); + var i2 = new WebAssembly.Instance(m2, {table: i1.exports.table}); + + assertEquals(11, i1.exports.main(0)); + assertEquals(11, i2.exports.main(0)); + + assertEquals(22, i1.exports.main(1)); + assertEquals(22, i2.exports.main(1)); + + assertThrows(() => i1.exports.main(2)); + assertThrows(() => i2.exports.main(2)); + assertThrows(() => i1.exports.main(3)); + assertThrows(() => i2.exports.main(3)); + +})(); + +(function MismatchedTableSize() { + print("MismatchedTableSize..."); + let kTableSize = 5; + + for (var expsize = 1; expsize < 4; expsize++) { + for (var impsize = 1; impsize < 4; impsize++) { + print(" expsize = " + expsize + ", impsize = " + impsize); + var builder = new WasmModuleBuilder(); + builder.setFunctionTableLength(expsize); + builder.addExportOfKind("expfoo", kExternalTable, 0); + + let m1 = new WebAssembly.Module(builder.toBuffer()); + + var builder = new WasmModuleBuilder(); + builder.addImportedTable("impfoo", undefined, impsize, impsize); + + let m2 = new WebAssembly.Module(builder.toBuffer()); + + var i1 = new WebAssembly.Instance(m1); + + // TODO(titzer): v8 currently requires import table size to match + // export table size. + var ffi = {impfoo: i1.exports.expfoo}; + if (expsize == impsize) { + var i2 = new WebAssembly.Instance(m2, ffi); + } else { + assertThrows(() => new WebAssembly.Instance(m2, ffi)); + } + } + } + + + +})(); diff --git a/deps/v8/test/mjsunit/wasm/instance-gc.js b/deps/v8/test/mjsunit/wasm/instance-gc.js index 1713f27b99..e5dd4edaf9 100644 --- a/deps/v8/test/mjsunit/wasm/instance-gc.js +++ b/deps/v8/test/mjsunit/wasm/instance-gc.js @@ -12,7 +12,7 @@ let nogc = () => {}; function newModule() { let builder = new WasmModuleBuilder(); builder.addMemory(1, 1, true); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0]) .exportFunc(); diff --git a/deps/v8/test/mjsunit/wasm/instantiate-module-basic.js b/deps/v8/test/mjsunit/wasm/instantiate-module-basic.js index a0c11bdadd..36f7429d96 100644 --- a/deps/v8/test/mjsunit/wasm/instantiate-module-basic.js +++ b/deps/v8/test/mjsunit/wasm/instantiate-module-basic.js @@ -12,7 +12,7 @@ let kReturnValue = 117; let buffer = (() => { let builder = new WasmModuleBuilder(); builder.addMemory(1, 1, true); - builder.addFunction("main", kSig_i) + builder.addFunction("main", kSig_i_v) .addBody([kExprI8Const, kReturnValue]) .exportFunc(); @@ -52,9 +52,6 @@ function CheckInstance(instance) { assertEquals(kReturnValue, main()); } -// Deprecated experimental API. -CheckInstance(Wasm.instantiateModule(buffer)); - // Official API let module = new WebAssembly.Module(buffer); CheckInstance(new WebAssembly.Instance(module)); @@ -119,7 +116,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); builder.addMemory(1,1, true); var kSig_v_i = makeSig([kAstI32], []); var signature = builder.addType(kSig_v_i); - builder.addImport("some_value", kSig_i); + builder.addImport("some_value", kSig_i_v); builder.addImport("writer", signature); builder.addFunction("main", kSig_i_i) @@ -127,7 +124,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); kExprGetLocal, 0, kExprI32LoadMem, 0, 0, kExprI32Const, 1, - kExprCallIndirect, signature, + kExprCallIndirect, signature, kTableZero, kExprGetLocal,0, kExprI32LoadMem,0, 0, kExprCallFunction, 0, @@ -144,10 +141,10 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); var module = new WebAssembly.Module(builder.toBuffer()); - var mem_1 = new ArrayBuffer(4); - var mem_2 = new ArrayBuffer(4); - var view_1 = new Int32Array(mem_1); - var view_2 = new Int32Array(mem_2); + var mem_1 = new WebAssembly.Memory({initial: 1}); + var mem_2 = new WebAssembly.Memory({initial: 1}); + var view_1 = new Int32Array(mem_1.buffer); + var view_2 = new Int32Array(mem_2.buffer); view_1[0] = 42; view_2[0] = 1000; @@ -169,7 +166,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); (function GlobalsArePrivateToTheInstance() { print("GlobalsArePrivateToTheInstance..."); var builder = new WasmModuleBuilder(); - builder.addGlobal(kAstI32); + builder.addGlobal(kAstI32, true); builder.addFunction("read", kSig_i_v) .addBody([ kExprGetGlobal, 0]) @@ -196,16 +193,16 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); var builder = new WasmModuleBuilder(); builder.addMemory(1,1, true); - builder.addFunction("f", kSig_i) + builder.addFunction("f", kSig_i_v) .addBody([ kExprI32Const, 0, kExprI32LoadMem, 0, 0 ]).exportFunc(); - var mem_1 = new ArrayBuffer(65536); - var mem_2 = new ArrayBuffer(65536); - var view_1 = new Int32Array(mem_1); - var view_2 = new Int32Array(mem_2); + var mem_1 = new WebAssembly.Memory({initial: 1}); + var mem_2 = new WebAssembly.Memory({initial: 1}); + var view_1 = new Int32Array(mem_1.buffer); + var view_2 = new Int32Array(mem_2.buffer); view_1[0] = 1; view_2[0] = 1000; @@ -216,3 +213,9 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); assertEquals(1, i1.exports.f()); assertEquals(1000, i2.exports.f()); })(); + +(function MustBeMemory() { + var memory = new ArrayBuffer(65536); + var module = new WebAssembly.Module(buffer); + assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError); +})(); diff --git a/deps/v8/test/mjsunit/wasm/memory-size.js b/deps/v8/test/mjsunit/wasm/memory-size.js index 197059eb49..bd747176a8 100644 --- a/deps/v8/test/mjsunit/wasm/memory-size.js +++ b/deps/v8/test/mjsunit/wasm/memory-size.js @@ -11,7 +11,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); print("testMemorySizeZero()"); var builder = new WasmModuleBuilder(); builder.addFunction("memory_size", kSig_i_v) - .addBody([kExprMemorySize]) + .addBody([kExprMemorySize, kMemoryZero]) .exportFunc(); var module = builder.instantiate(); assertEquals(0, module.exports.memory_size()); @@ -23,7 +23,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var size = 11; builder.addMemory(size, size, false); builder.addFunction("memory_size", kSig_i_v) - .addBody([kExprMemorySize]) + .addBody([kExprMemorySize, kMemoryZero]) .exportFunc(); var module = builder.instantiate(); assertEquals(size, module.exports.memory_size()); diff --git a/deps/v8/test/mjsunit/wasm/module-memory.js b/deps/v8/test/mjsunit/wasm/module-memory.js index 6707f08164..8c57ca00d5 100644 --- a/deps/v8/test/mjsunit/wasm/module-memory.js +++ b/deps/v8/test/mjsunit/wasm/module-memory.js @@ -38,11 +38,12 @@ function genModule(memory) { .exportFunc(); var module = builder.instantiate(null, memory); assertTrue(module.exports.memory instanceof WebAssembly.Memory); - if (memory != null) assertEquals(memory, module.exports.memory.buffer); + if (memory != null) assertEquals(memory.buffer, module.exports.memory.buffer); return module; } function testPokeMemory() { + print("testPokeMemory"); var module = genModule(null); var buffer = module.exports.memory.buffer; var main = module.exports.main; @@ -89,12 +90,13 @@ testSurvivalAcrossGc(); function testPokeOuterMemory() { - var buffer = new ArrayBuffer(kMemSize); + print("testPokeOuterMemory"); + var buffer = new WebAssembly.Memory({initial: kMemSize / kPageSize}); var module = genModule(buffer); var main = module.exports.main; - assertEquals(kMemSize, buffer.byteLength); + assertEquals(kMemSize, buffer.buffer.byteLength); - var array = new Int8Array(buffer); + var array = new Int8Array(buffer.buffer); assertEquals(kMemSize, array.length); for (var i = 0; i < kMemSize; i++) { @@ -116,7 +118,7 @@ function testPokeOuterMemory() { testPokeOuterMemory(); function testOuterMemorySurvivalAcrossGc() { - var buffer = new ArrayBuffer(kMemSize); + var buffer = new WebAssembly.Memory({initial: kMemSize / kPageSize}); var checker = genAndGetMain(buffer); for (var i = 0; i < 3; i++) { print("gc run ", i); diff --git a/deps/v8/test/mjsunit/wasm/stack.js b/deps/v8/test/mjsunit/wasm/stack.js index 71038507db..d7c399dc03 100644 --- a/deps/v8/test/mjsunit/wasm/stack.js +++ b/deps/v8/test/mjsunit/wasm/stack.js @@ -135,7 +135,7 @@ Error.prepareStackTrace = function(error, frames) { builder.addFunction("recursion", sig_index) .addBody([ kExprI32Const, 0, - kExprCallIndirect, sig_index + kExprCallIndirect, sig_index, kTableZero ]) .exportFunc() builder.appendToTable([0]); diff --git a/deps/v8/test/mjsunit/wasm/start-function.js b/deps/v8/test/mjsunit/wasm/start-function.js index f0fbd081ac..da1c7c37c4 100644 --- a/deps/v8/test/mjsunit/wasm/start-function.js +++ b/deps/v8/test/mjsunit/wasm/start-function.js @@ -18,16 +18,6 @@ function instantiate(sig, body) { return builder.instantiate(); } -function assertFails(sig, body) { - try { - var module = instantiate(sig, body); - print("expected failure, but passes"); - assertFalse(true); - } catch (expected) { - print("ok: " + expected); - } -} - function assertVerifies(sig, body) { var module = instantiate(sig, body); assertFalse(module === undefined); @@ -38,12 +28,12 @@ function assertVerifies(sig, body) { } assertVerifies(kSig_v_v, [kExprNop]); -assertVerifies(kSig_i, [kExprI8Const, 0]); // Arguments aren't allow to start functions. -assertFails(kSig_i_i, [kExprGetLocal, 0]); -assertFails(kSig_i_ii, [kExprGetLocal, 0]); -assertFails(kSig_i_dd, [kExprGetLocal, 0]); +assertThrows(() => {instantiate(kSig_i_i, [kExprGetLocal, 0]);}); +assertThrows(() => {instantiate(kSig_i_ii, [kExprGetLocal, 0]);}); +assertThrows(() => {instantiate(kSig_i_dd, [kExprGetLocal, 0]);}); +assertThrows(() => {instantiate(kSig_i_v, [kExprI8Const, 0]);}); (function testInvalidIndex() { print("testInvalidIndex"); @@ -72,14 +62,31 @@ assertFails(kSig_i_dd, [kExprGetLocal, 0]); })(); -(function testRun() { - print("testRun"); +(function testRun1() { + print("testRun1"); + var builder = new WasmModuleBuilder(); + + builder.addMemory(12, 12, true); + + var func = builder.addFunction("", kSig_v_v) + .addBody([kExprI8Const, 0, kExprI8Const, 66, kExprI32StoreMem, 0, 0]); + + builder.addStart(func.index); + + var module = builder.instantiate(); + var memory = module.exports.memory.buffer; + var view = new Int8Array(memory); + assertEquals(66, view[0]); +})(); + +(function testRun2() { + print("testRun2"); var builder = new WasmModuleBuilder(); builder.addMemory(12, 12, true); var func = builder.addFunction("", kSig_v_v) - .addBody([kExprI8Const, 0, kExprI8Const, 77, kExprI32StoreMem, 0, 0]); + .addBody([kExprI8Const, 0, kExprI8Const, 22, kExprI8Const, 55, kExprI32Add, kExprI32StoreMem, 0, 0]); builder.addStart(func.index); diff --git a/deps/v8/test/mjsunit/wasm/table.js b/deps/v8/test/mjsunit/wasm/table.js index 0275bc0522..1abc29664e 100644 --- a/deps/v8/test/mjsunit/wasm/table.js +++ b/deps/v8/test/mjsunit/wasm/table.js @@ -4,6 +4,11 @@ // Flags: --expose-wasm +'use strict'; + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + // Basic tests. var outOfUint32RangeValue = 1e12; @@ -45,25 +50,46 @@ function assertTableIsValid(table) { assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: int32ButOob})); - let table = new WebAssembly.Table({element: "anyfunc", initial: 1}); + let table; + table = new WebAssembly.Table({element: "anyfunc", initial: 1}); assertTableIsValid(table); -})(); + assertEquals(1, table.length); + assertEquals(null, table.get(0)); -(function TestConstructorWithMaximum() { - let table = new WebAssembly.Table({element: "anyfunc", maximum: 10}); + table = new WebAssembly.Table({element: "anyfunc", initial: "2"}); assertTableIsValid(table); -})(); + assertEquals(2, table.length); + assertEquals(null, table.get(0)); + assertEquals(null, table.get(1)); -(function TestInitialIsUndefined() { - // New memory with initial = undefined, which means initial = 0. - let table = new WebAssembly.Table({element: "anyfunc", initial: undefined}); + table = new WebAssembly.Table({element: "anyfunc", initial: {valueOf() { return "1" }}}); assertTableIsValid(table); -})(); + assertEquals(1, table.length); + assertEquals(null, table.get(0)); + + table = new WebAssembly.Table({element: "anyfunc", initial: undefined}); + assertTableIsValid(table); + assertEquals(0, table.length); + + table = new WebAssembly.Table({element: "anyfunc"}); + assertTableIsValid(table); + assertEquals(0, table.length); -(function TestMaximumIsUndefined() { - // New memory with maximum = undefined, which means maximum = 0. - let table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: undefined}); + table = new WebAssembly.Table({element: "anyfunc", maximum: 10}); assertTableIsValid(table); + assertEquals(0, table.length); + + table = new WebAssembly.Table({element: "anyfunc", maximum: "10"}); + assertTableIsValid(table); + assertEquals(0, table.length); + + table = new WebAssembly.Table({element: "anyfunc", maximum: {valueOf() { return "10" }}}); + assertTableIsValid(table); + assertEquals(0, table.length); + + table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: undefined}); + assertTableIsValid(table); + assertEquals(0, table.length); })(); (function TestMaximumIsReadOnce() { @@ -93,3 +119,114 @@ function assertTableIsValid(table) { let table = new WebAssembly.Table(desc); assertTableIsValid(table); })(); + +(function TestLength() { + for (let i = 0; i < 10; ++i) { + let table = new WebAssembly.Table({element: "anyfunc", initial: i}); + assertEquals(i, table.length); + } + + assertThrows(() => WebAssembly.Table.prototype.length.call([]), TypeError); +})(); + +(function TestGet() { + let table = new WebAssembly.Table({element: "anyfunc", initial: 10}); + + for (let i = 0; i < table.length; ++i) { + assertEquals(null, table.get(i)); + assertEquals(null, table.get(String(i))); + } + for (let key of [0.4, "", NaN, {}, [], () => {}]) { + assertEquals(null, table.get(key)); + } + for (let key of [-1, table.length, table.length * 10]) { + assertThrows(() => table.get(key), RangeError); + } + assertThrows(() => table.get(Symbol()), TypeError); + assertThrows(() => WebAssembly.Table.prototype.get.call([], 0), TypeError); +})(); + +(function TestSet() { + let builder = new WasmModuleBuilder; + builder.addExport("wasm", builder.addFunction("", kSig_v_v)); + builder.addExport("host", builder.addImportWithModule("test", "f", kSig_v_v)); + let {wasm, host} = builder.instantiate({test: {f() {}}}).exports; + + let table = new WebAssembly.Table({element: "anyfunc", initial: 10}); + + for (let f of [wasm, host]) { + for (let i = 0; i < table.length; ++i) table.set(i, null); + for (let i = 0; i < table.length; ++i) { + assertSame(null, table.get(i)); + assertSame(undefined, table.set(i, f)); + assertSame(f, table.get(i)); + } + + for (let i = 0; i < table.length; ++i) table.set(i, null); + for (let i = 0; i < table.length; ++i) { + assertSame(null, table.get(i)); + assertSame(undefined, table.set(String(i), f)); + assertSame(f, table.get(i)); + } + + for (let key of [0.4, "", NaN, {}, [], () => {}]) { + assertSame(undefined, table.set(0, null)); + assertSame(undefined, table.set(key, f)); + assertSame(f, table.get(0)); + } + + for (let key of [-1, table.length, table.length * 10]) { + assertThrows(() => table.set(key, f), RangeError); + } + + assertThrows(() => table.set(0), TypeError); + for (let val of [undefined, 0, "", {}, [], () => {}]) { + assertThrows(() => table.set(0, val), TypeError); + } + + assertThrows(() => table.set(Symbol(), f), TypeError); + assertThrows(() => WebAssembly.Table.prototype.set.call([], 0, f), + TypeError); + } +})(); + +(function TestGrow() { + let builder = new WasmModuleBuilder; + builder.addExport("wasm", builder.addFunction("", kSig_v_v)); + builder.addExport("host", builder.addImportWithModule("test", "f", kSig_v_v)); + let {wasm, host} = builder.instantiate({test: {f() {}}}).exports; + + function init(table) { + for (let i = 0; i < 5; ++i) table.set(i, wasm); + for (let i = 15; i < 20; ++i) table.set(i, host); + } + function check(table) { + for (let i = 0; i < 5; ++i) assertSame(wasm, table.get(i)); + for (let i = 6; i < 15; ++i) assertSame(null, table.get(i)); + for (let i = 15; i < 20; ++i) assertSame(host, table.get(i)); + for (let i = 21; i < table.length; ++i) assertSame(null, table.get(i)); + } + + let table = new WebAssembly.Table({element: "anyfunc", initial: 20}); + init(table); + check(table); + table.grow(0); + check(table); + table.grow(10); + check(table); + assertThrows(() => table.grow(-10), RangeError); + + table = new WebAssembly.Table({element: "anyfunc", initial: 20, maximum: 25}); + init(table); + check(table); + table.grow(0); + check(table); + table.grow(5); + check(table); + table.grow(0); + check(table); + assertThrows(() => table.grow(1), RangeError); + assertThrows(() => table.grow(-10), RangeError); + + assertThrows(() => WebAssembly.Table.prototype.grow.call([], 0), TypeError); +})(); diff --git a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js b/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js index df03aec9f5..e84881667d 100644 --- a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js +++ b/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js @@ -66,11 +66,71 @@ var expect_no_elison = 1; assertEquals(%CheckWasmWrapperElision(the_export, expect_elison), true); })(); +// Function calls stack: first_export -> first_func -> first_import -> +// second_export -> second_import +// In this test, first_import and second_export have the same signature, and +// therefore the wrappers will be removed. If the wrappers are not removed, then +// the test crashes because of the int64 parameter, which is not allowed in the +// wrappers. +(function TestWasmWrapperElisionInt64() { + var imported = function (a) { + return a; + }; + + var second_module = new WasmModuleBuilder(); + var sig_index1 = second_module.addType(kSig_i_i); + var sig_index_ll = second_module.addType(kSig_l_l); + second_module + .addImportWithModule("import_module_2", "import_name_2", sig_index1); + second_module + .addFunction("second_export", sig_index_ll) + .addBody([ + kExprGetLocal, 0, + kExprI32ConvertI64, + kExprCallFunction, 0, + kExprI64SConvertI32, + kExprReturn + ]) + .exportFunc(); + + var first_module = new WasmModuleBuilder(); + var sig_index = first_module.addType(kSig_i_v); + var sig_index_ll = first_module.addType(kSig_l_l); + first_module + .addImportWithModule("import_module_1", "import_name_1", sig_index_ll); + first_module + .addFunction("first_export", sig_index) + .addBody([ + kExprI64Const, 2, + kExprCallFunction, 2, + kExprI32ConvertI64, + kExprReturn + ]) + .exportFunc(); + first_module + .addFunction("first_func", sig_index_ll) + .addBody([ + kExprI64Const, 1, + kExprGetLocal, 0, + kExprI64Add, + kExprCallFunction, 0, + kExprReturn + ]); + + var f = second_module + .instantiate({import_module_2: {import_name_2: imported}}) + .exports.second_export; + var the_export = first_module + .instantiate({import_module_1: {import_name_1: f}}) + .exports.first_export; + assertEquals(the_export(), 3); +})(); + // function calls stack: first_export -> first_func -> first_import -> // second_export -> second_import -// In this case, second_export has less params than first_import, -// So that wrappers will not be removed -(function TestWasmWrapperNoElisionLessParams() { +// In this case, second_export has fewer params than first_import, +// so instantiation should fail. +assertThrows(function TestWasmWrapperNoElisionLessParams() { var imported = function (a) { return a; }; @@ -121,13 +181,13 @@ var expect_no_elison = 1; assertEquals(the_export(0, 2), 0); assertEquals(the_export(9.9, 4.3), 9); assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -})(); +}); // function calls stack: first_export -> first_func -> first_import -> // second_export -> second_import // In this case, second_export has more params than first_import, -// So that wrappers will not be removed -(function TestWasmWrapperNoElisionMoreParams() { +// so instantiation should fail. +assertThrows(function TestWasmWrapperNoElisionMoreParams() { var imported = function (a, b, c) { return a+b+c; }; @@ -180,13 +240,13 @@ var expect_no_elison = 1; assertEquals(the_export(0, 0), 0); assertEquals(the_export(1.1, 2.7), 3); assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -})(); +}); // function calls stack: first_export -> first_func -> first_import -> // second_export -> second_import // In this case, second_export has different params type with first_import, -// So that wrappers will not be removed -(function TestWasmWrapperNoElisionTypeMismatch() { +// so instantiation should fail. +assertThrows(function TestWasmWrapperNoElisionTypeMismatch() { var imported = function (a, b) { return a+b; }; @@ -238,4 +298,4 @@ var expect_no_elison = 1; assertEquals(the_export(0.0, 0.0), 0); assertEquals(the_export(2, -2), 0); assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -})(); +}); diff --git a/deps/v8/test/mjsunit/wasm/test-wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/test-wasm-module-builder.js index b1a2309770..30bbe4ac93 100644 --- a/deps/v8/test/mjsunit/wasm/test-wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/test-wasm-module-builder.js @@ -9,40 +9,44 @@ load('test/mjsunit/wasm/wasm-module-builder.js'); var debug = true; +function instantiate(buffer, ffi) { + return new WebAssembly.Instance(WebAssembly.Module(buffer), ffi); +} + (function BasicTest() { - var module = new WasmModuleBuilder(); - module.addMemory(1, 2, false); - module.addFunction("foo", kSig_i) + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 2, false); + builder.addFunction("foo", kSig_i_v) .addBody([kExprI8Const, 11]) .exportAs("blarg"); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer); assertEquals(11, instance.exports.blarg()); })(); (function ImportTest() { - var module = new WasmModuleBuilder(); - var index = module.addImport("print", makeSig_v_x(kAstI32)); - module.addFunction("foo", kSig_v_v) + let builder = new WasmModuleBuilder(); + var index = builder.addImport("print", makeSig_v_x(kAstI32)); + builder.addFunction("foo", kSig_v_v) .addBody([kExprI8Const, 13, kExprCallFunction, index]) .exportAs("main"); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer, {print: print}); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer, {print: print}); print("should print 13! "); instance.exports.main(); })(); (function LocalsTest() { - var module = new WasmModuleBuilder(); - module.addFunction(undefined, kSig_i_i) + let builder = new WasmModuleBuilder(); + builder.addFunction(undefined, kSig_i_i) .addLocals({i32_count: 1}) .addBody([kExprGetLocal, 0, kExprSetLocal, 1, kExprGetLocal, 1]) .exportAs("main"); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer); assertEquals(19, instance.exports.main(19)); assertEquals(27777, instance.exports.main(27777)); })(); @@ -57,72 +61,72 @@ var debug = true; ]; for (p of types) { - var module = new WasmModuleBuilder(); - module.addFunction(undefined, makeSig_r_x(p.type, p.type)) + let builder = new WasmModuleBuilder(); + builder.addFunction(undefined, makeSig_r_x(p.type, p.type)) .addLocals(p.locals) .addBody([kExprGetLocal, 0, kExprSetLocal, 1, kExprGetLocal, 1]) .exportAs("main"); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer); assertEquals(19, instance.exports.main(19)); assertEquals(27777, instance.exports.main(27777)); } })(); (function CallTest() { - var module = new WasmModuleBuilder(); - module.addFunction("add", kSig_i_ii) + let builder = new WasmModuleBuilder(); + builder.addFunction("add", kSig_i_ii) .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add]); - module.addFunction("main", kSig_i_ii) + builder.addFunction("main", kSig_i_ii) .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprCallFunction, 0]) .exportAs("main"); - var instance = module.instantiate(); + var instance = builder.instantiate(); assertEquals(44, instance.exports.main(11, 33)); assertEquals(7777, instance.exports.main(2222, 5555)); })(); (function IndirectCallTest() { - var module = new WasmModuleBuilder(); - module.addFunction("add", kSig_i_ii) + let builder = new WasmModuleBuilder(); + builder.addFunction("add", kSig_i_ii) .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add]); - module.addFunction("main", kSig_i_iii) + builder.addFunction("main", kSig_i_iii) .addBody([kExprGetLocal, - 1, kExprGetLocal, 2, kExprGetLocal, 0, kExprCallIndirect, 0]) + 1, kExprGetLocal, 2, kExprGetLocal, 0, kExprCallIndirect, 0, kTableZero]) .exportAs("main"); - module.appendToTable([0]); + builder.appendToTable([0]); - var instance = module.instantiate(); + var instance = builder.instantiate(); assertEquals(44, instance.exports.main(0, 11, 33)); assertEquals(7777, instance.exports.main(0, 2222, 5555)); assertThrows(function() { instance.exports.main(1, 1, 1); }); })(); (function DataSegmentTest() { - var module = new WasmModuleBuilder(); - module.addMemory(1, 1, false); - module.addFunction("load", kSig_i_i) + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 1, false); + builder.addFunction("load", kSig_i_i) .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) .exportAs("load"); - module.addDataSegment(0, [9, 9, 9, 9], true); + builder.addDataSegment(0, [9, 9, 9, 9]); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer); assertEquals(151587081, instance.exports.load(0)); })(); (function BasicTestWithUint8Array() { - var module = new WasmModuleBuilder(); - module.addMemory(1, 2, false); - module.addFunction("foo", kSig_i) + let builder = new WasmModuleBuilder(); + builder.addMemory(1, 2, false); + builder.addFunction("foo", kSig_i_v) .addBody([kExprI8Const, 17]) .exportAs("blarg"); - var buffer = module.toBuffer(debug); + var buffer = builder.toBuffer(debug); var array = new Uint8Array(buffer); - var instance = Wasm.instantiateModule(array); + var instance = instantiate(array); assertEquals(17, instance.exports.blarg()); var kPad = 5; @@ -135,19 +139,19 @@ var debug = true; for (var i = 0; i < array2.byteLength; i++) { array2[i] = array[i]; } - var instance = Wasm.instantiateModule(array2); + var instance = instantiate(array2); assertEquals(17, instance.exports.blarg()); })(); (function ImportTestTwoLevel() { - var module = new WasmModuleBuilder(); - var index = module.addImportWithModule("mod", "print", makeSig_v_x(kAstI32)); - module.addFunction("foo", kSig_v_v) + let builder = new WasmModuleBuilder(); + var index = builder.addImportWithModule("mod", "print", makeSig_v_x(kAstI32)); + builder.addFunction("foo", kSig_v_v) .addBody([kExprI8Const, 19, kExprCallFunction, index]) .exportAs("main"); - var buffer = module.toBuffer(debug); - var instance = Wasm.instantiateModule(buffer, {mod: {print: print}}); + var buffer = builder.toBuffer(debug); + var instance = instantiate(buffer, {mod: {print: print}}); print("should print 19! "); instance.exports.main(); })(); diff --git a/deps/v8/test/mjsunit/wasm/trap-location.js b/deps/v8/test/mjsunit/wasm/trap-location.js index bc8214f9b2..5e14584224 100644 --- a/deps/v8/test/mjsunit/wasm/trap-location.js +++ b/deps/v8/test/mjsunit/wasm/trap-location.js @@ -52,10 +52,11 @@ builder.addFunction("main", kSig_i_i) kExprEnd, // offset 30 kExprGetLocal, 0, - kExprCallIndirect, sig_index, + kExprCallIndirect, sig_index, kTableZero, kExprEnd, ]) .exportAs("main"); +builder.appendToTable([0]); var module = builder.instantiate(); diff --git a/deps/v8/test/mjsunit/wasm/verify-function-basic-errors.js b/deps/v8/test/mjsunit/wasm/verify-function-basic-errors.js deleted file mode 100644 index 74c9a96d68..0000000000 --- a/deps/v8/test/mjsunit/wasm/verify-function-basic-errors.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-wasm - -function Foo() { } - -assertThrows(function() { Wasm.verifyFunction(); }) -assertThrows(function() { Wasm.verifyFunction(0); }) -assertThrows(function() { Wasm.verifyFunction("s"); }) -assertThrows(function() { Wasm.verifyFunction(undefined); }) -assertThrows(function() { Wasm.verifyFunction(1.1); }) -assertThrows(function() { Wasm.verifyFunction(1/0); }) -assertThrows(function() { Wasm.verifyFunction(null); }) -assertThrows(function() { Wasm.verifyFunction(new Foo()); }) -assertThrows(function() { Wasm.verifyFunction(new ArrayBuffer(0)); }) -assertThrows(function() { Wasm.verifyFunction(new ArrayBuffer(140000)); }) diff --git a/deps/v8/test/mjsunit/wasm/verify-function-simple.js b/deps/v8/test/mjsunit/wasm/verify-function-simple.js deleted file mode 100644 index 1ac25143d7..0000000000 --- a/deps/v8/test/mjsunit/wasm/verify-function-simple.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-wasm - -load("test/mjsunit/wasm/wasm-constants.js"); - -try { - var data = bytes( - kWasmFunctionTypeForm, 0, kAstStmt, // signature - kDeclNoLocals, // -- - kExprNop // body - ); - - Wasm.verifyFunction(data); - print("ok"); -} catch (e) { - assertTrue(false); -} - - -var threw = false; -try { - var data = bytes( - kWasmFunctionTypeForm, 0, 1, kAstI32, // signature - kDeclNoLocals, // -- - kExprBlock, kAstStmt, kExprNop, kExprNop, kExprEnd // body - ); - - Wasm.verifyFunction(data); - print("not ok"); -} catch (e) { - print("ok: " + e); - threw = true; -} - -assertTrue(threw); diff --git a/deps/v8/test/mjsunit/wasm/verify-module-basic-errors.js b/deps/v8/test/mjsunit/wasm/verify-module-basic-errors.js index 29ef2aa611..c289dea105 100644 --- a/deps/v8/test/mjsunit/wasm/verify-module-basic-errors.js +++ b/deps/v8/test/mjsunit/wasm/verify-module-basic-errors.js @@ -6,13 +6,13 @@ function Foo() { } -assertThrows(function() { Wasm.verifyModule(); }) -assertThrows(function() { Wasm.verifyModule(0); }) -assertThrows(function() { Wasm.verifyModule("s"); }) -assertThrows(function() { Wasm.verifyModule(undefined); }) -assertThrows(function() { Wasm.verifyModule(1.1); }) -assertThrows(function() { Wasm.verifyModule(1/0); }) -assertThrows(function() { Wasm.verifyModule(null); }) -assertThrows(function() { Wasm.verifyModule(new Foo()); }) -assertThrows(function() { Wasm.verifyModule(new ArrayBuffer(0)); }) -assertThrows(function() { Wasm.verifyModule(new ArrayBuffer(7)); }) +assertThrows(function() { new WebAssembly.Module(); }) +assertThrows(function() { new WebAssembly.Module(0); }) +assertThrows(function() { new WebAssembly.Module("s"); }) +assertThrows(function() { new WebAssembly.Module(undefined); }) +assertThrows(function() { new WebAssembly.Module(1.1); }) +assertThrows(function() { new WebAssembly.Module(1/0); }) +assertThrows(function() { new WebAssembly.Module(null); }) +assertThrows(function() { new WebAssembly.Module(new Foo()); }) +assertThrows(function() { new WebAssembly.Module(new ArrayBuffer(0)); }) +assertThrows(function() { new WebAssembly.Module(new ArrayBuffer(7)); }) diff --git a/deps/v8/test/mjsunit/wasm/wasm-constants.js b/deps/v8/test/mjsunit/wasm/wasm-constants.js index 388e5f5015..a064d55aaf 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-constants.js +++ b/deps/v8/test/mjsunit/wasm/wasm-constants.js @@ -21,7 +21,7 @@ var kWasmH1 = 0x61; var kWasmH2 = 0x73; var kWasmH3 = 0x6d; -var kWasmV0 = 0xC; +var kWasmV0 = 0xD; var kWasmV1 = 0; var kWasmV2 = 0; var kWasmV3 = 0; @@ -48,64 +48,72 @@ function bytesWithHeader() { return buffer; } -var kDeclNoLocals = 0; +let kDeclNoLocals = 0; // Section declaration constants -var kUnknownSectionCode = 0; -var kTypeSectionCode = 1; // Function signature declarations -var kImportSectionCode = 2; // Import declarations -var kFunctionSectionCode = 3; // Function declarations -var kTableSectionCode = 4; // Indirect function table and other tables -var kMemorySectionCode = 5; // Memory attributes -var kGlobalSectionCode = 6; // Global declarations -var kExportSectionCode = 7; // Exports -var kStartSectionCode = 8; // Start function declaration -var kElementSectionCode = 9; // Elements section -var kCodeSectionCode = 10; // Function code -var kDataSectionCode = 11; // Data segments -var kNameSectionCode = 12; // Name section (encoded as string) +let kUnknownSectionCode = 0; +let kTypeSectionCode = 1; // Function signature declarations +let kImportSectionCode = 2; // Import declarations +let kFunctionSectionCode = 3; // Function declarations +let kTableSectionCode = 4; // Indirect function table and other tables +let kMemorySectionCode = 5; // Memory attributes +let kGlobalSectionCode = 6; // Global declarations +let kExportSectionCode = 7; // Exports +let kStartSectionCode = 8; // Start function declaration +let kElementSectionCode = 9; // Elements section +let kCodeSectionCode = 10; // Function code +let kDataSectionCode = 11; // Data segments +let kNameSectionCode = 12; // Name section (encoded as string) -var kWasmFunctionTypeForm = 0x40; -var kWasmAnyFunctionTypeForm = 0x20; +let kWasmFunctionTypeForm = 0x60; +let kWasmAnyFunctionTypeForm = 0x70; -var kResizableMaximumFlag = 1; +let kResizableMaximumFlag = 1; // Function declaration flags -var kDeclFunctionName = 0x01; -var kDeclFunctionImport = 0x02; -var kDeclFunctionLocals = 0x04; -var kDeclFunctionExport = 0x08; +let kDeclFunctionName = 0x01; +let kDeclFunctionImport = 0x02; +let kDeclFunctionLocals = 0x04; +let kDeclFunctionExport = 0x08; // Local types -var kAstStmt = 0; -var kAstI32 = 1; -var kAstI64 = 2; -var kAstF32 = 3; -var kAstF64 = 4; +let kAstStmt = 0x40; +let kAstI32 = 0x7f; +let kAstI64 = 0x7e; +let kAstF32 = 0x7d; +let kAstF64 = 0x7c; +let kAstS128 = 0x7b; -var kExternalFunction = 0; -var kExternalTable = 1; -var kExternalMemory = 2; -var kExternalGlobal = 3; +let kExternalFunction = 0; +let kExternalTable = 1; +let kExternalMemory = 2; +let kExternalGlobal = 3; + +let kTableZero = 0; +let kMemoryZero = 0; // Useful signatures -var kSig_i = makeSig([], [kAstI32]); -var kSig_d = makeSig([], [kAstF64]); -var kSig_i_i = makeSig([kAstI32], [kAstI32]); -var kSig_i_l = makeSig([kAstI64], [kAstI32]); -var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); -var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); -var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); -var kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); -var kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); -var kSig_v_v = makeSig([], []); -var kSig_i_v = makeSig([], [kAstI32]); -var kSig_v_i = makeSig([kAstI32], []); -var kSig_v_ii = makeSig([kAstI32, kAstI32], []); -var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); -var kSig_v_d = makeSig([kAstF64], []); -var kSig_v_dd = makeSig([kAstF64, kAstF64], []); -var kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); +let kSig_i_i = makeSig([kAstI32], [kAstI32]); +let kSig_l_l = makeSig([kAstI64], [kAstI64]); +let kSig_i_l = makeSig([kAstI64], [kAstI32]); +let kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); +let kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); +let kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); +let kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]); +let kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]); +let kSig_v_v = makeSig([], []); +let kSig_i_v = makeSig([], [kAstI32]); +let kSig_l_v = makeSig([], [kAstI64]); +let kSig_f_v = makeSig([], [kAstF64]); +let kSig_d_v = makeSig([], [kAstF64]); +let kSig_v_i = makeSig([kAstI32], []); +let kSig_v_ii = makeSig([kAstI32, kAstI32], []); +let kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []); +let kSig_v_l = makeSig([kAstI64], []); +let kSig_v_d = makeSig([kAstF64], []); +let kSig_v_dd = makeSig([kAstF64, kAstF64], []); +let kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []); +let kSig_s_v = makeSig([], [kAstS128]); function makeSig(params, results) { return {params: params, results: results}; @@ -132,198 +140,194 @@ function makeSig_r_xx(r, x) { } // Opcodes -var kExprUnreachable = 0x00; -var kExprNop = 0x0a; -var kExprBlock = 0x01; -var kExprLoop = 0x02; -var kExprIf = 0x03; -var kExprElse = 0x04; -var kExprSelect = 0x05; -var kExprBr = 0x06; -var kExprBrIf = 0x07; -var kExprBrTable = 0x08; -var kExprReturn = 0x09; -var kExprThrow = 0xfa; -var kExprTry = 0xfb; -var kExprCatch = 0xfe; -var kExprEnd = 0x0f; -var kExprTeeLocal = 0x19; -var kExprDrop = 0x0b; - -var kExprI32Const = 0x10; -var kExprI64Const = 0x11; -var kExprF64Const = 0x12; -var kExprF32Const = 0x13; -var kExprGetLocal = 0x14; -var kExprSetLocal = 0x15; -var kExprCallFunction = 0x16; -var kExprCallIndirect = 0x17; -var kExprI8Const = 0xcb; -var kExprGetGlobal = 0xbb; -var kExprSetGlobal = 0xbc; - -var kExprI32LoadMem8S = 0x20; -var kExprI32LoadMem8U = 0x21; -var kExprI32LoadMem16S = 0x22; -var kExprI32LoadMem16U = 0x23; -var kExprI64LoadMem8S = 0x24; -var kExprI64LoadMem8U = 0x25; -var kExprI64LoadMem16S = 0x26; -var kExprI64LoadMem16U = 0x27; -var kExprI64LoadMem32S = 0x28; -var kExprI64LoadMem32U = 0x29; -var kExprI32LoadMem = 0x2a; -var kExprI64LoadMem = 0x2b; -var kExprF32LoadMem = 0x2c; -var kExprF64LoadMem = 0x2d; - -var kExprI32StoreMem8 = 0x2e; -var kExprI32StoreMem16 = 0x2f; -var kExprI64StoreMem8 = 0x30; -var kExprI64StoreMem16 = 0x31; -var kExprI64StoreMem32 = 0x32; -var kExprI32StoreMem = 0x33; -var kExprI64StoreMem = 0x34; -var kExprF32StoreMem = 0x35; -var kExprF64StoreMem = 0x36; - -var kExprMemorySize = 0x3b; -var kExprGrowMemory = 0x39; - -var kExprI32Add = 0x40; -var kExprI32Sub = 0x41; -var kExprI32Mul = 0x42; -var kExprI32DivS = 0x43; -var kExprI32DivU = 0x44; -var kExprI32RemS = 0x45; -var kExprI32RemU = 0x46; -var kExprI32And = 0x47; -var kExprI32Ior = 0x48; -var kExprI32Xor = 0x49; -var kExprI32Shl = 0x4a; -var kExprI32ShrU = 0x4b; -var kExprI32ShrS = 0x4c; -var kExprI32Eq = 0x4d; -var kExprI32Ne = 0x4e; -var kExprI32LtS = 0x4f; -var kExprI32LeS = 0x50; -var kExprI32LtU = 0x51; -var kExprI32LeU = 0x52; -var kExprI32GtS = 0x53; -var kExprI32GeS = 0x54; -var kExprI32GtU = 0x55; -var kExprI32GeU = 0x56; -var kExprI32Clz = 0x57; -var kExprI32Ctz = 0x58; -var kExprI32Popcnt = 0x59; -var kExprI32Eqz = 0x5a; -var kExprI64Add = 0x5b; -var kExprI64Sub = 0x5c; -var kExprI64Mul = 0x5d; -var kExprI64DivS = 0x5e; -var kExprI64DivU = 0x5f; -var kExprI64RemS = 0x60; -var kExprI64RemU = 0x61; -var kExprI64And = 0x62; -var kExprI64Ior = 0x63; -var kExprI64Xor = 0x64; -var kExprI64Shl = 0x65; -var kExprI64ShrU = 0x66; -var kExprI64ShrS = 0x67; -var kExprI64Eq = 0x68; -var kExprI64Ne = 0x69; -var kExprI64LtS = 0x6a; -var kExprI64LeS = 0x6b; -var kExprI64LtU = 0x6c; -var kExprI64LeU = 0x6d; -var kExprI64GtS = 0x6e; -var kExprI64GeS = 0x6f; -var kExprI64GtU = 0x70; -var kExprI64GeU = 0x71; -var kExprI64Clz = 0x72; -var kExprI64Ctz = 0x73; -var kExprI64Popcnt = 0x74; -var kExprF32Add = 0x75; -var kExprF32Sub = 0x76; -var kExprF32Mul = 0x77; -var kExprF32Div = 0x78; -var kExprF32Min = 0x79; -var kExprF32Max = 0x7a; -var kExprF32Abs = 0x7b; -var kExprF32Neg = 0x7c; -var kExprF32CopySign = 0x7d; -var kExprF32Ceil = 0x7e; -var kExprF32Floor = 0x7f; -var kExprF32Trunc = 0x80; -var kExprF32NearestInt = 0x81; -var kExprF32Sqrt = 0x82; -var kExprF32Eq = 0x83; -var kExprF32Ne = 0x84; -var kExprF32Lt = 0x85; -var kExprF32Le = 0x86; -var kExprF32Gt = 0x87; -var kExprF32Ge = 0x88; -var kExprF64Add = 0x89; -var kExprF64Sub = 0x8a; -var kExprF64Mul = 0x8b; -var kExprF64Div = 0x8c; -var kExprF64Min = 0x8d; -var kExprF64Max = 0x8e; -var kExprF64Abs = 0x8f; -var kExprF64Neg = 0x90; -var kExprF64CopySign = 0x91; -var kExprF64Ceil = 0x92; -var kExprF64Floor = 0x93; -var kExprF64Trunc = 0x94; -var kExprF64NearestInt = 0x95; -var kExprF64Sqrt = 0x96; -var kExprF64Eq = 0x97; -var kExprF64Ne = 0x98; -var kExprF64Lt = 0x99; -var kExprF64Le = 0x9a; -var kExprF64Gt = 0x9b; -var kExprF64Ge = 0x9c; -var kExprI32SConvertF32 = 0x9d; -var kExprI32SConvertF64 = 0x9e; -var kExprI32UConvertF32 = 0x9f; -var kExprI32UConvertF64 = 0xa0; -var kExprI32ConvertI64 = 0xa1; -var kExprI64SConvertF32 = 0xa2; -var kExprI64SConvertF64 = 0xa3; -var kExprI64UConvertF32 = 0xa4; -var kExprI64UConvertF64 = 0xa5; -var kExprI64SConvertI32 = 0xa6; -var kExprI64UConvertI32 = 0xa7; -var kExprF32SConvertI32 = 0xa8; -var kExprF32UConvertI32 = 0xa9; -var kExprF32SConvertI64 = 0xaa; -var kExprF32UConvertI64 = 0xab; -var kExprF32ConvertF64 = 0xac; -var kExprF32ReinterpretI32 = 0xad; -var kExprF64SConvertI32 = 0xae; -var kExprF64UConvertI32 = 0xaf; -var kExprF64SConvertI64 = 0xb0; -var kExprF64UConvertI64 = 0xb1; -var kExprF64ConvertF32 = 0xb2; -var kExprF64ReinterpretI64 = 0xb3; -var kExprI32ReinterpretF32 = 0xb4; -var kExprI64ReinterpretF64 = 0xb5; -var kExprI32Ror = 0xb6; -var kExprI32Rol = 0xb7; -var kExprI64Ror = 0xb8; -var kExprI64Rol = 0xb9; +let kExprUnreachable = 0x00; +let kExprNop = 0x01; +let kExprBlock = 0x02; +let kExprLoop = 0x03; +let kExprIf = 0x04; +let kExprElse = 0x05; +let kExprTry = 0x06; +let kExprCatch = 0x07; +let kExprThrow = 0x08; +let kExprEnd = 0x0b; +let kExprBr = 0x0c; +let kExprBrIf = 0x0d; +let kExprBrTable = 0x0e; +let kExprReturn = 0x0f; +let kExprCallFunction = 0x10; +let kExprCallIndirect = 0x11; +let kExprDrop = 0x1a; +let kExprSelect = 0x1b; +let kExprGetLocal = 0x20; +let kExprSetLocal = 0x21; +let kExprTeeLocal = 0x22; +let kExprGetGlobal = 0x23; +let kExprSetGlobal = 0x24; +let kExprI32Const = 0x41; +let kExprI64Const = 0x42; +let kExprF32Const = 0x43; +let kExprF64Const = 0x44; +let kExprI8Const = 0xcb; +let kExprI32LoadMem = 0x28; +let kExprI64LoadMem = 0x29; +let kExprF32LoadMem = 0x2a; +let kExprF64LoadMem = 0x2b; +let kExprI32LoadMem8S = 0x2c; +let kExprI32LoadMem8U = 0x2d; +let kExprI32LoadMem16S = 0x2e; +let kExprI32LoadMem16U = 0x2f; +let kExprI64LoadMem8S = 0x30; +let kExprI64LoadMem8U = 0x31; +let kExprI64LoadMem16S = 0x32; +let kExprI64LoadMem16U = 0x33; +let kExprI64LoadMem32S = 0x34; +let kExprI64LoadMem32U = 0x35; +let kExprI32StoreMem = 0x36; +let kExprI64StoreMem = 0x37; +let kExprF32StoreMem = 0x38; +let kExprF64StoreMem = 0x39; +let kExprI32StoreMem8 = 0x3a; +let kExprI32StoreMem16 = 0x3b; +let kExprI64StoreMem8 = 0x3c; +let kExprI64StoreMem16 = 0x3d; +let kExprI64StoreMem32 = 0x3e; +let kExprMemorySize = 0x3f; +let kExprGrowMemory = 0x40; +let kExprI32Eqz = 0x45; +let kExprI32Eq = 0x46; +let kExprI32Ne = 0x47; +let kExprI32LtS = 0x48; +let kExprI32LtU = 0x49; +let kExprI32GtS = 0x4a; +let kExprI32GtU = 0x4b; +let kExprI32LeS = 0x4c; +let kExprI32LeU = 0x4d; +let kExprI32GeS = 0x4e; +let kExprI32GeU = 0x4f; +let kExprI64Eqz = 0x50; +let kExprI64Eq = 0x51; +let kExprI64Ne = 0x52; +let kExprI64LtS = 0x53; +let kExprI64LtU = 0x54; +let kExprI64GtS = 0x55; +let kExprI64GtU = 0x56; +let kExprI64LeS = 0x57; +let kExprI64LeU = 0x58; +let kExprI64GeS = 0x59; +let kExprI64GeU = 0x5a; +let kExprF32Eq = 0x5b; +let kExprF32Ne = 0x5c; +let kExprF32Lt = 0x5d; +let kExprF32Gt = 0x5e; +let kExprF32Le = 0x5f; +let kExprF32Ge = 0x60; +let kExprF64Eq = 0x61; +let kExprF64Ne = 0x62; +let kExprF64Lt = 0x63; +let kExprF64Gt = 0x64; +let kExprF64Le = 0x65; +let kExprF64Ge = 0x66; +let kExprI32Clz = 0x67; +let kExprI32Ctz = 0x68; +let kExprI32Popcnt = 0x69; +let kExprI32Add = 0x6a; +let kExprI32Sub = 0x6b; +let kExprI32Mul = 0x6c; +let kExprI32DivS = 0x6d; +let kExprI32DivU = 0x6e; +let kExprI32RemS = 0x6f; +let kExprI32RemU = 0x70; +let kExprI32And = 0x71; +let kExprI32Ior = 0x72; +let kExprI32Xor = 0x73; +let kExprI32Shl = 0x74; +let kExprI32ShrS = 0x75; +let kExprI32ShrU = 0x76; +let kExprI32Rol = 0x77; +let kExprI32Ror = 0x78; +let kExprI64Clz = 0x79; +let kExprI64Ctz = 0x7a; +let kExprI64Popcnt = 0x7b; +let kExprI64Add = 0x7c; +let kExprI64Sub = 0x7d; +let kExprI64Mul = 0x7e; +let kExprI64DivS = 0x7f; +let kExprI64DivU = 0x80; +let kExprI64RemS = 0x81; +let kExprI64RemU = 0x82; +let kExprI64And = 0x83; +let kExprI64Ior = 0x84; +let kExprI64Xor = 0x85; +let kExprI64Shl = 0x86; +let kExprI64ShrS = 0x87; +let kExprI64ShrU = 0x88; +let kExprI64Rol = 0x89; +let kExprI64Ror = 0x8a; +let kExprF32Abs = 0x8b; +let kExprF32Neg = 0x8c; +let kExprF32Ceil = 0x8d; +let kExprF32Floor = 0x8e; +let kExprF32Trunc = 0x8f; +let kExprF32NearestInt = 0x90; +let kExprF32Sqrt = 0x91; +let kExprF32Add = 0x92; +let kExprF32Sub = 0x93; +let kExprF32Mul = 0x94; +let kExprF32Div = 0x95; +let kExprF32Min = 0x96; +let kExprF32Max = 0x97; +let kExprF32CopySign = 0x98; +let kExprF64Abs = 0x99; +let kExprF64Neg = 0x9a; +let kExprF64Ceil = 0x9b; +let kExprF64Floor = 0x9c; +let kExprF64Trunc = 0x9d; +let kExprF64NearestInt = 0x9e; +let kExprF64Sqrt = 0x9f; +let kExprF64Add = 0xa0; +let kExprF64Sub = 0xa1; +let kExprF64Mul = 0xa2; +let kExprF64Div = 0xa3; +let kExprF64Min = 0xa4; +let kExprF64Max = 0xa5; +let kExprF64CopySign = 0xa6; +let kExprI32ConvertI64 = 0xa7; +let kExprI32SConvertF32 = 0xa8; +let kExprI32UConvertF32 = 0xa9; +let kExprI32SConvertF64 = 0xaa; +let kExprI32UConvertF64 = 0xab; +let kExprI64SConvertI32 = 0xac; +let kExprI64UConvertI32 = 0xad; +let kExprI64SConvertF32 = 0xae; +let kExprI64UConvertF32 = 0xaf; +let kExprI64SConvertF64 = 0xb0; +let kExprI64UConvertF64 = 0xb1; +let kExprF32SConvertI32 = 0xb2; +let kExprF32UConvertI32 = 0xb3; +let kExprF32SConvertI64 = 0xb4; +let kExprF32UConvertI64 = 0xb5; +let kExprF32ConvertF64 = 0xb6; +let kExprF64SConvertI32 = 0xb7; +let kExprF64UConvertI32 = 0xb8; +let kExprF64SConvertI64 = 0xb9; +let kExprF64UConvertI64 = 0xba; +let kExprF64ConvertF32 = 0xbb; +let kExprI32ReinterpretF32 = 0xbc; +let kExprI64ReinterpretF64 = 0xbd; +let kExprF32ReinterpretI32 = 0xbe; +let kExprF64ReinterpretI64 = 0xbf; -var kTrapUnreachable = 0; -var kTrapMemOutOfBounds = 1; -var kTrapDivByZero = 2; -var kTrapDivUnrepresentable = 3; -var kTrapRemByZero = 4; -var kTrapFloatUnrepresentable = 5; -var kTrapFuncInvalid = 6; -var kTrapFuncSigMismatch = 7; -var kTrapInvalidIndex = 8; +let kTrapUnreachable = 0; +let kTrapMemOutOfBounds = 1; +let kTrapDivByZero = 2; +let kTrapDivUnrepresentable = 3; +let kTrapRemByZero = 4; +let kTrapFloatUnrepresentable = 5; +let kTrapFuncInvalid = 6; +let kTrapFuncSigMismatch = 7; +let kTrapInvalidIndex = 8; -var kTrapMsgs = [ +let kTrapMsgs = [ "unreachable", "memory access out of bounds", "divide by zero", diff --git a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js index 7b77a8c9b1..900198d7d0 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js @@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Used for encoding f32 and double constants to bits. +let __buffer = new ArrayBuffer(8); +let byte_view = new Int8Array(__buffer); +let f32_view = new Float32Array(__buffer); +let f64_view = new Float64Array(__buffer); + class Binary extends Array { emit_u8(val) { this.push(val); @@ -19,7 +25,7 @@ class Binary extends Array { this.push((val >> 24) & 0xff); } - emit_varint(val) { + emit_u32v(val) { while (true) { let v = val & 0xff; val = val >>> 7; @@ -40,7 +46,7 @@ class Binary extends Array { emit_string(string) { // When testing illegal names, we pass a byte array directly. if (string instanceof Array) { - this.emit_varint(string.length); + this.emit_u32v(string.length); this.emit_bytes(string); return; } @@ -48,7 +54,7 @@ class Binary extends Array { // This is the hacky way to convert a JavaScript string to a UTF8 encoded // string only containing single-byte characters. let string_utf8 = unescape(encodeURIComponent(string)); - this.emit_varint(string_utf8.length); + this.emit_u32v(string_utf8.length); for (let i = 0; i < string_utf8.length; i++) { this.emit_u8(string_utf8.charCodeAt(i)); } @@ -66,26 +72,27 @@ class Binary extends Array { let section = new Binary; content_generator(section); // Emit section length. - this.emit_varint(section.length); + this.emit_u32v(section.length); // Copy the temporary buffer. this.push(...section); } } class WasmFunctionBuilder { - constructor(name, type_index) { + constructor(module, name, type_index) { + this.module = module; this.name = name; this.type_index = type_index; - this.exports = []; + this.body = []; } exportAs(name) { - this.exports.push(name); + this.module.addExport(name, this.index); return this; } exportFunc() { - this.exports.push(this.name); + this.exportAs(this.name); return this; } @@ -98,24 +105,47 @@ class WasmFunctionBuilder { this.locals = locals; return this; } + + end() { + return this.module; + } +} + +class WasmGlobalBuilder { + constructor(module, type, mutable) { + this.module = module; + this.type = type; + this.mutable = mutable; + this.init = 0; + } + + exportAs(name) { + this.module.exports.push({name: name, kind: kExternalGlobal, + index: this.index}); + return this; + } } class WasmModuleBuilder { constructor() { this.types = []; this.imports = []; + this.exports = []; this.globals = []; this.functions = []; - this.exports = []; - this.table = []; + this.function_table = []; + this.function_table_length = 0; + this.function_table_inits = []; this.segments = []; this.explicit = []; - this.pad = null; + this.num_imported_funcs = 0; + this.num_imported_globals = 0; return this; } addStart(start_index) { this.start_index = start_index; + return this; } addMemory(min, max, exp) { @@ -123,11 +153,6 @@ class WasmModuleBuilder { return this; } - addPadFunctionTable(size) { - this.pad = size; - return this; - } - addExplicitSection(bytes) { this.explicit.push(bytes); return this; @@ -139,40 +164,93 @@ class WasmModuleBuilder { return this.types.length - 1; } - addGlobal(local_type) { - this.globals.push(local_type); - return this.globals.length - 1; + addGlobal(local_type, mutable) { + let glob = new WasmGlobalBuilder(this, local_type, mutable); + glob.index = this.globals.length + this.num_imported_globals; + this.globals.push(glob); + return glob; } addFunction(name, type) { let type_index = (typeof type) == "number" ? type : this.addType(type); - let func = new WasmFunctionBuilder(name, type_index); - func.index = this.functions.length + this.imports.length; + let func = new WasmFunctionBuilder(this, name, type_index); + func.index = this.functions.length + this.num_imported_funcs; this.functions.push(func); return func; } addImportWithModule(module, name, type) { let type_index = (typeof type) == "number" ? type : this.addType(type); - this.imports.push({module: module, name: name, type: type_index}); - return this.imports.length - 1; + this.imports.push({module: module, name: name, kind: kExternalFunction, + type: type_index}); + return this.num_imported_funcs++; } addImport(name, type) { return this.addImportWithModule(name, undefined, type); } - addDataSegment(addr, data, init) { - this.segments.push({addr: addr, data: data, init: init}); + addImportedGlobal(module, name, type) { + let o = {module: module, name: name, kind: kExternalGlobal, type: type, + mutable: false} + this.imports.push(o); + return this.num_imported_globals++; + } + + addImportedMemory(module, name, initial = 0, maximum) { + let o = {module: module, name: name, kind: kExternalMemory, + initial: initial, maximum: maximum}; + this.imports.push(o); + return this; + } + + addImportedTable(module, name, initial, maximum) { + let o = {module: module, name: name, kind: kExternalTable, initial: initial, + maximum: maximum}; + this.imports.push(o); + } + + addExport(name, index) { + this.exports.push({name: name, kind: kExternalFunction, index: index}); + return this; + } + + addExportOfKind(name, kind, index) { + this.exports.push({name: name, kind: kind, index: index}); + return this; + } + + addDataSegment(addr, data, is_global = false) { + this.segments.push({addr: addr, data: data, is_global: is_global}); return this.segments.length - 1; } + exportMemoryAs(name) { + this.exports.push({name: name, kind: kExternalMemory, index: 0}); + } + + addFunctionTableInit(base, is_global, array) { + this.function_table_inits.push({base: base, is_global: is_global, + array: array}); + if (!is_global) { + var length = base + array.length; + if (length > this.function_table_length) { + this.function_table_length = length; + } + } + return this; + } + appendToTable(array) { - this.table.push(...array); + return this.addFunctionTableInit(this.function_table.length, false, array); + } + + setFunctionTableLength(length) { + this.function_table_length = length; return this; } - toArray(debug) { + toArray(debug = false) { let binary = new Binary; let wasm = this; @@ -183,14 +261,14 @@ class WasmModuleBuilder { if (wasm.types.length > 0) { if (debug) print("emitting types @ " + binary.length); binary.emit_section(kTypeSectionCode, section => { - section.emit_varint(wasm.types.length); + section.emit_u32v(wasm.types.length); for (let type of wasm.types) { section.emit_u8(kWasmFunctionTypeForm); - section.emit_varint(type.params.length); + section.emit_u32v(type.params.length); for (let param of type.params) { section.emit_u8(param); } - section.emit_varint(type.results.length); + section.emit_u32v(type.results.length); for (let result of type.results) { section.emit_u8(result); } @@ -202,12 +280,30 @@ class WasmModuleBuilder { if (wasm.imports.length > 0) { if (debug) print("emitting imports @ " + binary.length); binary.emit_section(kImportSectionCode, section => { - section.emit_varint(wasm.imports.length); + section.emit_u32v(wasm.imports.length); for (let imp of wasm.imports) { section.emit_string(imp.module); section.emit_string(imp.name || ''); - section.emit_u8(kExternalFunction); - section.emit_varint(imp.type); + section.emit_u8(imp.kind); + if (imp.kind == kExternalFunction) { + section.emit_u32v(imp.type); + } else if (imp.kind == kExternalGlobal) { + section.emit_u32v(imp.type); + section.emit_u8(imp.mutable); + } else if (imp.kind == kExternalMemory) { + var has_max = (typeof imp.maximum) != "undefined"; + section.emit_u8(has_max ? 1 : 0); // flags + section.emit_u32v(imp.initial); // initial + if (has_max) section.emit_u32v(imp.maximum); // maximum + } else if (imp.kind == kExternalTable) { + section.emit_u8(kWasmAnyFunctionTypeForm); + var has_max = (typeof imp.maximum) != "undefined"; + section.emit_u8(has_max ? 1 : 0); // flags + section.emit_u32v(imp.initial); // initial + if (has_max) section.emit_u32v(imp.maximum); // maximum + } else { + throw new Error("unknown/unsupported import kind " + imp.kind); + } } }); } @@ -215,29 +311,27 @@ class WasmModuleBuilder { // Add functions declarations let has_names = false; let names = false; - let exports = 0; if (wasm.functions.length > 0) { if (debug) print("emitting function decls @ " + binary.length); binary.emit_section(kFunctionSectionCode, section => { - section.emit_varint(wasm.functions.length); + section.emit_u32v(wasm.functions.length); for (let func of wasm.functions) { has_names = has_names || (func.name != undefined && func.name.length > 0); - exports += func.exports.length; - section.emit_varint(func.type_index); + section.emit_u32v(func.type_index); } }); } - // Add table. - if (wasm.table.length > 0) { + // Add function_table. + if (wasm.function_table_length > 0) { if (debug) print("emitting table @ " + binary.length); binary.emit_section(kTableSectionCode, section => { section.emit_u8(1); // one table entry section.emit_u8(kWasmAnyFunctionTypeForm); section.emit_u8(1); - section.emit_varint(wasm.table.length); - section.emit_varint(wasm.table.length); + section.emit_u32v(wasm.function_table_length); + section.emit_u32v(wasm.function_table_length); }); } @@ -246,9 +340,9 @@ class WasmModuleBuilder { if (debug) print("emitting memory @ " + binary.length); binary.emit_section(kMemorySectionCode, section => { section.emit_u8(1); // one memory entry - section.emit_varint(kResizableMaximumFlag); - section.emit_varint(wasm.memory.min); - section.emit_varint(wasm.memory.max); + section.emit_u32v(kResizableMaximumFlag); + section.emit_u32v(wasm.memory.min); + section.emit_u32v(wasm.memory.max); }); } @@ -256,28 +350,46 @@ class WasmModuleBuilder { if (wasm.globals.length > 0) { if (debug) print ("emitting globals @ " + binary.length); binary.emit_section(kGlobalSectionCode, section => { - section.emit_varint(wasm.globals.length); - for (let global_type of wasm.globals) { - section.emit_u8(global_type); - section.emit_u8(true); // mutable - switch (global_type) { + section.emit_u32v(wasm.globals.length); + for (let global of wasm.globals) { + section.emit_u8(global.type); + section.emit_u8(global.mutable); + if ((typeof global.init_index) == "undefined") { + // Emit a constant initializer. + switch (global.type) { case kAstI32: section.emit_u8(kExprI32Const); - section.emit_u8(0); + section.emit_u32v(global.init); break; case kAstI64: section.emit_u8(kExprI64Const); - section.emit_u8(0); + section.emit_u8(global.init); break; case kAstF32: section.emit_u8(kExprF32Const); - section.emit_u32(0); + f32_view[0] = global.init; + section.emit_u8(byte_view[0]); + section.emit_u8(byte_view[1]); + section.emit_u8(byte_view[2]); + section.emit_u8(byte_view[3]); break; case kAstF64: - section.emit_u8(kExprI32Const); - section.emit_u32(0); - section.emit_u32(0); + section.emit_u8(kExprF64Const); + f64_view[0] = global.init; + section.emit_u8(byte_view[0]); + section.emit_u8(byte_view[1]); + section.emit_u8(byte_view[2]); + section.emit_u8(byte_view[3]); + section.emit_u8(byte_view[4]); + section.emit_u8(byte_view[5]); + section.emit_u8(byte_view[6]); + section.emit_u8(byte_view[7]); break; + } + } else { + // Emit a global-index initializer. + section.emit_u8(kExprGetGlobal); + section.emit_u32v(global.init_index); } section.emit_u8(kExprEnd); // end of init expression } @@ -286,16 +398,15 @@ class WasmModuleBuilder { // Add export table. var mem_export = (wasm.memory != undefined && wasm.memory.exp); - if (exports > 0 || mem_export) { + var exports_count = wasm.exports.length + (mem_export ? 1 : 0); + if (exports_count > 0) { if (debug) print("emitting exports @ " + binary.length); binary.emit_section(kExportSectionCode, section => { - section.emit_varint(exports + (mem_export ? 1 : 0)); - for (let func of wasm.functions) { - for (let exp of func.exports) { - section.emit_string(exp); - section.emit_u8(kExternalFunction); - section.emit_varint(func.index); - } + section.emit_u32v(exports_count); + for (let exp of wasm.exports) { + section.emit_string(exp.name); + section.emit_u8(exp.kind); + section.emit_u32v(exp.index); } if (mem_export) { section.emit_string("memory"); @@ -309,22 +420,30 @@ class WasmModuleBuilder { if (wasm.start_index != undefined) { if (debug) print("emitting start function @ " + binary.length); binary.emit_section(kStartSectionCode, section => { - section.emit_varint(wasm.start_index); + section.emit_u32v(wasm.start_index); }); } // Add table elements. - if (wasm.table.length > 0) { + if (wasm.function_table_inits.length > 0) { if (debug) print("emitting table @ " + binary.length); binary.emit_section(kElementSectionCode, section => { - section.emit_u8(1); + var inits = wasm.function_table_inits; + section.emit_u32v(inits.length); section.emit_u8(0); // table index - section.emit_u8(kExprI32Const); - section.emit_u8(0); - section.emit_u8(kExprEnd); - section.emit_varint(wasm.table.length); - for (let index of wasm.table) { - section.emit_varint(index); + + for (let init of inits) { + if (init.is_global) { + section.emit_u8(kExprGetGlobal); + } else { + section.emit_u8(kExprI32Const); + } + section.emit_u32v(init.base); + section.emit_u8(kExprEnd); + section.emit_u32v(init.array.length); + for (let index of init.array) { + section.emit_u32v(index); + } } }); } @@ -334,7 +453,7 @@ class WasmModuleBuilder { // emit function bodies if (debug) print("emitting code @ " + binary.length); binary.emit_section(kCodeSectionCode, section => { - section.emit_varint(wasm.functions.length); + section.emit_u32v(wasm.functions.length); for (let func of wasm.functions) { // Function body length will be patched later. let local_decls = []; @@ -356,13 +475,13 @@ class WasmModuleBuilder { } let header = new Binary; - header.emit_varint(local_decls.length); + header.emit_u32v(local_decls.length); for (let decl of local_decls) { - header.emit_varint(decl.count); + header.emit_u32v(decl.count); header.emit_u8(decl.type); } - section.emit_varint(header.length + func.body.length); + section.emit_u32v(header.length + func.body.length); section.emit_bytes(header); section.emit_bytes(func.body); } @@ -373,13 +492,20 @@ class WasmModuleBuilder { if (wasm.segments.length > 0) { if (debug) print("emitting data segments @ " + binary.length); binary.emit_section(kDataSectionCode, section => { - section.emit_varint(wasm.segments.length); + section.emit_u32v(wasm.segments.length); for (let seg of wasm.segments) { section.emit_u8(0); // linear memory index 0 - section.emit_u8(kExprI32Const); - section.emit_varint(seg.addr); + if (seg.is_global) { + // initializer is a global variable + section.emit_u8(kExprGetGlobal); + section.emit_u32v(seg.addr); + } else { + // initializer is a constant + section.emit_u8(kExprI32Const); + section.emit_u32v(seg.addr); + } section.emit_u8(kExprEnd); - section.emit_varint(seg.data.length); + section.emit_u32v(seg.data.length); section.emit_bytes(seg.data); } }); @@ -396,7 +522,12 @@ class WasmModuleBuilder { if (debug) print("emitting names @ " + binary.length); binary.emit_section(kUnknownSectionCode, section => { section.emit_string("name"); - section.emit_varint(wasm.functions.length); + var count = wasm.functions.length + wasm.num_imported_funcs; + section.emit_u32v(count); + for (var i = 0; i < wasm.num_imported_funcs; i++) { + section.emit_u8(0); // empty string + section.emit_u8(0); // local names count == 0 + } for (let func of wasm.functions) { var name = func.name == undefined ? "" : func.name; section.emit_string(name); @@ -408,7 +539,7 @@ class WasmModuleBuilder { return binary; } - toBuffer(debug) { + toBuffer(debug = false) { let bytes = this.toArray(debug); let buffer = new ArrayBuffer(bytes.length); let view = new Uint8Array(buffer); diff --git a/deps/v8/test/mjsunit/wasm/wasm-object-api.js b/deps/v8/test/mjsunit/wasm/wasm-object-api.js index b8663b3b29..3888e3638b 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-object-api.js +++ b/deps/v8/test/mjsunit/wasm/wasm-object-api.js @@ -4,13 +4,10 @@ // Flags: --expose-wasm -assertFalse(undefined === Wasm); -assertFalse(undefined == Wasm); -assertEquals("function", typeof Wasm.verifyModule); -assertEquals("function", typeof Wasm.verifyFunction); -assertEquals("function", typeof Wasm.instantiateModule); -assertFalse(undefined == Wasm.experimentalVersion); +// Old API should be gone. +assertEquals("undefined", typeof Wasm); +// New API should rule. assertEquals('object', typeof WebAssembly); assertEquals('function', typeof WebAssembly.Module); assertEquals('function', typeof WebAssembly.Instance); |