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

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

Issue 2102243002: [heap] Iterate handles with special left-trim visitor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/heap-inl.h » ('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/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 4737 matching lines...) Expand 10 before | Expand all | Expand 10 after
4748 } 4748 }
4749 4749
4750 4750
4751 void Heap::IterateSmiRoots(ObjectVisitor* v) { 4751 void Heap::IterateSmiRoots(ObjectVisitor* v) {
4752 // Acquire execution access since we are going to read stack limit values. 4752 // Acquire execution access since we are going to read stack limit values.
4753 ExecutionAccess access(isolate()); 4753 ExecutionAccess access(isolate());
4754 v->VisitPointers(&roots_[kSmiRootsStart], &roots_[kRootListLength]); 4754 v->VisitPointers(&roots_[kSmiRootsStart], &roots_[kRootListLength]);
4755 v->Synchronize(VisitorSynchronization::kSmiRootList); 4755 v->Synchronize(VisitorSynchronization::kSmiRootList);
4756 } 4756 }
4757 4757
4758 // We cannot avoid stale handles to left-trimmed objects, but can only make
4759 // sure all handles still needed are updated. Filter out a stale pointer
4760 // and clear the slot to allow post processing of handles (needed because
4761 // the sweeper might actually free the underlying page).
4762 class FixStaleLeftTrimmedHandlesVisitor : public ObjectVisitor {
4763 public:
4764 explicit FixStaleLeftTrimmedHandlesVisitor(Heap* heap) : heap_(heap) {
4765 USE(heap_);
4766 }
4767
4768 void VisitPointer(Object** p) override { FixHandle(p); }
4769
4770 void VisitPointers(Object** start, Object** end) override {
4771 for (Object** p = start; p < end; p++) FixHandle(p);
4772 }
4773
4774 private:
4775 inline void FixHandle(Object** p) {
4776 HeapObject* current = reinterpret_cast<HeapObject*>(*p);
4777 if (current->IsFiller()) {
Hannes Payer (out of office) 2016/06/28 20:19:11 I think we have to check for forwarding pointers h
Michael Lippautz 2016/06/29 06:03:58 Done.(+ HeapObject check)
4778 #ifdef DEBUG
4779 // We need to find a FixedArrayBase map after walking the fillers.
4780 while (current->IsFiller()) {
4781 Address next = reinterpret_cast<Address>(current);
4782 if (current->map() == heap_->one_pointer_filler_map()) {
4783 next += kPointerSize;
4784 } else if (current->map() == heap_->two_pointer_filler_map()) {
4785 next += 2 * kPointerSize;
4786 } else {
4787 next += current->Size();
4788 }
4789 current = reinterpret_cast<HeapObject*>(next);
4790 }
4791 DCHECK(current->IsFixedArrayBase());
4792 #endif // DEBUG
4793 *p = nullptr;
4794 }
4795 }
4796
4797 Heap* heap_;
4798 };
4758 4799
4759 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { 4800 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
4760 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); 4801 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
4761 v->Synchronize(VisitorSynchronization::kStrongRootList); 4802 v->Synchronize(VisitorSynchronization::kStrongRootList);
4762 // The serializer/deserializer iterates the root list twice, first to pick 4803 // The serializer/deserializer iterates the root list twice, first to pick
4763 // off immortal immovable roots to make sure they end up on the first page, 4804 // off immortal immovable roots to make sure they end up on the first page,
4764 // and then again for the rest. 4805 // and then again for the rest.
4765 if (mode == VISIT_ONLY_STRONG_ROOT_LIST) return; 4806 if (mode == VISIT_ONLY_STRONG_ROOT_LIST) return;
4766 4807
4767 isolate_->bootstrapper()->Iterate(v); 4808 isolate_->bootstrapper()->Iterate(v);
4768 v->Synchronize(VisitorSynchronization::kBootstrapper); 4809 v->Synchronize(VisitorSynchronization::kBootstrapper);
4769 isolate_->Iterate(v); 4810 isolate_->Iterate(v);
4770 v->Synchronize(VisitorSynchronization::kTop); 4811 v->Synchronize(VisitorSynchronization::kTop);
4771 Relocatable::Iterate(isolate_, v); 4812 Relocatable::Iterate(isolate_, v);
4772 v->Synchronize(VisitorSynchronization::kRelocatable); 4813 v->Synchronize(VisitorSynchronization::kRelocatable);
4773 isolate_->debug()->Iterate(v); 4814 isolate_->debug()->Iterate(v);
4774 v->Synchronize(VisitorSynchronization::kDebug); 4815 v->Synchronize(VisitorSynchronization::kDebug);
4775 4816
4776 isolate_->compilation_cache()->Iterate(v); 4817 isolate_->compilation_cache()->Iterate(v);
4777 v->Synchronize(VisitorSynchronization::kCompilationCache); 4818 v->Synchronize(VisitorSynchronization::kCompilationCache);
4778 4819
4779 // Iterate over local handles in handle scopes. 4820 // Iterate over local handles in handle scopes.
4821 FixStaleLeftTrimmedHandlesVisitor left_trim_visitor(this);
4822 isolate_->handle_scope_implementer()->Iterate(&left_trim_visitor);
4780 isolate_->handle_scope_implementer()->Iterate(v); 4823 isolate_->handle_scope_implementer()->Iterate(v);
4781 isolate_->IterateDeferredHandles(v); 4824 isolate_->IterateDeferredHandles(v);
4782 v->Synchronize(VisitorSynchronization::kHandleScope); 4825 v->Synchronize(VisitorSynchronization::kHandleScope);
4783 4826
4784 // Iterate over the builtin code objects and code stubs in the 4827 // Iterate over the builtin code objects and code stubs in the
4785 // heap. Note that it is not necessary to iterate over code objects 4828 // heap. Note that it is not necessary to iterate over code objects
4786 // on scavenge collections. 4829 // on scavenge collections.
4787 if (mode != VISIT_ALL_IN_SCAVENGE) { 4830 if (mode != VISIT_ALL_IN_SCAVENGE) {
4788 isolate_->builtins()->IterateBuiltins(v); 4831 isolate_->builtins()->IterateBuiltins(v);
4789 v->Synchronize(VisitorSynchronization::kBuiltins); 4832 v->Synchronize(VisitorSynchronization::kBuiltins);
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
6382 } 6425 }
6383 6426
6384 6427
6385 // static 6428 // static
6386 int Heap::GetStaticVisitorIdForMap(Map* map) { 6429 int Heap::GetStaticVisitorIdForMap(Map* map) {
6387 return StaticVisitorBase::GetVisitorId(map); 6430 return StaticVisitorBase::GetVisitorId(map);
6388 } 6431 }
6389 6432
6390 } // namespace internal 6433 } // namespace internal
6391 } // namespace v8 6434 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698