| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 HeapObject* object, int object_size) { | 178 HeapObject* object, int object_size) { |
| 179 Heap* heap = map->GetHeap(); | 179 Heap* heap = map->GetHeap(); |
| 180 | 180 |
| 181 AllocationResult allocation = | 181 AllocationResult allocation = |
| 182 heap->old_space()->AllocateRaw(object_size, alignment); | 182 heap->old_space()->AllocateRaw(object_size, alignment); |
| 183 | 183 |
| 184 HeapObject* target = NULL; // Initialization to please compiler. | 184 HeapObject* target = NULL; // Initialization to please compiler. |
| 185 if (allocation.To(&target)) { | 185 if (allocation.To(&target)) { |
| 186 MigrateObject(heap, object, target, object_size); | 186 MigrateObject(heap, object, target, object_size); |
| 187 | 187 |
| 188 // Update slot to new target. | 188 // Update slot to new target using CAS. A concurrent sweeper thread my |
| 189 *slot = target; | 189 // filter the slot concurrently. |
| 190 HeapObject* old = *slot; |
| 191 base::Release_CompareAndSwap(reinterpret_cast<base::AtomicWord*>(slot), |
| 192 reinterpret_cast<base::AtomicWord>(old), |
| 193 reinterpret_cast<base::AtomicWord>(target)); |
| 190 | 194 |
| 191 if (object_contents == POINTER_OBJECT) { | 195 if (object_contents == POINTER_OBJECT) { |
| 192 heap->promotion_queue()->insert( | 196 heap->promotion_queue()->insert( |
| 193 target, object_size, | 197 target, object_size, |
| 194 Marking::IsBlack(ObjectMarking::MarkBitFrom(object))); | 198 Marking::IsBlack(ObjectMarking::MarkBitFrom(object))); |
| 195 } | 199 } |
| 196 heap->IncrementPromotedObjectsSize(object_size); | 200 heap->IncrementPromotedObjectsSize(object_size); |
| 197 return true; | 201 return true; |
| 198 } | 202 } |
| 199 return false; | 203 return false; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 void ScavengeVisitor::ScavengePointer(Object** p) { | 443 void ScavengeVisitor::ScavengePointer(Object** p) { |
| 440 Object* object = *p; | 444 Object* object = *p; |
| 441 if (!heap_->InNewSpace(object)) return; | 445 if (!heap_->InNewSpace(object)) return; |
| 442 | 446 |
| 443 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 447 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 444 reinterpret_cast<HeapObject*>(object)); | 448 reinterpret_cast<HeapObject*>(object)); |
| 445 } | 449 } |
| 446 | 450 |
| 447 } // namespace internal | 451 } // namespace internal |
| 448 } // namespace v8 | 452 } // namespace v8 |
| OLD | NEW |