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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( | 31 object->GetHeap()->UpdateAllocationSite<Heap::kGlobal>( |
32 object, object->GetHeap()->global_pretenuring_feedback_); | 32 object, object->GetHeap()->global_pretenuring_feedback_); |
33 | 33 |
34 // AllocationMementos are unrooted and shouldn't survive a scavenge | 34 // AllocationMementos are unrooted and shouldn't survive a scavenge |
35 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); | 35 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); |
36 // Call the slow part of scavenge object. | 36 // Call the slow part of scavenge object. |
37 return ScavengeObjectSlow(p, object); | 37 return ScavengeObjectSlow(p, object); |
38 } | 38 } |
39 | 39 |
| 40 SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap, |
| 41 Address slot_address) { |
| 42 Object** slot = reinterpret_cast<Object**>(slot_address); |
| 43 Object* object = *slot; |
| 44 if (heap->InFromSpace(object)) { |
| 45 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); |
| 46 DCHECK(heap_object->IsHeapObject()); |
| 47 |
| 48 ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object); |
| 49 |
| 50 object = *slot; |
| 51 // If the object was in from space before and is after executing the |
| 52 // callback in to space, the object is still live. |
| 53 // Unfortunately, we do not know about the slot. It could be in a |
| 54 // just freed free space object. |
| 55 if (heap->InToSpace(object)) { |
| 56 return KEEP_SLOT; |
| 57 } |
| 58 } else { |
| 59 DCHECK(!heap->InNewSpace(object)); |
| 60 } |
| 61 return REMOVE_SLOT; |
| 62 } |
40 | 63 |
41 // static | 64 // static |
42 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, | 65 void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj, |
43 Object** p) { | 66 Object** p) { |
44 Object* object = *p; | 67 Object* object = *p; |
45 if (!heap->InNewSpace(object)) return; | 68 if (!heap->InNewSpace(object)) return; |
46 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 69 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
47 reinterpret_cast<HeapObject*>(object)); | 70 reinterpret_cast<HeapObject*>(object)); |
48 } | 71 } |
49 | 72 |
50 } // namespace internal | 73 } // namespace internal |
51 } // namespace v8 | 74 } // namespace v8 |
52 | 75 |
53 #endif // V8_HEAP_SCAVENGER_INL_H_ | 76 #endif // V8_HEAP_SCAVENGER_INL_H_ |
OLD | NEW |