Chromium Code Reviews| 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 #ifndef V8_HEAP_SCAVENGER_INL_H_ | 5 #ifndef V8_HEAP_SCAVENGER_INL_H_ |
| 6 #define V8_HEAP_SCAVENGER_INL_H_ | 6 #define V8_HEAP_SCAVENGER_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap/scavenger.h" | 8 #include "src/heap/scavenger.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( | 32 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( |
| 33 object, object->GetHeap()->global_pretenuring_feedback_); | 33 object, object->GetHeap()->global_pretenuring_feedback_); |
| 34 | 34 |
| 35 // AllocationMementos are unrooted and shouldn't survive a scavenge | 35 // AllocationMementos are unrooted and shouldn't survive a scavenge |
| 36 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); | 36 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); |
| 37 // Call the slow part of scavenge object. | 37 // Call the slow part of scavenge object. |
| 38 return ScavengeObjectSlow(p, object, promotion_mode); | 38 return ScavengeObjectSlow(p, object, promotion_mode); |
| 39 } | 39 } |
| 40 | 40 |
| 41 SlotCallbackResult Scavenger::CheckAndScavengeObject( | 41 SlotCallbackResult Scavenger::CheckAndScavengeObject( |
| 42 Heap* heap, Address slot_address, PromotionMode promotion_mode) { | 42 Heap* heap, Address slot_address, PromotionMode promotion_mode) { |
|
ulan
2016/05/24 16:41:59
Callers of this function should be changed too.
I
| |
| 43 Object** slot = reinterpret_cast<Object**>(slot_address); | 43 Object** slot = reinterpret_cast<Object**>(slot_address); |
| 44 Object* object = *slot; | 44 Object* object = *slot; |
| 45 if (heap->InFromSpace(object)) { | 45 if (heap->InFromSpace(object)) { |
| 46 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); | 46 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); |
| 47 DCHECK(heap_object->IsHeapObject()); | 47 DCHECK(heap_object->IsHeapObject()); |
| 48 | 48 |
| 49 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object, | 49 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object, |
| 50 promotion_mode); | 50 promotion_mode); |
| 51 | 51 |
| 52 object = *slot; | 52 object = *slot; |
| 53 // If the object was in from space before and is after executing the | 53 // If the object was in from space before and is after executing the |
| 54 // callback in to space, the object is still live. | 54 // callback in to space, the object is still live. |
| 55 // Unfortunately, we do not know about the slot. It could be in a | 55 // Unfortunately, we do not know about the slot. It could be in a |
| 56 // just freed free space object. | 56 // just freed free space object. |
| 57 if (heap->InToSpace(object)) { | 57 if (heap->InToSpace(object)) { |
| 58 return KEEP_SLOT; | 58 return KEEP_SLOT; |
| 59 } | 59 } |
| 60 } else { | 60 } else { |
| 61 DCHECK(!heap->InNewSpace(object)); | 61 DCHECK(!heap->InNewSpace(object)); |
| 62 } | 62 } |
| 63 return REMOVE_SLOT; | 63 return REMOVE_SLOT; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // static | 66 // static |
| 67 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, | 67 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, |
| 68 Object** p) { | 68 Object** p) { |
| 69 Object* object = *p; | 69 Object* object = *p; |
| 70 if (!heap->InNewSpace(object)) return; | 70 if (!heap->InNewSpace(object)) return; |
| 71 PromotionMode promotion_mode = heap->incremental_marking()->IsMarking() | |
| 72 ? PROMOTE_MARKED | |
| 73 : DEFAULT_PROMOTION; | |
| 71 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 74 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 72 reinterpret_cast<HeapObject*>(object), | 75 reinterpret_cast<HeapObject*>(object), |
| 73 DEFAULT_PROMOTION); | 76 promotion_mode); |
| 74 } | 77 } |
| 75 | 78 |
| 76 } // namespace internal | 79 } // namespace internal |
| 77 } // namespace v8 | 80 } // namespace v8 |
| 78 | 81 |
| 79 #endif // V8_HEAP_SCAVENGER_INL_H_ | 82 #endif // V8_HEAP_SCAVENGER_INL_H_ |
| OLD | NEW |