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

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

Issue 1303393004: Revert of [heap] More flag cleanup. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/cctest/test-debug.cc » ('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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 455
456 THREADED_TEST(ScriptMakingExternalString) { 456 THREADED_TEST(ScriptMakingExternalString) {
457 int dispose_count = 0; 457 int dispose_count = 0;
458 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); 458 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3");
459 { 459 {
460 LocalContext env; 460 LocalContext env;
461 v8::HandleScope scope(env->GetIsolate()); 461 v8::HandleScope scope(env->GetIsolate());
462 Local<String> source = 462 Local<String> source =
463 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); 463 String::NewFromTwoByte(env->GetIsolate(), two_byte_source);
464 // Trigger GCs so that the newly allocated string moves to old gen. 464 // Trigger GCs so that the newly allocated string moves to old gen.
465 CcTest::heap()->CollectGarbageNewSpace(); // in survivor space now 465 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
466 CcTest::heap()->CollectGarbageNewSpace(); // in old gen now 466 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
467 CHECK_EQ(source->IsExternal(), false); 467 CHECK_EQ(source->IsExternal(), false);
468 CHECK_EQ(source->IsExternalOneByte(), false); 468 CHECK_EQ(source->IsExternalOneByte(), false);
469 String::Encoding encoding = String::UNKNOWN_ENCODING; 469 String::Encoding encoding = String::UNKNOWN_ENCODING;
470 CHECK(!source->GetExternalStringResourceBase(&encoding)); 470 CHECK(!source->GetExternalStringResourceBase(&encoding));
471 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); 471 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
472 bool success = source->MakeExternal(new TestResource(two_byte_source, 472 bool success = source->MakeExternal(new TestResource(two_byte_source,
473 &dispose_count)); 473 &dispose_count));
474 CHECK(success); 474 CHECK(success);
475 Local<Script> script = v8_compile(source); 475 Local<Script> script = v8_compile(source);
476 Local<Value> value = script->Run(); 476 Local<Value> value = script->Run();
477 CHECK(value->IsNumber()); 477 CHECK(value->IsNumber());
478 CHECK_EQ(7, value->Int32Value()); 478 CHECK_EQ(7, value->Int32Value());
479 CcTest::heap()->CollectAllGarbage(); 479 CcTest::heap()->CollectAllGarbage();
480 CHECK_EQ(0, dispose_count); 480 CHECK_EQ(0, dispose_count);
481 } 481 }
482 CcTest::i_isolate()->compilation_cache()->Clear(); 482 CcTest::i_isolate()->compilation_cache()->Clear();
483 CcTest::heap()->CollectAllGarbage(); 483 CcTest::heap()->CollectAllGarbage();
484 CHECK_EQ(1, dispose_count); 484 CHECK_EQ(1, dispose_count);
485 } 485 }
486 486
487 487
488 THREADED_TEST(ScriptMakingExternalOneByteString) { 488 THREADED_TEST(ScriptMakingExternalOneByteString) {
489 int dispose_count = 0; 489 int dispose_count = 0;
490 const char* c_source = "1 + 2 * 3"; 490 const char* c_source = "1 + 2 * 3";
491 { 491 {
492 LocalContext env; 492 LocalContext env;
493 v8::HandleScope scope(env->GetIsolate()); 493 v8::HandleScope scope(env->GetIsolate());
494 Local<String> source = v8_str(c_source); 494 Local<String> source = v8_str(c_source);
495 // Trigger GCs so that the newly allocated string moves to old gen. 495 // Trigger GCs so that the newly allocated string moves to old gen.
496 CcTest::heap()->CollectGarbageNewSpace(); // in survivor space now 496 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
497 CcTest::heap()->CollectGarbageNewSpace(); // in old gen now 497 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
498 bool success = source->MakeExternal( 498 bool success = source->MakeExternal(
499 new TestOneByteResource(i::StrDup(c_source), &dispose_count)); 499 new TestOneByteResource(i::StrDup(c_source), &dispose_count));
500 CHECK(success); 500 CHECK(success);
501 Local<Script> script = v8_compile(source); 501 Local<Script> script = v8_compile(source);
502 Local<Value> value = script->Run(); 502 Local<Value> value = script->Run();
503 CHECK(value->IsNumber()); 503 CHECK(value->IsNumber());
504 CHECK_EQ(7, value->Int32Value()); 504 CHECK_EQ(7, value->Int32Value());
505 CcTest::heap()->CollectAllGarbage(); 505 CcTest::heap()->CollectAllGarbage();
506 CHECK_EQ(0, dispose_count); 506 CHECK_EQ(0, dispose_count);
507 } 507 }
508 CcTest::i_isolate()->compilation_cache()->Clear(); 508 CcTest::i_isolate()->compilation_cache()->Clear();
509 CcTest::heap()->CollectAllGarbage(); 509 CcTest::heap()->CollectAllGarbage();
510 CHECK_EQ(1, dispose_count); 510 CHECK_EQ(1, dispose_count);
511 } 511 }
512 512
513 513
514 TEST(MakingExternalStringConditions) { 514 TEST(MakingExternalStringConditions) {
515 LocalContext env; 515 LocalContext env;
516 v8::HandleScope scope(env->GetIsolate()); 516 v8::HandleScope scope(env->GetIsolate());
517 517
518 // Free some space in the new space so that we can check freshness. 518 // Free some space in the new space so that we can check freshness.
519 CcTest::heap()->CollectGarbageNewSpace(); 519 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
520 CcTest::heap()->CollectGarbageNewSpace(); 520 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
521 521
522 uint16_t* two_byte_string = AsciiToTwoByteString("s1"); 522 uint16_t* two_byte_string = AsciiToTwoByteString("s1");
523 Local<String> small_string = 523 Local<String> small_string =
524 String::NewFromTwoByte(env->GetIsolate(), two_byte_string); 524 String::NewFromTwoByte(env->GetIsolate(), two_byte_string);
525 i::DeleteArray(two_byte_string); 525 i::DeleteArray(two_byte_string);
526 526
527 // We should refuse to externalize small strings. 527 // We should refuse to externalize small strings.
528 CHECK(!small_string->CanMakeExternal()); 528 CHECK(!small_string->CanMakeExternal());
529 // Trigger GCs so that the newly allocated string moves to old gen. 529 // Trigger GCs so that the newly allocated string moves to old gen.
530 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now 530 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
(...skipping 18 matching lines...) Expand all
549 // Large strings should be immediately accepted. 549 // Large strings should be immediately accepted.
550 CHECK(large_string->CanMakeExternal()); 550 CHECK(large_string->CanMakeExternal());
551 } 551 }
552 552
553 553
554 TEST(MakingExternalOneByteStringConditions) { 554 TEST(MakingExternalOneByteStringConditions) {
555 LocalContext env; 555 LocalContext env;
556 v8::HandleScope scope(env->GetIsolate()); 556 v8::HandleScope scope(env->GetIsolate());
557 557
558 // Free some space in the new space so that we can check freshness. 558 // Free some space in the new space so that we can check freshness.
559 CcTest::heap()->CollectGarbageNewSpace(); 559 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
560 CcTest::heap()->CollectGarbageNewSpace(); 560 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
561 561
562 Local<String> small_string = String::NewFromUtf8(env->GetIsolate(), "s1"); 562 Local<String> small_string = String::NewFromUtf8(env->GetIsolate(), "s1");
563 // We should refuse to externalize small strings. 563 // We should refuse to externalize small strings.
564 CHECK(!small_string->CanMakeExternal()); 564 CHECK(!small_string->CanMakeExternal());
565 // Trigger GCs so that the newly allocated string moves to old gen. 565 // Trigger GCs so that the newly allocated string moves to old gen.
566 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now 566 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
567 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now 567 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
568 // Old space strings should be accepted. 568 // Old space strings should be accepted.
569 CHECK(small_string->CanMakeExternal()); 569 CHECK(small_string->CanMakeExternal());
570 570
(...skipping 16 matching lines...) Expand all
587 "function slice(a) { return a.substring(1); }"); 587 "function slice(a) { return a.substring(1); }");
588 // Create a cons string that will land in old pointer space. 588 // Create a cons string that will land in old pointer space.
589 Local<String> cons = Local<String>::Cast(CompileRun( 589 Local<String> cons = Local<String>::Cast(CompileRun(
590 "cons('abcdefghijklm', 'nopqrstuvwxyz');")); 590 "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
591 // Create a sliced string that will land in old pointer space. 591 // Create a sliced string that will land in old pointer space.
592 Local<String> slice = Local<String>::Cast(CompileRun( 592 Local<String> slice = Local<String>::Cast(CompileRun(
593 "slice('abcdefghijklmnopqrstuvwxyz');")); 593 "slice('abcdefghijklmnopqrstuvwxyz');"));
594 594
595 // Trigger GCs so that the newly allocated string moves to old gen. 595 // Trigger GCs so that the newly allocated string moves to old gen.
596 SimulateFullSpace(CcTest::heap()->old_space()); 596 SimulateFullSpace(CcTest::heap()->old_space());
597 CcTest::heap()->CollectGarbageNewSpace(); // in survivor space now 597 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
598 CcTest::heap()->CollectGarbageNewSpace(); // in old gen now 598 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
599 599
600 // Turn into external string with unaligned resource data. 600 // Turn into external string with unaligned resource data.
601 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; 601 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
602 bool success = 602 bool success =
603 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); 603 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1));
604 CHECK(success); 604 CHECK(success);
605 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; 605 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
606 success = 606 success =
607 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1)); 607 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1));
608 CHECK(success); 608 CHECK(success);
609 609
610 // Trigger GCs and force evacuation. 610 // Trigger GCs and force evacuation.
611 CcTest::heap()->CollectAllGarbage(); 611 CcTest::heap()->CollectAllGarbage();
612 CcTest::heap()->CollectAllGarbage("MakingExternalUnalignedOneByteString", 612 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
613 i::Heap::kReduceMemoryFootprintMask);
614 } 613 }
615 614
616 615
617 THREADED_TEST(UsingExternalString) { 616 THREADED_TEST(UsingExternalString) {
618 i::Factory* factory = CcTest::i_isolate()->factory(); 617 i::Factory* factory = CcTest::i_isolate()->factory();
619 { 618 {
620 v8::HandleScope scope(CcTest::isolate()); 619 v8::HandleScope scope(CcTest::isolate());
621 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 620 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
622 Local<String> string = String::NewExternal( 621 Local<String> string = String::NewExternal(
623 CcTest::isolate(), new TestResource(two_byte_string)); 622 CcTest::isolate(), new TestResource(two_byte_string));
624 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 623 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
625 // Trigger GCs so that the newly allocated string moves to old gen. 624 // Trigger GCs so that the newly allocated string moves to old gen.
626 CcTest::heap()->CollectGarbageNewSpace(); // in survivor space now 625 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
627 CcTest::heap()->CollectGarbageNewSpace(); // in old gen now 626 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
628 i::Handle<i::String> isymbol = 627 i::Handle<i::String> isymbol =
629 factory->InternalizeString(istring); 628 factory->InternalizeString(istring);
630 CHECK(isymbol->IsInternalizedString()); 629 CHECK(isymbol->IsInternalizedString());
631 } 630 }
632 CcTest::heap()->CollectAllGarbage(); 631 CcTest::heap()->CollectAllGarbage();
633 CcTest::heap()->CollectAllGarbage(); 632 CcTest::heap()->CollectAllGarbage();
634 } 633 }
635 634
636 635
637 THREADED_TEST(UsingExternalOneByteString) { 636 THREADED_TEST(UsingExternalOneByteString) {
638 i::Factory* factory = CcTest::i_isolate()->factory(); 637 i::Factory* factory = CcTest::i_isolate()->factory();
639 { 638 {
640 v8::HandleScope scope(CcTest::isolate()); 639 v8::HandleScope scope(CcTest::isolate());
641 const char* one_byte_string = "test string"; 640 const char* one_byte_string = "test string";
642 Local<String> string = String::NewExternal( 641 Local<String> string = String::NewExternal(
643 CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string))); 642 CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string)));
644 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 643 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
645 // Trigger GCs so that the newly allocated string moves to old gen. 644 // Trigger GCs so that the newly allocated string moves to old gen.
646 CcTest::heap()->CollectGarbageNewSpace(); // in survivor space now 645 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
647 CcTest::heap()->CollectGarbageNewSpace(); // in old gen now 646 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
648 i::Handle<i::String> isymbol = 647 i::Handle<i::String> isymbol =
649 factory->InternalizeString(istring); 648 factory->InternalizeString(istring);
650 CHECK(isymbol->IsInternalizedString()); 649 CHECK(isymbol->IsInternalizedString());
651 } 650 }
652 CcTest::heap()->CollectAllGarbage(); 651 CcTest::heap()->CollectAllGarbage();
653 CcTest::heap()->CollectAllGarbage(); 652 CcTest::heap()->CollectAllGarbage();
654 } 653 }
655 654
656 655
657 class RandomLengthResource : public v8::String::ExternalStringResource { 656 class RandomLengthResource : public v8::String::ExternalStringResource {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 i::FLAG_stress_compaction = false; 704 i::FLAG_stress_compaction = false;
706 i::FLAG_gc_global = false; 705 i::FLAG_gc_global = false;
707 int dispose_count = 0; 706 int dispose_count = 0;
708 bool in_new_space = false; 707 bool in_new_space = false;
709 { 708 {
710 v8::HandleScope scope(CcTest::isolate()); 709 v8::HandleScope scope(CcTest::isolate());
711 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 710 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
712 Local<String> string = String::NewExternal( 711 Local<String> string = String::NewExternal(
713 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count)); 712 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count));
714 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 713 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
715 CcTest::heap()->CollectGarbageNewSpace(); 714 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
716 in_new_space = CcTest::heap()->InNewSpace(*istring); 715 in_new_space = CcTest::heap()->InNewSpace(*istring);
717 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring)); 716 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring));
718 CHECK_EQ(0, dispose_count); 717 CHECK_EQ(0, dispose_count);
719 } 718 }
720 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE); 719 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
721 CHECK_EQ(1, dispose_count); 720 CHECK_EQ(1, dispose_count);
722 } 721 }
723 722
724 723
725 THREADED_TEST(ScavengeExternalOneByteString) { 724 THREADED_TEST(ScavengeExternalOneByteString) {
726 i::FLAG_stress_compaction = false; 725 i::FLAG_stress_compaction = false;
727 i::FLAG_gc_global = false; 726 i::FLAG_gc_global = false;
728 int dispose_count = 0; 727 int dispose_count = 0;
729 bool in_new_space = false; 728 bool in_new_space = false;
730 { 729 {
731 v8::HandleScope scope(CcTest::isolate()); 730 v8::HandleScope scope(CcTest::isolate());
732 const char* one_byte_string = "test string"; 731 const char* one_byte_string = "test string";
733 Local<String> string = String::NewExternal( 732 Local<String> string = String::NewExternal(
734 CcTest::isolate(), 733 CcTest::isolate(),
735 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count)); 734 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count));
736 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 735 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
737 CcTest::heap()->CollectGarbageNewSpace(); 736 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
738 in_new_space = CcTest::heap()->InNewSpace(*istring); 737 in_new_space = CcTest::heap()->InNewSpace(*istring);
739 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring)); 738 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring));
740 CHECK_EQ(0, dispose_count); 739 CHECK_EQ(0, dispose_count);
741 } 740 }
742 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE); 741 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
743 CHECK_EQ(1, dispose_count); 742 CHECK_EQ(1, dispose_count);
744 } 743 }
745 744
746 745
747 class TestOneByteResourceWithDisposeControl : public TestOneByteResource { 746 class TestOneByteResourceWithDisposeControl : public TestOneByteResource {
(...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 Local<v8::Object> expected2 = NewObjectForIntKey(isolate, templ, 8); 3383 Local<v8::Object> expected2 = NewObjectForIntKey(isolate, templ, 8);
3385 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref); 3384 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref);
3386 CHECK_EQ(1, static_cast<int>(map.Size())); 3385 CHECK_EQ(1, static_cast<int>(map.Size()));
3387 CHECK(expected == removed); 3386 CHECK(expected == removed);
3388 CHECK(expected2->Equals(ref.NewLocal(isolate))); 3387 CHECK(expected2->Equals(ref.NewLocal(isolate)));
3389 } 3388 }
3390 } 3389 }
3391 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); 3390 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count());
3392 if (map.IsWeak()) { 3391 if (map.IsWeak()) {
3393 CcTest::i_isolate()->heap()->CollectAllGarbage( 3392 CcTest::i_isolate()->heap()->CollectAllGarbage(
3394 "TestGlobalValueMap", i::Heap::kAbortIncrementalMarkingMask); 3393 i::Heap::kAbortIncrementalMarkingMask);
3395 } else { 3394 } else {
3396 map.Clear(); 3395 map.Clear();
3397 } 3396 }
3398 CHECK_EQ(0, static_cast<int>(map.Size())); 3397 CHECK_EQ(0, static_cast<int>(map.Size()));
3399 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); 3398 CHECK_EQ(initial_handle_count, global_handles->global_handles_count());
3400 { 3399 {
3401 HandleScope scope(isolate); 3400 HandleScope scope(isolate);
3402 Local<v8::Object> value = NewObjectForIntKey(isolate, templ, 9); 3401 Local<v8::Object> value = NewObjectForIntKey(isolate, templ, 9);
3403 map.Set(9, value); 3402 map.Set(9, value);
3404 map.Clear(); 3403 map.Clear();
(...skipping 3132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6537 Local<Object> b(v8::Object::New(iso)); 6536 Local<Object> b(v8::Object::New(iso));
6538 object_a.handle.Reset(iso, a); 6537 object_a.handle.Reset(iso, a);
6539 object_b.handle.Reset(iso, b); 6538 object_b.handle.Reset(iso, b);
6540 if (interlinked) { 6539 if (interlinked) {
6541 a->Set(v8_str("x"), b); 6540 a->Set(v8_str("x"), b);
6542 b->Set(v8_str("x"), a); 6541 b->Set(v8_str("x"), a);
6543 } 6542 }
6544 if (global_gc) { 6543 if (global_gc) {
6545 CcTest::heap()->CollectAllGarbage(); 6544 CcTest::heap()->CollectAllGarbage();
6546 } else { 6545 } else {
6547 CcTest::heap()->CollectGarbageNewSpace(); 6546 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6548 } 6547 }
6549 // We are relying on this creating a big flag array and reserving the space 6548 // We are relying on this creating a big flag array and reserving the space
6550 // up front. 6549 // up front.
6551 v8::Handle<Value> big_array = CompileRun("new Array(50000)"); 6550 v8::Handle<Value> big_array = CompileRun("new Array(50000)");
6552 a->Set(v8_str("y"), big_array); 6551 a->Set(v8_str("y"), big_array);
6553 big_heap_size = CcTest::heap()->SizeOfObjects(); 6552 big_heap_size = CcTest::heap()->SizeOfObjects();
6554 } 6553 }
6555 6554
6556 object_a.flag = false; 6555 object_a.flag = false;
6557 object_b.flag = false; 6556 object_b.flag = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
6655 6654
6656 handle.SetWeak<v8::Persistent<v8::Object>>( 6655 handle.SetWeak<v8::Persistent<v8::Object>>(
6657 &handle, CheckInternalFields, v8::WeakCallbackType::kInternalFields); 6656 &handle, CheckInternalFields, v8::WeakCallbackType::kInternalFields);
6658 if (!global_gc) { 6657 if (!global_gc) {
6659 handle.MarkIndependent(); 6658 handle.MarkIndependent();
6660 } 6659 }
6661 } 6660 }
6662 if (global_gc) { 6661 if (global_gc) {
6663 CcTest::heap()->CollectAllGarbage(); 6662 CcTest::heap()->CollectAllGarbage();
6664 } else { 6663 } else {
6665 CcTest::heap()->CollectGarbageNewSpace(); 6664 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6666 } 6665 }
6667 6666
6668 CHECK_EQ(1729, t1->x()); 6667 CHECK_EQ(1729, t1->x());
6669 CHECK_EQ(33550336, t2->x()); 6668 CHECK_EQ(33550336, t2->x());
6670 6669
6671 delete t1; 6670 delete t1;
6672 delete t2; 6671 delete t2;
6673 } 6672 }
6674 6673
6675 6674
(...skipping 24 matching lines...) Expand all
6700 6699
6701 FlagAndPersistent object_a, object_b; 6700 FlagAndPersistent object_a, object_b;
6702 6701
6703 { 6702 {
6704 v8::HandleScope handle_scope(iso); 6703 v8::HandleScope handle_scope(iso);
6705 Local<Object> a(v8::Object::New(iso)); 6704 Local<Object> a(v8::Object::New(iso));
6706 Local<Object> b(v8::Object::New(iso)); 6705 Local<Object> b(v8::Object::New(iso));
6707 object_a.handle.Reset(iso, a); 6706 object_a.handle.Reset(iso, a);
6708 object_b.handle.Reset(iso, b); 6707 object_b.handle.Reset(iso, b);
6709 if (global_gc) { 6708 if (global_gc) {
6710 CcTest::heap()->CollectAllGarbage("ResetWeakHandle", 6709 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6711 Heap::kAbortIncrementalMarkingMask);
6712 } else { 6710 } else {
6713 CcTest::heap()->CollectGarbageNewSpace(); 6711 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6714 } 6712 }
6715 } 6713 }
6716 6714
6717 object_a.flag = false; 6715 object_a.flag = false;
6718 object_b.flag = false; 6716 object_b.flag = false;
6719 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag, 6717 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag,
6720 v8::WeakCallbackType::kParameter); 6718 v8::WeakCallbackType::kParameter);
6721 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, 6719 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag,
6722 v8::WeakCallbackType::kParameter); 6720 v8::WeakCallbackType::kParameter);
6723 if (!global_gc) { 6721 if (!global_gc) {
6724 object_a.handle.MarkIndependent(); 6722 object_a.handle.MarkIndependent();
6725 object_b.handle.MarkIndependent(); 6723 object_b.handle.MarkIndependent();
6726 CHECK(object_b.handle.IsIndependent()); 6724 CHECK(object_b.handle.IsIndependent());
6727 } 6725 }
6728 if (global_gc) { 6726 if (global_gc) {
6729 CcTest::heap()->CollectAllGarbage("ResetWeakHandle", 6727 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
6730 Heap::kAbortIncrementalMarkingMask);
6731 } else { 6728 } else {
6732 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 6729 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6733 } 6730 }
6734 CHECK(object_a.flag); 6731 CHECK(object_a.flag);
6735 CHECK(object_b.flag); 6732 CHECK(object_b.flag);
6736 } 6733 }
6737 6734
6738 6735
6739 THREADED_HEAP_TEST(ResetWeakHandle) { 6736 THREADED_HEAP_TEST(ResetWeakHandle) {
6740 v8::internal::HeapTester::ResetWeakHandle(false); 6737 v8::internal::HeapTester::ResetWeakHandle(false);
6741 v8::internal::HeapTester::ResetWeakHandle(true); 6738 v8::internal::HeapTester::ResetWeakHandle(true);
6742 } 6739 }
6743 6740
6744 6741
6745 static void InvokeScavenge() { CcTest::heap()->CollectGarbageNewSpace(); } 6742 static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); }
6746 6743
6747 6744
6748 static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); } 6745 static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); }
6749 6746
6750 6747
6751 static void ForceScavenge2( 6748 static void ForceScavenge2(
6752 const v8::WeakCallbackInfo<FlagAndPersistent>& data) { 6749 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
6753 data.GetParameter()->flag = true; 6750 data.GetParameter()->flag = true;
6754 InvokeScavenge(); 6751 InvokeScavenge();
6755 } 6752 }
(...skipping 4952 matching lines...) Expand 10 before | Expand all | Expand 10 after
11708 } 11705 }
11709 11706
11710 11707
11711 static void CheckSurvivingGlobalObjectsCount(int expected) { 11708 static void CheckSurvivingGlobalObjectsCount(int expected) {
11712 // We need to collect all garbage twice to be sure that everything 11709 // We need to collect all garbage twice to be sure that everything
11713 // has been collected. This is because inline caches are cleared in 11710 // has been collected. This is because inline caches are cleared in
11714 // the first garbage collection but some of the maps have already 11711 // the first garbage collection but some of the maps have already
11715 // been marked at that point. Therefore some of the maps are not 11712 // been marked at that point. Therefore some of the maps are not
11716 // collected until the second garbage collection. 11713 // collected until the second garbage collection.
11717 CcTest::heap()->CollectAllGarbage(); 11714 CcTest::heap()->CollectAllGarbage();
11718 CcTest::heap()->CollectAllGarbage("CheckSurvivingGlobalObjectsCount", 11715 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
11719 i::Heap::kMakeHeapIterableMask);
11720 int count = GetGlobalObjectsCount(); 11716 int count = GetGlobalObjectsCount();
11721 #ifdef DEBUG 11717 #ifdef DEBUG
11722 if (count != expected) CcTest::heap()->TracePathToGlobal(); 11718 if (count != expected) CcTest::heap()->TracePathToGlobal();
11723 #endif 11719 #endif
11724 CHECK_EQ(expected, count); 11720 CHECK_EQ(expected, count);
11725 } 11721 }
11726 11722
11727 11723
11728 TEST(DontLeakGlobalObjects) { 11724 TEST(DontLeakGlobalObjects) {
11729 // Regression test for issues 1139850 and 1174891. 11725 // Regression test for issues 1139850 and 1174891.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11808 { 11804 {
11809 v8::HandleScope scope(isolate); 11805 v8::HandleScope scope(isolate);
11810 v8::Local<v8::Object> obj = v8::Object::New(isolate); 11806 v8::Local<v8::Object> obj = v8::Object::New(isolate);
11811 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); 11807 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231));
11812 v8::Persistent<v8::Object>* handle = 11808 v8::Persistent<v8::Object>* handle =
11813 new v8::Persistent<v8::Object>(isolate, obj); 11809 new v8::Persistent<v8::Object>(isolate, obj);
11814 handle->SetWeak<v8::Persistent<v8::Object>>( 11810 handle->SetWeak<v8::Persistent<v8::Object>>(
11815 handle, WeakApiCallback, v8::WeakCallbackType::kParameter); 11811 handle, WeakApiCallback, v8::WeakCallbackType::kParameter);
11816 } 11812 }
11817 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( 11813 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
11818 "WeakCallbackApi", i::Heap::kAbortIncrementalMarkingMask); 11814 i::Heap::kAbortIncrementalMarkingMask);
11819 // Verify disposed. 11815 // Verify disposed.
11820 CHECK_EQ(initial_handles, globals->global_handles_count()); 11816 CHECK_EQ(initial_handles, globals->global_handles_count());
11821 } 11817 }
11822 11818
11823 11819
11824 v8::Persistent<v8::Object> some_object; 11820 v8::Persistent<v8::Object> some_object;
11825 v8::Persistent<v8::Object> bad_handle; 11821 v8::Persistent<v8::Object> bad_handle;
11826 11822
11827 11823
11828 void NewPersistentHandleCallback2( 11824 void NewPersistentHandleCallback2(
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after
15443 } 15439 }
15444 intptr_t final_size = CcTest::heap()->SizeOfObjects(); 15440 intptr_t final_size = CcTest::heap()->SizeOfObjects();
15445 CHECK(finished); 15441 CHECK(finished);
15446 CHECK_LT(final_size, initial_size + 1); 15442 CHECK_LT(final_size, initial_size + 1);
15447 } 15443 }
15448 15444
15449 15445
15450 TEST(Regress2333) { 15446 TEST(Regress2333) {
15451 LocalContext env; 15447 LocalContext env;
15452 for (int i = 0; i < 3; i++) { 15448 for (int i = 0; i < 3; i++) {
15453 CcTest::heap()->CollectGarbageNewSpace(); 15449 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
15454 } 15450 }
15455 } 15451 }
15456 15452
15457 static uint32_t* stack_limit; 15453 static uint32_t* stack_limit;
15458 15454
15459 static void GetStackLimitCallback( 15455 static void GetStackLimitCallback(
15460 const v8::FunctionCallbackInfo<v8::Value>& args) { 15456 const v8::FunctionCallbackInfo<v8::Value>& args) {
15461 stack_limit = reinterpret_cast<uint32_t*>( 15457 stack_limit = reinterpret_cast<uint32_t*>(
15462 CcTest::i_isolate()->stack_guard()->real_climit()); 15458 CcTest::i_isolate()->stack_guard()->real_climit());
15463 } 15459 }
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
16456 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 16452 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
16457 CHECK_EQ(gc_callbacks_isolate, isolate); 16453 CHECK_EQ(gc_callbacks_isolate, isolate);
16458 ++prologue_call_count_alloc; 16454 ++prologue_call_count_alloc;
16459 16455
16460 // Simulate full heap to see if we will reenter this callback 16456 // Simulate full heap to see if we will reenter this callback
16461 SimulateFullSpace(CcTest::heap()->new_space()); 16457 SimulateFullSpace(CcTest::heap()->new_space());
16462 16458
16463 Local<Object> obj = Object::New(isolate); 16459 Local<Object> obj = Object::New(isolate);
16464 CHECK(!obj.IsEmpty()); 16460 CHECK(!obj.IsEmpty());
16465 16461
16466 CcTest::heap()->CollectAllGarbage("PrologueCallbackAlloc", 16462 CcTest::heap()->CollectAllGarbage(
16467 i::Heap::kAbortIncrementalMarkingMask); 16463 i::Heap::kAbortIncrementalMarkingMask);
16468 } 16464 }
16469 16465
16470 16466
16471 void EpilogueCallbackAlloc(v8::Isolate* isolate, 16467 void EpilogueCallbackAlloc(v8::Isolate* isolate,
16472 v8::GCType, 16468 v8::GCType,
16473 v8::GCCallbackFlags flags) { 16469 v8::GCCallbackFlags flags) {
16474 v8::HandleScope scope(isolate); 16470 v8::HandleScope scope(isolate);
16475 16471
16476 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 16472 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
16477 CHECK_EQ(gc_callbacks_isolate, isolate); 16473 CHECK_EQ(gc_callbacks_isolate, isolate);
16478 ++epilogue_call_count_alloc; 16474 ++epilogue_call_count_alloc;
16479 16475
16480 // Simulate full heap to see if we will reenter this callback 16476 // Simulate full heap to see if we will reenter this callback
16481 SimulateFullSpace(CcTest::heap()->new_space()); 16477 SimulateFullSpace(CcTest::heap()->new_space());
16482 16478
16483 Local<Object> obj = Object::New(isolate); 16479 Local<Object> obj = Object::New(isolate);
16484 CHECK(!obj.IsEmpty()); 16480 CHECK(!obj.IsEmpty());
16485 16481
16486 CcTest::heap()->CollectAllGarbage("EpilogueCallbackAlloc", 16482 CcTest::heap()->CollectAllGarbage(
16487 i::Heap::kAbortIncrementalMarkingMask); 16483 i::Heap::kAbortIncrementalMarkingMask);
16488 } 16484 }
16489 16485
16490 16486
16491 TEST(GCCallbacksOld) { 16487 TEST(GCCallbacksOld) {
16492 LocalContext context; 16488 LocalContext context;
16493 16489
16494 v8::V8::AddGCPrologueCallback(PrologueCallback); 16490 v8::V8::AddGCPrologueCallback(PrologueCallback);
16495 v8::V8::AddGCEpilogueCallback(EpilogueCallback); 16491 v8::V8::AddGCEpilogueCallback(EpilogueCallback);
16496 CHECK_EQ(0, prologue_call_count); 16492 CHECK_EQ(0, prologue_call_count);
16497 CHECK_EQ(0, epilogue_call_count); 16493 CHECK_EQ(0, epilogue_call_count);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
16552 CcTest::heap()->CollectAllGarbage(); 16548 CcTest::heap()->CollectAllGarbage();
16553 CHECK_EQ(2, prologue_call_count); 16549 CHECK_EQ(2, prologue_call_count);
16554 CHECK_EQ(2, epilogue_call_count); 16550 CHECK_EQ(2, epilogue_call_count);
16555 CHECK_EQ(2, prologue_call_count_second); 16551 CHECK_EQ(2, prologue_call_count_second);
16556 CHECK_EQ(2, epilogue_call_count_second); 16552 CHECK_EQ(2, epilogue_call_count_second);
16557 16553
16558 CHECK_EQ(0, prologue_call_count_alloc); 16554 CHECK_EQ(0, prologue_call_count_alloc);
16559 CHECK_EQ(0, epilogue_call_count_alloc); 16555 CHECK_EQ(0, epilogue_call_count_alloc);
16560 isolate->AddGCPrologueCallback(PrologueCallbackAlloc); 16556 isolate->AddGCPrologueCallback(PrologueCallbackAlloc);
16561 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); 16557 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc);
16562 CcTest::heap()->CollectAllGarbage("GCCallbacks", 16558 CcTest::heap()->CollectAllGarbage(
16563 i::Heap::kAbortIncrementalMarkingMask); 16559 i::Heap::kAbortIncrementalMarkingMask);
16564 CHECK_EQ(1, prologue_call_count_alloc); 16560 CHECK_EQ(1, prologue_call_count_alloc);
16565 CHECK_EQ(1, epilogue_call_count_alloc); 16561 CHECK_EQ(1, epilogue_call_count_alloc);
16566 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc); 16562 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc);
16567 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc); 16563 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc);
16568 } 16564 }
16569 16565
16570 16566
16571 THREADED_TEST(TwoByteStringInOneByteCons) { 16567 THREADED_TEST(TwoByteStringInOneByteCons) {
16572 // See Chromium issue 47824. 16568 // See Chromium issue 47824.
16573 LocalContext context; 16569 LocalContext context;
(...skipping 5281 matching lines...) Expand 10 before | Expand all | Expand 10 after
21855 timeout_thread.Join(); 21851 timeout_thread.Join();
21856 } 21852 }
21857 21853
21858 21854
21859 TEST(EstimatedContextSize) { 21855 TEST(EstimatedContextSize) {
21860 v8::Isolate* isolate = CcTest::isolate(); 21856 v8::Isolate* isolate = CcTest::isolate();
21861 v8::HandleScope scope(isolate); 21857 v8::HandleScope scope(isolate);
21862 LocalContext env; 21858 LocalContext env;
21863 CHECK(50000 < env->EstimatedSize()); 21859 CHECK(50000 < env->EstimatedSize());
21864 } 21860 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698