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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 lo_space_->CommittedMemory() / KB); | 380 lo_space_->CommittedMemory() / KB); |
381 PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR | 381 PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR |
382 " KB" | 382 " KB" |
383 ", available: %6" V8PRIdPTR | 383 ", available: %6" V8PRIdPTR |
384 " KB" | 384 " KB" |
385 ", committed: %6" V8PRIdPTR " KB\n", | 385 ", committed: %6" V8PRIdPTR " KB\n", |
386 this->SizeOfObjects() / KB, this->Available() / KB, | 386 this->SizeOfObjects() / KB, this->Available() / KB, |
387 this->CommittedMemory() / KB); | 387 this->CommittedMemory() / KB); |
388 PrintIsolate( | 388 PrintIsolate( |
389 isolate_, "External memory reported: %6" V8PRIdPTR " KB\n", | 389 isolate_, "External memory reported: %6" V8PRIdPTR " KB\n", |
390 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB)); | 390 static_cast<intptr_t>(amount_of_external_allocated_memory_.Value() / KB)); |
391 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", | 391 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", |
392 total_gc_time_ms_); | 392 total_gc_time_ms_); |
393 } | 393 } |
394 | 394 |
395 // TODO(1238405): Combine the infrastructure for --heap-stats and | 395 // TODO(1238405): Combine the infrastructure for --heap-stats and |
396 // --log-gc to avoid the complicated preprocessor and flag testing. | 396 // --log-gc to avoid the complicated preprocessor and flag testing. |
397 void Heap::ReportStatisticsAfterGC() { | 397 void Heap::ReportStatisticsAfterGC() { |
398 // Similar to the before GC, we use some complicated logic to ensure that | 398 // Similar to the before GC, we use some complicated logic to ensure that |
399 // NewSpace statistics are logged exactly once when --log-gc is turned on. | 399 // NewSpace statistics are logged exactly once when --log-gc is turned on. |
400 #if defined(DEBUG) | 400 #if defined(DEBUG) |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 // Update relocatables. | 1334 // Update relocatables. |
1335 Relocatable::PostGarbageCollectionProcessing(isolate_); | 1335 Relocatable::PostGarbageCollectionProcessing(isolate_); |
1336 | 1336 |
1337 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); | 1337 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); |
1338 double mutator_speed = | 1338 double mutator_speed = |
1339 tracer()->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond(); | 1339 tracer()->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond(); |
1340 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); | 1340 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); |
1341 if (collector == MARK_COMPACTOR) { | 1341 if (collector == MARK_COMPACTOR) { |
1342 // Register the amount of external allocated memory. | 1342 // Register the amount of external allocated memory. |
1343 amount_of_external_allocated_memory_at_last_global_gc_ = | 1343 amount_of_external_allocated_memory_at_last_global_gc_ = |
1344 amount_of_external_allocated_memory_; | 1344 amount_of_external_allocated_memory_.Value(); |
1345 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1345 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
1346 } else if (HasLowYoungGenerationAllocationRate() && | 1346 } else if (HasLowYoungGenerationAllocationRate() && |
1347 old_generation_size_configured_) { | 1347 old_generation_size_configured_) { |
1348 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1348 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
1349 } | 1349 } |
1350 | 1350 |
1351 { | 1351 { |
1352 GCCallbacksScope scope(this); | 1352 GCCallbacksScope scope(this); |
1353 if (scope.CheckReenter()) { | 1353 if (scope.CheckReenter()) { |
1354 AllowHeapAllocation allow_allocation; | 1354 AllowHeapAllocation allow_allocation; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 gc_state_ = SCAVENGE; | 1619 gc_state_ = SCAVENGE; |
1620 | 1620 |
1621 // Implements Cheney's copying algorithm | 1621 // Implements Cheney's copying algorithm |
1622 LOG(isolate_, ResourceEvent("scavenge", "begin")); | 1622 LOG(isolate_, ResourceEvent("scavenge", "begin")); |
1623 | 1623 |
1624 // Used for updating survived_since_last_expansion_ at function end. | 1624 // Used for updating survived_since_last_expansion_ at function end. |
1625 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); | 1625 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); |
1626 | 1626 |
1627 scavenge_collector_->SelectScavengingVisitorsTable(); | 1627 scavenge_collector_->SelectScavengingVisitorsTable(); |
1628 | 1628 |
1629 array_buffer_tracker()->PrepareDiscoveryInNewSpace(); | |
1630 | |
1631 // Flip the semispaces. After flipping, to space is empty, from space has | 1629 // Flip the semispaces. After flipping, to space is empty, from space has |
1632 // live objects. | 1630 // live objects. |
1633 new_space_.Flip(); | 1631 new_space_.Flip(); |
1634 new_space_.ResetAllocationInfo(); | 1632 new_space_.ResetAllocationInfo(); |
1635 | 1633 |
1636 // We need to sweep newly copied objects which can be either in the | 1634 // 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 | 1635 // 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 | 1636 // 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 | 1637 // copied and unswept objects lie between a 'front' mark and the |
1640 // allocation pointer. | 1638 // allocation pointer. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1725 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
1728 | 1726 |
1729 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1727 ScavengeWeakObjectRetainer weak_object_retainer(this); |
1730 ProcessYoungWeakReferences(&weak_object_retainer); | 1728 ProcessYoungWeakReferences(&weak_object_retainer); |
1731 | 1729 |
1732 DCHECK(new_space_front == new_space_.top()); | 1730 DCHECK(new_space_front == new_space_.top()); |
1733 | 1731 |
1734 // Set age mark. | 1732 // Set age mark. |
1735 new_space_.set_age_mark(new_space_.top()); | 1733 new_space_.set_age_mark(new_space_.top()); |
1736 | 1734 |
1737 array_buffer_tracker()->FreeDead(true); | 1735 array_buffer_tracker()->FreeDeadInNewSpace(); |
1738 | 1736 |
1739 // Update how much has survived scavenge. | 1737 // Update how much has survived scavenge. |
1740 IncrementYoungSurvivorsCounter(static_cast<int>( | 1738 IncrementYoungSurvivorsCounter(static_cast<int>( |
1741 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1739 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
1742 | 1740 |
1743 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1741 LOG(isolate_, ResourceEvent("scavenge", "end")); |
1744 | 1742 |
1745 gc_state_ = NOT_IN_GC; | 1743 gc_state_ = NOT_IN_GC; |
1746 } | 1744 } |
1747 | 1745 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 return object; | 2005 return object; |
2008 } | 2006 } |
2009 | 2007 |
2010 | 2008 |
2011 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { | 2009 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { |
2012 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); | 2010 return AlignWithFiller(object, size - kPointerSize, size, kDoubleAligned); |
2013 } | 2011 } |
2014 | 2012 |
2015 | 2013 |
2016 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { | 2014 void Heap::RegisterNewArrayBuffer(JSArrayBuffer* buffer) { |
2017 return array_buffer_tracker()->RegisterNew(buffer); | 2015 const bool track_live = |
| 2016 Page::FromAddress(buffer->address())->IsFlagSet(Page::BLACK_PAGE); |
| 2017 return array_buffer_tracker()->RegisterNew(buffer, track_live); |
2018 } | 2018 } |
2019 | 2019 |
2020 | 2020 |
2021 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { | 2021 void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) { |
2022 return array_buffer_tracker()->Unregister(buffer); | 2022 return array_buffer_tracker()->Unregister(buffer); |
2023 } | 2023 } |
2024 | 2024 |
2025 | 2025 |
2026 void Heap::ConfigureInitialOldGenerationSize() { | 2026 void Heap::ConfigureInitialOldGenerationSize() { |
2027 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { | 2027 if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) { |
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5003 } | 5003 } |
5004 | 5004 |
5005 | 5005 |
5006 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5006 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
5007 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5007 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
5008 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); | 5008 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); |
5009 } | 5009 } |
5010 | 5010 |
5011 | 5011 |
5012 int64_t Heap::PromotedExternalMemorySize() { | 5012 int64_t Heap::PromotedExternalMemorySize() { |
5013 if (amount_of_external_allocated_memory_ <= | 5013 if (amount_of_external_allocated_memory_.Value() <= |
5014 amount_of_external_allocated_memory_at_last_global_gc_) | 5014 amount_of_external_allocated_memory_at_last_global_gc_) |
5015 return 0; | 5015 return 0; |
5016 return amount_of_external_allocated_memory_ - | 5016 return amount_of_external_allocated_memory_.Value() - |
5017 amount_of_external_allocated_memory_at_last_global_gc_; | 5017 amount_of_external_allocated_memory_at_last_global_gc_; |
5018 } | 5018 } |
5019 | 5019 |
5020 | 5020 |
5021 const double Heap::kMinHeapGrowingFactor = 1.1; | 5021 const double Heap::kMinHeapGrowingFactor = 1.1; |
5022 const double Heap::kMaxHeapGrowingFactor = 4.0; | 5022 const double Heap::kMaxHeapGrowingFactor = 4.0; |
5023 const double Heap::kMaxHeapGrowingFactorMemoryConstrained = 2.0; | 5023 const double Heap::kMaxHeapGrowingFactorMemoryConstrained = 2.0; |
5024 const double Heap::kMaxHeapGrowingFactorIdle = 1.5; | 5024 const double Heap::kMaxHeapGrowingFactorIdle = 1.5; |
5025 const double Heap::kTargetMutatorUtilization = 0.97; | 5025 const double Heap::kTargetMutatorUtilization = 0.97; |
5026 | 5026 |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6347 } | 6347 } |
6348 | 6348 |
6349 | 6349 |
6350 // static | 6350 // static |
6351 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6351 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6352 return StaticVisitorBase::GetVisitorId(map); | 6352 return StaticVisitorBase::GetVisitorId(map); |
6353 } | 6353 } |
6354 | 6354 |
6355 } // namespace internal | 6355 } // namespace internal |
6356 } // namespace v8 | 6356 } // namespace v8 |
OLD | NEW |