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

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

Issue 2078403002: [heap] Filter out stale left-trimmed handles (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove check that ensure that only a single handle points to left-trimmed array Created 4 years, 6 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/mark-compact.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/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; 3153 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize;
3154 const int bytes_to_trim = elements_to_trim * element_size; 3154 const int bytes_to_trim = elements_to_trim * element_size;
3155 Map* map = object->map(); 3155 Map* map = object->map();
3156 3156
3157 // For now this trick is only applied to objects in new and paged space. 3157 // For now this trick is only applied to objects in new and paged space.
3158 // In large object space the object's start must coincide with chunk 3158 // In large object space the object's start must coincide with chunk
3159 // and thus the trick is just not applicable. 3159 // and thus the trick is just not applicable.
3160 DCHECK(!lo_space()->Contains(object)); 3160 DCHECK(!lo_space()->Contains(object));
3161 DCHECK(object->map() != fixed_cow_array_map()); 3161 DCHECK(object->map() != fixed_cow_array_map());
3162 3162
3163 // Ensure that the no handle-scope has more than one pointer to the same
3164 // backing-store.
3165 SLOW_DCHECK(CountHandlesForObject(object) <= 1);
3166
3167 STATIC_ASSERT(FixedArrayBase::kMapOffset == 0); 3163 STATIC_ASSERT(FixedArrayBase::kMapOffset == 0);
3168 STATIC_ASSERT(FixedArrayBase::kLengthOffset == kPointerSize); 3164 STATIC_ASSERT(FixedArrayBase::kLengthOffset == kPointerSize);
3169 STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize); 3165 STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize);
3170 3166
3171 const int len = object->length(); 3167 const int len = object->length();
3172 DCHECK(elements_to_trim <= len); 3168 DCHECK(elements_to_trim <= len);
3173 3169
3174 // Calculate location of new array start. 3170 // Calculate location of new array start.
3175 Address new_start = object->address() + bytes_to_trim; 3171 Address new_start = object->address() + bytes_to_trim;
3176 3172
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after
5716 5712
5717 5713
5718 void Heap::PrintHandles() { 5714 void Heap::PrintHandles() {
5719 PrintF("Handles:\n"); 5715 PrintF("Handles:\n");
5720 PrintHandleVisitor v; 5716 PrintHandleVisitor v;
5721 isolate_->handle_scope_implementer()->Iterate(&v); 5717 isolate_->handle_scope_implementer()->Iterate(&v);
5722 } 5718 }
5723 5719
5724 #endif 5720 #endif
5725 5721
5726 #ifdef ENABLE_SLOW_DCHECKS
5727
5728 class CountHandleVisitor : public ObjectVisitor {
5729 public:
5730 explicit CountHandleVisitor(Object* object) : object_(object) {}
5731
5732 void VisitPointers(Object** start, Object** end) override {
5733 for (Object** p = start; p < end; p++) {
5734 if (object_ == reinterpret_cast<Object*>(*p)) count_++;
5735 }
5736 }
5737
5738 int count() { return count_; }
5739
5740 private:
5741 Object* object_;
5742 int count_ = 0;
5743 };
5744
5745 int Heap::CountHandlesForObject(Object* object) {
5746 CountHandleVisitor v(object);
5747 isolate_->handle_scope_implementer()->Iterate(&v);
5748 return v.count();
5749 }
5750 #endif
5751
5752 class CheckHandleCountVisitor : public ObjectVisitor { 5722 class CheckHandleCountVisitor : public ObjectVisitor {
5753 public: 5723 public:
5754 CheckHandleCountVisitor() : handle_count_(0) {} 5724 CheckHandleCountVisitor() : handle_count_(0) {}
5755 ~CheckHandleCountVisitor() override { 5725 ~CheckHandleCountVisitor() override {
5756 CHECK(handle_count_ < HandleScope::kCheckHandleThreshold); 5726 CHECK(handle_count_ < HandleScope::kCheckHandleThreshold);
5757 } 5727 }
5758 void VisitPointers(Object** start, Object** end) override { 5728 void VisitPointers(Object** start, Object** end) override {
5759 handle_count_ += end - start; 5729 handle_count_ += end - start;
5760 } 5730 }
5761 5731
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
6452 } 6422 }
6453 6423
6454 6424
6455 // static 6425 // static
6456 int Heap::GetStaticVisitorIdForMap(Map* map) { 6426 int Heap::GetStaticVisitorIdForMap(Map* map) {
6457 return StaticVisitorBase::GetVisitorId(map); 6427 return StaticVisitorBase::GetVisitorId(map);
6458 } 6428 }
6459 6429
6460 } // namespace internal 6430 } // namespace internal
6461 } // namespace v8 6431 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698