| 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/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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 current_gc_flags_(Heap::kNoGCFlags), | 157 current_gc_flags_(Heap::kNoGCFlags), |
| 158 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), | 158 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), |
| 159 external_string_table_(this), | 159 external_string_table_(this), |
| 160 chunks_queued_for_free_(NULL), | 160 chunks_queued_for_free_(NULL), |
| 161 concurrent_unmapping_tasks_active_(0), | 161 concurrent_unmapping_tasks_active_(0), |
| 162 pending_unmapping_tasks_semaphore_(0), | 162 pending_unmapping_tasks_semaphore_(0), |
| 163 gc_callbacks_depth_(0), | 163 gc_callbacks_depth_(0), |
| 164 deserialization_complete_(false), | 164 deserialization_complete_(false), |
| 165 strong_roots_list_(NULL), | 165 strong_roots_list_(NULL), |
| 166 array_buffer_tracker_(NULL), | 166 array_buffer_tracker_(NULL), |
| 167 heap_iterator_depth_(0), |
| 167 force_oom_(false) { | 168 force_oom_(false) { |
| 168 // Allow build-time customization of the max semispace size. Building | 169 // Allow build-time customization of the max semispace size. Building |
| 169 // V8 with snapshots and a non-default max semispace size is much | 170 // V8 with snapshots and a non-default max semispace size is much |
| 170 // easier if you can define it as part of the build environment. | 171 // easier if you can define it as part of the build environment. |
| 171 #if defined(V8_MAX_SEMISPACE_SIZE) | 172 #if defined(V8_MAX_SEMISPACE_SIZE) |
| 172 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 173 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
| 173 #endif | 174 #endif |
| 174 | 175 |
| 175 // Ensure old_generation_size_ is a multiple of kPageSize. | 176 // Ensure old_generation_size_ is a multiple of kPageSize. |
| 176 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0); | 177 DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0); |
| (...skipping 2917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 // (1) the object is not in old space, | 3095 // (1) the object is not in old space, |
| 3095 // (2) the page of the object was already swept, | 3096 // (2) the page of the object was already swept, |
| 3096 // (3) the page was already concurrently swept. This case is an optimization | 3097 // (3) the page was already concurrently swept. This case is an optimization |
| 3097 // for concurrent sweeping. The WasSwept predicate for concurrently swept | 3098 // for concurrent sweeping. The WasSwept predicate for concurrently swept |
| 3098 // pages is set after sweeping all pages. | 3099 // pages is set after sweeping all pages. |
| 3099 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); | 3100 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); |
| 3100 } | 3101 } |
| 3101 | 3102 |
| 3102 | 3103 |
| 3103 void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) { | 3104 void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) { |
| 3104 if (incremental_marking()->IsMarking() && | 3105 // As long as the inspected object is black and we are currently not iterating |
| 3106 // the heap using HeapIterator, we can update the live byte count. We cannot |
| 3107 // update while using HeapIterator because the iterator is temporarily |
| 3108 // marking the whole object graph, without updating live bytes. |
| 3109 if (!in_heap_iterator() && |
| 3105 Marking::IsBlack(Marking::MarkBitFrom(object->address()))) { | 3110 Marking::IsBlack(Marking::MarkBitFrom(object->address()))) { |
| 3106 if (mode == SEQUENTIAL_TO_SWEEPER) { | 3111 if (mode == SEQUENTIAL_TO_SWEEPER) { |
| 3107 MemoryChunk::IncrementLiveBytesFromGC(object, by); | 3112 MemoryChunk::IncrementLiveBytesFromGC(object, by); |
| 3108 } else { | 3113 } else { |
| 3109 MemoryChunk::IncrementLiveBytesFromMutator(object, by); | 3114 MemoryChunk::IncrementLiveBytesFromMutator(object, by); |
| 3110 } | 3115 } |
| 3111 } | 3116 } |
| 3112 } | 3117 } |
| 3113 | 3118 |
| 3114 | 3119 |
| (...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5651 | 5656 |
| 5652 HeapIterator::HeapIterator(Heap* heap, | 5657 HeapIterator::HeapIterator(Heap* heap, |
| 5653 HeapIterator::HeapObjectsFiltering filtering) | 5658 HeapIterator::HeapObjectsFiltering filtering) |
| 5654 : make_heap_iterable_helper_(heap), | 5659 : make_heap_iterable_helper_(heap), |
| 5655 no_heap_allocation_(), | 5660 no_heap_allocation_(), |
| 5656 heap_(heap), | 5661 heap_(heap), |
| 5657 filtering_(filtering), | 5662 filtering_(filtering), |
| 5658 filter_(nullptr), | 5663 filter_(nullptr), |
| 5659 space_iterator_(nullptr), | 5664 space_iterator_(nullptr), |
| 5660 object_iterator_(nullptr) { | 5665 object_iterator_(nullptr) { |
| 5666 heap_->heap_iterator_start(); |
| 5661 // Start the iteration. | 5667 // Start the iteration. |
| 5662 space_iterator_ = new SpaceIterator(heap_); | 5668 space_iterator_ = new SpaceIterator(heap_); |
| 5663 switch (filtering_) { | 5669 switch (filtering_) { |
| 5664 case kFilterUnreachable: | 5670 case kFilterUnreachable: |
| 5665 filter_ = new UnreachableObjectsFilter(heap_); | 5671 filter_ = new UnreachableObjectsFilter(heap_); |
| 5666 break; | 5672 break; |
| 5667 default: | 5673 default: |
| 5668 break; | 5674 break; |
| 5669 } | 5675 } |
| 5670 object_iterator_ = space_iterator_->next(); | 5676 object_iterator_ = space_iterator_->next(); |
| 5671 } | 5677 } |
| 5672 | 5678 |
| 5673 | 5679 |
| 5674 HeapIterator::~HeapIterator() { | 5680 HeapIterator::~HeapIterator() { |
| 5681 heap_->heap_iterator_end(); |
| 5675 #ifdef DEBUG | 5682 #ifdef DEBUG |
| 5676 // Assert that in filtering mode we have iterated through all | 5683 // Assert that in filtering mode we have iterated through all |
| 5677 // objects. Otherwise, heap will be left in an inconsistent state. | 5684 // objects. Otherwise, heap will be left in an inconsistent state. |
| 5678 if (filtering_ != kNoFiltering) { | 5685 if (filtering_ != kNoFiltering) { |
| 5679 DCHECK(object_iterator_ == nullptr); | 5686 DCHECK(object_iterator_ == nullptr); |
| 5680 } | 5687 } |
| 5681 #endif | 5688 #endif |
| 5682 // Make sure the last iterator is deallocated. | 5689 // Make sure the last iterator is deallocated. |
| 5683 delete object_iterator_; | 5690 delete object_iterator_; |
| 5684 delete space_iterator_; | 5691 delete space_iterator_; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6221 } | 6228 } |
| 6222 | 6229 |
| 6223 | 6230 |
| 6224 // static | 6231 // static |
| 6225 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6232 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6226 return StaticVisitorBase::GetVisitorId(map); | 6233 return StaticVisitorBase::GetVisitorId(map); |
| 6227 } | 6234 } |
| 6228 | 6235 |
| 6229 } // namespace internal | 6236 } // namespace internal |
| 6230 } // namespace v8 | 6237 } // namespace v8 |
| OLD | NEW |