OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_HEAP_SCAVENGER_INL_H_ |
| 6 #define V8_HEAP_SCAVENGER_INL_H_ |
| 7 |
| 8 #include "src/heap/scavenger.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 |
| 13 void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object) { |
| 14 DCHECK(object->GetIsolate()->heap()->InFromSpace(object)); |
| 15 |
| 16 // We use the first word (where the map pointer usually is) of a heap |
| 17 // object to record the forwarding pointer. A forwarding pointer can |
| 18 // point to an old space, the code space, or the to space of the new |
| 19 // generation. |
| 20 MapWord first_word = object->map_word(); |
| 21 |
| 22 // If the first word is a forwarding address, the object has already been |
| 23 // copied. |
| 24 if (first_word.IsForwardingAddress()) { |
| 25 HeapObject* dest = first_word.ToForwardingAddress(); |
| 26 DCHECK(object->GetIsolate()->heap()->InFromSpace(*p)); |
| 27 *p = dest; |
| 28 return; |
| 29 } |
| 30 |
| 31 Heap::UpdateAllocationSiteFeedback(object, Heap::IGNORE_SCRATCHPAD_SLOT); |
| 32 |
| 33 // AllocationMementos are unrooted and shouldn't survive a scavenge |
| 34 DCHECK(object->map() != object->GetHeap()->allocation_memento_map()); |
| 35 // Call the slow part of scavenge object. |
| 36 return ScavengeObjectSlow(p, object); |
| 37 } |
| 38 |
| 39 |
| 40 // static |
| 41 void StaticScavengeVisitor::VisitPointer(Heap* heap, Object** p) { |
| 42 Object* object = *p; |
| 43 if (!heap->InNewSpace(object)) return; |
| 44 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 45 reinterpret_cast<HeapObject*>(object)); |
| 46 } |
| 47 |
| 48 } // namespace internal |
| 49 } // namespace v8 |
| 50 |
| 51 #endif // V8_HEAP_SCAVENGER_INL_H_ |
OLD | NEW |