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