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

Side by Side Diff: runtime/vm/heap.cc

Issue 10442073: Implement growth policy for old space using time and space signals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/heap.h" 5 #include "vm/heap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/compiler_stats.h" 9 #include "vm/compiler_stats.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 uword Heap::AllocateOld(intptr_t size) { 70 uword Heap::AllocateOld(intptr_t size) {
71 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 71 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
72 uword addr = old_space_->TryAllocate(size); 72 uword addr = old_space_->TryAllocate(size);
73 if (addr == 0) { 73 if (addr == 0) {
74 CollectAllGarbage(); 74 CollectAllGarbage();
75 if (FLAG_verbose_gc) { 75 if (FLAG_verbose_gc) {
76 PrintSizes(); 76 PrintSizes();
77 } 77 }
78 addr = old_space_->TryAllocate(size); 78 addr = old_space_->TryAllocate(size);
79 if (addr == 0) { 79 if (addr == 0) {
80 // TODO(cshapiro): Support possible heap growth and OOM exception.
81 OS::PrintErr("Exhausted heap space, trying to allocate %d bytes.\n", 80 OS::PrintErr("Exhausted heap space, trying to allocate %d bytes.\n",
82 size); 81 size);
83 } 82 }
84 } 83 }
85 return addr; 84 return addr;
86 } 85 }
87 86
88 87
89 uword Heap::AllocateCode(PageSpace* space, intptr_t size) { 88 uword Heap::AllocateCode(PageSpace* space, intptr_t size) {
90 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 89 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 (raw_obj->ptr()->class_->ptr()->instance_kind_ == kInstructions)); 135 (raw_obj->ptr()->class_->ptr()->instance_kind_ == kInstructions));
137 return reinterpret_cast<RawInstructions*>(raw_obj); 136 return reinterpret_cast<RawInstructions*>(raw_obj);
138 } 137 }
139 138
140 139
141 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { 140 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) {
142 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); 141 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
143 switch (space) { 142 switch (space) {
144 case kNew: 143 case kNew:
145 new_space_->Scavenge(invoke_api_callbacks); 144 new_space_->Scavenge(invoke_api_callbacks);
145 if (new_space_->HadPromotionFailure()) {
146 old_space_->MarkSweep(true);
147 }
146 break; 148 break;
147 case kOld: 149 case kOld:
148 old_space_->MarkSweep(invoke_api_callbacks); 150 old_space_->MarkSweep(invoke_api_callbacks);
149 break; 151 break;
150 case kCode: 152 case kCode:
151 UNIMPLEMENTED(); 153 UNIMPLEMENTED();
152 code_space_->MarkSweep(invoke_api_callbacks); 154 code_space_->MarkSweep(invoke_api_callbacks);
153 break; 155 break;
154 default: 156 default:
155 UNREACHABLE(); 157 UNREACHABLE();
(...skipping 13 matching lines...) Expand all
169 171
170 172
171 void Heap::CollectAllGarbage() { 173 void Heap::CollectAllGarbage() {
172 new_space_->Scavenge(kInvokeApiCallbacks); 174 new_space_->Scavenge(kInvokeApiCallbacks);
173 old_space_->MarkSweep(kInvokeApiCallbacks); 175 old_space_->MarkSweep(kInvokeApiCallbacks);
174 // TODO(iposva): Merge old and code space. 176 // TODO(iposva): Merge old and code space.
175 // code_space_->MarkSweep(kInvokeApiCallbacks); 177 // code_space_->MarkSweep(kInvokeApiCallbacks);
176 } 178 }
177 179
178 180
181 void Heap::EnableGrowthControl() {
182 old_space_->EnableGrowthControl();
183 }
184
185
179 uword Heap::TopAddress() { 186 uword Heap::TopAddress() {
180 return reinterpret_cast<uword>(new_space_->TopAddress()); 187 return reinterpret_cast<uword>(new_space_->TopAddress());
181 } 188 }
182 189
183 190
184 uword Heap::EndAddress() { 191 uword Heap::EndAddress() {
185 return reinterpret_cast<uword>(new_space_->EndAddress()); 192 return reinterpret_cast<uword>(new_space_->EndAddress());
186 } 193 }
187 194
188 195
(...skipping 29 matching lines...) Expand all
218 isolate()->IncrementNoGCScopeDepth(); 225 isolate()->IncrementNoGCScopeDepth();
219 } 226 }
220 227
221 228
222 NoGCScope::~NoGCScope() { 229 NoGCScope::~NoGCScope() {
223 isolate()->DecrementNoGCScopeDepth(); 230 isolate()->DecrementNoGCScopeDepth();
224 } 231 }
225 #endif // defined(DEBUG) 232 #endif // defined(DEBUG)
226 233
227 } // namespace dart 234 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698