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

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

Issue 1425013006: Using override keyword in ObjectVisitor class hierarchy. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/incremental-marking.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/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 } 1084 }
1085 } 1085 }
1086 incremental_marking()->RecordWrites(array); 1086 incremental_marking()->RecordWrites(array);
1087 } 1087 }
1088 1088
1089 1089
1090 #ifdef VERIFY_HEAP 1090 #ifdef VERIFY_HEAP
1091 // Helper class for verifying the string table. 1091 // Helper class for verifying the string table.
1092 class StringTableVerifier : public ObjectVisitor { 1092 class StringTableVerifier : public ObjectVisitor {
1093 public: 1093 public:
1094 void VisitPointers(Object** start, Object** end) { 1094 void VisitPointers(Object** start, Object** end) override {
1095 // Visit all HeapObject pointers in [start, end). 1095 // Visit all HeapObject pointers in [start, end).
1096 for (Object** p = start; p < end; p++) { 1096 for (Object** p = start; p < end; p++) {
1097 if ((*p)->IsHeapObject()) { 1097 if ((*p)->IsHeapObject()) {
1098 // Check that the string is actually internalized. 1098 // Check that the string is actually internalized.
1099 CHECK((*p)->IsTheHole() || (*p)->IsUndefined() || 1099 CHECK((*p)->IsTheHole() || (*p)->IsUndefined() ||
1100 (*p)->IsInternalizedString()); 1100 (*p)->IsInternalizedString());
1101 } 1101 }
1102 } 1102 }
1103 } 1103 }
1104 }; 1104 };
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 ClearNormalizedMapCaches(); 1444 ClearNormalizedMapCaches();
1445 } 1445 }
1446 1446
1447 1447
1448 #ifdef VERIFY_HEAP 1448 #ifdef VERIFY_HEAP
1449 // Visitor class to verify pointers in code or data space do not point into 1449 // Visitor class to verify pointers in code or data space do not point into
1450 // new space. 1450 // new space.
1451 class VerifyNonPointerSpacePointersVisitor : public ObjectVisitor { 1451 class VerifyNonPointerSpacePointersVisitor : public ObjectVisitor {
1452 public: 1452 public:
1453 explicit VerifyNonPointerSpacePointersVisitor(Heap* heap) : heap_(heap) {} 1453 explicit VerifyNonPointerSpacePointersVisitor(Heap* heap) : heap_(heap) {}
1454 void VisitPointers(Object** start, Object** end) { 1454
1455 void VisitPointers(Object** start, Object** end) override {
1455 for (Object** current = start; current < end; current++) { 1456 for (Object** current = start; current < end; current++) {
1456 if ((*current)->IsHeapObject()) { 1457 if ((*current)->IsHeapObject()) {
1457 CHECK(!heap_->InNewSpace(HeapObject::cast(*current))); 1458 CHECK(!heap_->InNewSpace(HeapObject::cast(*current)));
1458 } 1459 }
1459 } 1460 }
1460 } 1461 }
1461 1462
1462 private: 1463 private:
1463 Heap* heap_; 1464 Heap* heap_;
1464 }; 1465 };
(...skipping 3926 matching lines...) Expand 10 before | Expand all | Expand 10 after
5391 5392
5392 5393
5393 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { 5394 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
5394 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); 5395 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot);
5395 } 5396 }
5396 5397
5397 #ifdef DEBUG 5398 #ifdef DEBUG
5398 5399
5399 class PrintHandleVisitor : public ObjectVisitor { 5400 class PrintHandleVisitor : public ObjectVisitor {
5400 public: 5401 public:
5401 void VisitPointers(Object** start, Object** end) { 5402 void VisitPointers(Object** start, Object** end) override {
5402 for (Object** p = start; p < end; p++) 5403 for (Object** p = start; p < end; p++)
5403 PrintF(" handle %p to %p\n", reinterpret_cast<void*>(p), 5404 PrintF(" handle %p to %p\n", reinterpret_cast<void*>(p),
5404 reinterpret_cast<void*>(*p)); 5405 reinterpret_cast<void*>(*p));
5405 } 5406 }
5406 }; 5407 };
5407 5408
5408 5409
5409 void Heap::PrintHandles() { 5410 void Heap::PrintHandles() {
5410 PrintF("Handles:\n"); 5411 PrintF("Handles:\n");
5411 PrintHandleVisitor v; 5412 PrintHandleVisitor v;
5412 isolate_->handle_scope_implementer()->Iterate(&v); 5413 isolate_->handle_scope_implementer()->Iterate(&v);
5413 } 5414 }
5414 5415
5415 #endif 5416 #endif
5416 5417
5417 class CheckHandleCountVisitor : public ObjectVisitor { 5418 class CheckHandleCountVisitor : public ObjectVisitor {
5418 public: 5419 public:
5419 CheckHandleCountVisitor() : handle_count_(0) {} 5420 CheckHandleCountVisitor() : handle_count_(0) {}
5420 ~CheckHandleCountVisitor() { 5421 ~CheckHandleCountVisitor() override {
5421 CHECK(handle_count_ < HandleScope::kCheckHandleThreshold); 5422 CHECK(handle_count_ < HandleScope::kCheckHandleThreshold);
5422 } 5423 }
5423 void VisitPointers(Object** start, Object** end) { 5424 void VisitPointers(Object** start, Object** end) override {
5424 handle_count_ += end - start; 5425 handle_count_ += end - start;
5425 } 5426 }
5426 5427
5427 private: 5428 private:
5428 ptrdiff_t handle_count_; 5429 ptrdiff_t handle_count_;
5429 }; 5430 };
5430 5431
5431 5432
5432 void Heap::CheckHandleCount() { 5433 void Heap::CheckHandleCount() {
5433 CheckHandleCountVisitor v; 5434 CheckHandleCountVisitor v;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
5560 if (object->IsFiller()) return true; 5561 if (object->IsFiller()) return true;
5561 MarkBit mark_bit = Marking::MarkBitFrom(object); 5562 MarkBit mark_bit = Marking::MarkBitFrom(object);
5562 return Marking::IsWhite(mark_bit); 5563 return Marking::IsWhite(mark_bit);
5563 } 5564 }
5564 5565
5565 private: 5566 private:
5566 class MarkingVisitor : public ObjectVisitor { 5567 class MarkingVisitor : public ObjectVisitor {
5567 public: 5568 public:
5568 MarkingVisitor() : marking_stack_(10) {} 5569 MarkingVisitor() : marking_stack_(10) {}
5569 5570
5570 void VisitPointers(Object** start, Object** end) { 5571 void VisitPointers(Object** start, Object** end) override {
5571 for (Object** p = start; p < end; p++) { 5572 for (Object** p = start; p < end; p++) {
5572 if (!(*p)->IsHeapObject()) continue; 5573 if (!(*p)->IsHeapObject()) continue;
5573 HeapObject* obj = HeapObject::cast(*p); 5574 HeapObject* obj = HeapObject::cast(*p);
5574 MarkBit mark_bit = Marking::MarkBitFrom(obj); 5575 MarkBit mark_bit = Marking::MarkBitFrom(obj);
5575 if (Marking::IsWhite(mark_bit)) { 5576 if (Marking::IsWhite(mark_bit)) {
5576 Marking::WhiteToBlack(mark_bit); 5577 Marking::WhiteToBlack(mark_bit);
5577 marking_stack_.Add(obj); 5578 marking_stack_.Add(obj);
5578 } 5579 }
5579 } 5580 }
5580 } 5581 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
5669 } 5670 }
5670 5671
5671 5672
5672 #ifdef DEBUG 5673 #ifdef DEBUG
5673 5674
5674 Object* const PathTracer::kAnyGlobalObject = NULL; 5675 Object* const PathTracer::kAnyGlobalObject = NULL;
5675 5676
5676 class PathTracer::MarkVisitor : public ObjectVisitor { 5677 class PathTracer::MarkVisitor : public ObjectVisitor {
5677 public: 5678 public:
5678 explicit MarkVisitor(PathTracer* tracer) : tracer_(tracer) {} 5679 explicit MarkVisitor(PathTracer* tracer) : tracer_(tracer) {}
5679 void VisitPointers(Object** start, Object** end) { 5680
5681 void VisitPointers(Object** start, Object** end) override {
5680 // Scan all HeapObject pointers in [start, end) 5682 // Scan all HeapObject pointers in [start, end)
5681 for (Object** p = start; !tracer_->found() && (p < end); p++) { 5683 for (Object** p = start; !tracer_->found() && (p < end); p++) {
5682 if ((*p)->IsHeapObject()) tracer_->MarkRecursively(p, this); 5684 if ((*p)->IsHeapObject()) tracer_->MarkRecursively(p, this);
5683 } 5685 }
5684 } 5686 }
5685 5687
5686 private: 5688 private:
5687 PathTracer* tracer_; 5689 PathTracer* tracer_;
5688 }; 5690 };
5689 5691
5690 5692
5691 class PathTracer::UnmarkVisitor : public ObjectVisitor { 5693 class PathTracer::UnmarkVisitor : public ObjectVisitor {
5692 public: 5694 public:
5693 explicit UnmarkVisitor(PathTracer* tracer) : tracer_(tracer) {} 5695 explicit UnmarkVisitor(PathTracer* tracer) : tracer_(tracer) {}
5694 void VisitPointers(Object** start, Object** end) { 5696
5697 void VisitPointers(Object** start, Object** end) override {
5695 // Scan all HeapObject pointers in [start, end) 5698 // Scan all HeapObject pointers in [start, end)
5696 for (Object** p = start; p < end; p++) { 5699 for (Object** p = start; p < end; p++) {
5697 if ((*p)->IsHeapObject()) tracer_->UnmarkRecursively(p, this); 5700 if ((*p)->IsHeapObject()) tracer_->UnmarkRecursively(p, this);
5698 } 5701 }
5699 } 5702 }
5700 5703
5701 private: 5704 private:
5702 PathTracer* tracer_; 5705 PathTracer* tracer_;
5703 }; 5706 };
5704 5707
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
6171 } 6174 }
6172 6175
6173 6176
6174 // static 6177 // static
6175 int Heap::GetStaticVisitorIdForMap(Map* map) { 6178 int Heap::GetStaticVisitorIdForMap(Map* map) {
6176 return StaticVisitorBase::GetVisitorId(map); 6179 return StaticVisitorBase::GetVisitorId(map);
6177 } 6180 }
6178 6181
6179 } // namespace internal 6182 } // namespace internal
6180 } // namespace v8 6183 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698