| 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-inl.h" | 8 #include "src/heap/heap-inl.h" |
| 9 #include "src/heap/incremental-marking.h" | 9 #include "src/heap/incremental-marking.h" |
| 10 #include "src/heap/objects-visiting-inl.h" | 10 #include "src/heap/objects-visiting-inl.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 template <ObjectContents object_contents, AllocationAlignment alignment> | 184 template <ObjectContents object_contents, AllocationAlignment alignment> |
| 185 static inline bool PromoteObject(Map* map, HeapObject** slot, | 185 static inline bool PromoteObject(Map* map, HeapObject** slot, |
| 186 HeapObject* object, int object_size) { | 186 HeapObject* object, int object_size) { |
| 187 Heap* heap = map->GetHeap(); | 187 Heap* heap = map->GetHeap(); |
| 188 | 188 |
| 189 AllocationResult allocation = | 189 AllocationResult allocation = |
| 190 heap->old_space()->AllocateRaw(object_size, alignment); | 190 heap->old_space()->AllocateRaw(object_size, alignment); |
| 191 | 191 |
| 192 HeapObject* target = NULL; // Initialization to please compiler. | 192 HeapObject* target = NULL; // Initialization to please compiler. |
| 193 if (allocation.To(&target)) { | 193 if (allocation.To(&target)) { |
| 194 DCHECK(ObjectMarking::IsWhite( |
| 195 target, heap->mark_compact_collector()->marking_state(target))); |
| 194 MigrateObject(heap, object, target, object_size); | 196 MigrateObject(heap, object, target, object_size); |
| 195 | 197 |
| 196 // Update slot to new target using CAS. A concurrent sweeper thread my | 198 // Update slot to new target using CAS. A concurrent sweeper thread my |
| 197 // filter the slot concurrently. | 199 // filter the slot concurrently. |
| 198 HeapObject* old = *slot; | 200 HeapObject* old = *slot; |
| 199 base::Release_CompareAndSwap(reinterpret_cast<base::AtomicWord*>(slot), | 201 base::Release_CompareAndSwap(reinterpret_cast<base::AtomicWord*>(slot), |
| 200 reinterpret_cast<base::AtomicWord>(old), | 202 reinterpret_cast<base::AtomicWord>(old), |
| 201 reinterpret_cast<base::AtomicWord>(target)); | 203 reinterpret_cast<base::AtomicWord>(target)); |
| 202 | 204 |
| 203 if (object_contents == POINTER_OBJECT) { | 205 if (object_contents == POINTER_OBJECT) { |
| 204 // TODO(mlippautz): Query collector for marking state. | 206 heap->promotion_queue()->insert(target, object_size); |
| 205 heap->promotion_queue()->insert( | |
| 206 target, object_size, | |
| 207 ObjectMarking::IsBlack(object, MarkingState::Internal(object))); | |
| 208 } | 207 } |
| 209 heap->IncrementPromotedObjectsSize(object_size); | 208 heap->IncrementPromotedObjectsSize(object_size); |
| 210 return true; | 209 return true; |
| 211 } | 210 } |
| 212 return false; | 211 return false; |
| 213 } | 212 } |
| 214 | 213 |
| 215 template <ObjectContents object_contents, AllocationAlignment alignment> | 214 template <ObjectContents object_contents, AllocationAlignment alignment> |
| 216 static inline void EvacuateObject(Map* map, HeapObject** slot, | 215 static inline void EvacuateObject(Map* map, HeapObject** slot, |
| 217 HeapObject* object, int object_size) { | 216 HeapObject* object, int object_size) { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 void RootScavengeVisitor::ScavengePointer(Object** p) { | 471 void RootScavengeVisitor::ScavengePointer(Object** p) { |
| 473 Object* object = *p; | 472 Object* object = *p; |
| 474 if (!heap_->InNewSpace(object)) return; | 473 if (!heap_->InNewSpace(object)) return; |
| 475 | 474 |
| 476 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 475 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 477 reinterpret_cast<HeapObject*>(object)); | 476 reinterpret_cast<HeapObject*>(object)); |
| 478 } | 477 } |
| 479 | 478 |
| 480 } // namespace internal | 479 } // namespace internal |
| 481 } // namespace v8 | 480 } // namespace v8 |
| OLD | NEW |