| 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 #ifndef V8_HEAP_HEAP_INL_H_ | 5 #ifndef V8_HEAP_HEAP_INL_H_ |
| 6 #define V8_HEAP_HEAP_INL_H_ | 6 #define V8_HEAP_HEAP_INL_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 | 699 |
| 700 void Heap::ExternalStringTable::AddString(String* string) { | 700 void Heap::ExternalStringTable::AddString(String* string) { |
| 701 DCHECK(string->IsExternalString()); | 701 DCHECK(string->IsExternalString()); |
| 702 if (heap_->InNewSpace(string)) { | 702 if (heap_->InNewSpace(string)) { |
| 703 new_space_strings_.Add(string); | 703 new_space_strings_.Add(string); |
| 704 } else { | 704 } else { |
| 705 old_space_strings_.Add(string); | 705 old_space_strings_.Add(string); |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 | 708 |
| 709 void Heap::ExternalStringTable::IterateNewSpaceStrings(ObjectVisitor* v) { | 709 void Heap::ExternalStringTable::IterateNewSpaceStrings(RootVisitor* v) { |
| 710 if (!new_space_strings_.is_empty()) { | 710 if (!new_space_strings_.is_empty()) { |
| 711 Object** start = &new_space_strings_[0]; | 711 Object** start = &new_space_strings_[0]; |
| 712 v->VisitPointers(start, start + new_space_strings_.length()); | 712 v->VisitRootPointers(Root::kExternalStringsTable, start, |
| 713 start + new_space_strings_.length()); |
| 713 } | 714 } |
| 714 } | 715 } |
| 715 | 716 |
| 716 void Heap::ExternalStringTable::IterateAll(ObjectVisitor* v) { | 717 void Heap::ExternalStringTable::IterateAll(RootVisitor* v) { |
| 717 IterateNewSpaceStrings(v); | 718 IterateNewSpaceStrings(v); |
| 718 if (!old_space_strings_.is_empty()) { | 719 if (!old_space_strings_.is_empty()) { |
| 719 Object** start = &old_space_strings_[0]; | 720 Object** start = &old_space_strings_[0]; |
| 720 v->VisitPointers(start, start + old_space_strings_.length()); | 721 v->VisitRootPointers(Root::kExternalStringsTable, start, |
| 722 start + old_space_strings_.length()); |
| 721 } | 723 } |
| 722 } | 724 } |
| 723 | 725 |
| 724 | 726 |
| 725 // Verify() is inline to avoid ifdef-s around its calls in release | 727 // Verify() is inline to avoid ifdef-s around its calls in release |
| 726 // mode. | 728 // mode. |
| 727 void Heap::ExternalStringTable::Verify() { | 729 void Heap::ExternalStringTable::Verify() { |
| 728 #ifdef DEBUG | 730 #ifdef DEBUG |
| 729 for (int i = 0; i < new_space_strings_.length(); ++i) { | 731 for (int i = 0; i < new_space_strings_.length(); ++i) { |
| 730 Object* obj = Object::cast(new_space_strings_[i]); | 732 Object* obj = Object::cast(new_space_strings_[i]); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 if (!dead_object_stats_) { | 845 if (!dead_object_stats_) { |
| 844 dead_object_stats_ = new ObjectStats(this); | 846 dead_object_stats_ = new ObjectStats(this); |
| 845 } | 847 } |
| 846 } | 848 } |
| 847 | 849 |
| 848 AlwaysAllocateScope::AlwaysAllocateScope(Isolate* isolate) | 850 AlwaysAllocateScope::AlwaysAllocateScope(Isolate* isolate) |
| 849 : heap_(isolate->heap()) { | 851 : heap_(isolate->heap()) { |
| 850 heap_->always_allocate_scope_count_.Increment(1); | 852 heap_->always_allocate_scope_count_.Increment(1); |
| 851 } | 853 } |
| 852 | 854 |
| 853 | |
| 854 AlwaysAllocateScope::~AlwaysAllocateScope() { | 855 AlwaysAllocateScope::~AlwaysAllocateScope() { |
| 855 heap_->always_allocate_scope_count_.Decrement(1); | 856 heap_->always_allocate_scope_count_.Decrement(1); |
| 856 } | 857 } |
| 857 | 858 |
| 859 void VerifyPointersVisitor::VisitPointers(Object** start, Object** end) { |
| 860 VerifyPointers(start, end); |
| 861 } |
| 858 | 862 |
| 859 void VerifyPointersVisitor::VisitPointers(Object** start, Object** end) { | 863 void VerifyPointersVisitor::VisitRootPointers(Root root, Object** start, |
| 864 Object** end) { |
| 865 VerifyPointers(start, end); |
| 866 } |
| 867 |
| 868 void VerifyPointersVisitor::VerifyPointers(Object** start, Object** end) { |
| 860 for (Object** current = start; current < end; current++) { | 869 for (Object** current = start; current < end; current++) { |
| 861 if ((*current)->IsHeapObject()) { | 870 if ((*current)->IsHeapObject()) { |
| 862 HeapObject* object = HeapObject::cast(*current); | 871 HeapObject* object = HeapObject::cast(*current); |
| 863 CHECK(object->GetIsolate()->heap()->Contains(object)); | 872 CHECK(object->GetIsolate()->heap()->Contains(object)); |
| 864 CHECK(object->map()->IsMap()); | 873 CHECK(object->map()->IsMap()); |
| 865 } else { | 874 } else { |
| 866 CHECK((*current)->IsSmi()); | 875 CHECK((*current)->IsSmi()); |
| 867 } | 876 } |
| 868 } | 877 } |
| 869 } | 878 } |
| 870 | 879 |
| 871 | 880 void VerifySmisVisitor::VisitRootPointers(Root root, Object** start, |
| 872 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 881 Object** end) { |
| 873 for (Object** current = start; current < end; current++) { | 882 for (Object** current = start; current < end; current++) { |
| 874 CHECK((*current)->IsSmi()); | 883 CHECK((*current)->IsSmi()); |
| 875 } | 884 } |
| 876 } | 885 } |
| 877 } // namespace internal | 886 } // namespace internal |
| 878 } // namespace v8 | 887 } // namespace v8 |
| 879 | 888 |
| 880 #endif // V8_HEAP_HEAP_INL_H_ | 889 #endif // V8_HEAP_HEAP_INL_H_ |
| OLD | NEW |