Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Side by Side Diff: src/heap/heap.cc

Issue 1288913003: [heap] Hide MemoryReducer inside the heap component. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-gc-tracer
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 total_gc_time_ms_(0.0), 113 total_gc_time_ms_(0.0),
114 max_alive_after_gc_(0), 114 max_alive_after_gc_(0),
115 min_in_mutator_(kMaxInt), 115 min_in_mutator_(kMaxInt),
116 marking_time_(0.0), 116 marking_time_(0.0),
117 sweeping_time_(0.0), 117 sweeping_time_(0.0),
118 last_idle_notification_time_(0.0), 118 last_idle_notification_time_(0.0),
119 last_gc_time_(0.0), 119 last_gc_time_(0.0),
120 mark_compact_collector_(this), 120 mark_compact_collector_(this),
121 store_buffer_(this), 121 store_buffer_(this),
122 incremental_marking_(this), 122 incremental_marking_(this),
123 memory_reducer_(this), 123 memory_reducer_(nullptr),
124 full_codegen_bytes_generated_(0), 124 full_codegen_bytes_generated_(0),
125 crankshaft_codegen_bytes_generated_(0), 125 crankshaft_codegen_bytes_generated_(0),
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),
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 event.time_ms = MonotonicallyIncreasingTimeInMs(); 932 event.time_ms = MonotonicallyIncreasingTimeInMs();
933 // Trigger one more GC if 933 // Trigger one more GC if
934 // - this GC decreased committed memory, 934 // - this GC decreased committed memory,
935 // - there is high fragmentation, 935 // - there is high fragmentation,
936 // - there are live detached contexts. 936 // - there are live detached contexts.
937 event.next_gc_likely_to_collect_more = 937 event.next_gc_likely_to_collect_more =
938 (committed_memory_before - committed_memory_after) > MB || 938 (committed_memory_before - committed_memory_after) > MB ||
939 HasHighFragmentation(used_memory_after, committed_memory_after) || 939 HasHighFragmentation(used_memory_after, committed_memory_after) ||
940 (detached_contexts()->length() > 0); 940 (detached_contexts()->length() > 0);
941 if (deserialization_complete_) { 941 if (deserialization_complete_) {
942 memory_reducer_.NotifyMarkCompact(event); 942 memory_reducer_->NotifyMarkCompact(event);
943 } 943 }
944 } 944 }
945 945
946 tracer()->Stop(collector); 946 tracer()->Stop(collector);
947 } 947 }
948 948
949 if (collector == MARK_COMPACTOR && 949 if (collector == MARK_COMPACTOR &&
950 (gc_callback_flags & kGCCallbackFlagForced) != 0) { 950 (gc_callback_flags & kGCCallbackFlagForced) != 0) {
951 isolate()->CountUsage(v8::Isolate::kForcedGC); 951 isolate()->CountUsage(v8::Isolate::kForcedGC);
952 } 952 }
(...skipping 18 matching lines...) Expand all
971 if (isolate()->concurrent_recompilation_enabled()) { 971 if (isolate()->concurrent_recompilation_enabled()) {
972 // Flush the queued recompilation tasks. 972 // Flush the queued recompilation tasks.
973 isolate()->optimizing_compile_dispatcher()->Flush(); 973 isolate()->optimizing_compile_dispatcher()->Flush();
974 } 974 }
975 AgeInlineCaches(); 975 AgeInlineCaches();
976 set_retained_maps(ArrayList::cast(empty_fixed_array())); 976 set_retained_maps(ArrayList::cast(empty_fixed_array()));
977 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis()); 977 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis());
978 MemoryReducer::Event event; 978 MemoryReducer::Event event;
979 event.type = MemoryReducer::kContextDisposed; 979 event.type = MemoryReducer::kContextDisposed;
980 event.time_ms = MonotonicallyIncreasingTimeInMs(); 980 event.time_ms = MonotonicallyIncreasingTimeInMs();
981 memory_reducer_.NotifyContextDisposed(event); 981 memory_reducer_->NotifyContextDisposed(event);
982 return ++contexts_disposed_; 982 return ++contexts_disposed_;
983 } 983 }
984 984
985 985
986 void Heap::StartIncrementalMarking(int gc_flags, 986 void Heap::StartIncrementalMarking(int gc_flags,
987 const GCCallbackFlags gc_callback_flags, 987 const GCCallbackFlags gc_callback_flags,
988 const char* reason) { 988 const char* reason) {
989 DCHECK(incremental_marking()->IsStopped()); 989 DCHECK(incremental_marking()->IsStopped());
990 incremental_marking()->Start(gc_flags, gc_callback_flags, reason); 990 incremental_marking()->Start(gc_flags, gc_callback_flags, reason);
991 } 991 }
(...skipping 3969 matching lines...) Expand 10 before | Expand all | Expand 10 after
4961 4961
4962 4962
4963 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms, 4963 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms,
4964 double now_ms) { 4964 double now_ms) {
4965 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { 4965 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) {
4966 MemoryReducer::Event event; 4966 MemoryReducer::Event event;
4967 event.type = MemoryReducer::kBackgroundIdleNotification; 4967 event.type = MemoryReducer::kBackgroundIdleNotification;
4968 event.time_ms = now_ms; 4968 event.time_ms = now_ms;
4969 event.can_start_incremental_gc = incremental_marking()->IsStopped() && 4969 event.can_start_incremental_gc = incremental_marking()->IsStopped() &&
4970 incremental_marking()->CanBeActivated(); 4970 incremental_marking()->CanBeActivated();
4971 memory_reducer_.NotifyBackgroundIdleNotification(event); 4971 memory_reducer_->NotifyBackgroundIdleNotification(event);
4972 optimize_for_memory_usage_ = true; 4972 optimize_for_memory_usage_ = true;
4973 } else { 4973 } else {
4974 optimize_for_memory_usage_ = false; 4974 optimize_for_memory_usage_ = false;
4975 } 4975 }
4976 } 4976 }
4977 4977
4978 4978
4979 double Heap::MonotonicallyIncreasingTimeInMs() { 4979 double Heap::MonotonicallyIncreasingTimeInMs() {
4980 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * 4980 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
4981 static_cast<double>(base::Time::kMillisecondsPerSecond); 4981 static_cast<double>(base::Time::kMillisecondsPerSecond);
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
5654 gc_speed, mutator_speed); 5654 gc_speed, mutator_speed);
5655 } 5655 }
5656 5656
5657 // We set the old generation growing factor to 2 to grow the heap slower on 5657 // We set the old generation growing factor to 2 to grow the heap slower on
5658 // memory-constrained devices. 5658 // memory-constrained devices.
5659 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || 5659 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice ||
5660 FLAG_optimize_for_size) { 5660 FLAG_optimize_for_size) {
5661 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); 5661 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
5662 } 5662 }
5663 5663
5664 if (memory_reducer_.ShouldGrowHeapSlowly() || optimize_for_memory_usage_) { 5664 if (memory_reducer_->ShouldGrowHeapSlowly() || optimize_for_memory_usage_) {
5665 factor = Min(factor, kConservativeHeapGrowingFactor); 5665 factor = Min(factor, kConservativeHeapGrowingFactor);
5666 } 5666 }
5667 5667
5668 if (FLAG_stress_compaction || 5668 if (FLAG_stress_compaction ||
5669 mark_compact_collector()->reduce_memory_footprint_) { 5669 mark_compact_collector()->reduce_memory_footprint_) {
5670 factor = kMinHeapGrowingFactor; 5670 factor = kMinHeapGrowingFactor;
5671 } 5671 }
5672 5672
5673 old_generation_allocation_limit_ = 5673 old_generation_allocation_limit_ =
5674 CalculateOldGenerationAllocationLimit(factor, old_gen_size); 5674 CalculateOldGenerationAllocationLimit(factor, old_gen_size);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5802 } 5802 }
5803 } 5803 }
5804 5804
5805 for (int i = 0; i < static_cast<int>(v8::Isolate::kUseCounterFeatureCount); 5805 for (int i = 0; i < static_cast<int>(v8::Isolate::kUseCounterFeatureCount);
5806 i++) { 5806 i++) {
5807 deferred_counters_[i] = 0; 5807 deferred_counters_[i] = 0;
5808 } 5808 }
5809 5809
5810 tracer_ = new GCTracer(this); 5810 tracer_ = new GCTracer(this);
5811 5811
5812 memory_reducer_ = new MemoryReducer(this);
5813
5812 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5814 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5813 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5815 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5814 5816
5815 store_buffer()->SetUp(); 5817 store_buffer()->SetUp();
5816 5818
5817 mark_compact_collector()->SetUp(); 5819 mark_compact_collector()->SetUp();
5818 5820
5819 return true; 5821 return true;
5820 } 5822 }
5821 5823
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5900 map_space_->MaximumCommittedMemory()); 5902 map_space_->MaximumCommittedMemory());
5901 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", 5903 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
5902 lo_space_->MaximumCommittedMemory()); 5904 lo_space_->MaximumCommittedMemory());
5903 PrintF("\n\n"); 5905 PrintF("\n\n");
5904 } 5906 }
5905 5907
5906 if (FLAG_verify_predictable) { 5908 if (FLAG_verify_predictable) {
5907 PrintAlloctionsHash(); 5909 PrintAlloctionsHash();
5908 } 5910 }
5909 5911
5910 memory_reducer_.TearDown(); 5912 if (memory_reducer_ != nullptr) {
5913 memory_reducer_->TearDown();
5914 delete memory_reducer_;
5915 memory_reducer_ = nullptr;
5916 }
5911 5917
5912 TearDownArrayBuffers(); 5918 TearDownArrayBuffers();
5913 5919
5914 isolate_->global_handles()->TearDown(); 5920 isolate_->global_handles()->TearDown();
5915 5921
5916 external_string_table_.TearDown(); 5922 external_string_table_.TearDown();
5917 5923
5918 mark_compact_collector()->TearDown(); 5924 mark_compact_collector()->TearDown();
5919 5925
5920 delete tracer_; 5926 delete tracer_;
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
6909 *object_type = "CODE_TYPE"; \ 6915 *object_type = "CODE_TYPE"; \
6910 *object_sub_type = "CODE_AGE/" #name; \ 6916 *object_sub_type = "CODE_AGE/" #name; \
6911 return true; 6917 return true;
6912 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6918 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6913 #undef COMPARE_AND_RETURN_NAME 6919 #undef COMPARE_AND_RETURN_NAME
6914 } 6920 }
6915 return false; 6921 return false;
6916 } 6922 }
6917 } // namespace internal 6923 } // namespace internal
6918 } // namespace v8 6924 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698