Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: src/heap/heap.cc

Issue 2868053002: [heap] Verify remembered set for objects in the old generation. (Closed)
Patch Set: remove old to old handling Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4761 matching lines...) Expand 10 before | Expand all | Expand 10 after
4772 VerifyPointersVisitor no_dirty_regions_visitor; 4772 VerifyPointersVisitor no_dirty_regions_visitor;
4773 code_space_->Verify(&no_dirty_regions_visitor); 4773 code_space_->Verify(&no_dirty_regions_visitor);
4774 4774
4775 lo_space_->Verify(); 4775 lo_space_->Verify();
4776 4776
4777 mark_compact_collector()->VerifyWeakEmbeddedObjectsInCode(); 4777 mark_compact_collector()->VerifyWeakEmbeddedObjectsInCode();
4778 if (FLAG_omit_map_checks_for_leaf_maps) { 4778 if (FLAG_omit_map_checks_for_leaf_maps) {
4779 mark_compact_collector()->VerifyOmittedMapChecks(); 4779 mark_compact_collector()->VerifyOmittedMapChecks();
4780 } 4780 }
4781 } 4781 }
4782
4783 class SlotVerifyingVisitor : public ObjectVisitor {
4784 public:
4785 SlotVerifyingVisitor(std::set<Address>* untyped,
4786 std::set<std::pair<SlotType, Address> >* typed)
4787 : untyped_(untyped), typed_(typed) {}
4788
4789 virtual bool ShouldHaveBeenRecorded(HeapObject* host, Object* target) = 0;
4790
4791 void VisitPointers(HeapObject* host, Object** start, Object** end) override {
4792 for (Object** slot = start; slot < end; slot++) {
4793 if (ShouldHaveBeenRecorded(host, *slot)) {
4794 CHECK_GT(untyped_->count(reinterpret_cast<Address>(slot)), 0);
4795 }
4796 }
4797 }
4798
4799 void VisitCodeTarget(Code* host, RelocInfo* rinfo) override {
4800 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
4801 if (ShouldHaveBeenRecorded(host, target)) {
4802 CHECK(InTypedSet(CODE_TARGET_SLOT, rinfo->pc()) ||
4803 (rinfo->IsInConstantPool() &&
4804 InTypedSet(CODE_ENTRY_SLOT, rinfo->pc())));
4805 }
4806 }
4807
4808 void VisitCodeAgeSequence(Code* host, RelocInfo* rinfo) override {
4809 Object* target = rinfo->code_age_stub();
4810 if (ShouldHaveBeenRecorded(host, target)) {
4811 CHECK(InTypedSet(CODE_TARGET_SLOT, rinfo->pc()) ||
4812 (rinfo->IsInConstantPool() &&
4813 InTypedSet(CODE_ENTRY_SLOT, rinfo->pc())));
4814 }
4815 }
4816
4817 void VisitCodeEntry(JSFunction* host, Address entry_address) override {
4818 Object* target = Code::GetObjectFromEntryAddress(entry_address);
4819 if (ShouldHaveBeenRecorded(host, target)) {
4820 CHECK(InTypedSet(CODE_ENTRY_SLOT, entry_address));
4821 }
4822 }
4823
4824 void VisitCellPointer(Code* host, RelocInfo* rinfo) override {
4825 Object* target = rinfo->target_cell();
4826 if (ShouldHaveBeenRecorded(host, target)) {
4827 CHECK(
4828 InTypedSet(CELL_TARGET_SLOT, rinfo->pc()) ||
4829 (rinfo->IsInConstantPool() && InTypedSet(OBJECT_SLOT, rinfo->pc())));
4830 }
4831 }
4832
4833 void VisitDebugTarget(Code* host, RelocInfo* rinfo) override {
4834 Object* target =
4835 Code::GetCodeFromTargetAddress(rinfo->debug_call_address());
4836 if (ShouldHaveBeenRecorded(host, target)) {
4837 CHECK(InTypedSet(DEBUG_TARGET_SLOT, rinfo->pc()) ||
4838 (rinfo->IsInConstantPool() &&
4839 InTypedSet(CODE_ENTRY_SLOT, rinfo->pc())));
4840 }
4841 }
4842
4843 void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo) override {
4844 Object* target = rinfo->target_object();
4845 if (ShouldHaveBeenRecorded(host, target)) {
4846 CHECK(
4847 InTypedSet(EMBEDDED_OBJECT_SLOT, rinfo->pc()) ||
4848 (rinfo->IsInConstantPool() && InTypedSet(OBJECT_SLOT, rinfo->pc())));
4849 }
4850 }
4851
4852 private:
4853 bool InTypedSet(SlotType type, Address slot) {
4854 return typed_->count(std::make_pair(type, slot)) > 0;
4855 }
4856 std::set<Address>* untyped_;
4857 std::set<std::pair<SlotType, Address> >* typed_;
4858 };
4859
4860 class OldToNewSlotVerifyingVisitor : public SlotVerifyingVisitor {
4861 public:
4862 OldToNewSlotVerifyingVisitor(Heap* heap, std::set<Address>* untyped,
4863 std::set<std::pair<SlotType, Address> >* typed)
4864 : SlotVerifyingVisitor(untyped, typed), heap_(heap) {}
4865
4866 bool ShouldHaveBeenRecorded(HeapObject* host, Object* target) override {
4867 return target->IsHeapObject() && heap_->InNewSpace(target) &&
4868 !heap_->InNewSpace(host);
4869 }
4870
4871 private:
4872 Heap* heap_;
4873 };
4874
4875 template <RememberedSetType direction>
4876 void CollectSlots(MemoryChunk* chunk, Address start, Address end,
4877 std::set<Address>* untyped,
4878 std::set<std::pair<SlotType, Address> >* typed) {
4879 RememberedSet<direction>::Iterate(chunk, [start, end, untyped](Address slot) {
4880 if (start <= slot && slot < end) {
4881 untyped->insert(slot);
4882 }
4883 return KEEP_SLOT;
4884 });
4885 RememberedSet<direction>::IterateTyped(
4886 chunk, [start, end, typed](SlotType type, Address host, Address slot) {
4887 if (start <= slot && slot < end) {
4888 typed->insert(std::make_pair(type, slot));
4889 }
4890 return KEEP_SLOT;
4891 });
4892 }
4893
4894 void Heap::VerifyRememberedSetFor(HeapObject* object) {
4895 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
4896 base::LockGuard<base::RecursiveMutex> lock_guard(chunk->mutex());
4897 Address start = object->address();
4898 Address end = start + object->Size();
4899 std::set<Address> old_to_new;
4900 std::set<std::pair<SlotType, Address> > typed_old_to_new;
4901 if (!InNewSpace(object)) {
4902 store_buffer()->MoveAllEntriesToRememberedSet();
4903 CollectSlots<OLD_TO_NEW>(chunk, start, end, &old_to_new, &typed_old_to_new);
4904 OldToNewSlotVerifyingVisitor visitor(this, &old_to_new, &typed_old_to_new);
4905 object->IterateBody(&visitor);
4906 }
4907 // TODO(ulan): Add old to old slot set verification once all weak objects
4908 // have their own instance types and slots are recorded for all weal fields.
4909 }
4782 #endif 4910 #endif
4783 4911
4784 4912
4785 void Heap::ZapFromSpace() { 4913 void Heap::ZapFromSpace() {
4786 if (!new_space_->IsFromSpaceCommitted()) return; 4914 if (!new_space_->IsFromSpaceCommitted()) return;
4787 for (Page* page : 4915 for (Page* page :
4788 PageRange(new_space_->FromSpaceStart(), new_space_->FromSpaceEnd())) { 4916 PageRange(new_space_->FromSpaceStart(), new_space_->FromSpaceEnd())) {
4789 for (Address cursor = page->area_start(), limit = page->area_end(); 4917 for (Address cursor = page->area_start(), limit = page->area_end();
4790 cursor < limit; cursor += kPointerSize) { 4918 cursor < limit; cursor += kPointerSize) {
4791 Memory::Address_at(cursor) = kFromSpaceZapValue; 4919 Memory::Address_at(cursor) = kFromSpaceZapValue;
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
6391 case LO_SPACE: 6519 case LO_SPACE:
6392 return "LO_SPACE"; 6520 return "LO_SPACE";
6393 default: 6521 default:
6394 UNREACHABLE(); 6522 UNREACHABLE();
6395 } 6523 }
6396 return NULL; 6524 return NULL;
6397 } 6525 }
6398 6526
6399 } // namespace internal 6527 } // namespace internal
6400 } // namespace v8 6528 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698