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

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

Issue 465026: Push bleeding_edge revision 3387, 3390 to trunk in order to fix test.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 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/version.cc ('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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 8398 matching lines...) Expand 10 before | Expand all | Expand 10 after
8409 v8::String::Utf8Value value(try_catch.Exception()); 8409 v8::String::Utf8Value value(try_catch.Exception());
8410 CHECK_EQ(0, strcmp(*value, "Hey!")); 8410 CHECK_EQ(0, strcmp(*value, "Hey!"));
8411 } 8411 }
8412 8412
8413 8413
8414 static int GetGlobalObjectsCount() { 8414 static int GetGlobalObjectsCount() {
8415 int count = 0; 8415 int count = 0;
8416 v8::internal::HeapIterator it; 8416 v8::internal::HeapIterator it;
8417 while (it.has_next()) { 8417 while (it.has_next()) {
8418 v8::internal::HeapObject* object = it.next(); 8418 v8::internal::HeapObject* object = it.next();
8419 if (object->IsJSGlobalObject()) { 8419 if (object->IsJSGlobalObject()) count++;
8420 count++;
8421 }
8422 } 8420 }
8423 #ifdef DEBUG
8424 if (count > 0) v8::internal::Heap::TracePathToGlobal();
8425 #endif
8426 return count; 8421 return count;
8427 } 8422 }
8428 8423
8429 8424
8430 TEST(Regress528) { 8425 TEST(Regress528) {
8431 v8::V8::Initialize(); 8426 v8::V8::Initialize();
8432 8427
8433 v8::HandleScope scope; 8428 v8::HandleScope scope;
8434 v8::Persistent<Context> context; 8429 v8::Persistent<Context> context;
8430 v8::Persistent<Context> other_context;
8435 int gc_count; 8431 int gc_count;
8436 8432
8433 // Create a context used to keep the code from aging in the compilation
8434 // cache.
8435 other_context = Context::New();
8436
8437 // Context-dependent context data creates reference from the compilation 8437 // Context-dependent context data creates reference from the compilation
8438 // cache to the global object. 8438 // cache to the global object.
8439 const char* source_simple = "1";
8439 context = Context::New(); 8440 context = Context::New();
8440 { 8441 {
8441 v8::HandleScope scope; 8442 v8::HandleScope scope;
8442 8443
8443 context->Enter(); 8444 context->Enter();
8444 Local<v8::String> obj = v8::String::New(""); 8445 Local<v8::String> obj = v8::String::New("");
8445 context->SetData(obj); 8446 context->SetData(obj);
8446 CompileRun("1"); 8447 CompileRun(source_simple);
8447 context->Exit(); 8448 context->Exit();
8448 } 8449 }
8449 context.Dispose(); 8450 context.Dispose();
8450 for (gc_count = 1; gc_count < 10; gc_count++) { 8451 for (gc_count = 1; gc_count < 10; gc_count++) {
8452 other_context->Enter();
8453 CompileRun(source_simple);
8454 other_context->Exit();
8451 v8::internal::Heap::CollectAllGarbage(false); 8455 v8::internal::Heap::CollectAllGarbage(false);
8452 if (GetGlobalObjectsCount() == 0) break; 8456 if (GetGlobalObjectsCount() == 1) break;
8453 } 8457 }
8454 CHECK_EQ(0, GetGlobalObjectsCount()); 8458 CHECK_GE(2, gc_count);
8455 CHECK_EQ(2, gc_count); 8459 CHECK_EQ(1, GetGlobalObjectsCount());
8456 8460
8457 // Eval in a function creates reference from the compilation cache to the 8461 // Eval in a function creates reference from the compilation cache to the
8458 // global object. 8462 // global object.
8463 const char* source_eval = "function f(){eval('1')}; f()";
8459 context = Context::New(); 8464 context = Context::New();
8460 { 8465 {
8461 v8::HandleScope scope; 8466 v8::HandleScope scope;
8462 8467
8463 context->Enter(); 8468 context->Enter();
8464 CompileRun("function f(){eval('1')}; f()"); 8469 CompileRun(source_eval);
8465 context->Exit(); 8470 context->Exit();
8466 } 8471 }
8467 context.Dispose(); 8472 context.Dispose();
8468 for (gc_count = 1; gc_count < 10; gc_count++) { 8473 for (gc_count = 1; gc_count < 10; gc_count++) {
8474 other_context->Enter();
8475 CompileRun(source_eval);
8476 other_context->Exit();
8469 v8::internal::Heap::CollectAllGarbage(false); 8477 v8::internal::Heap::CollectAllGarbage(false);
8470 if (GetGlobalObjectsCount() == 0) break; 8478 if (GetGlobalObjectsCount() == 1) break;
8471 } 8479 }
8472 CHECK_GE(2, gc_count); 8480 CHECK(gc_count <= 2);
8473 CHECK_EQ(1, GetGlobalObjectsCount()); 8481 CHECK_EQ(1, GetGlobalObjectsCount());
8474 8482
8475 // Looking up the line number for an exception creates reference from the 8483 // Looking up the line number for an exception creates reference from the
8476 // compilation cache to the global object. 8484 // compilation cache to the global object.
8485 const char* source_exception = "function f(){throw 1;} f()";
8477 context = Context::New(); 8486 context = Context::New();
8478 { 8487 {
8479 v8::HandleScope scope; 8488 v8::HandleScope scope;
8480 8489
8481 context->Enter(); 8490 context->Enter();
8482 v8::TryCatch try_catch; 8491 v8::TryCatch try_catch;
8483 CompileRun("function f(){throw 1;}; f()"); 8492 CompileRun(source_exception);
8484 CHECK(try_catch.HasCaught()); 8493 CHECK(try_catch.HasCaught());
8485 v8::Handle<v8::Message> message = try_catch.Message(); 8494 v8::Handle<v8::Message> message = try_catch.Message();
8486 CHECK(!message.IsEmpty()); 8495 CHECK(!message.IsEmpty());
8487 CHECK_EQ(1, message->GetLineNumber()); 8496 CHECK_EQ(1, message->GetLineNumber());
8488 context->Exit(); 8497 context->Exit();
8489 } 8498 }
8490 context.Dispose(); 8499 context.Dispose();
8491 for (gc_count = 1; gc_count < 10; gc_count++) { 8500 for (gc_count = 1; gc_count < 10; gc_count++) {
8501 other_context->Enter();
8502 CompileRun(source_exception);
8503 other_context->Exit();
8492 v8::internal::Heap::CollectAllGarbage(false); 8504 v8::internal::Heap::CollectAllGarbage(false);
8493 if (GetGlobalObjectsCount() == 0) break; 8505 if (GetGlobalObjectsCount() == 1) break;
8494 } 8506 }
8495 CHECK_EQ(0, GetGlobalObjectsCount()); 8507 CHECK_GE(2, gc_count);
8496 CHECK_EQ(2, gc_count); 8508 CHECK_EQ(1, GetGlobalObjectsCount());
8509
8510 other_context.Dispose();
8497 } 8511 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698