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

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

Issue 1404523002: [heap] inline allocation steps refactor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: work-around the requirements that set_limit needs to be aligned Created 5 years, 1 month 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') | src/heap/incremental-marking.h » ('j') | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 namespace v8 { 45 namespace v8 {
46 namespace internal { 46 namespace internal {
47 47
48 48
49 struct Heap::StrongRootsList { 49 struct Heap::StrongRootsList {
50 Object** start; 50 Object** start;
51 Object** end; 51 Object** end;
52 StrongRootsList* next; 52 StrongRootsList* next;
53 }; 53 };
54 54
55 class IdleScavengeObserver : public InlineAllocationObserver {
56 public:
57 IdleScavengeObserver(Heap& heap, intptr_t step_size)
58 : InlineAllocationObserver(step_size), heap_(heap) {}
59
60 virtual void Step(int bytes_allocated) {
61 heap_.ScheduleIdleScavengeIfNeeded(bytes_allocated);
62 }
63
64 private:
65 Heap& heap_;
66 };
67
55 68
56 Heap::Heap() 69 Heap::Heap()
57 : amount_of_external_allocated_memory_(0), 70 : amount_of_external_allocated_memory_(0),
58 amount_of_external_allocated_memory_at_last_global_gc_(0), 71 amount_of_external_allocated_memory_at_last_global_gc_(0),
59 isolate_(NULL), 72 isolate_(NULL),
60 code_range_size_(0), 73 code_range_size_(0),
61 // semispace_size_ should be a power of 2 and old_generation_size_ should 74 // semispace_size_ should be a power of 2 and old_generation_size_ should
62 // be a multiple of Page::kPageSize. 75 // be a multiple of Page::kPageSize.
63 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), 76 reserved_semispace_size_(8 * (kPointerSize / 4) * MB),
64 max_semi_space_size_(8 * (kPointerSize / 4) * MB), 77 max_semi_space_size_(8 * (kPointerSize / 4) * MB),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 last_idle_notification_time_(0.0), 135 last_idle_notification_time_(0.0),
123 last_gc_time_(0.0), 136 last_gc_time_(0.0),
124 scavenge_collector_(nullptr), 137 scavenge_collector_(nullptr),
125 mark_compact_collector_(nullptr), 138 mark_compact_collector_(nullptr),
126 store_buffer_(this), 139 store_buffer_(this),
127 incremental_marking_(nullptr), 140 incremental_marking_(nullptr),
128 gc_idle_time_handler_(nullptr), 141 gc_idle_time_handler_(nullptr),
129 memory_reducer_(nullptr), 142 memory_reducer_(nullptr),
130 object_stats_(nullptr), 143 object_stats_(nullptr),
131 scavenge_job_(nullptr), 144 scavenge_job_(nullptr),
145 idle_scavenge_observer_(nullptr),
132 full_codegen_bytes_generated_(0), 146 full_codegen_bytes_generated_(0),
133 crankshaft_codegen_bytes_generated_(0), 147 crankshaft_codegen_bytes_generated_(0),
134 new_space_allocation_counter_(0), 148 new_space_allocation_counter_(0),
135 old_generation_allocation_counter_(0), 149 old_generation_allocation_counter_(0),
136 old_generation_size_at_last_gc_(0), 150 old_generation_size_at_last_gc_(0),
137 gcs_since_last_deopt_(0), 151 gcs_since_last_deopt_(0),
138 allocation_sites_scratchpad_length_(0), 152 allocation_sites_scratchpad_length_(0),
139 ring_buffer_full_(false), 153 ring_buffer_full_(false),
140 ring_buffer_end_(0), 154 ring_buffer_end_(0),
141 promotion_queue_(this), 155 promotion_queue_(this),
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 incremental_marking()->UpdateMarkingDequeAfterScavenge(); 1726 incremental_marking()->UpdateMarkingDequeAfterScavenge();
1713 1727
1714 ScavengeWeakObjectRetainer weak_object_retainer(this); 1728 ScavengeWeakObjectRetainer weak_object_retainer(this);
1715 ProcessYoungWeakReferences(&weak_object_retainer); 1729 ProcessYoungWeakReferences(&weak_object_retainer);
1716 1730
1717 DCHECK(new_space_front == new_space_.top()); 1731 DCHECK(new_space_front == new_space_.top());
1718 1732
1719 // Set age mark. 1733 // Set age mark.
1720 new_space_.set_age_mark(new_space_.top()); 1734 new_space_.set_age_mark(new_space_.top());
1721 1735
1722 new_space_.LowerInlineAllocationLimit( 1736 // We start a new step without accounting the objects copied into to space
1723 new_space_.inline_allocation_limit_step()); 1737 // as those are not allocations.
1738 new_space_.UpdateInlineAllocationLimitStep();
1724 1739
1725 array_buffer_tracker()->FreeDead(true); 1740 array_buffer_tracker()->FreeDead(true);
1726 1741
1727 // Update how much has survived scavenge. 1742 // Update how much has survived scavenge.
1728 IncrementYoungSurvivorsCounter(static_cast<int>( 1743 IncrementYoungSurvivorsCounter(static_cast<int>(
1729 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); 1744 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size()));
1730 1745
1731 LOG(isolate_, ResourceEvent("scavenge", "end")); 1746 LOG(isolate_, ResourceEvent("scavenge", "end"));
1732 1747
1733 gc_state_ = NOT_IN_GC; 1748 gc_state_ = NOT_IN_GC;
(...skipping 3296 matching lines...) Expand 10 before | Expand all | Expand 10 after
5030 5045
5031 // Update inline allocation limit for old spaces. 5046 // Update inline allocation limit for old spaces.
5032 PagedSpaces spaces(this); 5047 PagedSpaces spaces(this);
5033 for (PagedSpace* space = spaces.next(); space != NULL; 5048 for (PagedSpace* space = spaces.next(); space != NULL;
5034 space = spaces.next()) { 5049 space = spaces.next()) {
5035 space->EmptyAllocationInfo(); 5050 space->EmptyAllocationInfo();
5036 } 5051 }
5037 } 5052 }
5038 5053
5039 5054
5040 void Heap::LowerInlineAllocationLimit(intptr_t step) {
5041 new_space()->LowerInlineAllocationLimit(step);
5042 }
5043
5044
5045 void Heap::ResetInlineAllocationLimit() {
5046 new_space()->LowerInlineAllocationLimit(
5047 ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
5048 }
5049
5050
5051 V8_DECLARE_ONCE(initialize_gc_once); 5055 V8_DECLARE_ONCE(initialize_gc_once);
5052 5056
5053 static void InitializeGCOnce() { 5057 static void InitializeGCOnce() {
5054 Scavenger::Initialize(); 5058 Scavenger::Initialize();
5055 StaticScavengeVisitor::Initialize(); 5059 StaticScavengeVisitor::Initialize();
5056 MarkCompactCollector::Initialize(); 5060 MarkCompactCollector::Initialize();
5057 } 5061 }
5058 5062
5059 5063
5060 bool Heap::SetUp() { 5064 bool Heap::SetUp() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
5149 5153
5150 array_buffer_tracker_ = new ArrayBufferTracker(this); 5154 array_buffer_tracker_ = new ArrayBufferTracker(this);
5151 5155
5152 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5156 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5153 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5157 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5154 5158
5155 store_buffer()->SetUp(); 5159 store_buffer()->SetUp();
5156 5160
5157 mark_compact_collector()->SetUp(); 5161 mark_compact_collector()->SetUp();
5158 5162
5159 ResetInlineAllocationLimit(); 5163 idle_scavenge_observer_ = new IdleScavengeObserver(
5164 *this, ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
5165 new_space()->AddInlineAllocationObserver(idle_scavenge_observer_);
5160 5166
5161 return true; 5167 return true;
5162 } 5168 }
5163 5169
5164 5170
5165 bool Heap::CreateHeapObjects() { 5171 bool Heap::CreateHeapObjects() {
5166 // Create initial maps. 5172 // Create initial maps.
5167 if (!CreateInitialMaps()) return false; 5173 if (!CreateInitialMaps()) return false;
5168 CreateApiObjects(); 5174 CreateApiObjects();
5169 5175
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5248 map_space_->MaximumCommittedMemory()); 5254 map_space_->MaximumCommittedMemory());
5249 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", 5255 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
5250 lo_space_->MaximumCommittedMemory()); 5256 lo_space_->MaximumCommittedMemory());
5251 PrintF("\n\n"); 5257 PrintF("\n\n");
5252 } 5258 }
5253 5259
5254 if (FLAG_verify_predictable) { 5260 if (FLAG_verify_predictable) {
5255 PrintAlloctionsHash(); 5261 PrintAlloctionsHash();
5256 } 5262 }
5257 5263
5264 new_space()->RemoveInlineAllocationObserver(idle_scavenge_observer_);
5265 delete idle_scavenge_observer_;
5266 idle_scavenge_observer_ = nullptr;
5267
5258 delete scavenge_collector_; 5268 delete scavenge_collector_;
5259 scavenge_collector_ = nullptr; 5269 scavenge_collector_ = nullptr;
5260 5270
5261 if (mark_compact_collector_ != nullptr) { 5271 if (mark_compact_collector_ != nullptr) {
5262 mark_compact_collector_->TearDown(); 5272 mark_compact_collector_->TearDown();
5263 delete mark_compact_collector_; 5273 delete mark_compact_collector_;
5264 mark_compact_collector_ = nullptr; 5274 mark_compact_collector_ = nullptr;
5265 } 5275 }
5266 5276
5267 delete incremental_marking_; 5277 delete incremental_marking_;
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
6186 } 6196 }
6187 6197
6188 6198
6189 // static 6199 // static
6190 int Heap::GetStaticVisitorIdForMap(Map* map) { 6200 int Heap::GetStaticVisitorIdForMap(Map* map) {
6191 return StaticVisitorBase::GetVisitorId(map); 6201 return StaticVisitorBase::GetVisitorId(map);
6192 } 6202 }
6193 6203
6194 } // namespace internal 6204 } // namespace internal
6195 } // namespace v8 6205 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698