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

Side by Side Diff: vm/heap.cc

Issue 10797021: - Start using the collected store buffer entries to find (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/hash_set.h ('k') | vm/isolate.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 54
55 uword Heap::AllocateNew(intptr_t size) { 55 uword Heap::AllocateNew(intptr_t size) {
56 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 56 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
57 uword addr = new_space_->TryAllocate(size); 57 uword addr = new_space_->TryAllocate(size);
58 if (addr != 0) { 58 if (addr != 0) {
59 return addr; 59 return addr;
60 } 60 }
61 CollectGarbage(kNew); 61 CollectGarbage(kNew);
62 if (FLAG_verbose_gc) {
63 PrintSizes();
64 }
65 addr = new_space_->TryAllocate(size); 62 addr = new_space_->TryAllocate(size);
66 if (addr != 0) { 63 if (addr != 0) {
67 return addr; 64 return addr;
68 } 65 }
69 return AllocateOld(size); 66 return AllocateOld(size);
70 } 67 }
71 68
72 69
73 uword Heap::AllocateOld(intptr_t size) { 70 uword Heap::AllocateOld(intptr_t size) {
74 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 71 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
75 uword addr = old_space_->TryAllocate(size); 72 uword addr = old_space_->TryAllocate(size);
76 if (addr == 0) { 73 if (addr == 0) {
77 CollectAllGarbage(); 74 CollectAllGarbage();
78 if (FLAG_verbose_gc) {
79 PrintSizes();
80 }
81 addr = old_space_->TryAllocate(size, PageSpace::kForceGrowth); 75 addr = old_space_->TryAllocate(size, PageSpace::kForceGrowth);
82 if (addr == 0) { 76 if (addr == 0) {
83 OS::PrintErr("Exhausted heap space, trying to allocate %d bytes.\n", 77 OS::PrintErr("Exhausted heap space, trying to allocate %d bytes.\n",
84 size); 78 size);
85 } 79 }
86 } 80 }
87 return addr; 81 return addr;
88 } 82 }
89 83
90 84
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 case kOld: 176 case kOld:
183 old_space_->MarkSweep(invoke_api_callbacks); 177 old_space_->MarkSweep(invoke_api_callbacks);
184 break; 178 break;
185 case kCode: 179 case kCode:
186 UNIMPLEMENTED(); 180 UNIMPLEMENTED();
187 code_space_->MarkSweep(invoke_api_callbacks); 181 code_space_->MarkSweep(invoke_api_callbacks);
188 break; 182 break;
189 default: 183 default:
190 UNREACHABLE(); 184 UNREACHABLE();
191 } 185 }
186 if (FLAG_verbose_gc) {
187 PrintSizes();
188 }
192 } 189 }
193 190
194 191
195 void Heap::CollectGarbage(Space space) { 192 void Heap::CollectGarbage(Space space) {
196 ApiCallbacks api_callbacks; 193 ApiCallbacks api_callbacks;
197 if (space == kOld) { 194 if (space == kOld) {
198 api_callbacks = kInvokeApiCallbacks; 195 api_callbacks = kInvokeApiCallbacks;
199 } else { 196 } else {
200 api_callbacks = kIgnoreApiCallbacks; 197 api_callbacks = kIgnoreApiCallbacks;
201 } 198 }
202 CollectGarbage(space, api_callbacks); 199 CollectGarbage(space, api_callbacks);
203 } 200 }
204 201
205 202
206 void Heap::CollectAllGarbage() { 203 void Heap::CollectAllGarbage() {
207 new_space_->Scavenge(kInvokeApiCallbacks); 204 new_space_->Scavenge(kInvokeApiCallbacks);
208 old_space_->MarkSweep(kInvokeApiCallbacks); 205 old_space_->MarkSweep(kInvokeApiCallbacks);
209 // TODO(iposva): Merge old and code space. 206 // TODO(iposva): Merge old and code space.
210 // code_space_->MarkSweep(kInvokeApiCallbacks); 207 // code_space_->MarkSweep(kInvokeApiCallbacks);
208 if (FLAG_verbose_gc) {
209 PrintSizes();
210 }
211 } 211 }
212 212
213 213
214 void Heap::EnableGrowthControl() { 214 void Heap::EnableGrowthControl() {
215 old_space_->EnableGrowthControl(); 215 old_space_->EnableGrowthControl();
216 } 216 }
217 217
218 218
219 uword Heap::TopAddress() { 219 uword Heap::TopAddress() {
220 return reinterpret_cast<uword>(new_space_->TopAddress()); 220 return reinterpret_cast<uword>(new_space_->TopAddress());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 isolate()->IncrementNoGCScopeDepth(); 319 isolate()->IncrementNoGCScopeDepth();
320 } 320 }
321 321
322 322
323 NoGCScope::~NoGCScope() { 323 NoGCScope::~NoGCScope() {
324 isolate()->DecrementNoGCScopeDepth(); 324 isolate()->DecrementNoGCScopeDepth();
325 } 325 }
326 #endif // defined(DEBUG) 326 #endif // defined(DEBUG)
327 327
328 } // namespace dart 328 } // namespace dart
OLDNEW
« no previous file with comments | « vm/hash_set.h ('k') | vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698