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 #include "src/v8.h" | 5 #include "src/v8.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 6097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6108 return heap_->old_space(); | 6108 return heap_->old_space(); |
6109 case CODE_SPACE: | 6109 case CODE_SPACE: |
6110 return heap_->code_space(); | 6110 return heap_->code_space(); |
6111 default: | 6111 default: |
6112 return NULL; | 6112 return NULL; |
6113 } | 6113 } |
6114 } | 6114 } |
6115 | 6115 |
6116 | 6116 |
6117 SpaceIterator::SpaceIterator(Heap* heap) | 6117 SpaceIterator::SpaceIterator(Heap* heap) |
6118 : heap_(heap), | 6118 : heap_(heap), current_space_(FIRST_SPACE), iterator_(NULL) {} |
6119 current_space_(FIRST_SPACE), | |
6120 iterator_(NULL), | |
6121 size_func_(NULL) {} | |
6122 | |
6123 | |
6124 SpaceIterator::SpaceIterator(Heap* heap, HeapObjectCallback size_func) | |
6125 : heap_(heap), | |
6126 current_space_(FIRST_SPACE), | |
6127 iterator_(NULL), | |
6128 size_func_(size_func) {} | |
6129 | 6119 |
6130 | 6120 |
6131 SpaceIterator::~SpaceIterator() { | 6121 SpaceIterator::~SpaceIterator() { |
6132 // Delete active iterator if any. | 6122 // Delete active iterator if any. |
6133 delete iterator_; | 6123 delete iterator_; |
6134 } | 6124 } |
6135 | 6125 |
6136 | 6126 |
6137 bool SpaceIterator::has_next() { | 6127 bool SpaceIterator::has_next() { |
6138 // Iterate until no more spaces. | 6128 // Iterate until no more spaces. |
(...skipping 16 matching lines...) Expand all Loading... |
6155 return CreateIterator(); | 6145 return CreateIterator(); |
6156 } | 6146 } |
6157 | 6147 |
6158 | 6148 |
6159 // Create an iterator for the space to iterate. | 6149 // Create an iterator for the space to iterate. |
6160 ObjectIterator* SpaceIterator::CreateIterator() { | 6150 ObjectIterator* SpaceIterator::CreateIterator() { |
6161 DCHECK(iterator_ == NULL); | 6151 DCHECK(iterator_ == NULL); |
6162 | 6152 |
6163 switch (current_space_) { | 6153 switch (current_space_) { |
6164 case NEW_SPACE: | 6154 case NEW_SPACE: |
6165 iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); | 6155 iterator_ = new SemiSpaceIterator(heap_->new_space()); |
6166 break; | 6156 break; |
6167 case OLD_SPACE: | 6157 case OLD_SPACE: |
6168 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); | 6158 iterator_ = new HeapObjectIterator(heap_->old_space()); |
6169 break; | 6159 break; |
6170 case CODE_SPACE: | 6160 case CODE_SPACE: |
6171 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 6161 iterator_ = new HeapObjectIterator(heap_->code_space()); |
6172 break; | 6162 break; |
6173 case MAP_SPACE: | 6163 case MAP_SPACE: |
6174 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 6164 iterator_ = new HeapObjectIterator(heap_->map_space()); |
6175 break; | 6165 break; |
6176 case LO_SPACE: | 6166 case LO_SPACE: |
6177 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); | 6167 iterator_ = new LargeObjectIterator(heap_->lo_space()); |
6178 break; | 6168 break; |
6179 } | 6169 } |
6180 | 6170 |
6181 // Return the newly allocated iterator; | 6171 // Return the newly allocated iterator; |
6182 DCHECK(iterator_ != NULL); | 6172 DCHECK(iterator_ != NULL); |
6183 return iterator_; | 6173 return iterator_; |
6184 } | 6174 } |
6185 | 6175 |
6186 | 6176 |
6187 class HeapObjectsFilter { | 6177 class HeapObjectsFilter { |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6910 *object_type = "CODE_TYPE"; \ | 6900 *object_type = "CODE_TYPE"; \ |
6911 *object_sub_type = "CODE_AGE/" #name; \ | 6901 *object_sub_type = "CODE_AGE/" #name; \ |
6912 return true; | 6902 return true; |
6913 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6903 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6914 #undef COMPARE_AND_RETURN_NAME | 6904 #undef COMPARE_AND_RETURN_NAME |
6915 } | 6905 } |
6916 return false; | 6906 return false; |
6917 } | 6907 } |
6918 } // namespace internal | 6908 } // namespace internal |
6919 } // namespace v8 | 6909 } // namespace v8 |
OLD | NEW |