| 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" |
| 11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
| 12 #include "src/log.h" | 12 #include "src/log.h" |
| 13 #include "src/profiler/cpu-profiler.h" | 13 #include "src/profiler/cpu-profiler.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 enum LoggingAndProfiling { | 18 enum LoggingAndProfiling { |
| 19 LOGGING_AND_PROFILING_ENABLED, | 19 LOGGING_AND_PROFILING_ENABLED, |
| 20 LOGGING_AND_PROFILING_DISABLED | 20 LOGGING_AND_PROFILING_DISABLED |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 | 23 |
| 24 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; | |
| 25 | |
| 26 | |
| 27 template <MarksHandling marks_handling, | 24 template <MarksHandling marks_handling, |
| 28 LoggingAndProfiling logging_and_profiling_mode> | 25 LoggingAndProfiling logging_and_profiling_mode> |
| 29 class ScavengingVisitor : public StaticVisitorBase { | 26 class ScavengingVisitor : public StaticVisitorBase { |
| 30 public: | 27 public: |
| 31 static void Initialize() { | 28 static void Initialize() { |
| 32 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); | 29 table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString); |
| 33 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); | 30 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); |
| 34 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); | 31 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); |
| 35 table_.Register(kVisitByteArray, &EvacuateByteArray); | 32 table_.Register(kVisitByteArray, &EvacuateByteArray); |
| 36 table_.Register(kVisitFixedArray, &EvacuateFixedArray); | 33 table_.Register(kVisitFixedArray, &EvacuateFixedArray); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 199 |
| 203 template <ObjectContents object_contents, AllocationAlignment alignment> | 200 template <ObjectContents object_contents, AllocationAlignment alignment> |
| 204 static inline void EvacuateObject(Map* map, HeapObject** slot, | 201 static inline void EvacuateObject(Map* map, HeapObject** slot, |
| 205 HeapObject* object, int object_size, | 202 HeapObject* object, int object_size, |
| 206 PromotionMode promotion_mode) { | 203 PromotionMode promotion_mode) { |
| 207 SLOW_DCHECK(object_size <= Page::kAllocatableMemory); | 204 SLOW_DCHECK(object_size <= Page::kAllocatableMemory); |
| 208 SLOW_DCHECK(object->Size() == object_size); | 205 SLOW_DCHECK(object->Size() == object_size); |
| 209 Heap* heap = map->GetHeap(); | 206 Heap* heap = map->GetHeap(); |
| 210 | 207 |
| 211 if (promotion_mode != FORCE_PROMOTION && | 208 if (promotion_mode != FORCE_PROMOTION && |
| 212 !heap->ShouldBePromoted(object->address(), object_size)) { | 209 !heap->ShouldBePromoted<marks_handling>(object->address(), |
| 210 object_size)) { |
| 213 // A semi-space copy may fail due to fragmentation. In that case, we | 211 // A semi-space copy may fail due to fragmentation. In that case, we |
| 214 // try to promote the object. | 212 // try to promote the object. |
| 215 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) { | 213 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) { |
| 216 return; | 214 return; |
| 217 } | 215 } |
| 218 } | 216 } |
| 219 | 217 |
| 220 if (PromoteObject<object_contents, alignment>(map, slot, object, | 218 if (PromoteObject<object_contents, alignment>(map, slot, object, |
| 221 object_size)) { | 219 object_size)) { |
| 222 return; | 220 return; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 468 |
| 471 void ScavengeVisitor::ScavengePointer(Object** p) { | 469 void ScavengeVisitor::ScavengePointer(Object** p) { |
| 472 Object* object = *p; | 470 Object* object = *p; |
| 473 if (!heap_->InNewSpace(object)) return; | 471 if (!heap_->InNewSpace(object)) return; |
| 474 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 472 Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 475 reinterpret_cast<HeapObject*>(object)); | 473 reinterpret_cast<HeapObject*>(object)); |
| 476 } | 474 } |
| 477 | 475 |
| 478 } // namespace internal | 476 } // namespace internal |
| 479 } // namespace v8 | 477 } // namespace v8 |
| OLD | NEW |