diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-06-29 17:26:51 +0200 |
commit | 33af2720f26c2b25bc7f75ce7eb454ff99db6d35 (patch) | |
tree | 9a38f0c96420edf503eebd6325dd8d2d8249f653 /deps/v8/test/mjsunit/compiler | |
parent | 6afdca885adeeeed9eef8cbb01c3d97af0bc084d (diff) | |
download | node-new-33af2720f26c2b25bc7f75ce7eb454ff99db6d35.tar.gz |
Upgrade V8 to 3.4.8
Diffstat (limited to 'deps/v8/test/mjsunit/compiler')
32 files changed, 673 insertions, 85 deletions
diff --git a/deps/v8/test/mjsunit/compiler/array-length.js b/deps/v8/test/mjsunit/compiler/array-length.js index 7adb9abb3d..462a1e7739 100644 --- a/deps/v8/test/mjsunit/compiler/array-length.js +++ b/deps/v8/test/mjsunit/compiler/array-length.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + function ArrayLength(a) { return a.length; } function Test(a0, a2, a5) { @@ -36,7 +38,12 @@ function Test(a0, a2, a5) { var a0 = []; var a2 = [1,2]; var a5 = [1,2,3,4,5]; -for (var i = 0; i < 10000000; i++) Test(a0, a2, a5); +for (var i = 0; i < 5; i++) Test(a0, a2, a5); +%OptimizeFunctionOnNextCall(ArrayLength); +%OptimizeFunctionOnNextCall(Test); +Test(a0, a2, a5); assertEquals("undefined", typeof(ArrayLength(0))); -for (var i = 0; i < 10000000; i++) Test(a0, a2, a5); +for (var i = 0; i < 5; i++) Test(a0, a2, a5); +%OptimizeFunctionOnNextCall(Test); +Test(a0, a2, a5); assertEquals(4, ArrayLength("hest")); diff --git a/deps/v8/test/mjsunit/compiler/assignment-deopt.js b/deps/v8/test/mjsunit/compiler/assignment-deopt.js index 74f185bb1c..2b00625417 100644 --- a/deps/v8/test/mjsunit/compiler/assignment-deopt.js +++ b/deps/v8/test/mjsunit/compiler/assignment-deopt.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test deopt with count operation on parameter. var max_smi = 1073741823; var o = {x:0}; @@ -44,12 +46,15 @@ o.x = "42"; assign2(o); assertEquals("421", o.x); -var s = max_smi - 10000; +var s = max_smi - 10; o.x = s; -for(var i = 0; i < 20000; i++) { +for(var i = 0; i < 20; i++) { assign2(o); + if (i == 4) { + %OptimizeFunctionOnNextCall(assign2); + } } -assertEquals(max_smi + 10000, o.x); +assertEquals(max_smi + 10, o.x); // Test deopt with count operation on keyed property. @@ -59,36 +64,48 @@ o = ["42"]; assign3(o, 0); assertEquals("421", o[0]); -var s = max_smi - 10000; +var s = max_smi - 10; o[0] = s; -for(var i = 0; i < 20000; i++) { +for(var i = 0; i < 20; i++) { assign3(o, 0); + if (i == 4) { + %OptimizeFunctionOnNextCall(assign3); + } } -assertEquals(max_smi + 10000, o[0]); +assertEquals(max_smi + 10, o[0]); -assign3(o,"0"); +assign3(o, "0"); -assertEquals(max_smi + 10001, o[0]); +assertEquals(max_smi + 11, o[0]); // Test bailout when accessing a non-existing array element. o[0] = 0; -for(var i = 0; i < 10000; i++) { +for(var i = 0; i < 5; i++) { assign3(o, 0); } -assign3(o,1); +%OptimizeFunctionOnNextCall(assign3); +assign3(o, 0); +assign3(o, 1); // Test bailout with count operation in a value context. function assign5(x,y) { return (x += 1) + y; } -for (var i = 0; i < 10000; ++i) assertEquals(4, assign5(2, 1)); +for (var i = 0; i < 5; ++i) assertEquals(4, assign5(2, 1)); +%OptimizeFunctionOnNextCall(assign5); +assertEquals(4, assign5(2, 1)); + assertEquals(4.1, assign5(2, 1.1)); assertEquals(4.1, assign5(2.1, 1)); function assign7(o,y) { return (o.x += 1) + y; } o = {x:0}; -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { o.x = 42; assertEquals(44, assign7(o, 1)); } +%OptimizeFunctionOnNextCall(assign7); +o.x = 42; +assertEquals(44, assign7(o, 1)); + o.x = 42; assertEquals(44.1, assign7(o, 1.1)); o.x = 42.1; @@ -96,10 +113,14 @@ assertEquals(44.1, assign7(o, 1)); function assign9(o,y) { return (o[0] += 1) + y; } q = [0]; -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { q[0] = 42; assertEquals(44, assign9(q, 1)); } +%OptimizeFunctionOnNextCall(assign9); +q[0] = 42; +assertEquals(44, assign9(q, 1)); + q[0] = 42; assertEquals(44.1, assign9(q, 1.1)); q[0] = 42.1; @@ -109,11 +130,16 @@ assertEquals(44.1, assign9(q, 1)); function assign10(p) { return p.x += 1 } var g1 = {x:0}; var g2 = {y:0, x:42}; -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { g1.x = 42; assertEquals(43, assign10(g1)); assertEquals(43, g1.x); } +%OptimizeFunctionOnNextCall(assign10); +g1.x = 42; +assertEquals(43, assign10(g1)); +assertEquals(43, g1.x); + assertEquals(43, assign10(g2)); assertEquals(43, g2.x); @@ -123,10 +149,14 @@ o = {x:0}; var g3 = { valueOf: function() { o.y = "bar"; return 42; }}; function assign11(p) { return p.x += 1; } -for (var i = 0; i < 10000; i++) { +for (var i = 0; i < 5; i++) { o.x = "a"; assign11(o); } +%OptimizeFunctionOnNextCall(assign11); +o.x = "a"; +assign11(o); + assertEquals("a11", assign11(o)); o.x = g3; assertEquals(43, assign11(o)); @@ -136,10 +166,14 @@ o = [0]; var g4 = { valueOf: function() { o.y = "bar"; return 42; }}; function assign12(p) { return p[0] += 1; } -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 5; i++) { o[0] = "a"; assign12(o); } +%OptimizeFunctionOnNextCall(assign12); +o[0] = "a"; +assign12(o); + assertEquals("a11", assign12(o)); o[0] = g4; assertEquals(43, assign12(o)); diff --git a/deps/v8/test/mjsunit/compiler/count-deopt.js b/deps/v8/test/mjsunit/compiler/count-deopt.js index dcd82f8774..415dadc0cf 100644 --- a/deps/v8/test/mjsunit/compiler/count-deopt.js +++ b/deps/v8/test/mjsunit/compiler/count-deopt.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test deopt with count operation on parameter. var max_smi = 1073741823; var o = {x:0}; @@ -44,12 +46,15 @@ o.x = "42"; inc2(o); assertEquals(43, o.x); -var s = max_smi - 10000; +var s = max_smi - 10; o.x = s; -for(var i = 0; i < 20000; i++) { +for(var i = 0; i < 20; i++) { inc2(o); + if (i == 4) { + %OptimizeFunctionOnNextCall(inc2); + } } -assertEquals(max_smi + 10000, o.x); +assertEquals(max_smi + 10, o.x); // Test deopt with count operation on keyed property. @@ -59,40 +64,52 @@ o = ["42"]; inc3(o, 0); assertEquals(43, o[0]); -var s = max_smi - 10000; +var s = max_smi - 10; o[0] = s; -for(var i = 0; i < 20000; i++) { +for(var i = 0; i < 20; i++) { inc3(o, 0); + if (i == 4) { + %OptimizeFunctionOnNextCall(inc3); + } } -assertEquals(max_smi + 10000, o[0]); +assertEquals(max_smi + 10, o[0]); inc3(o,"0"); -assertEquals(max_smi + 10001, o[0]); +assertEquals(max_smi + 11, o[0]); // Test bailout when accessing a non-existing array element. o[0] = 0; -for(var i = 0; i < 10000; i++) { +for(var i = 0; i < 5; i++) { inc3(o, 0); } -inc3(o,1); +%OptimizeFunctionOnNextCall(inc3); +inc3(o, 0); +inc3(o, 1); // Test bailout with count operation in a value context. function inc4(x,y) { return (x++) + y; } -for (var i = 0; i < 100000; ++i) assertEquals(3, inc4(2, 1)); +for (var i = 0; i < 5; ++i) assertEquals(3, inc4(2, 1)); +%OptimizeFunctionOnNextCall(inc4); +inc4(2, 1); assertEquals(3.1, inc4(2, 1.1)); function inc5(x,y) { return (++x) + y; } -for (var i = 0; i < 100000; ++i) assertEquals(4, inc5(2, 1)); +for (var i = 0; i < 5; ++i) assertEquals(4, inc5(2, 1)); +%OptimizeFunctionOnNextCall(inc5); +assertEquals(4, inc5(2, 1)); assertEquals(4.1, inc5(2, 1.1)); assertEquals(4.1, inc5(2.1, 1)); function inc6(o,y) { return (o.x++) + y; } o = {x:0}; -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { o.x = 42; assertEquals(43, inc6(o, 1)); } +%OptimizeFunctionOnNextCall(inc6); +o.x = 42; +assertEquals(43, inc6(o, 1)); o.x = 42; assertEquals(43.1, inc6(o, 1.1)); o.x = 42.1; @@ -100,10 +117,13 @@ assertEquals(43.1, inc6(o, 1)); function inc7(o,y) { return (++o.x) + y; } o = {x:0}; -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { o.x = 42; assertEquals(44, inc7(o, 1)); } +%OptimizeFunctionOnNextCall(inc7); +o.x = 42; +assertEquals(44, inc7(o, 1)); o.x = 42; assertEquals(44.1, inc7(o, 1.1)); o.x = 42.1; @@ -111,10 +131,13 @@ assertEquals(44.1, inc7(o, 1)); function inc8(o,y) { return (o[0]++) + y; } var q = [0]; -for (var i = 0; i < 100000; ++i) { +for (var i = 0; i < 5; ++i) { q[0] = 42; assertEquals(43, inc8(q, 1)); } +%OptimizeFunctionOnNextCall(inc8); +q[0] = 42; +assertEquals(43, inc8(q, 1)); q[0] = 42; assertEquals(43.1, inc8(q, 1.1)); q[0] = 42.1; @@ -122,10 +145,13 @@ assertEquals(43.1, inc8(q, 1)); function inc9(o,y) { return (++o[0]) + y; } q = [0]; -for (var i = 0; i < 100000; ++i) { +for (var i = 0; i < 5; ++i) { q[0] = 42; assertEquals(44, inc9(q, 1)); } +%OptimizeFunctionOnNextCall(inc9); +q[0] = 42; +assertEquals(44, inc9(q, 1)); q[0] = 42; assertEquals(44.1, inc9(q, 1.1)); q[0] = 42.1; @@ -135,11 +161,15 @@ assertEquals(44.1, inc9(q, 1)); function inc10(p) { return p.x++ } var g1 = {x:0}; var g2 = {y:0, x:42} -for (var i = 0; i < 10000; ++i) { +for (var i = 0; i < 5; ++i) { g1.x = 42; assertEquals(42, inc10(g1)); assertEquals(43, g1.x); } +%OptimizeFunctionOnNextCall(inc10); +g1.x = 42; +assertEquals(42, inc10(g1)); +assertEquals(43, g1.x); assertEquals(42, inc10(g2)); assertEquals(43, g2.x); diff --git a/deps/v8/test/mjsunit/compiler/deopt-args.js b/deps/v8/test/mjsunit/compiler/deopt-args.js index 780e2a24a0..17c397c152 100644 --- a/deps/v8/test/mjsunit/compiler/deopt-args.js +++ b/deps/v8/test/mjsunit/compiler/deopt-args.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + function g(x) { return x.f(0,1,2); } @@ -35,9 +37,11 @@ function f(a,b,c) { var object = { }; object.f = f; -for (var i = 0; i < 10000000; i++) { +for (var i = 0; i < 5; i++) { assertEquals(42, g(object)); } +%OptimizeFunctionOnNextCall(g); +g(object); object.f = function(a,b,c) { return 87; }; assertEquals(87, g(object)); diff --git a/deps/v8/test/mjsunit/compiler/eval-introduced-closure.js b/deps/v8/test/mjsunit/compiler/eval-introduced-closure.js new file mode 100644 index 0000000000..550c7c30ee --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/eval-introduced-closure.js @@ -0,0 +1,95 @@ +// 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. + +// Test that functions introduced by eval work both when there are +// strict mode and non-strict mode eval in scopes. + +// Flags: --allow-natives-syntax + +var x = 27; + +function f() { return x; } + +assertEquals(27, f()); + +function do_eval(str) { + "use strict"; + return eval(str); +} + +var eval_f = do_eval('(' + f + ')'); +for (var i = 0; i < 5; i++) assertEquals(27, eval_f()); +%OptimizeFunctionOnNextCall(eval_f); +assertEquals(27, eval_f()); + +function do_eval_local(str) { + "use strict"; + var x = 42; + return eval(str); +} + +eval_f = do_eval_local('(' + f + ')'); +for (var i = 0; i < 5; i++) assertEquals(42, eval_f()); +%OptimizeFunctionOnNextCall(eval_f); +assertEquals(42, eval_f()); + +function do_eval_with_other_eval_call(str) { + "use strict"; + var f = eval(str); + eval('var x = 1'); + return f; +} + +eval_f = do_eval_with_other_eval_call('(' + f + ')'); +for (var i = 0; i < 5; i++) assertEquals(27, eval_f()); +%OptimizeFunctionOnNextCall(eval_f); +assertEquals(27, eval_f()); + +function test_non_strict_outer_eval() { + function strict_eval(str) { "use strict"; return eval(str); } + var eval_f = strict_eval('(' + f + ')'); + for (var i = 0; i < 5; i++) assertEquals(27, eval_f()); + %OptimizeFunctionOnNextCall(eval_f); + assertEquals(27, eval_f()); + eval("var x = 3"); + assertEquals(3, eval_f()); +} + +test_non_strict_outer_eval(); + +function test_strict_outer_eval() { + "use strict"; + function strict_eval(str) { "use strict"; return eval(str); } + var eval_f = strict_eval('(' + f + ')'); + for (var i = 0; i < 5; i++) assertEquals(27, eval_f()); + %OptimizeFunctionOnNextCall(eval_f); + assertEquals(27, eval_f()); + eval("var x = 3"); + assertEquals(27, eval_f()); +} + +test_non_strict_outer_eval(); diff --git a/deps/v8/test/mjsunit/compiler/global-accessors.js b/deps/v8/test/mjsunit/compiler/global-accessors.js new file mode 100644 index 0000000000..bd031a8329 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/global-accessors.js @@ -0,0 +1,47 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This test tests that no bailouts are missing by not hitting asserts in debug +// mode. + +test_count_operation() +test_compound_assignment() + +function f() {} +function test_count_operation() +{ + this.__defineSetter__('x', f); + this.__defineGetter__('x', f); + x = x++; +} + +function test_compound_assignment() +{ + this.__defineSetter__('y', f); + this.__defineGetter__('y', f); + y += y; +} diff --git a/deps/v8/test/mjsunit/compiler/inline-arguments.js b/deps/v8/test/mjsunit/compiler/inline-arguments.js new file mode 100644 index 0000000000..532fc26a17 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/inline-arguments.js @@ -0,0 +1,37 @@ +// 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: --allow-natives-syntax + +// Test inlining functions that use arguments. +function f() { return g(1, 2, 3); } + +function g(x, y, z) { return %_ArgumentsLength(); } + +for (var i = 0; i < 5; ++i) f(); +%OptimizeFunctionOnNextCall(f); +assertEquals(3, f()); diff --git a/deps/v8/test/mjsunit/compiler/inline-compare.js b/deps/v8/test/mjsunit/compiler/inline-compare.js index 6efe154247..d97dce2e96 100644 --- a/deps/v8/test/mjsunit/compiler/inline-compare.js +++ b/deps/v8/test/mjsunit/compiler/inline-compare.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that we can inline a function that returns the result of // a compare operation. function TestInlineCompare(o) { @@ -42,5 +44,7 @@ function TestInlineCompare(o) { var o = {}; o.f = function() { return 0 === 1; }; -for (var i = 0; i < 10000000; i++) TestInlineCompare(o); +for (var i = 0; i < 5; i++) TestInlineCompare(o); +%OptimizeFunctionOnNextCall(TestInlineCompare); +TestInlineCompare(o); TestInlineCompare({f: o.f}); diff --git a/deps/v8/test/mjsunit/compiler/inline-global-access.js b/deps/v8/test/mjsunit/compiler/inline-global-access.js index 379517343b..b52652a764 100644 --- a/deps/v8/test/mjsunit/compiler/inline-global-access.js +++ b/deps/v8/test/mjsunit/compiler/inline-global-access.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that we can inline a function that returns the result of a // global variable load. var GLOBAL; @@ -45,5 +47,7 @@ function TestInlineGlobalLoad(o) { var o = {}; o.f = function() { return GLOBAL; }; -for (var i = 0; i < 10000000; i++) TestInlineGlobalLoad(o); +for (var i = 0; i < 5; i++) TestInlineGlobalLoad(o); +%OptimizeFunctionOnNextCall(TestInlineGlobalLoad); +TestInlineGlobalLoad(o); TestInlineGlobalLoad({f: o.f}); diff --git a/deps/v8/test/mjsunit/compiler/inline-param.js b/deps/v8/test/mjsunit/compiler/inline-param.js index 8e0933a399..8fa80088fe 100644 --- a/deps/v8/test/mjsunit/compiler/inline-param.js +++ b/deps/v8/test/mjsunit/compiler/inline-param.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that we can inline a call with a parameter. function TestInlineOneParam(o, p) { // Effect context. @@ -42,7 +44,9 @@ function TestInlineOneParam(o, p) { var obj = {x:42}; var o1 = {}; o1.f = function(o) { return o.x; }; -for (var i = 0; i < 10000; i++) TestInlineOneParam(o1, obj); +for (var i = 0; i < 5; i++) TestInlineOneParam(o1, obj); +%OptimizeFunctionOnNextCall(TestInlineOneParam); +TestInlineOneParam(o1, obj); TestInlineOneParam({f: o1.f}, {x:42}); @@ -76,5 +80,7 @@ function TestInlineTwoParams(o, p) { var o2 = {}; o2.h = function(i, j) { return i < j; }; -for (var i = 0; i < 10000; i++) TestInlineTwoParams(o2, 42); +for (var i = 0; i < 5; i++) TestInlineTwoParams(o2, 42); +%OptimizeFunctionOnNextCall(TestInlineTwoParams); +TestInlineTwoParams(o2, 42); TestInlineTwoParams({h: o2.h}, 42); diff --git a/deps/v8/test/mjsunit/compiler/inline-throw.js b/deps/v8/test/mjsunit/compiler/inline-throw.js new file mode 100644 index 0000000000..e3aab39efa --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/inline-throw.js @@ -0,0 +1,69 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --allow-natives-syntax + +// Test inlined functions contain throw. +function doThrow() { + throw "uha"; +} + +function f(x) { + if (x == 42) throw doThrow(); + if (x == 43) throw "wow"; + return x == 0; +} + +function g(x) { + return f(x); +} + +for (var i = 0; i < 5; i++) g(0); +%OptimizeFunctionOnNextCall(g); +assertEquals(true, g(0)); + +try { + g(42); +} catch(e) { + assertEquals("uha", e); +} + +// Test inlining in a test context. +function h(x) { + return f(x) ? "yes" : "no"; +} + +for (var i = 0; i < 5; i++) h(0); +%OptimizeFunctionOnNextCall(h); +assertEquals("yes", h(0)); + +try { + h(43); +} catch(e) { + assertEquals("wow", e); +} + diff --git a/deps/v8/test/mjsunit/compiler/inline-two.js b/deps/v8/test/mjsunit/compiler/inline-two.js index 30f579dfae..68372a979e 100644 --- a/deps/v8/test/mjsunit/compiler/inline-two.js +++ b/deps/v8/test/mjsunit/compiler/inline-two.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that we can inline a function that calls another function. function TestInlineX(o) { // Effect context. @@ -42,7 +44,9 @@ function TestInlineX(o) { var o2 = {}; o2.size = function() { return 42; } o2.g = function() { return this.size(); }; -for (var i = 0; i < 10000; i++) TestInlineX(o2); +for (var i = 0; i < 5; i++) TestInlineX(o2); +%OptimizeFunctionOnNextCall(TestInlineX); +TestInlineX(o2); TestInlineX({g: o2.g, size:o2.size}); @@ -65,7 +69,9 @@ obj.foo = function() { return 42; } var o3 = {}; o3.v = obj; o3.h = function() { return this.v.foo(); }; -for (var i = 0; i < 10000; i++) TestInlineX2(o3); +for (var i = 0; i < 5; i++) TestInlineX2(o3); +%OptimizeFunctionOnNextCall(TestInlineX2); +TestInlineX2(o3); TestInlineX2({h: o3.h, v:obj}); @@ -89,5 +95,7 @@ var o3 = {}; o3.v = obj; o3.f = function() { return this.v; } o3.h = function() { return this.f().g(); }; -for (var i = 0; i < 10000; i++) TestInlineFG(o3); +for (var i = 0; i < 5; i++) TestInlineFG(o3); +%OptimizeFunctionOnNextCall(TestInlineFG); +TestInlineFG(o3); TestInlineFG({h: o3.h, f: o3.f, v:obj}); diff --git a/deps/v8/test/mjsunit/compiler/logical-and.js b/deps/v8/test/mjsunit/compiler/logical-and.js index 1d31a0a513..783edb6a79 100644 --- a/deps/v8/test/mjsunit/compiler/logical-and.js +++ b/deps/v8/test/mjsunit/compiler/logical-and.js @@ -46,8 +46,8 @@ assertFalse(AndBB(1, 0)); assertFalse(AndBB(0, 1)); assertFalse(AndBB(1, 1)); -assertFalse(AndBN(0, 0)); -assertTrue(AndBN(0, 1)); +assertEquals(0, AndBN(0, 0)); +assertEquals(1, AndBN(0, 1)); assertFalse(AndBN(1, 0)); assertEquals(1, AndBN(0, 1)); assertEquals(2, AndBN(0, 2)); diff --git a/deps/v8/test/mjsunit/compiler/optimized-function-calls.js b/deps/v8/test/mjsunit/compiler/optimized-function-calls.js index 1b5f3b0353..c3e69d71f5 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-function-calls.js +++ b/deps/v8/test/mjsunit/compiler/optimized-function-calls.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: --expose-gc +// Flags: --allow-natives-syntax --expose-gc function f() { gc(); @@ -48,7 +48,9 @@ delete object.x; function call_f(o) { return o.f(); } -for (var i = 0; i < 10000000; i++) call_f(object); +for (var i = 0; i < 5; i++) call_f(object); +%OptimizeFunctionOnNextCall(call_f); +call_f(object); // Check that nested global function calls work. diff --git a/deps/v8/test/mjsunit/compiler/pic.js b/deps/v8/test/mjsunit/compiler/pic.js index a0b5d8f968..f5b136ce91 100644 --- a/deps/v8/test/mjsunit/compiler/pic.js +++ b/deps/v8/test/mjsunit/compiler/pic.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + function GetX(o) { return o.x; } function CallF(o) { return o.f(); } function SetX(o) { o.x = 42; } @@ -53,11 +55,15 @@ o1.f = o2.f = o3.f = function() { return 99; } // Run the test until we're fairly sure we've optimized the // polymorphic property access. -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 5; i++) { Test(o1); Test(o2); Test(o3); } +%OptimizeFunctionOnNextCall(Test); +Test(o1); +Test(o2); +Test(o3); // Make sure that the following doesn't crash. GetX(0); diff --git a/deps/v8/test/mjsunit/compiler/property-calls.js b/deps/v8/test/mjsunit/compiler/property-calls.js index 3366971e8b..ad5ca81bfd 100644 --- a/deps/v8/test/mjsunit/compiler/property-calls.js +++ b/deps/v8/test/mjsunit/compiler/property-calls.js @@ -25,12 +25,16 @@ // (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(o) { return o.g(); } function g() { return 42; } var object = { }; object.g = g; -for (var i = 0; i < 10000000; i++) f(object); +for (var i = 0; i < 5; i++) f(object); +%OptimizeFunctionOnNextCall(f); +f(object); assertEquals(42, f(object)); object = { g: function() { return 87; } }; diff --git a/deps/v8/test/mjsunit/compiler/property-refs.js b/deps/v8/test/mjsunit/compiler/property-refs.js index 3f6f7937c3..6f1f19f0a6 100644 --- a/deps/v8/test/mjsunit/compiler/property-refs.js +++ b/deps/v8/test/mjsunit/compiler/property-refs.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + function Load(o) { return o.outer.x | o.outer.inner.y; } @@ -45,7 +47,9 @@ function LoadXY(x, y) { return Load(object); } -for (var i = 0; i < 10000; i++) LoadXY(i, i); +for (var i = 0; i < 5; i++) LoadXY(i, i); +%OptimizeFunctionOnNextCall(LoadXY); +LoadXY(6, 6); assertEquals(42 | 87, LoadXY(42, 87)); assertEquals(42 | 87, LoadXY(42, 87)); assertEquals(42 | 99, LoadXY(42, "99")); diff --git a/deps/v8/test/mjsunit/compiler/property-stores.js b/deps/v8/test/mjsunit/compiler/property-stores.js index 0dec82ad20..4ffac07ad0 100644 --- a/deps/v8/test/mjsunit/compiler/property-stores.js +++ b/deps/v8/test/mjsunit/compiler/property-stores.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + var a = 42; var obj = {x: 0, @@ -33,11 +35,17 @@ var obj = {x: 0, h: function() { this.x = a; }}; var i; -for (i = 0; i < 10000; i++) { obj.f(); } +for (i = 0; i < 5; i++) { obj.f(); } +%OptimizeFunctionOnNextCall(obj.f); +obj.f(); assertEquals(7, obj.x); -for (i = 0; i < 10000; i++) { obj.g(); } +for (i = 0; i < 5; i++) { obj.g(); } +%OptimizeFunctionOnNextCall(obj.g); +obj.g(); assertEquals(43, obj.x); -for (i = 0; i < 10000; i++) { obj.h(); } +for (i = 0; i < 5; i++) { obj.h(); } +%OptimizeFunctionOnNextCall(obj.h); +obj.h(); assertEquals(42, obj.x); diff --git a/deps/v8/test/mjsunit/compiler/recursive-deopt.js b/deps/v8/test/mjsunit/compiler/recursive-deopt.js index 366f59ae1b..c921ade65a 100644 --- a/deps/v8/test/mjsunit/compiler/recursive-deopt.js +++ b/deps/v8/test/mjsunit/compiler/recursive-deopt.js @@ -25,6 +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 function f(n) { // Force deopt in both leaf case and when returning. To make @@ -34,15 +35,11 @@ function f(n) { return f(n - 1) << one; } -function RunTests() { - assertEquals(1 << 1, f(0)); - assertEquals(1 << 2, f(1)); - assertEquals(1 << 5, f(4)); -} - var one = 1; -for (var i = 0; i < 1000000; i++) RunTests(); +for (var i = 0; i < 5; i++) assertEquals(1 << 5, f(4)); +%OptimizeFunctionOnNextCall(f); +assertEquals(1 << 5, f(4)); var one = { valueOf: function() { return 1; } }; -for (var j = 0; j < 100000; j++) RunTests(); +assertEquals(1 << 5, f(4)); diff --git a/deps/v8/test/mjsunit/compiler/regress-1085.js b/deps/v8/test/mjsunit/compiler/regress-1085.js index 5d787a45e6..cea587f500 100644 --- a/deps/v8/test/mjsunit/compiler/regress-1085.js +++ b/deps/v8/test/mjsunit/compiler/regress-1085.js @@ -25,11 +25,14 @@ // (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 // Test correct checks for negative zero. // This test relies on specific type feedback for Math.min. function f(x) { return 1 / Math.min(1, x); } -for (var i=0; i<1000000; i++) f(1); +for (var i = 0; i < 5; ++i) f(1); +%OptimizeFunctionOnNextCall(f); +%OptimizeFunctionOnNextCall(Math.min); assertEquals(-Infinity, f(-0)); diff --git a/deps/v8/test/mjsunit/compiler/regress-1394.js b/deps/v8/test/mjsunit/compiler/regress-1394.js new file mode 100644 index 0000000000..b1ce19267f --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-1394.js @@ -0,0 +1,59 @@ +// 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: --allow-natives-syntax + +function f(x) { + var ret = -1; + switch(x){ + default: + case 0: + ret = 0; + break; + case 1: + ret = 1; + break; + case 2: + ret = 2; + break; + case 3: + ret = 3; + break; + case 4: + ret = 4; + break; + } + return ret; +}; + +for (var i = 0; i < 3; i++) assertEquals(i, f(i)); + +%OptimizeFunctionOnNextCall(f); + +assertEquals(0, f(0)); +assertEquals(1, f(1)); + diff --git a/deps/v8/test/mjsunit/compiler/regress-3218915.js b/deps/v8/test/mjsunit/compiler/regress-3218915.js index d27c319e41..dfce815afb 100644 --- a/deps/v8/test/mjsunit/compiler/regress-3218915.js +++ b/deps/v8/test/mjsunit/compiler/regress-3218915.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Regression test for failure to deoptimize properly when the most recent // side effect occurred in a comma expression in an effect context. @@ -40,7 +42,9 @@ function observe(x, y) { try {} finally {} return x; } function test(x) { return observe(this, ((0, side_effect()), x + 1)); } // Run test enough times to get it optimized. -for (var i = 0; i < 1000000; ++i) test(0); +for (var i = 0; i < 5; ++i) test(0); +%OptimizeFunctionOnNextCall(test); +test(0); // Force test to deopt. If it behaves normally, it should return the global // object. If the value of the call to side_effect() is lingering after the diff --git a/deps/v8/test/mjsunit/compiler/regress-closures-with-eval.js b/deps/v8/test/mjsunit/compiler/regress-closures-with-eval.js index 507d74f33e..57afb1643e 100644 --- a/deps/v8/test/mjsunit/compiler/regress-closures-with-eval.js +++ b/deps/v8/test/mjsunit/compiler/regress-closures-with-eval.js @@ -25,12 +25,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Verifies that closures in presence of eval work fine. function withEval(expr, filter) { function walk(v) { for (var i in v) { for (var i in v) {} } + %OptimizeFunctionOnNextCall(filter); return filter(v); } @@ -46,6 +49,8 @@ function makeTagInfoJSON(n) { var expr = '([' + makeTagInfoJSON(128).join(', ') + '])' -for (var n = 0; n < 300; n++) { +for (var n = 0; n < 5; n++) { withEval(expr, function(a) { return a; }); } +%OptimizeFunctionOnNextCall(withEval); +withEval(expr, function(a) { return a; });
\ No newline at end of file diff --git a/deps/v8/test/mjsunit/compiler/regress-const.js b/deps/v8/test/mjsunit/compiler/regress-const.js new file mode 100644 index 0000000000..aa55d0fd3a --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-const.js @@ -0,0 +1,68 @@ +// 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: --allow-natives-syntax + +// Test const initialization and assignments. +function f() { + var x = 42; + while (true) { + const y = x; + if (--x == 0) return y; + } +} + +function g() { + const x = 42; + x += 1; + return x; +} + +for (var i = 0; i < 5; i++) { + f(); + g(); +} + +%OptimizeFunctionOnNextCall(f); +%OptimizeFunctionOnNextCall(g); + +assertEquals(42, f()); +assertEquals(42, g()); + + +function h(a, b) { + var r = a + b; + const X = 42; + return r + X; +} + +for (var i = 0; i < 5; i++) h(1,2); + +%OptimizeFunctionOnNextCall(h); + +assertEquals(45, h(1,2)); +assertEquals("foo742", h("foo", 7)); diff --git a/deps/v8/test/mjsunit/compiler/regress-intoverflow.js b/deps/v8/test/mjsunit/compiler/regress-intoverflow.js index d3842f1c23..063a376148 100644 --- a/deps/v8/test/mjsunit/compiler/regress-intoverflow.js +++ b/deps/v8/test/mjsunit/compiler/regress-intoverflow.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test overflow checks in optimized code. function testMul(a, b) { a *= 2; @@ -34,7 +36,8 @@ function testMul(a, b) { } } -for (var i=0; i<1000000; i++) testMul(0,0); +for (var i=0; i<5; i++) testMul(0,0); +%OptimizeFunctionOnNextCall(testMul); assertEquals(4611686018427388000, testMul(-0x40000000, -0x40000000)); function testAdd(a, b) { @@ -45,7 +48,8 @@ function testAdd(a, b) { } } -for (var i=0; i<1000000; i++) testAdd(0,0); +for (var i=0; i<5; i++) testAdd(0,0); +%OptimizeFunctionOnNextCall(testAdd); assertEquals(-4294967296, testAdd(-0x40000000, -0x40000000)); @@ -58,5 +62,6 @@ function testSub(a, b) { } } -for (var i=0; i<1000000; i++) testSub(0,0); +for (var i=0; i<5; i++) testSub(0,0); +%OptimizeFunctionOnNextCall(testSub); assertEquals(-2147483650, testSub(-0x40000000, 1)); diff --git a/deps/v8/test/mjsunit/compiler/regress-loadfield.js b/deps/v8/test/mjsunit/compiler/regress-loadfield.js index a202891900..a3da156e3b 100644 --- a/deps/v8/test/mjsunit/compiler/regress-loadfield.js +++ b/deps/v8/test/mjsunit/compiler/regress-loadfield.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Regression test for GVN on field loads. function bar() {} @@ -58,8 +60,10 @@ a.p9 = ""; a.p10 = ""; a.p11 = ""; a.foo = "foo"; -for (var i = 0; i < 100000; i++) { +for (var i = 0; i < 5; i++) { test(a); } +%OptimizeFunctionOnNextCall(test); +test(a); test(""); diff --git a/deps/v8/test/mjsunit/compiler/regress-max-locals-for-osr.js b/deps/v8/test/mjsunit/compiler/regress-max-locals-for-osr.js new file mode 100644 index 0000000000..cc150edfd7 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-max-locals-for-osr.js @@ -0,0 +1,43 @@ +// 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: --allow-natives-syntax + +var limit = %RunningInSimulator() ? 10000 : 10000000; + +function f() { + var a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, + a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, + a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, + a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, + a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, + a61, a62, a63, a64; + for (a1 = 0; a1 < limit; a1++) a2 = 23; +} + +f(); diff --git a/deps/v8/test/mjsunit/compiler/regress-max.js b/deps/v8/test/mjsunit/compiler/regress-max.js index 94c543a6a5..ee2fd587ec 100644 --- a/deps/v8/test/mjsunit/compiler/regress-max.js +++ b/deps/v8/test/mjsunit/compiler/regress-max.js @@ -25,10 +25,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Test Math.max with negative zero as input. -function f(x, y) { return Math.max(x, y) } +// Flags: --allow-natives-syntax -for (var i = 0; i < 1000000; i++) f(0, 0); +// Test Math.max with negative zero as input. +for (var i = 0; i < 5; i++) Math.max(0, 0); +%OptimizeFunctionOnNextCall(Math.max); +Math.max(0, 0); -var r = f(-0, -0); +var r = Math.max(-0, -0); assertEquals(-Infinity, 1 / r); diff --git a/deps/v8/test/mjsunit/compiler/regress-stacktrace-methods.js b/deps/v8/test/mjsunit/compiler/regress-stacktrace-methods.js index 4900ccf8d2..4d2872793d 100644 --- a/deps/v8/test/mjsunit/compiler/regress-stacktrace-methods.js +++ b/deps/v8/test/mjsunit/compiler/regress-stacktrace-methods.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test stack traces with method calls. function Hest() {} function Svin() {} @@ -39,9 +41,12 @@ var o = new Hest(); var s = new Svin(); var v = 0; -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 5; i++) { o.one(s); } +%OptimizeFunctionOnNextCall(Hest.prototype.one); +%OptimizeFunctionOnNextCall(Hest.prototype.three); +o.one(s); v = 42; @@ -57,8 +62,8 @@ try { assertTrue(p1 != -1); assertTrue(p3 < p2); assertTrue(p2 < p1); - assertTrue(stack.indexOf("36:56") != -1); - assertTrue(stack.indexOf("32:51") != -1); - assertTrue(stack.indexOf("34:38") != -1); - assertTrue(stack.indexOf("49:5") != -1); + assertTrue(stack.indexOf("38:56") != -1); + assertTrue(stack.indexOf("34:51") != -1); + assertTrue(stack.indexOf("36:38") != -1); + assertTrue(stack.indexOf("54:5") != -1); } diff --git a/deps/v8/test/mjsunit/compiler/simple-deopt.js b/deps/v8/test/mjsunit/compiler/simple-deopt.js index 8befd9f6e9..7f985acc76 100644 --- a/deps/v8/test/mjsunit/compiler/simple-deopt.js +++ b/deps/v8/test/mjsunit/compiler/simple-deopt.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + function f(x) { return ~x; } @@ -59,7 +61,9 @@ obj.g = g; function k(o) { return o.g(); } -for (var i = 0; i < 1000000; i++) k(obj); +for (var i = 0; i < 5; i++) k(obj); +%OptimizeFunctionOnNextCall(k); +k(obj); assertEquals(42, k(obj)); assertEquals(87, k({g: function() { return 87; }})); @@ -88,9 +92,11 @@ assertEquals('lit[42]', LiteralToStack(42)); var str = "abc"; var r; function CallCharAt(n) { return str.charAt(n); } -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 5; i++) { r = CallCharAt(0); } +%OptimizeFunctionOnNextCall(CallCharAt); +r = CallCharAt(0); assertEquals("a", r); diff --git a/deps/v8/test/mjsunit/compiler/simple-inlining.js b/deps/v8/test/mjsunit/compiler/simple-inlining.js index 219580f088..8bd37eae20 100644 --- a/deps/v8/test/mjsunit/compiler/simple-inlining.js +++ b/deps/v8/test/mjsunit/compiler/simple-inlining.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that we can inline a function that returns a constant. function TestInlineConstant(o) { // Effect context. @@ -41,7 +43,9 @@ function TestInlineConstant(o) { var o1 = {}; o1.f = function() { return 42; }; -for (var i = 0; i < 10000; i++) TestInlineConstant(o1); +for (var i = 0; i < 5; i++) TestInlineConstant(o1); +%OptimizeFunctionOnNextCall(TestInlineConstant); +TestInlineConstant(o1); TestInlineConstant({f: o1.f}); @@ -61,7 +65,9 @@ function TestInlineThis(o) { var o2 = {}; o2.g = function() { return this; }; -for (var i = 0; i < 10000; i++) TestInlineThis(o2); +for (var i = 0; i < 5; i++) TestInlineThis(o2); +%OptimizeFunctionOnNextCall(TestInlineThis); +TestInlineThis(o2); TestInlineThis({g: o2.g}); @@ -81,7 +87,9 @@ function TestInlineThisX(o) { var o3 = {y:0,x:42}; o3.h = function() { return this.x; }; -for (var i = 0; i < 10000; i++) TestInlineThisX(o3); +for (var i = 0; i < 5; i++) TestInlineThisX(o3); +%OptimizeFunctionOnNextCall(TestInlineThisX); +TestInlineThisX(o3); TestInlineThisX({h: o3.h, x:42}); @@ -101,7 +109,9 @@ function TestInlineThisXLength(o) { var o4 = {x:[1,2,3]}; o4.h = function() { return this.x.length; }; -for (var i = 0; i < 10000; i++) TestInlineThisXLength(o4); +for (var i = 0; i < 5; i++) TestInlineThisXLength(o4); +%OptimizeFunctionOnNextCall(TestInlineThisXLength); +TestInlineThisXLength(o4); TestInlineThisXLength({h: o4.h, x:[1,2,3]}); @@ -122,7 +132,9 @@ function TestInlineThisXY(o) { var o6 = {y:42} var o5 = {e:o6}; o5.h = function() { return this.e.y; }; -for (var i = 0; i < 10000; i++) TestInlineThisXY(o5); +for (var i = 0; i < 5; i++) TestInlineThisXY(o5); +%OptimizeFunctionOnNextCall(TestInlineThisXY); +TestInlineThisXY(o5); TestInlineThisXY({h: o5.h, e:o6}); @@ -142,5 +154,7 @@ function TestInlineThisX0(o) { var o7 = {x:[42,43,44]}; o7.foo = function() { return this.x[0]; }; -for (var i = 0; i < 10000; i++) TestInlineThisX0(o7); +for (var i = 0; i < 5; i++) TestInlineThisX0(o7); +%OptimizeFunctionOnNextCall(TestInlineThisX0); +TestInlineThisX0(o7); TestInlineThisX0({foo: o7.foo, x:[42,0,0]}); diff --git a/deps/v8/test/mjsunit/compiler/switch-bailout.js b/deps/v8/test/mjsunit/compiler/switch-bailout.js index 8011d44ab0..084074e0b0 100644 --- a/deps/v8/test/mjsunit/compiler/switch-bailout.js +++ b/deps/v8/test/mjsunit/compiler/switch-bailout.js @@ -25,6 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Flags: --allow-natives-syntax + // Test that bailing out of the optimized compilation doesn't mess with // the labels in the AST. function f(x) { @@ -35,5 +37,7 @@ function f(x) { return 99; } -for (var i = 0; i < 10000; i++) f("foo"); +for (var i = 0; i < 5; i++) f("foo"); +%OptimizeFunctionOnNextCall(f); +f("foo"); assertEquals(42, f("bar")); |