From 8b917d4d9656553a18be600524f1b183ce6d1494 Mon Sep 17 00:00:00 2001 From: "karlklose@chromium.org" Date: Tue, 3 May 2011 13:53:08 +0000 Subject: [PATCH] Replace long running loops by OptimizeFunctionOnNextCall in some tests that are often timing out on ARM. Review URL: http://codereview.chromium.org/6910022 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7765 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/mjsunit/closures.js | 8 +++++--- test/mjsunit/compiler/regress-closures-with-eval.js | 7 ++++++- test/mjsunit/compiler/regress-intoverflow.js | 11 ++++++++--- test/mjsunit/regress/regress-1099.js | 7 ++++++- test/mjsunit/strict-mode-opt.js | 7 ++++++- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/test/mjsunit/closures.js b/test/mjsunit/closures.js index ee487a4b03..7c1197107f 100644 --- a/test/mjsunit/closures.js +++ b/test/mjsunit/closures.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 + function runner(f, expected) { - for (var i = 0; i < 1000000; i++) { - assertEquals(expected, f.call(this)); - } + assertEquals(expected, f.call(this)); } function test(n) { @@ -36,6 +36,8 @@ function test(n) { var result = n * 2 + arguments.length; return result; } + for (var i = 0; i < 5; ++i) MyFunction(); + %OptimizeFunctionOnNextCall(MyFunction) runner(MyFunction, n * 2); } diff --git a/test/mjsunit/compiler/regress-closures-with-eval.js b/test/mjsunit/compiler/regress-closures-with-eval.js index 507d74f33e..57afb1643e 100644 --- a/test/mjsunit/compiler/regress-closures-with-eval.js +++ b/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/test/mjsunit/compiler/regress-intoverflow.js b/test/mjsunit/compiler/regress-intoverflow.js index d3842f1c23..063a376148 100644 --- a/test/mjsunit/compiler/regress-intoverflow.js +++ b/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/test/mjsunit/regress/regress-1099.js b/test/mjsunit/regress/regress-1099.js index 0ed6ede4af..36f09e4eb9 100644 --- a/test/mjsunit/regress/regress-1099.js +++ b/test/mjsunit/regress/regress-1099.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 LApplyArguments lithium instruction restores context after the call. function X() { @@ -41,6 +43,9 @@ function Y(x) { var y = Y(X()); -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 5; i++) { assertTrue(y("foo")); } + +%OptimizeFunctionOnNextCall(y); +assertTrue(y("foo")); \ No newline at end of file diff --git a/test/mjsunit/strict-mode-opt.js b/test/mjsunit/strict-mode-opt.js index e2eae33fc4..5ca5c279e1 100644 --- a/test/mjsunit/strict-mode-opt.js +++ b/test/mjsunit/strict-mode-opt.js @@ -25,8 +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 + var global = 0; -var MAX = 1000000; +var MAX = 5; // Attempt to inline strcit in non-strict. @@ -43,6 +45,7 @@ function nonstrictCallStrict(n) { (function testInlineStrictInNonStrict() { for (var i = 0; i <= MAX; i ++) { try { + if (i == MAX - 1) %OptimizeFunctionOnNextCall(nonstrictCallStrict); nonstrictCallStrict(i); } catch (e) { assertInstanceof(e, ReferenceError); @@ -68,6 +71,7 @@ function strictCallNonStrict(n) { (function testInlineNonStrictInStrict() { for (var i = 0; i <= MAX; i ++) { try { + if (i == MAX - 1) %OptimizeFunctionOnNextCall(nonstrictCallStrict); strictCallNonStrict(i); } catch (e) { fail("no exception", "exception"); @@ -87,6 +91,7 @@ function strictAssignToUndefined(n) { (function testOptimizeStrictAssignToUndefined() { for (var i = 0; i <= MAX; i ++) { try { + if (i == MAX - 1) %OptimizeFunctionOnNextCall(nonstrictCallStrict); strictAssignToUndefined(i); } catch (e) { assertInstanceof(e, ReferenceError);