| 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 VM_HEAP_H_ | 5 #ifndef VM_HEAP_H_ |
| 6 #define VM_HEAP_H_ | 6 #define 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 11 matching lines...) Expand all Loading... |
| 22 DECLARE_FLAG(bool, verbose_gc); | 22 DECLARE_FLAG(bool, verbose_gc); |
| 23 DECLARE_FLAG(bool, verify_before_gc); | 23 DECLARE_FLAG(bool, verify_before_gc); |
| 24 DECLARE_FLAG(bool, verify_after_gc); | 24 DECLARE_FLAG(bool, verify_after_gc); |
| 25 DECLARE_FLAG(bool, gc_at_alloc); | 25 DECLARE_FLAG(bool, gc_at_alloc); |
| 26 | 26 |
| 27 class Heap { | 27 class Heap { |
| 28 public: | 28 public: |
| 29 enum Space { | 29 enum Space { |
| 30 kNew, | 30 kNew, |
| 31 kOld, | 31 kOld, |
| 32 kDartCode, | 32 kCode, |
| 33 kStubCode, | |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 enum ApiCallbacks { | 35 enum ApiCallbacks { |
| 37 kIgnoreApiCallbacks, | 36 kIgnoreApiCallbacks, |
| 38 kInvokeApiCallbacks | 37 kInvokeApiCallbacks |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 // Default allocation sizes in MB for the old gen and code heaps. | 40 // Default allocation sizes in MB for the old gen and code heaps. |
| 42 static const intptr_t kHeapSizeInMB = 512; | 41 static const intptr_t kHeapSizeInMB = 512; |
| 43 static const intptr_t kCodeHeapSizeInMB = 8; | 42 static const intptr_t kCodeHeapSizeInMB = 8; |
| 44 static const intptr_t kStubCodeHeapSizeInKB = 256; | |
| 45 | 43 |
| 46 ~Heap(); | 44 ~Heap(); |
| 47 | 45 |
| 48 uword Allocate(intptr_t size, Space space) { | 46 uword Allocate(intptr_t size, Space space) { |
| 49 switch (space) { | 47 switch (space) { |
| 50 case kNew: | 48 case kNew: |
| 51 // Do not attempt to allocate very large objects in new space. | 49 // Do not attempt to allocate very large objects in new space. |
| 52 if (!PageSpace::IsPageAllocatableSize(size)) { | 50 if (!PageSpace::IsPageAllocatableSize(size)) { |
| 53 return AllocateOld(size); | 51 return AllocateOld(size); |
| 54 } | 52 } |
| 55 return AllocateNew(size); | 53 return AllocateNew(size); |
| 56 case kOld: | 54 case kOld: |
| 57 return AllocateOld(size); | 55 return AllocateOld(size); |
| 58 case kDartCode: | 56 case kCode: |
| 59 return AllocateCode(code_space_, size); | 57 return AllocateCode(code_space_, size); |
| 60 case kStubCode: | |
| 61 return AllocateCode(stub_code_space_, size); | |
| 62 default: | 58 default: |
| 63 UNREACHABLE(); | 59 UNREACHABLE(); |
| 64 } | 60 } |
| 65 return 0; | 61 return 0; |
| 66 } | 62 } |
| 67 | 63 |
| 68 uword TryAllocate(intptr_t size, Space space) { | 64 uword TryAllocate(intptr_t size, Space space) { |
| 69 switch (space) { | 65 switch (space) { |
| 70 case kNew: | 66 case kNew: |
| 71 return new_space_->TryAllocate(size); | 67 return new_space_->TryAllocate(size); |
| 72 case kOld: | 68 case kOld: |
| 73 return old_space_->TryAllocate(size); | 69 return old_space_->TryAllocate(size); |
| 74 case kDartCode: | 70 case kCode: |
| 75 return code_space_->TryAllocate(size); | 71 return code_space_->TryAllocate(size); |
| 76 case kStubCode: | |
| 77 return stub_code_space_->TryAllocate(size); | |
| 78 default: | 72 default: |
| 79 UNREACHABLE(); | 73 UNREACHABLE(); |
| 80 } | 74 } |
| 81 return 0; | 75 return 0; |
| 82 } | 76 } |
| 83 | 77 |
| 84 // Heap contains the specified address. | 78 // Heap contains the specified address. |
| 85 bool Contains(uword addr) const; | 79 bool Contains(uword addr) const; |
| 86 bool CodeContains(uword addr) const; | 80 bool CodeContains(uword addr) const; |
| 87 bool StubCodeContains(uword addr) const; | 81 bool StubCodeContains(uword addr) const; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 public: | 141 public: |
| 148 NoGCScope() {} | 142 NoGCScope() {} |
| 149 private: | 143 private: |
| 150 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 144 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 151 }; | 145 }; |
| 152 #endif // defined(DEBUG) | 146 #endif // defined(DEBUG) |
| 153 | 147 |
| 154 } // namespace dart | 148 } // namespace dart |
| 155 | 149 |
| 156 #endif // VM_HEAP_H_ | 150 #endif // VM_HEAP_H_ |
| OLD | NEW |