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

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

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: rebase Created 4 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 | « test/cctest/cctest.cc ('k') | test/cctest/heap/test-alloc.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/cctest/heap/heap-utils.h" 5 #include "test/cctest/heap/heap-utils.h"
6 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/heap/incremental-marking.h" 9 #include "src/heap/incremental-marking.h"
10 #include "src/heap/mark-compact.h" 10 #include "src/heap/mark-compact.h"
11 #include "src/isolate.h" 11 #include "src/isolate.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace heap { 15 namespace heap {
16 16
17 void SealCurrentObjects(Heap* heap) { 17 void SealCurrentObjects(Heap* heap) {
18 heap->CollectAllGarbage(); 18 heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask,
19 heap->CollectAllGarbage(); 19 GarbageCollectionReason::kTesting);
20 heap->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask,
21 GarbageCollectionReason::kTesting);
20 heap->mark_compact_collector()->EnsureSweepingCompleted(); 22 heap->mark_compact_collector()->EnsureSweepingCompleted();
21 heap->old_space()->EmptyAllocationInfo(); 23 heap->old_space()->EmptyAllocationInfo();
22 for (Page* page : *heap->old_space()) { 24 for (Page* page : *heap->old_space()) {
23 page->MarkNeverAllocateForTesting(); 25 page->MarkNeverAllocateForTesting();
24 } 26 }
25 } 27 }
26 28
27 int FixedArrayLenFromSize(int size) { 29 int FixedArrayLenFromSize(int size) {
28 return (size - FixedArray::kHeaderSize) / kPointerSize; 30 return (size - FixedArray::kHeaderSize) / kPointerSize;
29 } 31 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 i::IncrementalMarking* marking = heap->incremental_marking(); 146 i::IncrementalMarking* marking = heap->incremental_marking();
145 i::MarkCompactCollector* collector = heap->mark_compact_collector(); 147 i::MarkCompactCollector* collector = heap->mark_compact_collector();
146 if (collector->sweeping_in_progress()) { 148 if (collector->sweeping_in_progress()) {
147 collector->EnsureSweepingCompleted(); 149 collector->EnsureSweepingCompleted();
148 } 150 }
149 if (marking->IsSweeping()) { 151 if (marking->IsSweeping()) {
150 marking->FinalizeSweeping(); 152 marking->FinalizeSweeping();
151 } 153 }
152 CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete()); 154 CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete());
153 if (marking->IsStopped()) { 155 if (marking->IsStopped()) {
154 heap->StartIncrementalMarking(); 156 heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
157 i::GarbageCollectionReason::kTesting);
155 } 158 }
156 CHECK(marking->IsMarking() || marking->IsComplete()); 159 CHECK(marking->IsMarking() || marking->IsComplete());
157 if (!force_completion) return; 160 if (!force_completion) return;
158 161
159 while (!marking->IsComplete()) { 162 while (!marking->IsComplete()) {
160 marking->Step(i::MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, 163 marking->Step(i::MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
161 i::IncrementalMarking::FORCE_COMPLETION); 164 i::IncrementalMarking::FORCE_COMPLETION);
162 if (marking->IsReadyToOverApproximateWeakClosure()) { 165 if (marking->IsReadyToOverApproximateWeakClosure()) {
163 marking->FinalizeIncrementally(); 166 marking->FinalizeIncrementally();
164 } 167 }
165 } 168 }
166 CHECK(marking->IsComplete()); 169 CHECK(marking->IsComplete());
167 } 170 }
168 171
169 void SimulateFullSpace(v8::internal::PagedSpace* space) { 172 void SimulateFullSpace(v8::internal::PagedSpace* space) {
170 space->EmptyAllocationInfo(); 173 space->EmptyAllocationInfo();
171 space->ResetFreeList(); 174 space->ResetFreeList();
172 space->ClearStats(); 175 space->ClearStats();
173 } 176 }
174 177
175 void AbandonCurrentlyFreeMemory(PagedSpace* space) { 178 void AbandonCurrentlyFreeMemory(PagedSpace* space) {
176 space->EmptyAllocationInfo(); 179 space->EmptyAllocationInfo();
177 for (Page* page : *space) { 180 for (Page* page : *space) {
178 page->MarkNeverAllocateForTesting(); 181 page->MarkNeverAllocateForTesting();
179 } 182 }
180 } 183 }
181 184
182 void GcAndSweep(Heap* heap, AllocationSpace space) { 185 void GcAndSweep(Heap* heap, AllocationSpace space) {
183 heap->CollectGarbage(space); 186 heap->CollectGarbage(space, GarbageCollectionReason::kTesting);
184 if (heap->mark_compact_collector()->sweeping_in_progress()) { 187 if (heap->mark_compact_collector()->sweeping_in_progress()) {
185 heap->mark_compact_collector()->EnsureSweepingCompleted(); 188 heap->mark_compact_collector()->EnsureSweepingCompleted();
186 } 189 }
187 } 190 }
188 191
189 } // namespace heap 192 } // namespace heap
190 } // namespace internal 193 } // namespace internal
191 } // namespace v8 194 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/cctest/heap/test-alloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698