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