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

Side by Side Diff: src/heap/scavenger.cc

Issue 2005173003: Immediatelly promote marked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rewrite using PromotionMode Created 4 years, 7 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/heap/scavenger.h" 5 #include "src/heap/scavenger.h"
6 6
7 #include "src/contexts.h" 7 #include "src/contexts.h"
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/heap/objects-visiting-inl.h" 9 #include "src/heap/objects-visiting-inl.h"
10 #include "src/heap/scavenger-inl.h" 10 #include "src/heap/scavenger-inl.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 template <ObjectContents object_contents, AllocationAlignment alignment> 203 template <ObjectContents object_contents, AllocationAlignment alignment>
204 static inline void EvacuateObject(Map* map, HeapObject** slot, 204 static inline void EvacuateObject(Map* map, HeapObject** slot,
205 HeapObject* object, int object_size, 205 HeapObject* object, int object_size,
206 PromotionMode promotion_mode) { 206 PromotionMode promotion_mode) {
207 SLOW_DCHECK(object_size <= Page::kAllocatableMemory); 207 SLOW_DCHECK(object_size <= Page::kAllocatableMemory);
208 SLOW_DCHECK(object->Size() == object_size); 208 SLOW_DCHECK(object->Size() == object_size);
209 Heap* heap = map->GetHeap(); 209 Heap* heap = map->GetHeap();
210 210
211 if (promotion_mode != FORCE_PROMOTION && 211 if (!heap->ShouldBePromoted(object->address(), object_size,
212 !heap->ShouldBePromoted(object->address(), object_size)) { 212 promotion_mode)) {
213 // A semi-space copy may fail due to fragmentation. In that case, we 213 // A semi-space copy may fail due to fragmentation. In that case, we
214 // try to promote the object. 214 // try to promote the object.
215 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) { 215 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) {
216 return; 216 return;
217 } 217 }
218 } 218 }
219 219
220 if (PromoteObject<object_contents, alignment>(map, slot, object, 220 if (PromoteObject<object_contents, alignment>(map, slot, object,
221 object_size)) { 221 object_size)) {
222 return; 222 return;
223 } 223 }
224 if (promotion_mode == FORCE_PROMOTION) { 224 if (promotion_mode == FORCE_PROMOTION) {
225 FatalProcessOutOfMemory("Scavenger: forced promotion\n"); 225 FatalProcessOutOfMemory("Scavenger: forced promotion\n");
226 } 226 }
227 if (promotion_mode == PROMOTE_MARKED) {
228 FatalProcessOutOfMemory("Scavenger: promoting marked\n");
229 }
227 // If promotion failed, we try to copy the object to the other semi-space 230 // If promotion failed, we try to copy the object to the other semi-space
228 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return; 231 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
229 232
230 FatalProcessOutOfMemory("Scavenger: semi-space copy\n"); 233 FatalProcessOutOfMemory("Scavenger: semi-space copy\n");
231 } 234 }
232 235
233 static inline void EvacuateJSFunction(Map* map, HeapObject** slot, 236 static inline void EvacuateJSFunction(Map* map, HeapObject** slot,
234 HeapObject* object, 237 HeapObject* object,
235 PromotionMode promotion_mode) { 238 PromotionMode promotion_mode) {
236 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object, 239 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 467
465 void ScavengeVisitor::VisitPointers(Object** start, Object** end) { 468 void ScavengeVisitor::VisitPointers(Object** start, Object** end) {
466 // Copy all HeapObject pointers in [start, end) 469 // Copy all HeapObject pointers in [start, end)
467 for (Object** p = start; p < end; p++) ScavengePointer(p); 470 for (Object** p = start; p < end; p++) ScavengePointer(p);
468 } 471 }
469 472
470 473
471 void ScavengeVisitor::ScavengePointer(Object** p) { 474 void ScavengeVisitor::ScavengePointer(Object** p) {
472 Object* object = *p; 475 Object* object = *p;
473 if (!heap_->InNewSpace(object)) return; 476 if (!heap_->InNewSpace(object)) return;
477 PromotionMode promotion_mode = heap_->incremental_marking()->IsMarking()
478 ? PROMOTE_MARKED
479 : DEFAULT_PROMOTION;
474 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), 480 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p),
475 reinterpret_cast<HeapObject*>(object)); 481 reinterpret_cast<HeapObject*>(object),
482 promotion_mode);
476 } 483 }
477 484
478 } // namespace internal 485 } // namespace internal
479 } // namespace v8 486 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/scavenger.h ('k') | src/heap/scavenger-inl.h » ('j') | src/heap/scavenger-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698