OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); | 29 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); |
30 DEFINE_FLAG(int, new_gen_heap_size, 32, "new gen heap size in MB," | 30 DEFINE_FLAG(int, new_gen_heap_size, 32, "new gen heap size in MB," |
31 "e.g: --new_gen_heap_size=64 allocates a 64MB new gen heap"); | 31 "e.g: --new_gen_heap_size=64 allocates a 64MB new gen heap"); |
32 DEFINE_FLAG(int, old_gen_heap_size, Heap::kHeapSizeInMB, | 32 DEFINE_FLAG(int, old_gen_heap_size, Heap::kHeapSizeInMB, |
33 "old gen heap size in MB," | 33 "old gen heap size in MB," |
34 "e.g: --old_gen_heap_size=1024 allocates a 1024MB old gen heap"); | 34 "e.g: --old_gen_heap_size=1024 allocates a 1024MB old gen heap"); |
35 DEFINE_FLAG(int, code_heap_size, Heap::kCodeHeapSizeInMB, | 35 DEFINE_FLAG(int, code_heap_size, Heap::kCodeHeapSizeInMB, |
36 "code heap size in MB," | 36 "code heap size in MB," |
37 "e.g: --code_heap_size=8 allocates a 8MB code heap"); | 37 "e.g: --code_heap_size=8 allocates a 8MB code heap"); |
38 | 38 |
39 Heap::Heap() { | 39 Heap::Heap() : read_only_(false) { |
40 new_space_ = new Scavenger(this, | 40 new_space_ = new Scavenger(this, |
41 (FLAG_new_gen_heap_size * MB), | 41 (FLAG_new_gen_heap_size * MB), |
42 kNewObjectAlignmentOffset); | 42 kNewObjectAlignmentOffset); |
43 old_space_ = new PageSpace(this, (FLAG_old_gen_heap_size * MB)); | 43 old_space_ = new PageSpace(this, (FLAG_old_gen_heap_size * MB)); |
44 code_space_ = new PageSpace(this, (FLAG_code_heap_size * MB), true); | 44 code_space_ = new PageSpace(this, (FLAG_code_heap_size * MB), true); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 Heap::~Heap() { | 48 Heap::~Heap() { |
49 delete new_space_; | 49 delete new_space_; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 PrintSizes(); | 219 PrintSizes(); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 void Heap::EnableGrowthControl() { | 224 void Heap::EnableGrowthControl() { |
225 old_space_->EnableGrowthControl(); | 225 old_space_->EnableGrowthControl(); |
226 } | 226 } |
227 | 227 |
228 | 228 |
| 229 void Heap::WriteProtect(bool read_only) { |
| 230 read_only_ = read_only; |
| 231 new_space_->WriteProtect(read_only); |
| 232 old_space_->WriteProtect(read_only); |
| 233 // TODO(iposva): Merge old and code space. |
| 234 // code_space_->WriteProtect(read_only); |
| 235 } |
| 236 |
| 237 |
229 uword Heap::TopAddress() { | 238 uword Heap::TopAddress() { |
230 return reinterpret_cast<uword>(new_space_->TopAddress()); | 239 return reinterpret_cast<uword>(new_space_->TopAddress()); |
231 } | 240 } |
232 | 241 |
233 | 242 |
234 uword Heap::EndAddress() { | 243 uword Heap::EndAddress() { |
235 return reinterpret_cast<uword>(new_space_->EndAddress()); | 244 return reinterpret_cast<uword>(new_space_->EndAddress()); |
236 } | 245 } |
237 | 246 |
238 | 247 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 isolate()->IncrementNoGCScopeDepth(); | 338 isolate()->IncrementNoGCScopeDepth(); |
330 } | 339 } |
331 | 340 |
332 | 341 |
333 NoGCScope::~NoGCScope() { | 342 NoGCScope::~NoGCScope() { |
334 isolate()->DecrementNoGCScopeDepth(); | 343 isolate()->DecrementNoGCScopeDepth(); |
335 } | 344 } |
336 #endif // defined(DEBUG) | 345 #endif // defined(DEBUG) |
337 | 346 |
338 } // namespace dart | 347 } // namespace dart |
OLD | NEW |