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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 const double pressure = | 929 const double pressure = |
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, | 939 deadline, IncrementalMarking::GC_VIA_STACK_GUARD, |
940 IncrementalMarking::StepActions(IncrementalMarking::GC_VIA_STACK_GUARD, | 940 IncrementalMarking::FORCE_COMPLETION); |
941 IncrementalMarking::FORCE_MARKING, | |
942 IncrementalMarking::FORCE_COMPLETION)); | |
943 } | 941 } |
944 } | 942 } |
945 | 943 |
946 | 944 |
947 void Heap::EnsureFillerObjectAtTop() { | 945 void Heap::EnsureFillerObjectAtTop() { |
948 // 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 |
949 // 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 |
950 // 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 |
951 // with a filler. | 949 // with a filler. |
952 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... |
1049 } | 1047 } |
1050 | 1048 |
1051 if (collector == MARK_COMPACTOR && | 1049 if (collector == MARK_COMPACTOR && |
1052 (gc_callback_flags & (kGCCallbackFlagForced | | 1050 (gc_callback_flags & (kGCCallbackFlagForced | |
1053 kGCCallbackFlagCollectAllAvailableGarbage)) != 0) { | 1051 kGCCallbackFlagCollectAllAvailableGarbage)) != 0) { |
1054 isolate()->CountUsage(v8::Isolate::kForcedGC); | 1052 isolate()->CountUsage(v8::Isolate::kForcedGC); |
1055 } | 1053 } |
1056 | 1054 |
1057 // Start incremental marking for the next cycle. The heap snapshot | 1055 // Start incremental marking for the next cycle. The heap snapshot |
1058 // generator needs incremental marking to stay off after it aborted. | 1056 // generator needs incremental marking to stay off after it aborted. |
1059 if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() && | 1057 if (!ShouldAbortIncrementalMarking()) { |
1060 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { | 1058 StartIncrementalMarkingIfNeeded(kNoGCFlags, kNoGCCallbackFlags, |
1061 StartIncrementalMarking(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue"); | 1059 "GC epilogue"); |
1062 } | 1060 } |
1063 | 1061 |
1064 return next_gc_likely_to_collect_more; | 1062 return next_gc_likely_to_collect_more; |
1065 } | 1063 } |
1066 | 1064 |
1067 | 1065 |
1068 int Heap::NotifyContextDisposed(bool dependant_context) { | 1066 int Heap::NotifyContextDisposed(bool dependant_context) { |
1069 if (!dependant_context) { | 1067 if (!dependant_context) { |
1070 tracer()->ResetSurvivalEvents(); | 1068 tracer()->ResetSurvivalEvents(); |
1071 old_generation_size_configured_ = false; | 1069 old_generation_size_configured_ = false; |
(...skipping 15 matching lines...) Expand all Loading... |
1087 | 1085 |
1088 void Heap::StartIncrementalMarking(int gc_flags, | 1086 void Heap::StartIncrementalMarking(int gc_flags, |
1089 const GCCallbackFlags gc_callback_flags, | 1087 const GCCallbackFlags gc_callback_flags, |
1090 const char* reason) { | 1088 const char* reason) { |
1091 DCHECK(incremental_marking()->IsStopped()); | 1089 DCHECK(incremental_marking()->IsStopped()); |
1092 set_current_gc_flags(gc_flags); | 1090 set_current_gc_flags(gc_flags); |
1093 current_gc_callback_flags_ = gc_callback_flags; | 1091 current_gc_callback_flags_ = gc_callback_flags; |
1094 incremental_marking()->Start(reason); | 1092 incremental_marking()->Start(reason); |
1095 } | 1093 } |
1096 | 1094 |
| 1095 void Heap::StartIncrementalMarkingIfNeeded( |
| 1096 int gc_flags, const GCCallbackFlags gc_callback_flags, const char* reason) { |
| 1097 if (incremental_marking()->IsStopped() && |
| 1098 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { |
| 1099 StartIncrementalMarking(gc_flags, gc_callback_flags, reason); |
| 1100 } |
| 1101 } |
1097 | 1102 |
1098 void Heap::StartIdleIncrementalMarking() { | 1103 void Heap::StartIdleIncrementalMarking() { |
1099 gc_idle_time_handler_->ResetNoProgressCounter(); | 1104 gc_idle_time_handler_->ResetNoProgressCounter(); |
1100 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags, | 1105 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags, |
1101 "idle"); | 1106 "idle"); |
1102 } | 1107 } |
1103 | 1108 |
1104 | 1109 |
1105 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, | 1110 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, |
1106 int len) { | 1111 int len) { |
(...skipping 5357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6464 } | 6469 } |
6465 | 6470 |
6466 | 6471 |
6467 // static | 6472 // static |
6468 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6473 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6469 return StaticVisitorBase::GetVisitorId(map); | 6474 return StaticVisitorBase::GetVisitorId(map); |
6470 } | 6475 } |
6471 | 6476 |
6472 } // namespace internal | 6477 } // namespace internal |
6473 } // namespace v8 | 6478 } // namespace v8 |
OLD | NEW |