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 #ifndef RUNTIME_VM_HEAP_H_ | 5 #ifndef RUNTIME_VM_HEAP_H_ |
6 #define RUNTIME_VM_HEAP_H_ | 6 #define RUNTIME_VM_HEAP_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 enum GCReason { | 40 enum GCReason { |
41 kNewSpace, | 41 kNewSpace, |
42 kPromotion, | 42 kPromotion, |
43 kOldSpace, | 43 kOldSpace, |
44 kFull, | 44 kFull, |
45 kGCAtAlloc, | 45 kGCAtAlloc, |
46 kGCTestCase, | 46 kGCTestCase, |
47 }; | 47 }; |
48 | 48 |
49 #if defined(DEBUG) | |
50 // Pattern for unused new space and swept old space. | 49 // Pattern for unused new space and swept old space. |
51 static const uint64_t kZap64Bits = 0xf3f3f3f3f3f3f3f3; | |
52 static const uint32_t kZap32Bits = 0xf3f3f3f3; | |
53 static const uint8_t kZapByte = 0xf3; | 50 static const uint8_t kZapByte = 0xf3; |
54 #endif // DEBUG | |
55 | 51 |
56 ~Heap(); | 52 ~Heap(); |
57 | 53 |
58 Scavenger* new_space() { return &new_space_; } | 54 Scavenger* new_space() { return &new_space_; } |
59 PageSpace* old_space() { return &old_space_; } | 55 PageSpace* old_space() { return &old_space_; } |
60 | 56 |
61 uword Allocate(intptr_t size, Space space) { | 57 uword Allocate(intptr_t size, Space space) { |
62 ASSERT(!read_only_); | 58 ASSERT(!read_only_); |
63 switch (space) { | 59 switch (space) { |
64 case kNew: | 60 case kNew: |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (space == kNew) { | 205 if (space == kNew) { |
210 new_weak_tables_[selector] = value; | 206 new_weak_tables_[selector] = value; |
211 } else { | 207 } else { |
212 ASSERT(space == kOld); | 208 ASSERT(space == kOld); |
213 old_weak_tables_[selector] = value; | 209 old_weak_tables_[selector] = value; |
214 } | 210 } |
215 } | 211 } |
216 | 212 |
217 // Stats collection. | 213 // Stats collection. |
218 void RecordTime(int id, int64_t micros) { | 214 void RecordTime(int id, int64_t micros) { |
219 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); | 215 ASSERT((id >= 0) && (id < GCStats::kTimeEntries)); |
220 stats_.times_[id] = micros; | 216 stats_.times_[id] = micros; |
221 } | 217 } |
222 | 218 |
223 void RecordData(int id, intptr_t value) { | 219 void RecordData(int id, intptr_t value) { |
224 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); | 220 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); |
225 stats_.data_[id] = value; | 221 stats_.data_[id] = value; |
226 } | 222 } |
227 | 223 |
228 void UpdateGlobalMaxUsed(); | 224 void UpdateGlobalMaxUsed(); |
229 | 225 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 public: | 257 public: |
262 Data() {} | 258 Data() {} |
263 int64_t micros_; | 259 int64_t micros_; |
264 SpaceUsage new_; | 260 SpaceUsage new_; |
265 SpaceUsage old_; | 261 SpaceUsage old_; |
266 | 262 |
267 private: | 263 private: |
268 DISALLOW_COPY_AND_ASSIGN(Data); | 264 DISALLOW_COPY_AND_ASSIGN(Data); |
269 }; | 265 }; |
270 | 266 |
| 267 enum { kTimeEntries = 6 }; |
271 enum { kDataEntries = 4 }; | 268 enum { kDataEntries = 4 }; |
272 | 269 |
273 Data before_; | 270 Data before_; |
274 Data after_; | 271 Data after_; |
275 int64_t times_[kDataEntries]; | 272 int64_t times_[kTimeEntries]; |
276 intptr_t data_[kDataEntries]; | 273 intptr_t data_[kDataEntries]; |
277 | 274 |
278 private: | 275 private: |
279 DISALLOW_COPY_AND_ASSIGN(GCStats); | 276 DISALLOW_COPY_AND_ASSIGN(GCStats); |
280 }; | 277 }; |
281 | 278 |
282 static const intptr_t kNewAllocatableSize = 256 * KB; | 279 static const intptr_t kNewAllocatableSize = 256 * KB; |
283 | 280 |
284 Heap(Isolate* isolate, | 281 Heap(Isolate* isolate, |
285 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. | 282 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Note: During this scope, the code pages are non-executable. | 387 // Note: During this scope, the code pages are non-executable. |
391 class WritableVMIsolateScope : StackResource { | 388 class WritableVMIsolateScope : StackResource { |
392 public: | 389 public: |
393 explicit WritableVMIsolateScope(Thread* thread); | 390 explicit WritableVMIsolateScope(Thread* thread); |
394 ~WritableVMIsolateScope(); | 391 ~WritableVMIsolateScope(); |
395 }; | 392 }; |
396 | 393 |
397 } // namespace dart | 394 } // namespace dart |
398 | 395 |
399 #endif // RUNTIME_VM_HEAP_H_ | 396 #endif // RUNTIME_VM_HEAP_H_ |
OLD | NEW |