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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ring_buffer_full_(false), | 153 ring_buffer_full_(false), |
154 ring_buffer_end_(0), | 154 ring_buffer_end_(0), |
155 promotion_queue_(this), | 155 promotion_queue_(this), |
156 configured_(false), | 156 configured_(false), |
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 gc_callbacks_depth_(0), | 160 gc_callbacks_depth_(0), |
161 deserialization_complete_(false), | 161 deserialization_complete_(false), |
162 strong_roots_list_(NULL), | 162 strong_roots_list_(NULL), |
| 163 array_buffer_tracker_(NULL), |
163 heap_iterator_depth_(0), | 164 heap_iterator_depth_(0), |
164 force_oom_(false) { | 165 force_oom_(false) { |
165 // Allow build-time customization of the max semispace size. Building | 166 // Allow build-time customization of the max semispace size. Building |
166 // V8 with snapshots and a non-default max semispace size is much | 167 // V8 with snapshots and a non-default max semispace size is much |
167 // easier if you can define it as part of the build environment. | 168 // easier if you can define it as part of the build environment. |
168 #if defined(V8_MAX_SEMISPACE_SIZE) | 169 #if defined(V8_MAX_SEMISPACE_SIZE) |
169 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 170 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
170 #endif | 171 #endif |
171 | 172 |
172 // Ensure old_generation_size_ is a multiple of kPageSize. | 173 // Ensure old_generation_size_ is a multiple of kPageSize. |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 gc_state_ = SCAVENGE; | 1619 gc_state_ = SCAVENGE; |
1619 | 1620 |
1620 // Implements Cheney's copying algorithm | 1621 // Implements Cheney's copying algorithm |
1621 LOG(isolate_, ResourceEvent("scavenge", "begin")); | 1622 LOG(isolate_, ResourceEvent("scavenge", "begin")); |
1622 | 1623 |
1623 // Used for updating survived_since_last_expansion_ at function end. | 1624 // Used for updating survived_since_last_expansion_ at function end. |
1624 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); | 1625 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); |
1625 | 1626 |
1626 scavenge_collector_->SelectScavengingVisitorsTable(); | 1627 scavenge_collector_->SelectScavengingVisitorsTable(); |
1627 | 1628 |
| 1629 array_buffer_tracker()->PrepareDiscoveryInNewSpace(); |
| 1630 |
1628 // Flip the semispaces. After flipping, to space is empty, from space has | 1631 // Flip the semispaces. After flipping, to space is empty, from space has |
1629 // live objects. | 1632 // live objects. |
1630 new_space_.Flip(); | 1633 new_space_.Flip(); |
1631 new_space_.ResetAllocationInfo(); | 1634 new_space_.ResetAllocationInfo(); |
1632 | 1635 |
1633 // We need to sweep newly copied objects which can be either in the | 1636 // We need to sweep newly copied objects which can be either in the |
1634 // to space or promoted to the old generation. For to-space | 1637 // to space or promoted to the old generation. For to-space |
1635 // objects, we treat the bottom of the to space as a queue. Newly | 1638 // objects, we treat the bottom of the to space as a queue. Newly |
1636 // copied and unswept objects lie between a 'front' mark and the | 1639 // copied and unswept objects lie between a 'front' mark and the |
1637 // allocation pointer. | 1640 // allocation pointer. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1740 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
1738 | 1741 |
1739 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1742 ScavengeWeakObjectRetainer weak_object_retainer(this); |
1740 ProcessYoungWeakReferences(&weak_object_retainer); | 1743 ProcessYoungWeakReferences(&weak_object_retainer); |
1741 | 1744 |
1742 DCHECK(new_space_front == new_space_.top()); | 1745 DCHECK(new_space_front == new_space_.top()); |
1743 | 1746 |
1744 // Set age mark. | 1747 // Set age mark. |
1745 new_space_.set_age_mark(new_space_.top()); | 1748 new_space_.set_age_mark(new_space_.top()); |
1746 | 1749 |
1747 ArrayBufferTracker::FreeDeadInNewSpace(this); | 1750 array_buffer_tracker()->FreeDead(true); |
1748 | 1751 |
1749 // Update how much has survived scavenge. | 1752 // Update how much has survived scavenge. |
1750 IncrementYoungSurvivorsCounter(static_cast<int>( | 1753 IncrementYoungSurvivorsCounter(static_cast<int>( |
1751 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1754 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
1752 | 1755 |
1753 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1756 LOG(isolate_, ResourceEvent("scavenge", "end")); |
1754 | 1757 |
1755 gc_state_ = NOT_IN_GC; | 1758 gc_state_ = NOT_IN_GC; |
1756 } | 1759 } |
1757 | 1760 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 return object; | 2020 return object; |
2018 } | 2021 } |
2019 | 2022 |
2020 | 2023 |
2021 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { | 2024 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { |
2022 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); | 2025 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); |
2023 } | 2026 } |
2024 | 2027 |
2025 | 2028 |
2026 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { | 2029 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { |
2027 ArrayBufferTracker::RegisterNew(this, buffer); | 2030 return array_buffer_tracker()->RegisterNew(buffer); |
2028 } | 2031 } |
2029 | 2032 |
2030 | 2033 |
2031 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { | 2034 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { |
2032 ArrayBufferTracker::Unregister(this, buffer); | 2035 return array_buffer_tracker()->Unregister(buffer); |
2033 } | 2036 } |
2034 | 2037 |
2035 | 2038 |
2036 void Heap::ConfigureInitialOldGenerationSize() { | 2039 void Heap::ConfigureInitialOldGenerationSize() { |
2037 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { | 2040 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { |
2038 old_generation_allocation_limit_ = | 2041 old_generation_allocation_limit_ = |
2039 Max(kMinimumOldGenerationAllocationLimit, | 2042 Max(kMinimumOldGenerationAllocationLimit, |
2040 static_cast<intptr_t>( | 2043 static_cast<intptr_t>( |
2041 static_cast<double>(old_generation_allocation_limit_) * | 2044 static_cast<double>(old_generation_allocation_limit_) * |
2042 (tracer()->AverageSurvivalRatio() / 100))); | 2045 (tracer()->AverageSurvivalRatio() / 100))); |
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5315 | 5318 |
5316 gc_idle_time_handler_ = new GCIdleTimeHandler(); | 5319 gc_idle_time_handler_ = new GCIdleTimeHandler(); |
5317 | 5320 |
5318 memory_reducer_ = new MemoryReducer(this); | 5321 memory_reducer_ = new MemoryReducer(this); |
5319 | 5322 |
5320 object_stats_ = new ObjectStats(this); | 5323 object_stats_ = new ObjectStats(this); |
5321 object_stats_->ClearObjectStats(true); | 5324 object_stats_->ClearObjectStats(true); |
5322 | 5325 |
5323 scavenge_job_ = new ScavengeJob(); | 5326 scavenge_job_ = new ScavengeJob(); |
5324 | 5327 |
| 5328 array_buffer_tracker_ = new ArrayBufferTracker(this); |
| 5329 |
5325 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 5330 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
5326 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 5331 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
5327 | 5332 |
5328 store_buffer()->SetUp(); | 5333 store_buffer()->SetUp(); |
5329 | 5334 |
5330 mark_compact_collector()->SetUp(); | 5335 mark_compact_collector()->SetUp(); |
5331 | 5336 |
5332 idle_scavenge_observer_ = new IdleScavengeObserver( | 5337 idle_scavenge_observer_ = new IdleScavengeObserver( |
5333 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); | 5338 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); |
5334 new_space()->AddAllocationObserver(idle_scavenge_observer_); | 5339 new_space()->AddAllocationObserver(idle_scavenge_observer_); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5474 delete memory_reducer_; | 5479 delete memory_reducer_; |
5475 memory_reducer_ = nullptr; | 5480 memory_reducer_ = nullptr; |
5476 } | 5481 } |
5477 | 5482 |
5478 delete object_stats_; | 5483 delete object_stats_; |
5479 object_stats_ = nullptr; | 5484 object_stats_ = nullptr; |
5480 | 5485 |
5481 delete scavenge_job_; | 5486 delete scavenge_job_; |
5482 scavenge_job_ = nullptr; | 5487 scavenge_job_ = nullptr; |
5483 | 5488 |
| 5489 delete array_buffer_tracker_; |
| 5490 array_buffer_tracker_ = nullptr; |
| 5491 |
5484 isolate_->global_handles()->TearDown(); | 5492 isolate_->global_handles()->TearDown(); |
5485 | 5493 |
5486 external_string_table_.TearDown(); | 5494 external_string_table_.TearDown(); |
5487 | 5495 |
5488 delete tracer_; | 5496 delete tracer_; |
5489 tracer_ = nullptr; | 5497 tracer_ = nullptr; |
5490 | 5498 |
5491 new_space_.TearDown(); | 5499 new_space_.TearDown(); |
5492 | 5500 |
5493 if (old_space_ != NULL) { | 5501 if (old_space_ != NULL) { |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6383 } | 6391 } |
6384 | 6392 |
6385 | 6393 |
6386 // static | 6394 // static |
6387 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6395 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6388 return StaticVisitorBase::GetVisitorId(map); | 6396 return StaticVisitorBase::GetVisitorId(map); |
6389 } | 6397 } |
6390 | 6398 |
6391 } // namespace internal | 6399 } // namespace internal |
6392 } // namespace v8 | 6400 } // namespace v8 |
OLD | NEW |