Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { |
|
cshapiro
2011/12/19 17:44:48
Lines 77-82 are a copy of lines 58-63. Maybe it i
Ivan Posva
2011/12/19 19:24:23
I am planning to pull the GC stats gathering out i
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |