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

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

Issue 2139133003: [heap] Untangle Marking and friends from heap dependencies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comment formatting Created 4 years, 5 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/v8.gyp ('k') | test/cctest/test-unboxed-doubles.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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 713
714 TEST(DoNotPromoteWhiteObjectsOnScavenge) { 714 TEST(DoNotPromoteWhiteObjectsOnScavenge) {
715 CcTest::InitializeVM(); 715 CcTest::InitializeVM();
716 Isolate* isolate = CcTest::i_isolate(); 716 Isolate* isolate = CcTest::i_isolate();
717 Heap* heap = isolate->heap(); 717 Heap* heap = isolate->heap();
718 Factory* factory = isolate->factory(); 718 Factory* factory = isolate->factory();
719 719
720 HandleScope scope(isolate); 720 HandleScope scope(isolate);
721 Handle<Object> white = factory->NewStringFromStaticChars("white"); 721 Handle<Object> white = factory->NewStringFromStaticChars("white");
722 722
723 CHECK(Marking::IsWhite(Marking::MarkBitFrom(HeapObject::cast(*white)))); 723 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(HeapObject::cast(*white))));
724 724
725 heap->CollectGarbage(NEW_SPACE); 725 heap->CollectGarbage(NEW_SPACE);
726 726
727 CHECK(heap->InNewSpace(*white)); 727 CHECK(heap->InNewSpace(*white));
728 } 728 }
729 729
730 TEST(PromoteGreyOrBlackObjectsOnScavenge) { 730 TEST(PromoteGreyOrBlackObjectsOnScavenge) {
731 CcTest::InitializeVM(); 731 CcTest::InitializeVM();
732 Isolate* isolate = CcTest::i_isolate(); 732 Isolate* isolate = CcTest::i_isolate();
733 Heap* heap = isolate->heap(); 733 Heap* heap = isolate->heap();
734 Factory* factory = isolate->factory(); 734 Factory* factory = isolate->factory();
735 735
736 HandleScope scope(isolate); 736 HandleScope scope(isolate);
737 Handle<Object> marked = factory->NewStringFromStaticChars("marked"); 737 Handle<Object> marked = factory->NewStringFromStaticChars("marked");
738 738
739 IncrementalMarking* marking = heap->incremental_marking(); 739 IncrementalMarking* marking = heap->incremental_marking();
740 marking->Stop(); 740 marking->Stop();
741 heap->StartIncrementalMarking(); 741 heap->StartIncrementalMarking();
742 while (Marking::IsWhite(Marking::MarkBitFrom(HeapObject::cast(*marked)))) { 742 while (
743 Marking::IsWhite(ObjectMarking::MarkBitFrom(HeapObject::cast(*marked)))) {
743 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, 744 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD,
744 IncrementalMarking::FORCE_MARKING, 745 IncrementalMarking::FORCE_MARKING,
745 IncrementalMarking::DO_NOT_FORCE_COMPLETION); 746 IncrementalMarking::DO_NOT_FORCE_COMPLETION);
746 } 747 }
747 748
748 heap->CollectGarbage(NEW_SPACE); 749 heap->CollectGarbage(NEW_SPACE);
749 750
750 CHECK(!heap->InNewSpace(*marked)); 751 CHECK(!heap->InNewSpace(*marked));
751 } 752 }
752 753
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2626 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2626 marking->Stop(); 2627 marking->Stop();
2627 CcTest::heap()->StartIncrementalMarking(); 2628 CcTest::heap()->StartIncrementalMarking();
2628 2629
2629 i::Handle<JSFunction> f = i::Handle<JSFunction>::cast( 2630 i::Handle<JSFunction> f = i::Handle<JSFunction>::cast(
2630 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( 2631 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
2631 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); 2632 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
2632 2633
2633 CHECK(f->IsOptimized()); 2634 CHECK(f->IsOptimized());
2634 2635
2635 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && 2636 while (!Marking::IsBlack(ObjectMarking::MarkBitFrom(f->code())) &&
2636 !marking->IsStopped()) { 2637 !marking->IsStopped()) {
2637 // Discard any pending GC requests otherwise we will get GC when we enter 2638 // Discard any pending GC requests otherwise we will get GC when we enter
2638 // code below. 2639 // code below.
2639 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 2640 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
2640 } 2641 }
2641 2642
2642 CHECK(marking->IsMarking()); 2643 CHECK(marking->IsMarking());
2643 2644
2644 { 2645 {
2645 v8::HandleScope scope(CcTest::isolate()); 2646 v8::HandleScope scope(CcTest::isolate());
(...skipping 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after
5758 "}" 5759 "}"
5759 "weak_map"); 5760 "weak_map");
5760 if (marking->IsStopped()) { 5761 if (marking->IsStopped()) {
5761 CcTest::heap()->StartIncrementalMarking(); 5762 CcTest::heap()->StartIncrementalMarking();
5762 } 5763 }
5763 // Incrementally mark the backing store. 5764 // Incrementally mark the backing store.
5764 Handle<JSReceiver> obj = 5765 Handle<JSReceiver> obj =
5765 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); 5766 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result));
5766 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj)); 5767 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj));
5767 while (!Marking::IsBlack( 5768 while (!Marking::IsBlack(
5768 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) && 5769 ObjectMarking::MarkBitFrom(HeapObject::cast(weak_map->table()))) &&
5769 !marking->IsStopped()) { 5770 !marking->IsStopped()) {
5770 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 5771 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
5771 } 5772 }
5772 // Stash the backing store in a handle. 5773 // Stash the backing store in a handle.
5773 Handle<Object> save(weak_map->table(), isolate); 5774 Handle<Object> save(weak_map->table(), isolate);
5774 // The following line will update the backing store. 5775 // The following line will update the backing store.
5775 CompileRun( 5776 CompileRun(
5776 "for (var i = 0; i < 50; i++) {" 5777 "for (var i = 0; i < 50; i++) {"
5777 " weak_map.set(future_keys[i], i);" 5778 " weak_map.set(future_keys[i], i);"
5778 "}"); 5779 "}");
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
6673 CHECK_NOT_NULL(page); 6674 CHECK_NOT_NULL(page);
6674 6675
6675 // GC to cleanup state 6676 // GC to cleanup state
6676 heap->CollectGarbage(OLD_SPACE); 6677 heap->CollectGarbage(OLD_SPACE);
6677 MarkCompactCollector* collector = heap->mark_compact_collector(); 6678 MarkCompactCollector* collector = heap->mark_compact_collector();
6678 if (collector->sweeping_in_progress()) { 6679 if (collector->sweeping_in_progress()) {
6679 collector->EnsureSweepingCompleted(); 6680 collector->EnsureSweepingCompleted();
6680 } 6681 }
6681 6682
6682 CHECK(heap->lo_space()->Contains(arr.get())); 6683 CHECK(heap->lo_space()->Contains(arr.get()));
6683 CHECK(Marking::IsWhite(Marking::MarkBitFrom(arr.get()))); 6684 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(arr.get())));
6684 for (int i = 0; i < arr.get()->length(); i++) { 6685 for (int i = 0; i < arr.get()->length(); i++) {
6685 CHECK(Marking::IsWhite( 6686 CHECK(Marking::IsWhite(
6686 Marking::MarkBitFrom(HeapObject::cast(arr.get()->get(i))))); 6687 ObjectMarking::MarkBitFrom(HeapObject::cast(arr.get()->get(i)))));
6687 } 6688 }
6688 6689
6689 // Start incremental marking. 6690 // Start incremental marking.
6690 IncrementalMarking* marking = heap->incremental_marking(); 6691 IncrementalMarking* marking = heap->incremental_marking();
6691 CHECK(marking->IsMarking() || marking->IsStopped()); 6692 CHECK(marking->IsMarking() || marking->IsStopped());
6692 if (marking->IsStopped()) { 6693 if (marking->IsStopped()) {
6693 heap->StartIncrementalMarking(); 6694 heap->StartIncrementalMarking();
6694 } 6695 }
6695 CHECK(marking->IsMarking()); 6696 CHECK(marking->IsMarking());
6696 6697
6697 // Check that we have not marked the interesting array during root scanning. 6698 // Check that we have not marked the interesting array during root scanning.
6698 for (int i = 0; i < arr.get()->length(); i++) { 6699 for (int i = 0; i < arr.get()->length(); i++) {
6699 CHECK(Marking::IsWhite( 6700 CHECK(Marking::IsWhite(
6700 Marking::MarkBitFrom(HeapObject::cast(arr.get()->get(i))))); 6701 ObjectMarking::MarkBitFrom(HeapObject::cast(arr.get()->get(i)))));
6701 } 6702 }
6702 6703
6703 // Now we search for a state where we are in incremental marking and have 6704 // Now we search for a state where we are in incremental marking and have
6704 // only partially marked the large object. 6705 // only partially marked the large object.
6705 while (!marking->IsComplete()) { 6706 while (!marking->IsComplete()) {
6706 marking->Step(i::KB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD); 6707 marking->Step(i::KB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD);
6707 if (page->IsFlagSet(Page::HAS_PROGRESS_BAR) && page->progress_bar() > 0) { 6708 if (page->IsFlagSet(Page::HAS_PROGRESS_BAR) && page->progress_bar() > 0) {
6708 CHECK_NE(page->progress_bar(), arr.get()->Size()); 6709 CHECK_NE(page->progress_bar(), arr.get()->Size());
6709 { 6710 {
6710 // Shift by 1, effectively moving one white object across the progress 6711 // Shift by 1, effectively moving one white object across the progress
(...skipping 13 matching lines...) Expand all
6724 if (marking->IsReadyToOverApproximateWeakClosure()) { 6725 if (marking->IsReadyToOverApproximateWeakClosure()) {
6725 marking->FinalizeIncrementally(); 6726 marking->FinalizeIncrementally();
6726 } 6727 }
6727 } 6728 }
6728 CHECK(marking->IsComplete()); 6729 CHECK(marking->IsComplete());
6729 6730
6730 // All objects need to be black after marking. If a white object crossed the 6731 // All objects need to be black after marking. If a white object crossed the
6731 // progress bar, we would fail here. 6732 // progress bar, we would fail here.
6732 for (int i = 0; i < arr.get()->length(); i++) { 6733 for (int i = 0; i < arr.get()->length(); i++) {
6733 CHECK(Marking::IsBlack( 6734 CHECK(Marking::IsBlack(
6734 Marking::MarkBitFrom(HeapObject::cast(arr.get()->get(i))))); 6735 ObjectMarking::MarkBitFrom(HeapObject::cast(arr.get()->get(i)))));
6735 } 6736 }
6736 } 6737 }
6737 6738
6738 TEST(Regress609761) { 6739 TEST(Regress609761) {
6739 CcTest::InitializeVM(); 6740 CcTest::InitializeVM();
6740 v8::HandleScope scope(CcTest::isolate()); 6741 v8::HandleScope scope(CcTest::isolate());
6741 Heap* heap = CcTest::heap(); 6742 Heap* heap = CcTest::heap();
6742 Isolate* isolate = heap->isolate(); 6743 Isolate* isolate = heap->isolate();
6743 6744
6744 intptr_t size_before = heap->SizeOfObjects(); 6745 intptr_t size_before = heap->SizeOfObjects();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
6884 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); 6885 chunk, chunk->area_end() - kPointerSize, chunk->area_end());
6885 slots[chunk->area_end() - kPointerSize] = false; 6886 slots[chunk->area_end() - kPointerSize] = false;
6886 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { 6887 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) {
6887 CHECK(slots[addr]); 6888 CHECK(slots[addr]);
6888 return KEEP_SLOT; 6889 return KEEP_SLOT;
6889 }); 6890 });
6890 } 6891 }
6891 6892
6892 } // namespace internal 6893 } // namespace internal
6893 } // namespace v8 6894 } // namespace v8
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/test-unboxed-doubles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698