| 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" |
| 11 #include "vm/os.h" | 11 #include "vm/os.h" |
| 12 #include "vm/pages.h" | 12 #include "vm/pages.h" |
| 13 #include "vm/scavenger.h" | 13 #include "vm/scavenger.h" |
| 14 #include "vm/utils.h" | 14 #include "vm/utils.h" |
| 15 #include "vm/verifier.h" | 15 #include "vm/verifier.h" |
| 16 #include "vm/virtual_memory.h" | 16 #include "vm/virtual_memory.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); | 20 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); |
| 21 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); | 21 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); |
| 22 DEFINE_FLAG(int, new_gen_heap_size, 32, "new gen heap size in MB," |
| 23 "e.g: --new_gen_heap_size=64 allocates a 64MB new gen heap"); |
| 24 DEFINE_FLAG(int, old_gen_heap_size, Heap::kHeapSizeInMB, |
| 25 "old gen heap size in MB," |
| 26 "e.g: --old_gen_heap_size=1024 allocates a 1024MB old gen heap"); |
| 27 DEFINE_FLAG(int, code_heap_size, Heap::kCodeHeapSizeInMB, |
| 28 "code heap size in MB," |
| 29 "e.g: --code_heap_size=8 allocates a 8MB old gen heap"); |
| 22 | 30 |
| 23 Heap::Heap() { | 31 Heap::Heap() { |
| 24 new_space_ = new Scavenger(this, 32 * MB, kNewObjectAlignmentOffset); | 32 new_space_ = new Scavenger(this, |
| 25 old_space_ = new PageSpace(this, kHeapSize); | 33 (FLAG_new_gen_heap_size * MB), |
| 26 code_space_ = new PageSpace(this, kCodeHeapSize, true); | 34 kNewObjectAlignmentOffset); |
| 35 old_space_ = new PageSpace(this, (FLAG_old_gen_heap_size * MB)); |
| 36 code_space_ = new PageSpace(this, (FLAG_code_heap_size * MB), true); |
| 27 } | 37 } |
| 28 | 38 |
| 29 | 39 |
| 30 Heap::~Heap() { | 40 Heap::~Heap() { |
| 31 delete new_space_; | 41 delete new_space_; |
| 32 delete old_space_; | 42 delete old_space_; |
| 33 delete code_space_; | 43 delete code_space_; |
| 34 } | 44 } |
| 35 | 45 |
| 36 | 46 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 isolate_->IncrementNoGCScopeDepth(); | 141 isolate_->IncrementNoGCScopeDepth(); |
| 132 } | 142 } |
| 133 | 143 |
| 134 | 144 |
| 135 NoGCScope::~NoGCScope() { | 145 NoGCScope::~NoGCScope() { |
| 136 isolate_->DecrementNoGCScopeDepth(); | 146 isolate_->DecrementNoGCScopeDepth(); |
| 137 } | 147 } |
| 138 #endif // defined(DEBUG) | 148 #endif // defined(DEBUG) |
| 139 | 149 |
| 140 } // namespace dart | 150 } // namespace dart |
| OLD | NEW |