From f6e049b0ce8f57c6618403189c4d0438a13c8526 Mon Sep 17 00:00:00 2001 From: "ager@chromium.org" Date: Mon, 12 Jul 2010 15:29:25 +0000 Subject: [PATCH] Remove the special error message for overflows when using Function.prototype.apply. This avoids having more than one error message for stack overflow situations which makes testing a pain. Review URL: http://codereview.chromium.org/2967003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5045 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/messages.js | 1 - src/runtime.js | 4 ++-- test/mjsunit/apply.js | 23 +++-------------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/messages.js b/src/messages.js index e99d864334..b0f8aa16e4 100644 --- a/src/messages.js +++ b/src/messages.js @@ -181,7 +181,6 @@ function FormatMessage(message) { // RangeError invalid_array_length: "Invalid array length", stack_overflow: "Maximum call stack size exceeded", - apply_overflow: "Function.prototype.apply cannot support %0 arguments", // SyntaxError unable_to_parse: "Parse error", duplicate_regexp_flag: "Duplicate RegExp flag %0", diff --git a/src/runtime.js b/src/runtime.js index ab6e3e9df1..dfe37f50a2 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -431,7 +431,7 @@ function APPLY_PREPARE(args) { // big enough, but sanity check the value to avoid overflow when // multiplying with pointer size. if (length > 0x800000) { - throw %MakeRangeError('apply_overflow', [length]); + throw %MakeRangeError('stack_overflow', []); } if (!IS_FUNCTION(this)) { @@ -450,7 +450,7 @@ function APPLY_PREPARE(args) { function APPLY_OVERFLOW(length) { - throw %MakeRangeError('apply_overflow', [length]); + throw %MakeRangeError('stack_overflow', []); } diff --git a/test/mjsunit/apply.js b/test/mjsunit/apply.js index cab7eb82f7..613d37d9e3 100644 --- a/test/mjsunit/apply.js +++ b/test/mjsunit/apply.js @@ -94,7 +94,7 @@ function f() { } return doo; } - + assertEquals("42foofishhorse", f.apply(this, arr), "apply to this"); function s() { @@ -112,28 +112,13 @@ function al() { return arguments.length + arguments[arguments.length - 1]; } -var stack_corner_case_failure = false; - for (var j = 1; j < 0x40000000; j <<= 1) { try { var a = new Array(j); a[j - 1] = 42; assertEquals(42 + j, al.apply(345, a)); } catch (e) { - if (e.toString().indexOf("Maximum call stack size exceeded") != -1) { - // For some combinations of build settings, it may be the case that the - // stack here is just tall enough to contain the array whose size is - // specified by j but is not tall enough to contain the activation - // record for the apply call. Allow one such corner case through, - // checking that the length check will do the right thing for an array - // the next size up. - assertEquals(false, stack_corner_case_failure); - stack_corner_case_failure = true; - continue; - } - assertTrue(e.toString().indexOf("Function.prototype.apply") != -1, - "exception does not contain Function.prototype.apply: " + - e.toString()); + assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); for (; j < 0x40000000; j <<= 1) { var caught = false; try { @@ -143,9 +128,7 @@ for (var j = 1; j < 0x40000000; j <<= 1) { assertUnreachable("Apply of array with length " + a.length + " should have thrown"); } catch (e) { - assertTrue(e.toString().indexOf("Function.prototype.apply") != -1, - "exception does not contain Function.prototype.apply [" + - "length = " + j + "]: " + e.toString()); + assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); caught = true; } assertTrue(caught, "exception not caught");