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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1742 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
1746 | 1743 |
1747 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1744 ScavengeWeakObjectRetainer weak_object_retainer(this); |
1748 ProcessYoungWeakReferences(&weak_object_retainer); | 1745 ProcessYoungWeakReferences(&weak_object_retainer); |
1749 | 1746 |
1750 DCHECK(new_space_front == new_space_.top()); | 1747 DCHECK(new_space_front == new_space_.top()); |
1751 | 1748 |
1752 // Set age mark. | 1749 // Set age mark. |
1753 new_space_.set_age_mark(new_space_.top()); | 1750 new_space_.set_age_mark(new_space_.top()); |
1754 | 1751 |
1755 array_buffer_tracker()->FreeDead(true); | 1752 ArrayBufferTracker::FreeDeadInNewSpace(this); |
1756 | 1753 |
1757 // Update how much has survived scavenge. | 1754 // Update how much has survived scavenge. |
1758 IncrementYoungSurvivorsCounter(static_cast<int>( | 1755 IncrementYoungSurvivorsCounter(static_cast<int>( |
1759 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1756 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
1760 | 1757 |
1761 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1758 LOG(isolate_, ResourceEvent("scavenge", "end")); |
1762 | 1759 |
1763 gc_state_ = NOT_IN_GC; | 1760 gc_state_ = NOT_IN_GC; |
1764 } | 1761 } |
1765 | 1762 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 return object; | 2028 return object; |
2032 } | 2029 } |
2033 | 2030 |
2034 | 2031 |
2035 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { | 2032 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { |
2036 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); | 2033 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); |
2037 } | 2034 } |
2038 | 2035 |
2039 | 2036 |
2040 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { | 2037 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { |
2041 return array_buffer_tracker()->RegisterNew(buffer); | 2038 ArrayBufferTracker::RegisterNew(this, buffer); |
2042 } | 2039 } |
2043 | 2040 |
2044 | 2041 |
2045 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { | 2042 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { |
2046 return array_buffer_tracker()->Unregister(buffer); | 2043 ArrayBufferTracker::Unregister(this, buffer); |
2047 } | 2044 } |
2048 | 2045 |
2049 | 2046 |
2050 void Heap::ConfigureInitialOldGenerationSize() { | 2047 void Heap::ConfigureInitialOldGenerationSize() { |
2051 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { | 2048 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { |
2052 old_generation_allocation_limit_ = | 2049 old_generation_allocation_limit_ = |
2053 Max(kMinimumOldGenerationAllocationLimit, | 2050 Max(kMinimumOldGenerationAllocationLimit, |
2054 static_cast<intptr_t>( | 2051 static_cast<intptr_t>( |
2055 static_cast<double>(old_generation_allocation_limit_) * | 2052 static_cast<double>(old_generation_allocation_limit_) * |
2056 (tracer()->AverageSurvivalRatio() / 100))); | 2053 (tracer()->AverageSurvivalRatio() / 100))); |
(...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5330 | 5327 |
5331 gc_idle_time_handler_ = new GCIdleTimeHandler(); | 5328 gc_idle_time_handler_ = new GCIdleTimeHandler(); |
5332 | 5329 |
5333 memory_reducer_ = new MemoryReducer(this); | 5330 memory_reducer_ = new MemoryReducer(this); |
5334 | 5331 |
5335 object_stats_ = new ObjectStats(this); | 5332 object_stats_ = new ObjectStats(this); |
5336 object_stats_->ClearObjectStats(true); | 5333 object_stats_->ClearObjectStats(true); |
5337 | 5334 |
5338 scavenge_job_ = new ScavengeJob(); | 5335 scavenge_job_ = new ScavengeJob(); |
5339 | 5336 |
5340 array_buffer_tracker_ = new ArrayBufferTracker(this); | |
5341 | |
5342 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); | 5337 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); |
5343 LOG(isolate_, IntPtrTEvent("heap-available", Available())); | 5338 LOG(isolate_, IntPtrTEvent("heap-available", Available())); |
5344 | 5339 |
5345 store_buffer()->SetUp(); | 5340 store_buffer()->SetUp(); |
5346 | 5341 |
5347 mark_compact_collector()->SetUp(); | 5342 mark_compact_collector()->SetUp(); |
5348 | 5343 |
5349 idle_scavenge_observer_ = new IdleScavengeObserver( | 5344 idle_scavenge_observer_ = new IdleScavengeObserver( |
5350 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); | 5345 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask); |
5351 new_space()->AddAllocationObserver(idle_scavenge_observer_); | 5346 new_space()->AddAllocationObserver(idle_scavenge_observer_); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5491 delete memory_reducer_; | 5486 delete memory_reducer_; |
5492 memory_reducer_ = nullptr; | 5487 memory_reducer_ = nullptr; |
5493 } | 5488 } |
5494 | 5489 |
5495 delete object_stats_; | 5490 delete object_stats_; |
5496 object_stats_ = nullptr; | 5491 object_stats_ = nullptr; |
5497 | 5492 |
5498 delete scavenge_job_; | 5493 delete scavenge_job_; |
5499 scavenge_job_ = nullptr; | 5494 scavenge_job_ = nullptr; |
5500 | 5495 |
5501 delete array_buffer_tracker_; | |
5502 array_buffer_tracker_ = nullptr; | |
5503 | |
5504 isolate_->global_handles()->TearDown(); | 5496 isolate_->global_handles()->TearDown(); |
5505 | 5497 |
5506 external_string_table_.TearDown(); | 5498 external_string_table_.TearDown(); |
5507 | 5499 |
5508 delete tracer_; | 5500 delete tracer_; |
5509 tracer_ = nullptr; | 5501 tracer_ = nullptr; |
5510 | 5502 |
5511 new_space_.TearDown(); | 5503 new_space_.TearDown(); |
5512 | 5504 |
5513 if (old_space_ != NULL) { | 5505 if (old_space_ != NULL) { |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6403 } | 6395 } |
6404 | 6396 |
6405 | 6397 |
6406 // static | 6398 // static |
6407 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6399 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6408 return StaticVisitorBase::GetVisitorId(map); | 6400 return StaticVisitorBase::GetVisitorId(map); |
6409 } | 6401 } |
6410 | 6402 |
6411 } // namespace internal | 6403 } // namespace internal |
6412 } // namespace v8 | 6404 } // namespace v8 |
OLD | NEW |