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

Side by Side Diff: test/cctest/test-strings.cc

Issue 9963104: Regression test for large string joins. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 2
3 // Check that we can traverse very deep stacks of ConsStrings using 3 // Check that we can traverse very deep stacks of ConsStrings using
4 // StringInputBuffer. Check that Get(int) works on very deep stacks 4 // StringInputBuffer. Check that Get(int) works on very deep stacks
5 // of ConsStrings. These operations may not be very fast, but they 5 // of ConsStrings. These operations may not be very fast, but they
6 // should be possible without getting errors due to too deep recursion. 6 // should be possible without getting errors due to too deep recursion.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "v8.h" 10 #include "v8.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 580 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
581 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString())); 581 CHECK_EQ("bcdefghijklmnopqrstuvwxy", *(string->ToCString()));
582 582
583 result = CompileRun(slice_from_slice); 583 result = CompileRun(slice_from_slice);
584 CHECK(result->IsString()); 584 CHECK(result->IsString());
585 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 585 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
586 CHECK(string->IsSlicedString()); 586 CHECK(string->IsSlicedString());
587 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 587 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
588 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString())); 588 CHECK_EQ("cdefghijklmnopqrstuvwx", *(string->ToCString()));
589 } 589 }
590
591
592 // string s is made of 2^17 = 131072 'c' characters.
593 // a is an array starting with 'bad', followed by 2^14 times the string s.
594 // That means the total length of the concatenated strings is 2^31 + 3.
595 // So on 32bits systems summing the lengths of the strings (as smis) overflows
596 // and wraps.
597 static const char* join_causing_out_of_memory =
598 "var two_14 = Math.pow(2, 14);"
599 "var two_17 = Math.pow(2, 17);"
600 "var s = Array(two_17 + 1).join('c');"
601 "var a = ['bad'];"
602 "for (var i = 1; i <= two_14; i++) a.push(s);"
603 "a.join("");";
604
605
606 TEST(AsciiArrayJoin) {
607 // Set heap limits.
608 static const int K = 1024;
609 v8::ResourceConstraints constraints;
610 constraints.set_max_young_space_size(256 * K);
611 constraints.set_max_old_space_size(4 * K * K);
612 v8::SetResourceConstraints(&constraints);
613
614 v8::HandleScope scope;
615 LocalContext context;
616 v8::V8::IgnoreOutOfMemoryException();
617 v8::Local<v8::Script> script =
618 v8::Script::Compile(v8::String::New(join_causing_out_of_memory));
619 v8::Local<v8::Value> result = script->Run();
620
621 // Check for out of memory state.
622 CHECK(result.IsEmpty());
623 CHECK(context->HasOutOfMemoryException());
624 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698