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

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

Issue 114943004: Reland "Handlify concat string and substring." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix test case. Created 7 years 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 | « src/runtime.cc ('k') | test/mjsunit/string-slices.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4382 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 " ProvokeOutOfMemory();" 4393 " ProvokeOutOfMemory();"
4394 "} catch (e) {" 4394 "} catch (e) {"
4395 " thrown = true;" 4395 " thrown = true;"
4396 "}"); 4396 "}");
4397 // Check for out of memory state. 4397 // Check for out of memory state.
4398 CHECK(result.IsEmpty()); 4398 CHECK(result.IsEmpty());
4399 CHECK(context->HasOutOfMemoryException()); 4399 CHECK(context->HasOutOfMemoryException());
4400 } 4400 }
4401 4401
4402 4402
4403 void OOMCallback(const char* location, const char* message) {
4404 exit(0);
4405 }
4406
4407
4403 TEST(HugeConsStringOutOfMemory) { 4408 TEST(HugeConsStringOutOfMemory) {
4404 // It's not possible to read a snapshot into a heap with different dimensions. 4409 // It's not possible to read a snapshot into a heap with different dimensions.
4405 if (i::Snapshot::IsEnabled()) return; 4410 if (i::Snapshot::IsEnabled()) return;
4406 // Set heap limits. 4411 // Set heap limits.
4407 static const int K = 1024; 4412 static const int K = 1024;
4408 v8::ResourceConstraints constraints; 4413 v8::ResourceConstraints constraints;
4409 constraints.set_max_young_space_size(256 * K); 4414 constraints.set_max_young_space_size(256 * K);
4410 constraints.set_max_old_space_size(4 * K * K); 4415 constraints.set_max_old_space_size(4 * K * K);
4411 v8::SetResourceConstraints(CcTest::isolate(), &constraints); 4416 v8::SetResourceConstraints(CcTest::isolate(), &constraints);
4412 4417
4413 // Execute a script that causes out of memory. 4418 // Execute a script that causes out of memory.
4414 v8::V8::IgnoreOutOfMemoryException(); 4419 v8::V8::SetFatalErrorHandler(OOMCallback);
4415 4420
4416 LocalContext context; 4421 LocalContext context;
4417 v8::HandleScope scope(context->GetIsolate()); 4422 v8::HandleScope scope(context->GetIsolate());
4418 4423
4419 // Build huge string. This should fail with out of memory exception. 4424 // Build huge string. This should fail with out of memory exception.
4420 Local<Value> result = CompileRun( 4425 CompileRun(
4421 "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();" 4426 "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();"
4422 "for (var i = 0; i < 22; i++) { str = str + str; }"); 4427 "for (var i = 0; i < 22; i++) { str = str + str; }");
4423 4428
4424 // Check for out of memory state. 4429 CHECK(false); // Should not return.
4425 CHECK(result.IsEmpty());
4426 CHECK(context->HasOutOfMemoryException());
4427 } 4430 }
4428 4431
4429 4432
4430 THREADED_TEST(ConstructCall) { 4433 THREADED_TEST(ConstructCall) {
4431 LocalContext context; 4434 LocalContext context;
4432 v8::HandleScope scope(context->GetIsolate()); 4435 v8::HandleScope scope(context->GetIsolate());
4433 CompileRun( 4436 CompileRun(
4434 "function Foo() {" 4437 "function Foo() {"
4435 " var result = [];" 4438 " var result = [];"
4436 " for (var i = 0; i < arguments.length; i++) {" 4439 " for (var i = 0; i < arguments.length; i++) {"
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after
6918 6921
6919 6922
6920 static const char* js_code_causing_huge_string_flattening = 6923 static const char* js_code_causing_huge_string_flattening =
6921 "var str = 'X';" 6924 "var str = 'X';"
6922 "for (var i = 0; i < 30; i++) {" 6925 "for (var i = 0; i < 30; i++) {"
6923 " str = str + str;" 6926 " str = str + str;"
6924 "}" 6927 "}"
6925 "str.match(/X/);"; 6928 "str.match(/X/);";
6926 6929
6927 6930
6928 void OOMCallback(const char* location, const char* message) {
6929 exit(0);
6930 }
6931
6932
6933 TEST(RegexpOutOfMemory) { 6931 TEST(RegexpOutOfMemory) {
6934 // Execute a script that causes out of memory when flattening a string. 6932 // Execute a script that causes out of memory when flattening a string.
6935 v8::HandleScope scope(CcTest::isolate()); 6933 v8::HandleScope scope(CcTest::isolate());
6936 v8::V8::SetFatalErrorHandler(OOMCallback); 6934 v8::V8::SetFatalErrorHandler(OOMCallback);
6937 LocalContext context; 6935 LocalContext context;
6938 Local<Script> script = Script::Compile(String::NewFromUtf8( 6936 Local<Script> script = Script::Compile(String::NewFromUtf8(
6939 CcTest::isolate(), js_code_causing_huge_string_flattening)); 6937 CcTest::isolate(), js_code_causing_huge_string_flattening));
6940 last_location = NULL; 6938 last_location = NULL;
6941 script->Run(); 6939 script->Run();
6942 6940
(...skipping 14007 matching lines...) Expand 10 before | Expand all | Expand 10 after
20950 } 20948 }
20951 for (int i = 0; i < runs; i++) { 20949 for (int i = 0; i < runs; i++) {
20952 Local<String> expected; 20950 Local<String> expected;
20953 if (i != 0) { 20951 if (i != 0) {
20954 CHECK_EQ(v8_str("escape value"), values[i]); 20952 CHECK_EQ(v8_str("escape value"), values[i]);
20955 } else { 20953 } else {
20956 CHECK(values[i].IsEmpty()); 20954 CHECK(values[i].IsEmpty());
20957 } 20955 }
20958 } 20956 }
20959 } 20957 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/string-slices.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698