OLD | NEW |
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 Loading... |
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
474 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 477 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
475 reinterpret_cast<HeapObject*>(object)); | 478 reinterpret_cast<HeapObject*>(object), |
| 479 heap_->CurrentPromotionMode()); |
476 } | 480 } |
477 | 481 |
478 } // namespace internal | 482 } // namespace internal |
479 } // namespace v8 | 483 } // namespace v8 |
OLD | NEW |