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

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

Issue 2211893002: [heap] Temporarily do not use size to iterate live object to investigate Win 10 memory regression. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove invalid check Created 4 years, 4 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/heap/mark-compact-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 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 6810 matching lines...) Expand 10 before | Expand all | Expand 10 after
6821 } 6821 }
6822 } 6822 }
6823 CHECK(marking->IsComplete()); 6823 CHECK(marking->IsComplete());
6824 intptr_t size_before = heap->SizeOfObjects(); 6824 intptr_t size_before = heap->SizeOfObjects();
6825 CcTest::heap()->CollectAllGarbage(); 6825 CcTest::heap()->CollectAllGarbage();
6826 intptr_t size_after = heap->SizeOfObjects(); 6826 intptr_t size_after = heap->SizeOfObjects();
6827 // Live size does not increase after garbage collection. 6827 // Live size does not increase after garbage collection.
6828 CHECK_LE(size_after, size_before); 6828 CHECK_LE(size_after, size_before);
6829 } 6829 }
6830 6830
6831 TEST(LeftTrimFixedArrayInBlackArea) {
6832 FLAG_black_allocation = true;
6833 CcTest::InitializeVM();
6834 v8::HandleScope scope(CcTest::isolate());
6835 Heap* heap = CcTest::heap();
6836 Isolate* isolate = heap->isolate();
6837 heap->CollectAllGarbage();
6838
6839 i::MarkCompactCollector* collector = heap->mark_compact_collector();
6840 i::IncrementalMarking* marking = heap->incremental_marking();
6841 if (collector->sweeping_in_progress()) {
6842 collector->EnsureSweepingCompleted();
6843 }
6844 CHECK(marking->IsMarking() || marking->IsStopped());
6845 if (marking->IsStopped()) {
6846 heap->StartIncrementalMarking();
6847 }
6848 CHECK(marking->IsMarking());
6849 marking->StartBlackAllocationForTesting();
6850
6851 // Ensure that we allocate a new page, set up a bump pointer area, and
6852 // perform the allocation in a black area.
6853 heap::SimulateFullSpace(heap->old_space());
6854 isolate->factory()->NewFixedArray(4, TENURED);
6855 Handle<FixedArray> array = isolate->factory()->NewFixedArray(50, TENURED);
6856 CHECK(heap->old_space()->Contains(*array));
6857 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
6858
6859 // Now left trim the allocated black area. A filler has to be installed
6860 // for the trimmed area and all mark bits of the trimmed area have to be
6861 // cleared.
6862 FixedArrayBase* trimmed = heap->LeftTrimFixedArray(*array, 10);
6863 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
6864
6865 heap::GcAndSweep(heap, OLD_SPACE);
6866 }
6867
6868 TEST(ContinuousLeftTrimFixedArrayInBlackArea) {
6869 FLAG_black_allocation = true;
6870 CcTest::InitializeVM();
6871 v8::HandleScope scope(CcTest::isolate());
6872 Heap* heap = CcTest::heap();
6873 Isolate* isolate = heap->isolate();
6874 heap->CollectAllGarbage();
6875
6876 i::MarkCompactCollector* collector = heap->mark_compact_collector();
6877 i::IncrementalMarking* marking = heap->incremental_marking();
6878 if (collector->sweeping_in_progress()) {
6879 collector->EnsureSweepingCompleted();
6880 }
6881 CHECK(marking->IsMarking() || marking->IsStopped());
6882 if (marking->IsStopped()) {
6883 heap->StartIncrementalMarking();
6884 }
6885 CHECK(marking->IsMarking());
6886 marking->StartBlackAllocationForTesting();
6887
6888 // Ensure that we allocate a new page, set up a bump pointer area, and
6889 // perform the allocation in a black area.
6890 heap::SimulateFullSpace(heap->old_space());
6891 isolate->factory()->NewFixedArray(10, TENURED);
6892
6893 // Allocate the fixed array that will be trimmed later.
6894 Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
6895 Address start_address = array->address();
6896 Address end_address = start_address + array->Size();
6897 Page* page = Page::FromAddress(start_address);
6898 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
6899 CHECK(page->markbits()->AllBitsSetInRange(
6900 page->AddressToMarkbitIndex(start_address),
6901 page->AddressToMarkbitIndex(end_address)));
6902 CHECK(heap->old_space()->Contains(*array));
6903
6904 FixedArrayBase* previous = *array;
6905 FixedArrayBase* trimmed;
6906
6907 // First trim in one word steps.
6908 for (int i = 0; i < 10; i++) {
6909 trimmed = heap->LeftTrimFixedArray(previous, 1);
6910 HeapObject* filler = HeapObject::FromAddress(previous->address());
6911 CHECK(filler->IsFiller());
6912 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
6913 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
6914 previous = trimmed;
6915 }
6916
6917 // Then trim in two and three word steps.
6918 for (int i = 2; i <= 3; i++) {
6919 for (int j = 0; j < 10; j++) {
6920 trimmed = heap->LeftTrimFixedArray(previous, i);
6921 HeapObject* filler = HeapObject::FromAddress(previous->address());
6922 CHECK(filler->IsFiller());
6923 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
6924 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
6925 previous = trimmed;
6926 }
6927 }
6928
6929 heap::GcAndSweep(heap, OLD_SPACE);
6930 }
6931
6932 TEST(ContinuousRightTrimFixedArrayInBlackArea) {
6933 FLAG_black_allocation = true;
6934 CcTest::InitializeVM();
6935 v8::HandleScope scope(CcTest::isolate());
6936 Heap* heap = CcTest::heap();
6937 Isolate* isolate = heap->isolate();
6938 heap->CollectAllGarbage();
6939
6940 i::MarkCompactCollector* collector = heap->mark_compact_collector();
6941 i::IncrementalMarking* marking = heap->incremental_marking();
6942 if (collector->sweeping_in_progress()) {
6943 collector->EnsureSweepingCompleted();
6944 }
6945 CHECK(marking->IsMarking() || marking->IsStopped());
6946 if (marking->IsStopped()) {
6947 heap->StartIncrementalMarking();
6948 }
6949 CHECK(marking->IsMarking());
6950 marking->StartBlackAllocationForTesting();
6951
6952 // Ensure that we allocate a new page, set up a bump pointer area, and
6953 // perform the allocation in a black area.
6954 heap::SimulateFullSpace(heap->old_space());
6955 isolate->factory()->NewFixedArray(10, TENURED);
6956
6957 // Allocate the fixed array that will be trimmed later.
6958 Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
6959 Address start_address = array->address();
6960 Address end_address = start_address + array->Size();
6961 Page* page = Page::FromAddress(start_address);
6962 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
6963 CHECK(page->markbits()->AllBitsSetInRange(
6964 page->AddressToMarkbitIndex(start_address),
6965 page->AddressToMarkbitIndex(end_address)));
6966 CHECK(heap->old_space()->Contains(*array));
6967
6968 // Trim it once by one word to make checking for white marking color uniform.
6969 Address previous = end_address - kPointerSize;
6970 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, 1);
6971 HeapObject* filler = HeapObject::FromAddress(previous);
6972 CHECK(filler->IsFiller());
6973 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
6974
6975 // Trim 10 times by one, two, and three word.
6976 for (int i = 1; i <= 3; i++) {
6977 for (int j = 0; j < 10; j++) {
6978 previous -= kPointerSize * i;
6979 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, i);
6980 HeapObject* filler = HeapObject::FromAddress(previous);
6981 CHECK(filler->IsFiller());
6982 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
6983 }
6984 }
6985
6986 heap::GcAndSweep(heap, OLD_SPACE);
6987 }
6988
6989 TEST(Regress618958) { 6831 TEST(Regress618958) {
6990 CcTest::InitializeVM(); 6832 CcTest::InitializeVM();
6991 v8::HandleScope scope(CcTest::isolate()); 6833 v8::HandleScope scope(CcTest::isolate());
6992 Heap* heap = CcTest::heap(); 6834 Heap* heap = CcTest::heap();
6993 bool isolate_is_locked = true; 6835 bool isolate_is_locked = true;
6994 heap->update_external_memory(100 * MB); 6836 heap->update_external_memory(100 * MB);
6995 int mark_sweep_count_before = heap->ms_count(); 6837 int mark_sweep_count_before = heap->ms_count();
6996 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, 6838 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical,
6997 isolate_is_locked); 6839 isolate_is_locked);
6998 int mark_sweep_count_after = heap->ms_count(); 6840 int mark_sweep_count_after = heap->ms_count();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
7085 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); 6927 chunk, chunk->area_end() - kPointerSize, chunk->area_end());
7086 slots[chunk->area_end() - kPointerSize] = false; 6928 slots[chunk->area_end() - kPointerSize] = false;
7087 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { 6929 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) {
7088 CHECK(slots[addr]); 6930 CHECK(slots[addr]);
7089 return KEEP_SLOT; 6931 return KEEP_SLOT;
7090 }); 6932 });
7091 } 6933 }
7092 6934
7093 } // namespace internal 6935 } // namespace internal
7094 } // namespace v8 6936 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698