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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 new_space_allocation_counter_(0), | 126 new_space_allocation_counter_(0), |
127 old_generation_allocation_counter_(0), | 127 old_generation_allocation_counter_(0), |
128 old_generation_size_at_last_gc_(0), | 128 old_generation_size_at_last_gc_(0), |
129 gcs_since_last_deopt_(0), | 129 gcs_since_last_deopt_(0), |
130 allocation_sites_scratchpad_length_(0), | 130 allocation_sites_scratchpad_length_(0), |
131 ring_buffer_full_(false), | 131 ring_buffer_full_(false), |
132 ring_buffer_end_(0), | 132 ring_buffer_end_(0), |
133 promotion_queue_(this), | 133 promotion_queue_(this), |
134 configured_(false), | 134 configured_(false), |
135 current_gc_flags_(Heap::kNoGCFlags), | 135 current_gc_flags_(Heap::kNoGCFlags), |
| 136 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), |
136 external_string_table_(this), | 137 external_string_table_(this), |
137 chunks_queued_for_free_(NULL), | 138 chunks_queued_for_free_(NULL), |
138 pending_unmap_job_semaphore_(0), | 139 pending_unmap_job_semaphore_(0), |
139 gc_callbacks_depth_(0), | 140 gc_callbacks_depth_(0), |
140 deserialization_complete_(false), | 141 deserialization_complete_(false), |
141 concurrent_sweeping_enabled_(false), | 142 concurrent_sweeping_enabled_(false), |
142 strong_roots_list_(NULL) { | 143 strong_roots_list_(NULL) { |
143 // Allow build-time customization of the max semispace size. Building | 144 // Allow build-time customization of the max semispace size. Building |
144 // V8 with snapshots and a non-default max semispace size is much | 145 // V8 with snapshots and a non-default max semispace size is much |
145 // easier if you can define it as part of the build environment. | 146 // easier if you can define it as part of the build environment. |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 // We must not compact the weak fixed list here, as we may be in the middle | 736 // We must not compact the weak fixed list here, as we may be in the middle |
736 // of writing to it, when the GC triggered. Instead, we reset the root value. | 737 // of writing to it, when the GC triggered. Instead, we reset the root value. |
737 set_weak_stack_trace_list(Smi::FromInt(0)); | 738 set_weak_stack_trace_list(Smi::FromInt(0)); |
738 } | 739 } |
739 | 740 |
740 | 741 |
741 void Heap::HandleGCRequest() { | 742 void Heap::HandleGCRequest() { |
742 if (incremental_marking()->request_type() == | 743 if (incremental_marking()->request_type() == |
743 IncrementalMarking::COMPLETE_MARKING) { | 744 IncrementalMarking::COMPLETE_MARKING) { |
744 CollectAllGarbage(current_gc_flags(), "GC interrupt", | 745 CollectAllGarbage(current_gc_flags(), "GC interrupt", |
745 incremental_marking()->CallbackFlags()); | 746 current_gc_callback_flags()); |
746 return; | 747 return; |
747 } | 748 } |
748 DCHECK(FLAG_overapproximate_weak_closure); | 749 DCHECK(FLAG_overapproximate_weak_closure); |
749 if (!incremental_marking()->weak_closure_was_overapproximated()) { | 750 if (!incremental_marking()->weak_closure_was_overapproximated()) { |
750 OverApproximateWeakClosure("GC interrupt"); | 751 OverApproximateWeakClosure("GC interrupt"); |
751 } | 752 } |
752 } | 753 } |
753 | 754 |
754 | 755 |
755 void Heap::OverApproximateWeakClosure(const char* gc_reason) { | 756 void Heap::OverApproximateWeakClosure(const char* gc_reason) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 945 |
945 if (collector == MARK_COMPACTOR && | 946 if (collector == MARK_COMPACTOR && |
946 (gc_callback_flags & kGCCallbackFlagForced) != 0) { | 947 (gc_callback_flags & kGCCallbackFlagForced) != 0) { |
947 isolate()->CountUsage(v8::Isolate::kForcedGC); | 948 isolate()->CountUsage(v8::Isolate::kForcedGC); |
948 } | 949 } |
949 | 950 |
950 // Start incremental marking for the next cycle. The heap snapshot | 951 // Start incremental marking for the next cycle. The heap snapshot |
951 // generator needs incremental marking to stay off after it aborted. | 952 // generator needs incremental marking to stay off after it aborted. |
952 if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() && | 953 if (!ShouldAbortIncrementalMarking() && incremental_marking()->IsStopped() && |
953 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { | 954 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { |
954 incremental_marking()->Start(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue"); | 955 StartIncrementalMarking(kNoGCFlags, kNoGCCallbackFlags, "GC epilogue"); |
955 } | 956 } |
956 | 957 |
957 return next_gc_likely_to_collect_more; | 958 return next_gc_likely_to_collect_more; |
958 } | 959 } |
959 | 960 |
960 | 961 |
961 int Heap::NotifyContextDisposed(bool dependant_context) { | 962 int Heap::NotifyContextDisposed(bool dependant_context) { |
962 if (!dependant_context) { | 963 if (!dependant_context) { |
963 tracer()->ResetSurvivalEvents(); | 964 tracer()->ResetSurvivalEvents(); |
964 old_generation_size_configured_ = false; | 965 old_generation_size_configured_ = false; |
(...skipping 10 matching lines...) Expand all Loading... |
975 event.time_ms = MonotonicallyIncreasingTimeInMs(); | 976 event.time_ms = MonotonicallyIncreasingTimeInMs(); |
976 memory_reducer_->NotifyContextDisposed(event); | 977 memory_reducer_->NotifyContextDisposed(event); |
977 return ++contexts_disposed_; | 978 return ++contexts_disposed_; |
978 } | 979 } |
979 | 980 |
980 | 981 |
981 void Heap::StartIncrementalMarking(int gc_flags, | 982 void Heap::StartIncrementalMarking(int gc_flags, |
982 const GCCallbackFlags gc_callback_flags, | 983 const GCCallbackFlags gc_callback_flags, |
983 const char* reason) { | 984 const char* reason) { |
984 DCHECK(incremental_marking()->IsStopped()); | 985 DCHECK(incremental_marking()->IsStopped()); |
985 incremental_marking()->Start(gc_flags, gc_callback_flags, reason); | 986 set_current_gc_flags(gc_flags); |
| 987 set_current_gc_callback_flags(gc_callback_flags); |
| 988 incremental_marking()->Start(reason); |
986 } | 989 } |
987 | 990 |
988 | 991 |
989 void Heap::StartIdleIncrementalMarking() { | 992 void Heap::StartIdleIncrementalMarking() { |
990 gc_idle_time_handler_.ResetNoProgressCounter(); | 993 gc_idle_time_handler_.ResetNoProgressCounter(); |
991 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags, | 994 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags, |
992 "idle"); | 995 "idle"); |
993 } | 996 } |
994 | 997 |
995 | 998 |
(...skipping 5780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6776 *object_type = "CODE_TYPE"; \ | 6779 *object_type = "CODE_TYPE"; \ |
6777 *object_sub_type = "CODE_AGE/" #name; \ | 6780 *object_sub_type = "CODE_AGE/" #name; \ |
6778 return true; | 6781 return true; |
6779 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6782 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6780 #undef COMPARE_AND_RETURN_NAME | 6783 #undef COMPARE_AND_RETURN_NAME |
6781 } | 6784 } |
6782 return false; | 6785 return false; |
6783 } | 6786 } |
6784 } // namespace internal | 6787 } // namespace internal |
6785 } // namespace v8 | 6788 } // namespace v8 |
OLD | NEW |