Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Unified Diff: test/mjsunit/regress/regress-319722-ArrayBuffer.js

Issue 73943004: Limit the size for typed arrays to MaxSmi. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Typo Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/regress/regress-319722-ArrayBuffer.js
diff --git a/test/mjsunit/stack-traces-custom-lazy.js b/test/mjsunit/regress/regress-319722-ArrayBuffer.js
similarity index 72%
copy from test/mjsunit/stack-traces-custom-lazy.js
copy to test/mjsunit/regress/regress-319722-ArrayBuffer.js
index 91d97f3739dc746434731352a0ec7ade0d839484..6d4ecd03f6cd79e5699371e0896182ef14162dfd 100644
--- a/test/mjsunit/stack-traces-custom-lazy.js
+++ b/test/mjsunit/regress/regress-319722-ArrayBuffer.js
@@ -25,25 +25,35 @@
// (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 testPrepareStackTrace(closure) {
- var error = undefined;
+// Flags: --nostress-opt --allow-natives-syntax
+var maxSize = %MaxSmi() + 1;
+var ab = null;
+
+// Allocate the largest ArrayBuffer we can on this architecture.
+for (k = 8; k >= 1 && ab == null; k = k/2) {
Jakob Kummerow 2013/11/15 15:13:08 the update step should be "k = k >> 1", otherwise
Dmitry Lomov (no reviews) 2013/11/15 16:03:07 No, I think it is fine as it is, because 1/2 = 0.5
try {
- closure();
- assertUnreachable();
+ ab = new ArrayBuffer(maxSize * k);
} catch (e) {
- error = e;
+ ab = null;
}
+}
+
+assertTrue(ab != null);
- // We expect custom formatting to be lazy. Setting the custom
- // function right before calling error.stack should be fine.
- Error.prepareStackTrace = function(e, frames) {
- return "bar";
- }
- assertEquals("bar", error.stack);
- Error.prepareStackTrace = undefined;
+function TestArray(constr) {
+ assertThrows(function() {
+ new constr(ab, 0, maxSize);
+ }, RangeError);
}
-testPrepareStackTrace(function() { throw new Error("foo"); });
-testPrepareStackTrace(function f() { f(); });
+TestArray(Uint8Array);
+TestArray(Int8Array);
+TestArray(Uint16Array);
+TestArray(Int16Array);
+TestArray(Uint32Array);
+TestArray(Int32Array);
+TestArray(Float32Array);
+TestArray(Float64Array);
+TestArray(Uint8ClampedArray);

Powered by Google App Engine
This is Rietveld 408576698