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

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

Issue 6340: If an allocation is so huge that we cannot code the size needed in the failur... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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 | « src/objects-inl.h ('k') | 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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 static const char* bDeps[] = { "A" }; 2334 static const char* bDeps[] = { "A" };
2335 v8::RegisterExtension(new Extension("B", "", 1, bDeps)); 2335 v8::RegisterExtension(new Extension("B", "", 1, bDeps));
2336 last_location = NULL; 2336 last_location = NULL;
2337 v8::ExtensionConfiguration config(1, bDeps); 2337 v8::ExtensionConfiguration config(1, bDeps);
2338 v8::Handle<Context> context = Context::New(&config); 2338 v8::Handle<Context> context = Context::New(&config);
2339 CHECK(context.IsEmpty()); 2339 CHECK(context.IsEmpty());
2340 CHECK_NE(last_location, NULL); 2340 CHECK_NE(last_location, NULL);
2341 } 2341 }
2342 2342
2343 2343
2344 static const char* js_code_causing_huge_string_flattening =
2345 "var str = 'X';"
2346 "for (var i = 0; i < 29; i++) {"
2347 " str = str + str;"
2348 "}"
2349 "str.match(/X/);";
2350
2351
2352 void OOMCallback(const char* location, const char* message) {
2353 exit(0);
2354 }
2355
2356
2357 TEST(RegexpOutOfMemory) {
2358 // Execute a script that causes out of memory when flattening a string.
2359 v8::HandleScope scope;
2360 v8::V8::SetFatalErrorHandler(OOMCallback);
2361 LocalContext context;
2362 Local<Script> script =
2363 Script::Compile(String::New(js_code_causing_huge_string_flattening));
2364 last_location = NULL;
2365 Local<Value> result = script->Run();
2366
2367 CHECK(false); // Should not return.
2368 }
2369
2370
2344 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, 2371 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
2345 v8::Handle<Value> data) { 2372 v8::Handle<Value> data) {
2346 CHECK_EQ(v8::Undefined(), data); 2373 CHECK_EQ(v8::Undefined(), data);
2347 CHECK(message->GetScriptResourceName().IsEmpty()); 2374 CHECK(message->GetScriptResourceName().IsEmpty());
2348 CHECK_EQ(v8::Undefined(), message->GetSourceData()); 2375 CHECK_EQ(v8::Undefined(), message->GetSourceData());
2349 message->GetLineNumber(); 2376 message->GetLineNumber();
2350 message->GetSourceLine(); 2377 message->GetSourceLine();
2351 } 2378 }
2352 2379
2353 2380
(...skipping 2587 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 v8::HandleScope scope; 4968 v8::HandleScope scope;
4942 LocalContext context; 4969 LocalContext context;
4943 Local<ObjectTemplate> t = ObjectTemplate::New(); 4970 Local<ObjectTemplate> t = ObjectTemplate::New();
4944 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); 4971 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
4945 context->Global()->Set(v8_str("obj"), t->NewInstance()); 4972 context->Global()->Set(v8_str("obj"), t->NewInstance());
4946 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); 4973 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
4947 CHECK(value->IsString()); 4974 CHECK(value->IsString());
4948 v8::String::AsciiValue name(value); 4975 v8::String::AsciiValue name(value);
4949 CHECK_EQ("asdf", *name); 4976 CHECK_EQ("asdf", *name);
4950 } 4977 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698