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

Side by Side Diff: vm/heap.cc

Issue 8996011: - Trigger old-gen GCs when needed. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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/heap.h ('k') | vm/heap_test.cc » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 7 #include "vm/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 delete code_space_; 47 delete code_space_;
48 } 48 }
49 49
50 50
51 uword Heap::AllocateNew(intptr_t size) { 51 uword Heap::AllocateNew(intptr_t size) {
52 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 52 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
53 uword addr = new_space_->TryAllocate(size); 53 uword addr = new_space_->TryAllocate(size);
54 if (addr != 0) { 54 if (addr != 0) {
55 return addr; 55 return addr;
56 } 56 }
57 new_space_->Scavenge(); 57 CollectGarbage(kNew);
58 if (FLAG_verbose_gc) { 58 if (FLAG_verbose_gc) {
59 OS::PrintErr("New space (%dk) Old space (%dk) Code space (%dk)\n", 59 OS::PrintErr("New space (%dk) Old space (%dk) Code space (%dk)\n",
60 (new_space_->in_use() / KB), 60 (new_space_->in_use() / KB),
61 (old_space_->in_use() / KB), 61 (old_space_->in_use() / KB),
62 (code_space_->in_use() / KB)); 62 (code_space_->in_use() / KB));
63 } 63 }
64 addr = new_space_->TryAllocate(size); 64 addr = new_space_->TryAllocate(size);
65 if (addr != 0) { 65 if (addr != 0) {
66 return addr; 66 return addr;
67 } 67 }
68 return AllocateOld(size); 68 return AllocateOld(size);
69 } 69 }
70 70
71 71
72 uword Heap::AllocateOld(intptr_t size) { 72 uword Heap::AllocateOld(intptr_t size) {
73 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 73 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
74 uword addr = old_space_->TryAllocate(size); 74 uword addr = old_space_->TryAllocate(size);
75 if (addr == 0) { 75 if (addr == 0) {
76 // TODO(iposva): Support GC. 76 CollectGarbage(kOld);
77 FATAL("Exhausted heap space."); 77 if (FLAG_verbose_gc) {
78 OS::PrintErr("New space (%dk) Old space (%dk) Code space (%dk)\n",
79 (new_space_->in_use() / KB),
80 (old_space_->in_use() / KB),
81 (code_space_->in_use() / KB));
82 }
83 addr = old_space_->TryAllocate(size);
78 } 84 }
79 return addr; 85 return addr;
80 } 86 }
81 87
82 88
83 uword Heap::AllocateCode(intptr_t size) { 89 uword Heap::AllocateCode(intptr_t size) {
84 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); 90 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0);
85 ASSERT(Utils::IsAligned(size, OS::PreferredCodeAlignment())); 91 ASSERT(Utils::IsAligned(size, OS::PreferredCodeAlignment()));
86 uword addr = code_space_->TryAllocate(size); 92 uword addr = code_space_->TryAllocate(size);
87 if (addr == 0) { 93 if (addr == 0) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 isolate()->IncrementNoGCScopeDepth(); 187 isolate()->IncrementNoGCScopeDepth();
182 } 188 }
183 189
184 190
185 NoGCScope::~NoGCScope() { 191 NoGCScope::~NoGCScope() {
186 isolate()->DecrementNoGCScopeDepth(); 192 isolate()->DecrementNoGCScopeDepth();
187 } 193 }
188 #endif // defined(DEBUG) 194 #endif // defined(DEBUG)
189 195
190 } // namespace dart 196 } // namespace dart
OLDNEW
« no previous file with comments | « vm/heap.h ('k') | vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698