Chromium Code Reviews| 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/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 static_cast<double>(external_memory_ - | 930 static_cast<double>(external_memory_ - |
| 931 external_memory_at_last_mark_compact_ - | 931 external_memory_at_last_mark_compact_ - |
| 932 kExternalAllocationSoftLimit) / | 932 kExternalAllocationSoftLimit) / |
| 933 external_memory_hard_limit(); | 933 external_memory_hard_limit(); |
| 934 DCHECK_GE(1, pressure); | 934 DCHECK_GE(1, pressure); |
| 935 const double kMaxStepSizeOnExternalLimit = 25; | 935 const double kMaxStepSizeOnExternalLimit = 25; |
| 936 const double deadline = MonotonicallyIncreasingTimeInMs() + | 936 const double deadline = MonotonicallyIncreasingTimeInMs() + |
| 937 pressure * kMaxStepSizeOnExternalLimit; | 937 pressure * kMaxStepSizeOnExternalLimit; |
| 938 incremental_marking()->AdvanceIncrementalMarking( | 938 incremental_marking()->AdvanceIncrementalMarking( |
| 939 deadline, IncrementalMarking::GC_VIA_STACK_GUARD, | 939 deadline, IncrementalMarking::GC_VIA_STACK_GUARD, |
| 940 IncrementalMarking::FORCE_COMPLETION); | 940 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kV8); |
| 941 } | 941 } |
| 942 } | 942 } |
| 943 | 943 |
| 944 | 944 |
| 945 void Heap::EnsureFillerObjectAtTop() { | 945 void Heap::EnsureFillerObjectAtTop() { |
| 946 // There may be an allocation memento behind objects in new space. Upon | 946 // There may be an allocation memento behind objects in new space. Upon |
| 947 // evacuation of a non-full new space (or if we are on the last page) there | 947 // evacuation of a non-full new space (or if we are on the last page) there |
| 948 // may be uninitialized memory behind top. We fill the remainder of the page | 948 // may be uninitialized memory behind top. We fill the remainder of the page |
| 949 // with a filler. | 949 // with a filler. |
| 950 Address to_top = new_space_->top(); | 950 Address to_top = new_space_->top(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 if (collector == MARK_COMPACTOR && | 1049 if (collector == MARK_COMPACTOR && |
| 1050 (gc_callback_flags & (kGCCallbackFlagForced | | 1050 (gc_callback_flags & (kGCCallbackFlagForced | |
| 1051 kGCCallbackFlagCollectAllAvailableGarbage)) != 0) { | 1051 kGCCallbackFlagCollectAllAvailableGarbage)) != 0) { |
| 1052 isolate()->CountUsage(v8::Isolate::kForcedGC); | 1052 isolate()->CountUsage(v8::Isolate::kForcedGC); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 // Start incremental marking for the next cycle. The heap snapshot | 1055 // Start incremental marking for the next cycle. The heap snapshot |
| 1056 // generator needs incremental marking to stay off after it aborted. | 1056 // generator needs incremental marking to stay off after it aborted. |
| 1057 if (!ShouldAbortIncrementalMarking()) { | 1057 // We do this only for scavener to avoid a loop where mark-compact |
|
Michael Lippautz
2016/09/07 15:46:24
nit: scavenger
| |
| 1058 // causes another mark-compact. | |
| 1059 if (collector == SCAVENGER && !ShouldAbortIncrementalMarking()) { | |
| 1058 StartIncrementalMarkingIfAllocationLimitIsReached(kNoGCFlags, | 1060 StartIncrementalMarkingIfAllocationLimitIsReached(kNoGCFlags, |
| 1059 kNoGCCallbackFlags); | 1061 kNoGCCallbackFlags); |
| 1060 } | 1062 } |
| 1061 | 1063 |
| 1062 return next_gc_likely_to_collect_more; | 1064 return next_gc_likely_to_collect_more; |
| 1063 } | 1065 } |
| 1064 | 1066 |
| 1065 | 1067 |
| 1066 int Heap::NotifyContextDisposed(bool dependant_context) { | 1068 int Heap::NotifyContextDisposed(bool dependant_context) { |
| 1067 if (!dependant_context) { | 1069 if (!dependant_context) { |
| (...skipping 3225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4293 | 4295 |
| 4294 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, | 4296 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, |
| 4295 GCIdleTimeHeapState heap_state, | 4297 GCIdleTimeHeapState heap_state, |
| 4296 double deadline_in_ms) { | 4298 double deadline_in_ms) { |
| 4297 bool result = false; | 4299 bool result = false; |
| 4298 switch (action.type) { | 4300 switch (action.type) { |
| 4299 case DONE: | 4301 case DONE: |
| 4300 result = true; | 4302 result = true; |
| 4301 break; | 4303 break; |
| 4302 case DO_INCREMENTAL_STEP: { | 4304 case DO_INCREMENTAL_STEP: { |
| 4303 if (incremental_marking()->incremental_marking_job()->IdleTaskPending()) { | 4305 const double remaining_idle_time_in_ms = |
| 4304 result = true; | 4306 incremental_marking()->AdvanceIncrementalMarking( |
| 4305 } else { | 4307 deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 4306 incremental_marking() | 4308 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kTask); |
| 4307 ->incremental_marking_job() | 4309 if (remaining_idle_time_in_ms > 0.0) { |
| 4308 ->NotifyIdleTaskProgress(); | 4310 TryFinalizeIdleIncrementalMarking( |
| 4309 result = IncrementalMarkingJob::IdleTask::Step(this, deadline_in_ms) == | 4311 remaining_idle_time_in_ms, |
| 4310 IncrementalMarkingJob::IdleTask::kDone; | 4312 GarbageCollectionReason::kFinalizeMarkingViaTask); |
| 4311 } | 4313 } |
| 4314 result = incremental_marking()->IsStopped(); | |
| 4312 break; | 4315 break; |
| 4313 } | 4316 } |
| 4314 case DO_FULL_GC: { | 4317 case DO_FULL_GC: { |
| 4315 DCHECK(contexts_disposed_ > 0); | 4318 DCHECK(contexts_disposed_ > 0); |
| 4316 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4319 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4317 TRACE_EVENT0("v8", "V8.GCContext"); | 4320 TRACE_EVENT0("v8", "V8.GCContext"); |
| 4318 CollectAllGarbage(kNoGCFlags, GarbageCollectionReason::kContextDisposal); | 4321 CollectAllGarbage(kNoGCFlags, GarbageCollectionReason::kContextDisposal); |
| 4319 break; | 4322 break; |
| 4320 } | 4323 } |
| 4321 case DO_NOTHING: | 4324 case DO_NOTHING: |
| (...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6529 } | 6532 } |
| 6530 | 6533 |
| 6531 | 6534 |
| 6532 // static | 6535 // static |
| 6533 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6536 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6534 return StaticVisitorBase::GetVisitorId(map); | 6537 return StaticVisitorBase::GetVisitorId(map); |
| 6535 } | 6538 } |
| 6536 | 6539 |
| 6537 } // namespace internal | 6540 } // namespace internal |
| 6538 } // namespace v8 | 6541 } // namespace v8 |
| OLD | NEW |