Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/heap.h" | 5 #include "src/heap/heap.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
| 10 #include "src/ast/context-slot-cache.h" | 10 #include "src/ast/context-slot-cache.h" |
| (...skipping 4269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4280 addr += obj->Size(); | 4280 addr += obj->Size(); |
| 4281 } | 4281 } |
| 4282 } | 4282 } |
| 4283 } | 4283 } |
| 4284 } | 4284 } |
| 4285 } | 4285 } |
| 4286 | 4286 |
| 4287 void Heap::NotifyObjectLayoutChange(HeapObject* object, | 4287 void Heap::NotifyObjectLayoutChange(HeapObject* object, |
| 4288 const DisallowHeapAllocation&) { | 4288 const DisallowHeapAllocation&) { |
| 4289 if (FLAG_incremental_marking && incremental_marking()->IsMarking()) { | 4289 if (FLAG_incremental_marking && incremental_marking()->IsMarking()) { |
| 4290 incremental_marking()->MarkGrey(object); | 4290 incremental_marking()->WhiteToGreyAndPush(object); |
|
ulan
2017/05/02 18:20:31
MarkGrey is defined as WhiteToGreyAndPush. The lat
| |
| 4291 } | 4291 } |
| 4292 #ifdef VERIFY_HEAP | 4292 #ifdef VERIFY_HEAP |
| 4293 DCHECK(pending_layout_change_object_ == nullptr); | 4293 DCHECK(pending_layout_change_object_ == nullptr); |
| 4294 pending_layout_change_object_ = object; | 4294 pending_layout_change_object_ = object; |
| 4295 #endif | 4295 #endif |
| 4296 } | 4296 } |
| 4297 | 4297 |
| 4298 #ifdef VERIFY_HEAP | 4298 #ifdef VERIFY_HEAP |
| 4299 void Heap::VerifyObjectLayoutChange(HeapObject* object, Map* new_map) { | 4299 void Heap::VerifyObjectLayoutChange(HeapObject* object, Map* new_map) { |
| 4300 if (pending_layout_change_object_ == nullptr) { | 4300 if (pending_layout_change_object_ == nullptr) { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4845 slot_address += kPointerSize; | 4845 slot_address += kPointerSize; |
| 4846 } | 4846 } |
| 4847 } | 4847 } |
| 4848 | 4848 |
| 4849 inline void VisitCodeEntry(JSFunction* host, | 4849 inline void VisitCodeEntry(JSFunction* host, |
| 4850 Address code_entry_slot) override { | 4850 Address code_entry_slot) override { |
| 4851 // Black allocation requires us to process objects referenced by | 4851 // Black allocation requires us to process objects referenced by |
| 4852 // promoted objects. | 4852 // promoted objects. |
| 4853 if (heap_->incremental_marking()->black_allocation()) { | 4853 if (heap_->incremental_marking()->black_allocation()) { |
| 4854 Code* code = Code::cast(Code::GetObjectFromEntryAddress(code_entry_slot)); | 4854 Code* code = Code::cast(Code::GetObjectFromEntryAddress(code_entry_slot)); |
| 4855 heap_->incremental_marking()->MarkGrey(code); | 4855 heap_->incremental_marking()->WhiteToGreyAndPush(code); |
| 4856 } | 4856 } |
| 4857 } | 4857 } |
| 4858 | 4858 |
| 4859 private: | 4859 private: |
| 4860 Heap* heap_; | 4860 Heap* heap_; |
| 4861 bool record_slots_; | 4861 bool record_slots_; |
| 4862 }; | 4862 }; |
| 4863 | 4863 |
| 4864 void Heap::IterateAndScavengePromotedObject(HeapObject* target, int size, | 4864 void Heap::IterateAndScavengePromotedObject(HeapObject* target, int size, |
| 4865 bool was_marked_black) { | 4865 bool was_marked_black) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4884 target->IterateBody(target->map()->instance_type(), size, &visitor); | 4884 target->IterateBody(target->map()->instance_type(), size, &visitor); |
| 4885 } | 4885 } |
| 4886 | 4886 |
| 4887 // When black allocations is on, we have to visit not already marked black | 4887 // When black allocations is on, we have to visit not already marked black |
| 4888 // objects (in new space) promoted to black pages to keep their references | 4888 // objects (in new space) promoted to black pages to keep their references |
| 4889 // alive. | 4889 // alive. |
| 4890 // TODO(hpayer): Implement a special promotion visitor that incorporates | 4890 // TODO(hpayer): Implement a special promotion visitor that incorporates |
| 4891 // regular visiting and IteratePromotedObjectPointers. | 4891 // regular visiting and IteratePromotedObjectPointers. |
| 4892 if (!was_marked_black) { | 4892 if (!was_marked_black) { |
| 4893 if (incremental_marking()->black_allocation()) { | 4893 if (incremental_marking()->black_allocation()) { |
| 4894 incremental_marking()->MarkGrey(target->map()); | 4894 incremental_marking()->WhiteToGreyAndPush(target->map()); |
| 4895 incremental_marking()->IterateBlackObject(target); | 4895 incremental_marking()->IterateBlackObject(target); |
| 4896 } | 4896 } |
| 4897 } | 4897 } |
| 4898 } | 4898 } |
| 4899 | 4899 |
| 4900 void Heap::IterateRoots(RootVisitor* v, VisitMode mode) { | 4900 void Heap::IterateRoots(RootVisitor* v, VisitMode mode) { |
| 4901 IterateStrongRoots(v, mode); | 4901 IterateStrongRoots(v, mode); |
| 4902 IterateWeakRoots(v, mode); | 4902 IterateWeakRoots(v, mode); |
| 4903 } | 4903 } |
| 4904 | 4904 |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5648 } | 5648 } |
| 5649 } | 5649 } |
| 5650 | 5650 |
| 5651 void Heap::RegisterExternallyReferencedObject(Object** object) { | 5651 void Heap::RegisterExternallyReferencedObject(Object** object) { |
| 5652 // The embedder is not aware of whether numbers are materialized as heap | 5652 // The embedder is not aware of whether numbers are materialized as heap |
| 5653 // objects are just passed around as Smis. | 5653 // objects are just passed around as Smis. |
| 5654 if (!(*object)->IsHeapObject()) return; | 5654 if (!(*object)->IsHeapObject()) return; |
| 5655 HeapObject* heap_object = HeapObject::cast(*object); | 5655 HeapObject* heap_object = HeapObject::cast(*object); |
| 5656 DCHECK(Contains(heap_object)); | 5656 DCHECK(Contains(heap_object)); |
| 5657 if (FLAG_incremental_marking_wrappers && incremental_marking()->IsMarking()) { | 5657 if (FLAG_incremental_marking_wrappers && incremental_marking()->IsMarking()) { |
| 5658 incremental_marking()->MarkGrey(heap_object); | 5658 incremental_marking()->WhiteToGreyAndPush(heap_object); |
| 5659 } else { | 5659 } else { |
| 5660 DCHECK(mark_compact_collector()->in_use()); | 5660 DCHECK(mark_compact_collector()->in_use()); |
| 5661 mark_compact_collector()->MarkObject(heap_object); | 5661 mark_compact_collector()->MarkObject(heap_object); |
| 5662 } | 5662 } |
| 5663 } | 5663 } |
| 5664 | 5664 |
| 5665 void Heap::TearDown() { | 5665 void Heap::TearDown() { |
| 5666 #ifdef VERIFY_HEAP | 5666 #ifdef VERIFY_HEAP |
| 5667 if (FLAG_verify_heap) { | 5667 if (FLAG_verify_heap) { |
| 5668 Verify(); | 5668 Verify(); |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6416 case LO_SPACE: | 6416 case LO_SPACE: |
| 6417 return "LO_SPACE"; | 6417 return "LO_SPACE"; |
| 6418 default: | 6418 default: |
| 6419 UNREACHABLE(); | 6419 UNREACHABLE(); |
| 6420 } | 6420 } |
| 6421 return NULL; | 6421 return NULL; |
| 6422 } | 6422 } |
| 6423 | 6423 |
| 6424 } // namespace internal | 6424 } // namespace internal |
| 6425 } // namespace v8 | 6425 } // namespace v8 |
| OLD | NEW |