diff options
Diffstat (limited to 'deps/v8/test/mjsunit')
44 files changed, 1429 insertions, 166 deletions
diff --git a/deps/v8/test/mjsunit/array-push-non-smi-value.js b/deps/v8/test/mjsunit/array-push-non-smi-value.js new file mode 100644 index 0000000000..460dd2a911 --- /dev/null +++ b/deps/v8/test/mjsunit/array-push-non-smi-value.js @@ -0,0 +1,36 @@ +// 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. + +// Check pushes of non-SMI values. +var a = []; +function func() { + return a.push(0x40000000) > 60; +} + +assertFalse(func()); +assertFalse(func()); +assertFalse(func()); diff --git a/deps/v8/test/mjsunit/array-store-and-grow.js b/deps/v8/test/mjsunit/array-store-and-grow.js index a03a753e44..5ac95e9b3a 100644 --- a/deps/v8/test/mjsunit/array-store-and-grow.js +++ b/deps/v8/test/mjsunit/array-store-and-grow.js @@ -187,6 +187,7 @@ array_store_1(a, 0, 0.5); assertEquals(0.5, a[0]); assertEquals(0.5, array_store_1([], 0, 0.5)); + // Verify that a grow store will deoptimize if the max gap (difference between // the end of an array capacity and a new index) is passed. The wrapper is to // make sure array_store_10 isn't inlined. @@ -207,3 +208,49 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); %ClearFunctionTypeFeedback(grow_store); })(); + +// Verify that a polymorphic store and grow IC when crankshafted is still +// a grow IC (earlier it would revert to a standard store in the polymorphic +// case). +(function() { + function f(o, k, v) { + o[k] = v; + } + + a = [3.5]; + f(a, 1, "hi"); // DOUBLE packed array -> tagged packed grow + a = {}; + a.p = "property"; + a[0] = 1; + f(a, 0, 5.4); + + %OptimizeFunctionOnNextCall(f); + // Should be a polymorphic grow stub. If not a grow stub it will deopt. + f(new Array("hi"), 1, 3); + assertOptimized(f); + %ClearFunctionTypeFeedback(f); +})(); + + +// Now verify that a polymorphic store (non-growing) IC when crankshafted WILL +// deopt if you pass an element out of bounds. +(function() { + function f(o, k, v) { + o[k] = v; + } + + a = [3.5]; + f(a, 0, "hi"); // DOUBLE packed array -> tagged packed grow + a = {}; + a.p = "property"; + a[0] = 1; + f(a, 0, 5.4); + + %OptimizeFunctionOnNextCall(f); + f(new Array("hi"), 0, 3); + assertOptimized(f); + // An attempt to grow should cause deopt + f(new Array("hi"), 1, 3); + assertUnoptimized(f); + %ClearFunctionTypeFeedback(f); +})(); diff --git a/deps/v8/test/mjsunit/assert-opt-and-deopt.js b/deps/v8/test/mjsunit/assert-opt-and-deopt.js index bfd2f3f489..d653bb5905 100644 --- a/deps/v8/test/mjsunit/assert-opt-and-deopt.js +++ b/deps/v8/test/mjsunit/assert-opt-and-deopt.js @@ -25,10 +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: --allow-natives-syntax +// Flags: --allow-natives-syntax --noconcurrent-recompilation -if (%IsParallelRecompilationSupported()) { - print("Parallel recompilation is turned on after all. Skipping this test."); +if (%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is turned on after all. Skipping this test."); quit(); } diff --git a/deps/v8/test/mjsunit/compiler/escape-analysis.js b/deps/v8/test/mjsunit/compiler/escape-analysis.js index 9776f67ccf..74e638a538 100644 --- a/deps/v8/test/mjsunit/compiler/escape-analysis.js +++ b/deps/v8/test/mjsunit/compiler/escape-analysis.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --use-escape-analysis +// Flags: --allow-natives-syntax --use-escape-analysis --expose-gc // Test stores on a join path. @@ -132,3 +132,142 @@ delete deopt.deopt; func(); func(); })(); + + +// Test deoptimization with captured objects on operand stack. +(function testDeoptOperand() { + var deopt = { deopt:false }; + function constructor1() { + this.a = 1.0; + this.b = 2.3; + deopt.deopt; + assertEquals(1.0, this.a); + assertEquals(2.3, this.b); + this.b = 2.7; + this.c = 3.0; + this.d = 4.5; + } + function constructor2() { + this.e = 5.0; + this.f = new constructor1(); + assertEquals(1.0, this.f.a); + assertEquals(2.7, this.f.b); + assertEquals(3.0, this.f.c); + assertEquals(4.5, this.f.d); + assertEquals(5.0, this.e); + this.e = 5.9; + this.g = 6.7; + } + function func() { + var o = new constructor2(); + assertEquals(1.0, o.f.a); + assertEquals(2.7, o.f.b); + assertEquals(3.0, o.f.c); + assertEquals(4.5, o.f.d); + assertEquals(5.9, o.e); + assertEquals(6.7, o.g); + } + func(); func(); + %OptimizeFunctionOnNextCall(func); + func(); func(); + delete deopt.deopt; + func(); func(); +})(); + + +// Test map checks on captured objects. +(function testMapCheck() { + var sum = 0; + function getter() { return 27; } + function setter(v) { sum += v; } + function constructor() { + this.x = 23; + this.y = 42; + } + function check(x, y) { + var o = new constructor(); + assertEquals(x, o.x); + assertEquals(y, o.y); + } + var monkey = Object.create(null, { + x: { get:getter, set:setter }, + y: { get:getter, set:setter } + }); + check(23, 42); check(23, 42); + %OptimizeFunctionOnNextCall(check); + check(23, 42); check(23, 42); + constructor.prototype = monkey; + check(27, 27); check(27, 27); + assertEquals(130, sum); +})(); + + +// Test OSR into a loop with captured objects. +(function testOSR() { + function constructor() { + this.a = 23; + } + function osr1(length) { + assertEquals(23, (new constructor()).a); + var result = 0; + for (var i = 0; i < length; i++) { + result = (result + i) % 99; + } + return result; + } + function osr2(length) { + var result = 0; + for (var i = 0; i < length; i++) { + result = (result + i) % 99; + } + assertEquals(23, (new constructor()).a); + return result; + } + function osr3(length) { + var result = 0; + var o = new constructor(); + for (var i = 0; i < length; i++) { + result = (result + i) % 99; + } + assertEquals(23, o.a); + return result; + } + function test(closure) { + assertEquals(45, closure(10)); + assertEquals(45, closure(10)); + assertEquals(10, closure(50000)); + } + test(osr1); + test(osr2); + test(osr3); +})(); + + +// Test out-of-bounds access on captured objects. +(function testOOB() { + function cons1() { + this.x = 1; + this.y = 2; + this.z = 3; + } + function cons2() { + this.a = 7; + } + function oob(constructor, branch) { + var o = new constructor(); + if (branch) { + return o.a; + } else { + return o.z; + } + } + assertEquals(3, oob(cons1, false)); + assertEquals(3, oob(cons1, false)); + assertEquals(7, oob(cons2, true)); + assertEquals(7, oob(cons2, true)); + gc(); // Clears type feedback of constructor call. + assertEquals(7, oob(cons2, true)); + assertEquals(7, oob(cons2, true)); + %OptimizeFunctionOnNextCall(oob); + assertEquals(7, oob(cons2, true)); +})(); diff --git a/deps/v8/test/mjsunit/compiler/increment-typefeedback.js b/deps/v8/test/mjsunit/compiler/increment-typefeedback.js new file mode 100644 index 0000000000..798959296c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/increment-typefeedback.js @@ -0,0 +1,39 @@ +// 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: --allow-natives-syntax + +function f(x) { + x++; + return x; +} + +f(0.5); +f(0.5); +%OptimizeFunctionOnNextCall(f); +f(0.5); +assertOptimized(f); diff --git a/deps/v8/test/mjsunit/compiler/optimized-for-in.js b/deps/v8/test/mjsunit/compiler/optimized-for-in.js index cb8c66df9f..9c756aafa7 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-for-in.js +++ b/deps/v8/test/mjsunit/compiler/optimized-for-in.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --optimize-for-in --allow-natives-syntax +// Flags: --no-concurrent-osr // Test for-in support in Crankshaft. For simplicity this tests assumes certain // fixed iteration order for properties and will have to be adjusted if V8 diff --git a/deps/v8/test/mjsunit/compiler/osr-assert.js b/deps/v8/test/mjsunit/compiler/osr-assert.js new file mode 100644 index 0000000000..94b901fd4f --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-assert.js @@ -0,0 +1,41 @@ +// 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: --use-osr + +function f(x, b, c) { + var outer = 1000000; + var a = 1; + while (outer > 0) { + a = a + 5; + assertEquals(b + 1, c); + outer--; + } + return a + 4; +} + +assertEquals(5000005, f(5, "122", "1221")); diff --git a/deps/v8/test/mjsunit/compiler/osr-sar.js b/deps/v8/test/mjsunit/compiler/osr-sar.js new file mode 100644 index 0000000000..fd68b98a45 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-sar.js @@ -0,0 +1,49 @@ +// 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 + +function test() { + // Loop to force OSR. + var j = 0; + for (var i = 0; i < 80000; i++) { + j++; + } + + function SarShr(val) { + return val >> (-2 >>> 0); + } + + var K3 = 0x80000000; + assertEquals(-2, SarShr(K3 | 0)); + assertEquals(-2, SarShr(K3 | 0)); + %OptimizeFunctionOnNextCall(SarShr); + assertEquals(-2, SarShr(K3 | 0)); +} + +test(); +//test(); diff --git a/deps/v8/test/mjsunit/compiler/osr-uint32.js b/deps/v8/test/mjsunit/compiler/osr-uint32.js new file mode 100644 index 0000000000..d6fcae546c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-uint32.js @@ -0,0 +1,39 @@ +// 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. + +// Loop to force OSR. +var j = 0; +for (var i = 0; i < 80000; i++) { + j++; +} + +function SarShr(val) { + return val >> (-2 >>> 0); +} + +var K3 = 0x80000000; +assertEquals(-2, SarShr(K3 | 0)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-298392.js b/deps/v8/test/mjsunit/compiler/osr-warm.js index 8370654b6c..65ada1e114 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-298392.js +++ b/deps/v8/test/mjsunit/compiler/osr-warm.js @@ -25,27 +25,26 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function foo() { - return [[1,2,3], [5,6,6]]; -} +// Flags: --use-osr -function bar() { - return ["foo", "bar"]; +function f1(x) { + while (x > 0) { + x--; + } + return x; } -function baz() { - return [foo(), bar(), foo(), bar()]; -} +assertEquals(0, f1(1)); +assertEquals(0, f1(10000000)); -function thingy() { - var result = []; - for (var i = 0; i < 50000; ++i) { - result.push(baz()); +function f2(x) { + var sum = 1; + while (x > 0) { + x--; + sum++; } - return result; + return sum; } -var size = thingy().length; -if (size != 50000) { - throw "Error: bad size: " + size; -} +assertEquals(2, f2(1)); +assertEquals(10000001, f2(10000000)); diff --git a/deps/v8/test/mjsunit/compiler/parallel-proto-change.js b/deps/v8/test/mjsunit/compiler/parallel-proto-change.js index 25ea3b59df..7602279893 100644 --- a/deps/v8/test/mjsunit/compiler/parallel-proto-change.js +++ b/deps/v8/test/mjsunit/compiler/parallel-proto-change.js @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax -// Flags: --parallel-recompilation --parallel-recompilation-delay=50 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=50 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -41,11 +41,11 @@ o.__proto__ = { __proto__: { bar: function() { return 1; } } }; assertEquals(1, f(o)); assertEquals(1, f(o)); -// Mark for parallel optimization. -%OptimizeFunctionOnNextCall(f, "parallel"); -// Trigger optimization in the parallel thread. +// Mark for concurrent optimization. +%OptimizeFunctionOnNextCall(f, "concurrent"); +// Trigger optimization in the background thread. assertEquals(1, f(o)); -// While parallel recompilation is running, optimization not yet done. +// While concurrent recompilation is running, optimization not yet done. assertUnoptimized(f, "no sync"); // Change the prototype chain during optimization to trigger map invalidation. o.__proto__.__proto__ = { bar: function() { return 2; } }; diff --git a/deps/v8/test/mjsunit/debug-script.js b/deps/v8/test/mjsunit/debug-script.js index 6e673f71c0..1cbdb376cc 100644 --- a/deps/v8/test/mjsunit/debug-script.js +++ b/deps/v8/test/mjsunit/debug-script.js @@ -59,9 +59,9 @@ for (i = 0; i < scripts.length; i++) { } // This has to be updated if the number of native scripts change. -assertEquals(16, named_native_count); -// Only the 'gc' and (depending on flags) the 'i18n' extensions are loaded. -assertTrue(extension_count == 1 || extension_count == 2); +assertTrue(named_native_count == 16 || named_native_count == 17); +// Only the 'gc' extension is loaded. +assertEquals(1, extension_count); // This script and mjsunit.js has been loaded. If using d8, d8 loads // a normal script during startup too. assertTrue(normal_count == 2 || normal_count == 3); diff --git a/deps/v8/test/mjsunit/debug-step-4-in-frame.js b/deps/v8/test/mjsunit/debug-step-4-in-frame.js new file mode 100644 index 0000000000..65ac4902dd --- /dev/null +++ b/deps/v8/test/mjsunit/debug-step-4-in-frame.js @@ -0,0 +1,132 @@ +// 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] < 5; state[2]++) { + void String(a); + } +} +function g() { + for (state[1] = 0; state[1] < 5; state[1]++) { + f(); + } +} +function h() { + state = [-1, -1, -1]; + for (state[0] = 0; state[0] < 5; state[0]++) { + g(); + } +} + +function TestCase(frame_index, step_count, expected_final_state) { + print("Test case, parameters " + frame_index + "/" + step_count); + + 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); + var context_frame; + if (frame_index !== undefined) { + context_frame = exec_state.frame(frame_index); + } + exec_state.prepareStep(Debug.StepAction.StepNext, + step_count, context_frame); + 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(); + + +// Stepping in the default (top) frame. +TestCase(undefined, 0, "0,0,-1"); +TestCase(undefined, 1, "0,0,-1"); +TestCase(undefined, 2, "0,0,0"); +TestCase(undefined, 5, "0,0,1"); +TestCase(undefined, 8, "0,0,3"); + +// Stepping in the frame #0 (should be exactly the same as above). +TestCase(0, 0, "0,0,-1"); +TestCase(0, 1, "0,0,-1"); +TestCase(0, 2, "0,0,0"); +TestCase(0, 5, "0,0,1"); +TestCase(0, 8, "0,0,3"); + +// Stepping in the frame #1. +TestCase(1, 0, "0,0,5"); +TestCase(1, 3, "0,1,5"); +TestCase(1, 8, "0,4,5"); + +// Stepping in the frame #2. +TestCase(2, 3, "1,5,5"); +TestCase(2, 8, "4,5,5"); diff --git a/deps/v8/test/mjsunit/debug-stepin-positions.js b/deps/v8/test/mjsunit/debug-stepin-positions.js index 482e21be4d..e6d8204611 100644 --- a/deps/v8/test/mjsunit/debug-stepin-positions.js +++ b/deps/v8/test/mjsunit/debug-stepin-positions.js @@ -30,26 +30,35 @@ Debug = debug.Debug function DebuggerStatement() { - debugger; + debugger; /*pause*/ } -function TestCase(fun) { +function TestCase(fun, frame_number) { var exception = false; var codeSnippet = undefined; var resultPositions = undefined; function listener(event, exec_state, event_data, data) { try { - if (event == Debug.DebugEvent.Break) { + if (event == Debug.DebugEvent.Break || + event == Debug.DebugEvent.Exception) { Debug.setListener(null); - - var secondFrame = exec_state.frame(1); - codeSnippet = secondFrame.sourceLineText(); - resultPositions = secondFrame.stepInPositions(); + assertHasLineMark(/pause/, exec_state.frame(0)); + assertHasLineMark(/positions/, exec_state.frame(frame_number)); + var frame = exec_state.frame(frame_number); + codeSnippet = frame.sourceLineText(); + resultPositions = frame.stepInPositions(); } } catch (e) { exception = e } + + function assertHasLineMark(mark, frame) { + var line = frame.sourceLineText(); + if (!mark.exec(frame.sourceLineText())) { + throw new Error("Line " + line + " should contain mark " + mark); + } + } } Debug.setListener(listener); @@ -101,26 +110,98 @@ function TestCase(fun) { decoratedResult); } +function TestCaseWithDebugger(fun) { + TestCase(fun, 1); +} + +function TestCaseWithBreakpoint(fun, line_number, frame_number) { + var breakpointId = Debug.setBreakPoint(fun, line_number); + TestCase(fun, frame_number); + Debug.clearBreakPoint(breakpointId); +} + +function TestCaseWithException(fun, frame_number) { + Debug.setBreakOnException(); + TestCase(fun, frame_number); + Debug.clearBreakOnException(); +} + // Test cases. +// Step in position, when the function call that we are standing at is already +// being executed. +var fun = function() { + function g(p) { + throw String(p); /*pause*/ + } + try { + var res = [ g(1), /*#*/g(2) ]; /*positions*/ + } catch (e) { + } +}; +TestCaseWithBreakpoint(fun, 2, 1); +TestCaseWithException(fun, 1); + + +// Step in position, when the function call that we are standing at is raising +// an exception. +var fun = function() { + var o = { + g: function(p) { + throw p; + } + }; + try { + var res = [ /*#*/f(1), /*#*/g(2) ]; /*pause, positions*/ + } catch (e) { + } +}; +TestCaseWithException(fun, 0); + + +// Step-in position, when already paused almost on the first call site. +var fun = function() { + function g(p) { + throw p; + } + try { + var res = [ /*#*/g(Math.rand), /*#*/g(2) ]; /*pause, positions*/ + } catch (e) { + } +}; +TestCaseWithBreakpoint(fun, 5, 0); + +// Step-in position, when already paused on the first call site. +var fun = function() { + function g() { + throw "Debug"; + } + try { + var res = [ /*#*/g(), /*#*/g() ]; /*pause, positions*/ + } catch (e) { + } +}; +TestCaseWithBreakpoint(fun, 5, 0); + + // Method calls. var fun = function() { var data = { a: function() {} }; - var res = [ DebuggerStatement(), data./*#*/a(), data[/*#*/String("a")]/*#*/(), data["a"]/*#*/(), data.a, data["a"] ]; + var res = [ DebuggerStatement(), data./*#*/a(), data[/*#*/String("a")]/*#*/(), data["a"]/*#*/(), data.a, data["a"] ]; /*positions*/ }; -TestCase(fun); +TestCaseWithDebugger(fun); // Function call on a value. var fun = function() { function g(p) { return g; } - var res = [ DebuggerStatement(), /*#*/g(2), /*#*/g(2)/*#*/(3), /*#*/g(0)/*#*/(0)/*#*/(g) ]; + var res = [ DebuggerStatement(), /*#*/g(2), /*#*/g(2)/*#*/(3), /*#*/g(0)/*#*/(0)/*#*/(g) ]; /*positions*/ }; -TestCase(fun); +TestCaseWithDebugger(fun); // Local function call, closure function call, // local function construction call. @@ -128,15 +209,17 @@ var fun = (function(p) { return function() { function f(a, b) { } - var res = /*#*/f(DebuggerStatement(), /*#*/p(/*#*/new f())); + var res = /*#*/f(DebuggerStatement(), /*#*/p(/*#*/new f())); /*positions*/ }; })(Object); -TestCase(fun); +TestCaseWithDebugger(fun); // Global function, global object construction, calls before pause point. var fun = (function(p) { return function() { - var res = [ Math.abs(new Object()), DebuggerStatement(), Math./*#*/abs(4), /*#*/new Object()./*#*/toString() ]; + var res = [ Math.abs(new Object()), DebuggerStatement(), Math./*#*/abs(4), /*#*/new Object()./*#*/toString() ]; /*positions*/ }; })(Object); -TestCase(fun); +TestCaseWithDebugger(fun); + + diff --git a/deps/v8/test/mjsunit/external-array-no-sse2.js b/deps/v8/test/mjsunit/external-array-no-sse2.js index 11e61ba186..575a8b53cf 100644 --- a/deps/v8/test/mjsunit/external-array-no-sse2.js +++ b/deps/v8/test/mjsunit/external-array-no-sse2.js @@ -679,3 +679,37 @@ boo(built_in_array, 0, 2.5); assertEquals(2.5, goo(built_in_array, 0)); %ClearFunctionTypeFeedback(goo); %ClearFunctionTypeFeedback(boo); + +// Check all int range edge cases +function checkRange() { + var e32 = Math.pow(2,32); var e31 = Math.pow(2,31); + var e16 = Math.pow(2,16); var e15 = Math.pow(2,15); + var e8 = Math.pow(2,8); var e7 = Math.pow(2,7); + var a7 = new Uint32Array(2); var a71 = new Int32Array(2); + var a72 = new Uint16Array(2); var a73 = new Int16Array(2); + var a74 = new Uint8Array(2); var a75 = new Int8Array(2); + for (i = 1; i <= Math.pow(2,33); i *= 2) { + var j = i-1; + a7[0] = i; a71[0] = i; a72[0] = i; a73[0] = i; a74[0] = i; a75[0] = i; + a7[1] = j; a71[1] = j; a72[1] = j; a73[1] = j; a74[1] = j; a75[1] = j; + + if (i < e32) { assertEquals(a7[0], i); } else { assertEquals(a7[0], 0); } + if (j < e32) { assertEquals(a7[1], j); } else { assertEquals(a7[1],e32-1); } + if (i < e31) { assertEquals(a71[0], i); } else { + assertEquals(a71[0], (i < e32) ? -e31 : 0 ); } + if (j < e31) { assertEquals(a71[1], j); } else { assertEquals(a71[1], -1); } + + if (i < e16) { assertEquals(a72[0], i); } else { assertEquals(a72[0], 0); } + if (j < e16) { assertEquals(a72[1], j); } else { assertEquals(a72[1], e16-1); } + if (i < e15) { assertEquals(a73[0], i); } else { + assertEquals(a73[0], (i < e16) ? -e15 : 0 ); } + if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } + + if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } + if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1); } + if (i < e7) { assertEquals(a75[0], i); } else { + assertEquals(a75[0], (i < e8) ? -e7 : 0); } + if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } + } +} +checkRange(); diff --git a/deps/v8/test/mjsunit/external-array.js b/deps/v8/test/mjsunit/external-array.js index 3fcd544ab6..ab5435e5d6 100644 --- a/deps/v8/test/mjsunit/external-array.js +++ b/deps/v8/test/mjsunit/external-array.js @@ -678,3 +678,37 @@ boo(built_in_array, 0, 2.5); assertEquals(2.5, goo(built_in_array, 0)); %ClearFunctionTypeFeedback(goo); %ClearFunctionTypeFeedback(boo); + +// Check all int range edge cases +function checkRange() { + var e32 = Math.pow(2,32); var e31 = Math.pow(2,31); + var e16 = Math.pow(2,16); var e15 = Math.pow(2,15); + var e8 = Math.pow(2,8); var e7 = Math.pow(2,7); + var a7 = new Uint32Array(2); var a71 = new Int32Array(2); + var a72 = new Uint16Array(2); var a73 = new Int16Array(2); + var a74 = new Uint8Array(2); var a75 = new Int8Array(2); + for (i = 1; i <= Math.pow(2,33); i *= 2) { + var j = i-1; + a7[0] = i; a71[0] = i; a72[0] = i; a73[0] = i; a74[0] = i; a75[0] = i; + a7[1] = j; a71[1] = j; a72[1] = j; a73[1] = j; a74[1] = j; a75[1] = j; + + if (i < e32) { assertEquals(a7[0], i); } else { assertEquals(a7[0], 0); } + if (j < e32) { assertEquals(a7[1], j); } else { assertEquals(a7[1],e32-1); } + if (i < e31) { assertEquals(a71[0], i); } else { + assertEquals(a71[0], (i < e32) ? -e31 : 0 ); } + if (j < e31) { assertEquals(a71[1], j); } else { assertEquals(a71[1], -1); } + + if (i < e16) { assertEquals(a72[0], i); } else { assertEquals(a72[0], 0); } + if (j < e16) { assertEquals(a72[1], j); } else { assertEquals(a72[1], e16-1); } + if (i < e15) { assertEquals(a73[0], i); } else { + assertEquals(a73[0], (i < e16) ? -e15 : 0 ); } + if (j < e15) { assertEquals(a73[1], j); } else { assertEquals(a73[1], -1); } + + if (i < e8) { assertEquals(a74[0], i); } else { assertEquals(a74[0], 0); } + if (j < e8) { assertEquals(a74[1], j); } else { assertEquals(a74[1], e8-1); } + if (i < e7) { assertEquals(a75[0], i); } else { + assertEquals(a75[0], (i < e8) ? -e7 : 0); } + if (j < e7) { assertEquals(a75[1], j); } else { assertEquals(a75[1], -1); } + } +} +checkRange(); diff --git a/deps/v8/test/mjsunit/fast-literal.js b/deps/v8/test/mjsunit/fast-literal.js new file mode 100644 index 0000000000..822d90656b --- /dev/null +++ b/deps/v8/test/mjsunit/fast-literal.js @@ -0,0 +1,42 @@ +// 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 --no-inline-new --nouse-allocation-folding + +%SetAllocationTimeout(10, 0); +function f() { + return [[1, 2, 3], [1.1, 1.2, 1.3], [[], [], []]]; +} + +f(); f(); f(); +%OptimizeFunctionOnNextCall(f); +for (var i=0; i<1000; i++) { + f(); +} + + + diff --git a/deps/v8/test/mjsunit/fuzz-natives-part1.js b/deps/v8/test/mjsunit/fuzz-natives-part1.js index 8ca523cc6f..e76b9be6d4 100644 --- a/deps/v8/test/mjsunit/fuzz-natives-part1.js +++ b/deps/v8/test/mjsunit/fuzz-natives-part1.js @@ -150,8 +150,7 @@ var knownProblems = { "PushModuleContext": true, "LazyCompile": true, "LazyRecompile": true, - "ParallelRecompile": true, - "InstallRecompiledCode": true, + "ConcurrentRecompile": true, "NotifyDeoptimized": true, "NotifyStubFailure": true, "NotifyOSR": true, diff --git a/deps/v8/test/mjsunit/fuzz-natives-part2.js b/deps/v8/test/mjsunit/fuzz-natives-part2.js index ec84f35ada..0797deb18d 100644 --- a/deps/v8/test/mjsunit/fuzz-natives-part2.js +++ b/deps/v8/test/mjsunit/fuzz-natives-part2.js @@ -150,8 +150,7 @@ var knownProblems = { "PushModuleContext": true, "LazyCompile": true, "LazyRecompile": true, - "ParallelRecompile": true, - "InstallRecompiledCode": true, + "ConcurrentRecompile": true, "NotifyDeoptimized": true, "NotifyStubFailure": true, "NotifyOSR": true, @@ -165,6 +164,7 @@ var knownProblems = { "DeclareGlobals": true, "ArrayConstructor": true, "InternalArrayConstructor": true, + "SetAccessorProperty": true, "PromoteScheduledException": true, "DeleteHandleScopeExtensions": true, diff --git a/deps/v8/test/mjsunit/fuzz-natives-part3.js b/deps/v8/test/mjsunit/fuzz-natives-part3.js index 928fb4634f..9a3a883fe4 100644 --- a/deps/v8/test/mjsunit/fuzz-natives-part3.js +++ b/deps/v8/test/mjsunit/fuzz-natives-part3.js @@ -150,8 +150,7 @@ var knownProblems = { "PushModuleContext": true, "LazyCompile": true, "LazyRecompile": true, - "ParallelRecompile": true, - "InstallRecompiledCode": true, + "ConcurrentRecompile": true, "NotifyDeoptimized": true, "NotifyStubFailure": true, "NotifyOSR": true, diff --git a/deps/v8/test/mjsunit/fuzz-natives-part4.js b/deps/v8/test/mjsunit/fuzz-natives-part4.js index d47db3467e..83e00d2b66 100644 --- a/deps/v8/test/mjsunit/fuzz-natives-part4.js +++ b/deps/v8/test/mjsunit/fuzz-natives-part4.js @@ -150,8 +150,7 @@ var knownProblems = { "PushModuleContext": true, "LazyCompile": true, "LazyRecompile": true, - "ParallelRecompile": true, - "InstallRecompiledCode": true, + "ConcurrentRecompile": true, "NotifyDeoptimized": true, "NotifyStubFailure": true, "NotifyOSR": true, diff --git a/deps/v8/test/mjsunit/harmony/object-observe.js b/deps/v8/test/mjsunit/harmony/object-observe.js index 830eb1b09a..75f0ff8bb8 100644 --- a/deps/v8/test/mjsunit/harmony/object-observe.js +++ b/deps/v8/test/mjsunit/harmony/object-observe.js @@ -145,13 +145,8 @@ assertThrows(function() { notifier.performChange(1, function(){}); }, TypeError) assertThrows(function() { notifier.performChange(undefined, function(){}); }, TypeError); assertThrows(function() { notifier.performChange('foo', undefined); }, TypeError); assertThrows(function() { notifier.performChange('foo', 'bar'); }, TypeError); -var testSelf = {}; notifier.performChange('foo', function() { - assertTrue(testSelf === this); -}, testSelf); -var self = this; -notifier.performChange('foo', function() { - assertTrue(self === this); + assertEquals(undefined, this); }); var notify = notifier.notify; @@ -400,10 +395,11 @@ Thingy.prototype = { increment: function(amount) { var notifier = Object.getNotifier(this); + var self = this; notifier.performChange(Thingy.INCREMENT, function() { - this.a += amount; - this.b += amount; - }, this); + self.a += amount; + self.b += amount; + }); notifier.notify({ object: this, @@ -415,10 +411,11 @@ Thingy.prototype = { multiply: function(amount) { var notifier = Object.getNotifier(this); + var self = this; notifier.performChange(Thingy.MULTIPLY, function() { - this.a *= amount; - this.b *= amount; - }, this); + self.a *= amount; + self.b *= amount; + }); notifier.notify({ object: this, @@ -430,10 +427,11 @@ Thingy.prototype = { incrementAndMultiply: function(incAmount, multAmount) { var notifier = Object.getNotifier(this); + var self = this; notifier.performChange(Thingy.INCREMENT_AND_MULTIPLY, function() { - this.increment(incAmount); - this.multiply(multAmount); - }, this); + self.increment(incAmount); + self.multiply(multAmount); + }); notifier.notify({ object: this, @@ -505,10 +503,11 @@ RecursiveThingy.prototype = { if (!n) return; var notifier = Object.getNotifier(this); + var self = this; notifier.performChange(RecursiveThingy.MULTIPLY_FIRST_N, function() { - this[n-1] = this[n-1]*amount; - this.multiplyFirstN(amount, n-1); - }, this); + self[n-1] = self[n-1]*amount; + self.multiplyFirstN(amount, n-1); + }); notifier.notify({ object: this, @@ -557,18 +556,19 @@ DeckSuit.prototype = { shuffle: function() { var notifier = Object.getNotifier(this); + var self = this; notifier.performChange(DeckSuit.SHUFFLE, function() { - this.reverse(); - this.sort(function() { return Math.random()* 2 - 1; }); - var cut = this.splice(0, 6); - Array.prototype.push.apply(this, cut); - this.reverse(); - this.sort(function() { return Math.random()* 2 - 1; }); - var cut = this.splice(0, 6); - Array.prototype.push.apply(this, cut); - this.reverse(); - this.sort(function() { return Math.random()* 2 - 1; }); - }, this); + self.reverse(); + self.sort(function() { return Math.random()* 2 - 1; }); + var cut = self.splice(0, 6); + Array.prototype.push.apply(self, cut); + self.reverse(); + self.sort(function() { return Math.random()* 2 - 1; }); + var cut = self.splice(0, 6); + Array.prototype.push.apply(self, cut); + self.reverse(); + self.sort(function() { return Math.random()* 2 - 1; }); + }); notifier.notify({ object: this, diff --git a/deps/v8/test/mjsunit/lithium/MulI.js b/deps/v8/test/mjsunit/lithium/MulI.js new file mode 100644 index 0000000000..68588bd512 --- /dev/null +++ b/deps/v8/test/mjsunit/lithium/MulI.js @@ -0,0 +1,70 @@ +// 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: --allow-natives-syntax --no-use-osr + +function foo_smi(a, b) { + var result = a * b; + result += a * 35; + result += a * -1; + result += a * 1; + result += a * 0; + return result * a; +} + +function foo_int(a, b) { + var result = a * b; + result += a * 35; + result += a * -1; + result += a * 1; + result += a * 0; + return result * a; +} + +foo_smi(10, 5); +var r1 = foo_smi(10, 5); +%OptimizeFunctionOnNextCall(foo_smi); +var r2 = foo_smi(10, 5); + +assertEquals(r1, r2); + +foo_int(10, 21474800); +var r3 = foo_int(10, 21474800); +%OptimizeFunctionOnNextCall(foo_int); +var r4 = foo_int(10, 21474800); + +assertEquals(r3, r4); + +// Check overflow with -1 constant. +function foo2(value) { + return value * -1; +} + +foo2(-2147483600); +foo2(-2147483600); +%OptimizeFunctionOnNextCall(foo2); +assertEquals(2147483648, foo2(-2147483648)); diff --git a/deps/v8/test/mjsunit/manual-parallel-recompile.js b/deps/v8/test/mjsunit/manual-parallel-recompile.js index 84bfff1a57..0a0e61d524 100644 --- a/deps/v8/test/mjsunit/manual-parallel-recompile.js +++ b/deps/v8/test/mjsunit/manual-parallel-recompile.js @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax --expose-gc -// Flags: --parallel-recompilation --parallel-recompilation-delay=50 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=50 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -53,12 +53,12 @@ f(g(1)); assertUnoptimized(f); assertUnoptimized(g); -%OptimizeFunctionOnNextCall(f, "parallel"); -%OptimizeFunctionOnNextCall(g, "parallel"); +%OptimizeFunctionOnNextCall(f, "concurrent"); +%OptimizeFunctionOnNextCall(g, "concurrent"); f(g(2)); // Trigger optimization. -assertUnoptimized(f, "no sync"); // Not yet optimized while parallel thread +assertUnoptimized(f, "no sync"); // Not yet optimized while background thread assertUnoptimized(g, "no sync"); // is running. -assertOptimized(f, "sync"); // Optimized once we sync with the parallel thread. -assertOptimized(g, "sync"); +assertOptimized(f, "sync"); // Optimized once we sync with the +assertOptimized(g, "sync"); // background thread. diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js index 83449cc1e6..129353730c 100644 --- a/deps/v8/test/mjsunit/mjsunit.js +++ b/deps/v8/test/mjsunit/mjsunit.js @@ -100,7 +100,7 @@ var assertInstanceof; var assertUnreachable; // Assert that the function code is (not) optimized. If "no sync" is passed -// as second argument, we do not wait for the parallel optimization thread to +// as second argument, we do not wait for the concurrent optimization thread to // finish when polling for optimization status. // Only works with --allow-natives-syntax. var assertOptimized; diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 829efaf583..ee35af5a61 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -251,8 +251,5 @@ harmony/object-observe: SKIP readonly: SKIP array-feedback: SKIP -# TODO(mstarzinger): Enable once escape analysis is stabilized. -compiler/escape-analysis: SKIP - # Deopt every n garbage collections collides with the deopt every n times flag. regress/regress-2653: SKIP diff --git a/deps/v8/test/mjsunit/parallel-initial-prototype-change.js b/deps/v8/test/mjsunit/parallel-initial-prototype-change.js index 942d9abc3c..625b590fcc 100644 --- a/deps/v8/test/mjsunit/parallel-initial-prototype-change.js +++ b/deps/v8/test/mjsunit/parallel-initial-prototype-change.js @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --allow-natives-syntax -// Flags: --parallel-recompilation --parallel-recompilation-delay=100 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=100 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -42,7 +42,7 @@ assertEquals(0.5, f1(arr, 0)); assertEquals(0.5, f1(arr, 0)); // Optimized code of f1 depends on initial object and array maps. -%OptimizeFunctionOnNextCall(f1, "parallel"); +%OptimizeFunctionOnNextCall(f1, "concurrent"); // Trigger optimization in the background thread assertEquals(0.5, f1(arr, 0)); Object.prototype[1] = 1.5; // Invalidate current initial object map. diff --git a/deps/v8/test/mjsunit/parallel-invalidate-transition-map.js b/deps/v8/test/mjsunit/parallel-invalidate-transition-map.js index 716f63198c..9a5d31003f 100644 --- a/deps/v8/test/mjsunit/parallel-invalidate-transition-map.js +++ b/deps/v8/test/mjsunit/parallel-invalidate-transition-map.js @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --track-fields --track-double-fields --allow-natives-syntax -// Flags: --parallel-recompilation --parallel-recompilation-delay=100 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=100 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -46,7 +46,7 @@ function add_field(obj) { add_field(new_object()); add_field(new_object()); -%OptimizeFunctionOnNextCall(add_field, "parallel"); +%OptimizeFunctionOnNextCall(add_field, "concurrent"); var o = new_object(); // Trigger optimization in the background thread. diff --git a/deps/v8/test/mjsunit/parallel-optimize-disabled.js b/deps/v8/test/mjsunit/parallel-optimize-disabled.js index e19dbd095b..c144e649cc 100644 --- a/deps/v8/test/mjsunit/parallel-optimize-disabled.js +++ b/deps/v8/test/mjsunit/parallel-optimize-disabled.js @@ -25,11 +25,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --nodead-code-elimination --parallel-recompilation +// Flags: --nodead-code-elimination --concurrent-recompilation // Flags: --allow-natives-syntax -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -45,7 +45,7 @@ function f(x) { f(); f(); %OptimizeFunctionOnNextCall(f); -%OptimizeFunctionOnNextCall(g, "parallel"); +%OptimizeFunctionOnNextCall(g, "concurrent"); f(0); // g() is disabled for optimization on inlining attempt. // Attempt to optimize g() should not run into any assertion. assertUnoptimized(g, "sync"); diff --git a/deps/v8/test/mjsunit/regress/post-increment-close-context.js b/deps/v8/test/mjsunit/regress/post-increment-close-context.js new file mode 100644 index 0000000000..08ade10f1d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/post-increment-close-context.js @@ -0,0 +1,42 @@ +// 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: --allow-natives-syntax + +var foo = {bar: -2}; +function crash() { + return !(foo.bar++); +} +assertFalse(crash()); +assertEquals(-1, foo.bar); +%OptimizeFunctionOnNextCall(crash); +assertFalse(crash()); +assertEquals(0, foo.bar); +assertTrue(crash()); +assertEquals(1, foo.bar); +assertFalse(crash()); +assertEquals(2, foo.bar); diff --git a/deps/v8/test/mjsunit/regress/regress-2594.js b/deps/v8/test/mjsunit/regress/regress-2594.js new file mode 100644 index 0000000000..60720cb804 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2594.js @@ -0,0 +1,104 @@ +// 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. + +// In the assertions but the first, the ES5 spec actually requires 0, but +// that is arguably a spec bug, and other browsers return 1 like us. +// In ES6, all of those will presumably result in a ReferenceError. +// Our main concern with this test is that we do not crash, though. + +function f1() { + var XXX = 0 + try { throw 1 } catch (XXX) { + eval("var h = function() { return XXX }") + } + return h() +} +assertEquals(1, f1()) + +function f2() { + var XXX = 0 + try { throw 1 } catch (XXX) { + eval("function h(){ return XXX }") + } + return h() +} +assertEquals(1, f2()) + +function f3() { + var XXX = 0 + try { throw 1 } catch (XXX) { + try { throw 2 } catch (y) { + eval("function h(){ return XXX }") + } + } + return h() +} +assertEquals(1, f3()) + +function f4() { + var XXX = 0 + try { throw 1 } catch (XXX) { + with ({}) { + eval("function h(){ return XXX }") + } + } + return h() +} +assertEquals(1, f4()) + +function f5() { + var XXX = 0 + try { throw 1 } catch (XXX) { + eval('eval("function h(){ return XXX }")') + } + return h() +} +assertEquals(1, f5()) + +function f6() { + var XXX = 0 + try { throw 1 } catch (XXX) { + eval("var h = (function() { function g(){ return XXX } return g })()") + } + return h() +} +assertEquals(1, f6()) + +function f7() { + var XXX = 0 + try { throw 1 } catch (XXX) { + eval("function h() { var XXX=2; function g(){ return XXX } return g }") + } + return h()() +} +assertEquals(2, f7()) // ! + +var XXX = 0 +try { throw 1 } catch (XXX) { + eval("function h(){ return XXX }") +} +assertEquals(1, h()) diff --git a/deps/v8/test/mjsunit/regress/regress-2829.js b/deps/v8/test/mjsunit/regress/regress-2829.js new file mode 100644 index 0000000000..a046ae0395 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2829.js @@ -0,0 +1,53 @@ +// 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: --harmony-collections + +(function test1() { + var wm1 = new WeakMap(); + wm1.set(Object.prototype, 23); + assertTrue(wm1.has(Object.prototype)); + Object.freeze(Object.prototype); + + var wm2 = new WeakMap(); + var o = {}; + wm2.set(o, 42); + assertEquals(42, wm2.get(o)); +})(); + +(function test2() { + var wm1 = new WeakMap(); + var o1 = {}; + wm1.set(o1, 23); + assertTrue(wm1.has(o1)); + Object.freeze(o1); + + var wm2 = new WeakMap(); + var o2 = Object.create(o1); + wm2.set(o2, 42); + assertEquals(42, wm2.get(o2)); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-2855.js b/deps/v8/test/mjsunit/regress/regress-2855.js new file mode 100644 index 0000000000..24ec452d59 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2855.js @@ -0,0 +1,57 @@ +// 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. + +function foo(a) { + for (var i = 0; i < 100; ++i) + a = new String(a); + return a; +} + +var expected = "hello"; +for (var i = 0; i < 4; ++i) { + if (i == 2) { + String.prototype.valueOf = function() { return 42; } + expected = "42"; + } + assertEquals(expected, "" + foo("hello")); +} + +// Make sure we look up "valueOf" only once. +var count = 0; +var x = new String("foo"); +Object.defineProperty(x, "valueOf", + { get: function() { + count++; + return function() { + return 11; + } + } + }); +for (var i = 0; i < 3; i++) { + assertEquals("11", "" + x); + assertEquals(i + 1, count); +} diff --git a/deps/v8/test/mjsunit/regress/regress-convert-function-to-double.js b/deps/v8/test/mjsunit/regress/regress-convert-function-to-double.js new file mode 100644 index 0000000000..fca44f9632 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-convert-function-to-double.js @@ -0,0 +1,36 @@ +// 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. + +function f(v) { + this.func = v; +} + +var o1 = new f(f); +var d = 1.4; +var o2 = new f(d); +o2.func = 1.8; +assertEquals(1.4, d) diff --git a/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js b/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js index 3a66235684..52c32e9cc3 100644 --- a/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js +++ b/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js @@ -61,8 +61,8 @@ g(); // Mark with builtin. %OptimizeFunctionOnNextCall(f); -if (%IsParallelRecompilationSupported()) { - %OptimizeFunctionOnNextCall(g, "parallel"); +if (%IsConcurrentRecompilationSupported()) { + %OptimizeFunctionOnNextCall(g, "concurrent"); } // Activate debugger. 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 6a63da2fde..58a0b1c869 100644 --- a/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js +++ b/deps/v8/test/mjsunit/regress/regress-embedded-cons-string.js @@ -27,27 +27,27 @@ // Flags: --fold-constants --nodead-code-elimination // Flags: --expose-gc --allow-natives-syntax -// Flags: --parallel-recompilation --parallel-recompilation-delay=300 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=300 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } function test(fun) { fun(); fun(); - // Mark for parallel optimization. - %OptimizeFunctionOnNextCall(fun, "parallel"); + // Mark for concurrent optimization. + %OptimizeFunctionOnNextCall(fun, "concurrent"); //Trigger optimization in the background. fun(); //Tenure cons string. gc(); - // In the mean time, parallel recompiling is not complete yet. + // In the mean time, concurrent recompiling is not complete yet. assertUnoptimized(fun, "no sync"); - // Parallel recompilation eventually finishes and embeds tenured cons string. + // Concurrent recompilation eventually finishes, embeds tenured cons string. assertOptimized(fun, "sync"); - //Visit embedded cons string during mark compact. + // Visit embedded cons string during mark compact. gc(); } diff --git a/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js b/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js index 6605ba7858..1f896a495f 100644 --- a/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js +++ b/deps/v8/test/mjsunit/regress/regress-map-invalidation-2.js @@ -31,19 +31,24 @@ var c = { x: 2, y: 1 }; function g() { var outer = { foo: 1 }; - function f() { + function f(b, c) { var n = outer.foo; - for (var i = 0; i < 100000; i++) { + for (var i = 0; i < 10; i++) { n += c.x + outer.foo; } - var o2 = [{ x: 1.5, y: 1 }]; - return o2; + if (b) return [{ x: 1.5, y: 1 }]; + else return c; } + // Clear type feedback from previous stress runs. + %ClearFunctionTypeFeedback(f); return f; } var fun = g(); -fun(); +fun(false, c); +fun(false, c); +fun(false, c); +%OptimizeFunctionOnNextCall(fun); +fun(false, c); +fun(true, c); assertOptimized(fun); -fun(); - diff --git a/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js b/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js new file mode 100644 index 0000000000..a84a6254a0 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js @@ -0,0 +1,92 @@ +// 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. + +var extend = function (d, b) { + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; + +var Car = (function (Super) { + var Car = function () { + var self = this; + + Super.call(self); + + Object.defineProperties(self, { + "make": { + enumerable: true, + configurable: true, + get: function () { + return "Ford"; + } + } + }); + + self.copy = function () { + throw new Error("Meant to be overriden"); + }; + + return self; + }; + + extend(Car, Super); + + return Car; +}(Object)); + + +var SuperCar = ((function (Super) { + var SuperCar = function (make) { + var self = this; + + Super.call(self); + + + Object.defineProperties(self, { + "make": { + enumerable: true, + configurable: true, + get: function () { + return make; + } + } + }); + + // Convert self.copy from CONSTANT to FIELD. + self.copy = function () { }; + + return self; + }; + extend(SuperCar, Super); + return SuperCar; +})(Car)); + +assertEquals("Ford", new Car().make); +assertEquals("Bugatti", new SuperCar("Bugatti").make); +assertEquals("Lambo", new SuperCar("Lambo").make); +assertEquals("Shelby", new SuperCar("Shelby").make); 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 index 3de0217c81..8bf95ec5aa 100644 --- a/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js +++ b/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug --allow-natives-syntax -// Flags: --parallel-recompilation --parallel-recompilation-delay=100 +// Flags: --concurrent-recompilation --concurrent-recompilation-delay=100 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -57,12 +57,12 @@ var f = function() { f(); f(); -%OptimizeFunctionOnNextCall(f, "parallel"); // Mark with builtin. -f(); // Kick off parallel recompilation. +%OptimizeFunctionOnNextCall(f, "concurrent"); // Mark with builtin. +f(); // Kick off concurrent recompilation. Debug.setListener(listener); // Activate debugger. Debug.setBreakPoint(f, 2, 0); // Force deopt. -// Sync with parallel optimization thread. But no optimized code is installed. +// Sync with optimization thread. But no optimized code is installed. assertUnoptimized(f, "sync"); f(); // Trigger break point. 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 e494173856..2fad5ca0d2 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 @@ -26,10 +26,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug --allow-natives-syntax -// Flags: --parallel-recompilation-delay=300 +// Flags: --concurrent-recompilation-delay=300 -if (!%IsParallelRecompilationSupported()) { - print("Parallel recompilation is disabled. Skipping this test."); +if (!%IsConcurrentRecompilationSupported()) { + print("Concurrent recompilation is disabled. Skipping this test."); quit(); } @@ -46,8 +46,8 @@ function bar() { } foo(); -// Mark and trigger parallel optimization. -%OptimizeFunctionOnNextCall(foo, "parallel"); +// Mark and trigger concurrent optimization. +%OptimizeFunctionOnNextCall(foo, "concurrent"); foo(); // Set break points on an unrelated function. This clears both optimized @@ -56,7 +56,7 @@ foo(); Debug.setBreakPoint(bar, 0, 0); Debug.clearAllBreakPoints(); -// Install optimized code when parallel optimization finishes. +// Install optimized code when concurrent optimization finishes. // This needs to be able to deal with shared code being a builtin. assertUnoptimized(foo, "sync"); diff --git a/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js b/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js new file mode 100644 index 0000000000..e9c9fc25b4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-store-uncacheable.js @@ -0,0 +1,40 @@ +// 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: --allow-natives-syntax + +function f() { + var o = {}; + o["<abc>"] = 123; +} + +f(); +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); +assertOptimized(f); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-282736.js b/deps/v8/test/mjsunit/regress/regress-x87.js index afd9f75be4..60380a8fcb 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-282736.js +++ b/deps/v8/test/mjsunit/regress/regress-x87.js @@ -25,35 +25,24 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function funcify(obj) { - var type = typeof obj; - if (type === "object") { - var funcified = {}, foo = {}; - for (var prop in obj) { - funcified[prop] = funcify(obj[prop]); - foo[prop] = true; - } - return funcified; - } else if (type === "function") { - return obj; +// Flags: --allow-natives-syntax --noenable-sse2 + +// Regression for register allocation. +var x; +var a = new Float32Array([1,2, 4, 6, 8, 11, NaN, 1/0, -3]) +var val = 2.1*a[1]*a[0]*a[1*2*3*0]*a[1*1]*1.0; +assertEquals(8.4, val); + +// Regression for double-phis +var a; +var t = true; +var res = [2.5, 2]; +for (var i = 0; i < 2; i++) { + if (t) { + a = 1.5; } else { - return function () { return obj; }; + a = true; } + assertEquals(res[i], a+1); + t = false; } - -var obj = {}; - -obj.A = 1; -obj.B = function () { return 2; }; -obj.C = 3; -obj.D = 4; - -var funcified = funcify(obj); - -assertEquals("function", typeof funcified.A); -assertEquals(1, funcified.A()); -assertEquals("function", typeof funcified.B); -assertEquals(2, funcified.B()); -assertEquals("function", typeof funcified.C); -assertEquals("function", typeof funcified.D); -assertEquals(4, funcified.D()); diff --git a/deps/v8/test/mjsunit/smi-mul.js b/deps/v8/test/mjsunit/smi-mul.js new file mode 100644 index 0000000000..6f23d5e3a0 --- /dev/null +++ b/deps/v8/test/mjsunit/smi-mul.js @@ -0,0 +1,67 @@ +// 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: --allow-natives-syntax --noalways-opt + +function mul(a, b) { + return a * b; +} + + +mul(-1, 2); +mul(-1, 2); +%OptimizeFunctionOnNextCall(mul); +assertEquals(-2, mul(-1, 2)); +assertOptimized(mul); + +// Deopt on minus zero. +assertEquals(-0, mul(-1, 0)); +assertUnoptimized(mul); + + +function mul2(a, b) { + return a * b; +} + +mul2(-1, 2); +mul2(-1, 2); +%OptimizeFunctionOnNextCall(mul2); + +// 2^30 is a smi boundary on arm and ia32. +var two_30 = 1 << 30; +// 2^31 is a smi boundary on x64. +var two_31 = 2 * two_30; + +if (%IsValidSmi(two_31)) { + // Deopt on two_31 on x64. + assertEquals(two_31, mul2(-two_31, -1)); + assertUnoptimized(mul2); +} else { + // Deopt on two_30 on ia32. + assertEquals(two_30, mul2(-two_30, -1)); + assertUnoptimized(mul2); +} diff --git a/deps/v8/test/mjsunit/track-fields.js b/deps/v8/test/mjsunit/track-fields.js index 8b0ec29623..4da1ab5d22 100644 --- a/deps/v8/test/mjsunit/track-fields.js +++ b/deps/v8/test/mjsunit/track-fields.js @@ -211,7 +211,6 @@ assertFalse(%HaveSameMap(o18, o19)); delete o18.to_delete; delete o19.to_delete; -assertTrue(%HaveSameMap(o18, o19)); assertEquals(1, o18.field2); assertEquals(1.6, o19.field2); |