| 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/v8.h" | 5 #include "src/v8.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/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 new_space_.LowerInlineAllocationLimit( | 1541 new_space_.LowerInlineAllocationLimit( |
| 1542 new_space_.inline_allocation_limit_step()); | 1542 new_space_.inline_allocation_limit_step()); |
| 1543 | 1543 |
| 1544 // Update how much has survived scavenge. | 1544 // Update how much has survived scavenge. |
| 1545 IncrementYoungSurvivorsCounter(static_cast<int>( | 1545 IncrementYoungSurvivorsCounter(static_cast<int>( |
| 1546 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1546 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
| 1547 | 1547 |
| 1548 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1548 LOG(isolate_, ResourceEvent("scavenge", "end")); |
| 1549 | 1549 |
| 1550 gc_state_ = NOT_IN_GC; | 1550 gc_state_ = NOT_IN_GC; |
| 1551 |
| 1552 gc_idle_time_handler_.NotifyScavenge(); |
| 1551 } | 1553 } |
| 1552 | 1554 |
| 1553 | 1555 |
| 1554 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, | 1556 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, |
| 1555 Object** p) { | 1557 Object** p) { |
| 1556 MapWord first_word = HeapObject::cast(*p)->map_word(); | 1558 MapWord first_word = HeapObject::cast(*p)->map_word(); |
| 1557 | 1559 |
| 1558 if (!first_word.IsForwardingAddress()) { | 1560 if (!first_word.IsForwardingAddress()) { |
| 1559 // Unreachable external string can be finalized. | 1561 // Unreachable external string can be finalized. |
| 1560 heap->FinalizeExternalString(String::cast(*p)); | 1562 heap->FinalizeExternalString(String::cast(*p)); |
| (...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4250 if (!IsHeapIterable()) { | 4252 if (!IsHeapIterable()) { |
| 4251 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); | 4253 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); |
| 4252 } | 4254 } |
| 4253 if (mark_compact_collector()->sweeping_in_progress()) { | 4255 if (mark_compact_collector()->sweeping_in_progress()) { |
| 4254 mark_compact_collector()->EnsureSweepingCompleted(); | 4256 mark_compact_collector()->EnsureSweepingCompleted(); |
| 4255 } | 4257 } |
| 4256 DCHECK(IsHeapIterable()); | 4258 DCHECK(IsHeapIterable()); |
| 4257 } | 4259 } |
| 4258 | 4260 |
| 4259 | 4261 |
| 4262 void Heap::IdleMarkCompact(const char* message) { |
| 4263 bool uncommit = false; |
| 4264 if (gc_count_at_last_idle_gc_ == gc_count_) { |
| 4265 // No GC since the last full GC, the mutator is probably not active. |
| 4266 isolate_->compilation_cache()->Clear(); |
| 4267 uncommit = true; |
| 4268 } |
| 4269 CollectAllGarbage(kReduceMemoryFootprintMask, message); |
| 4270 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
| 4271 gc_count_at_last_idle_gc_ = gc_count_; |
| 4272 if (uncommit) { |
| 4273 new_space_.Shrink(); |
| 4274 UncommitFromSpace(); |
| 4275 } |
| 4276 } |
| 4277 |
| 4278 |
| 4260 void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { | 4279 void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { |
| 4261 incremental_marking()->Step(step_size, | 4280 incremental_marking()->Step(step_size, |
| 4262 IncrementalMarking::NO_GC_VIA_STACK_GUARD, true); | 4281 IncrementalMarking::NO_GC_VIA_STACK_GUARD, true); |
| 4263 | 4282 |
| 4264 if (incremental_marking()->IsComplete()) { | 4283 if (incremental_marking()->IsComplete()) { |
| 4265 bool uncommit = false; | 4284 IdleMarkCompact("idle notification: finalize incremental"); |
| 4266 if (gc_count_at_last_idle_gc_ == gc_count_) { | |
| 4267 // No GC since the last full GC, the mutator is probably not active. | |
| 4268 isolate_->compilation_cache()->Clear(); | |
| 4269 uncommit = true; | |
| 4270 } | |
| 4271 CollectAllGarbage(kReduceMemoryFootprintMask, | |
| 4272 "idle notification: finalize incremental"); | |
| 4273 gc_idle_time_handler_.NotifyIdleMarkCompact(); | |
| 4274 gc_count_at_last_idle_gc_ = gc_count_; | |
| 4275 if (uncommit) { | |
| 4276 new_space_.Shrink(); | |
| 4277 UncommitFromSpace(); | |
| 4278 } | |
| 4279 } | 4285 } |
| 4280 } | 4286 } |
| 4281 | 4287 |
| 4282 | 4288 |
| 4283 bool Heap::WorthActivatingIncrementalMarking() { | 4289 bool Heap::WorthActivatingIncrementalMarking() { |
| 4284 return incremental_marking()->IsStopped() && | 4290 return incremental_marking()->IsStopped() && |
| 4285 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); | 4291 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); |
| 4286 } | 4292 } |
| 4287 | 4293 |
| 4288 | 4294 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4326 result = true; | 4332 result = true; |
| 4327 break; | 4333 break; |
| 4328 case DO_INCREMENTAL_MARKING: | 4334 case DO_INCREMENTAL_MARKING: |
| 4329 if (incremental_marking()->IsStopped()) { | 4335 if (incremental_marking()->IsStopped()) { |
| 4330 incremental_marking()->Start(); | 4336 incremental_marking()->Start(); |
| 4331 } | 4337 } |
| 4332 AdvanceIdleIncrementalMarking(action.parameter); | 4338 AdvanceIdleIncrementalMarking(action.parameter); |
| 4333 break; | 4339 break; |
| 4334 case DO_FULL_GC: { | 4340 case DO_FULL_GC: { |
| 4335 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4341 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4336 const char* message = contexts_disposed_ | 4342 if (contexts_disposed_) { |
| 4337 ? "idle notification: contexts disposed" | 4343 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 4338 : "idle notification: finalize idle round"; | 4344 "idle notification: contexts disposed"); |
| 4339 CollectAllGarbage(kReduceMemoryFootprintMask, message); | 4345 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
| 4340 gc_idle_time_handler_.NotifyIdleMarkCompact(); | 4346 gc_count_at_last_idle_gc_ = gc_count_; |
| 4347 } else { |
| 4348 IdleMarkCompact("idle notification: finalize idle round"); |
| 4349 } |
| 4341 break; | 4350 break; |
| 4342 } | 4351 } |
| 4343 case DO_SCAVENGE: | 4352 case DO_SCAVENGE: |
| 4344 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); | 4353 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); |
| 4345 break; | 4354 break; |
| 4346 case DO_FINALIZE_SWEEPING: | 4355 case DO_FINALIZE_SWEEPING: |
| 4347 mark_compact_collector()->EnsureSweepingCompleted(); | 4356 mark_compact_collector()->EnsureSweepingCompleted(); |
| 4348 break; | 4357 break; |
| 4349 case DO_NOTHING: | 4358 case DO_NOTHING: |
| 4350 break; | 4359 break; |
| (...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6141 static_cast<int>(object_sizes_last_time_[index])); | 6150 static_cast<int>(object_sizes_last_time_[index])); |
| 6142 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6151 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6143 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6152 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6144 | 6153 |
| 6145 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6154 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6146 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6155 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6147 ClearObjectStats(); | 6156 ClearObjectStats(); |
| 6148 } | 6157 } |
| 6149 } | 6158 } |
| 6150 } // namespace v8::internal | 6159 } // namespace v8::internal |
| OLD | NEW |