| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 // Protect access to the heap. | 157 // Protect access to the heap. |
| 158 void WriteProtect(bool read_only); | 158 void WriteProtect(bool read_only); |
| 159 | 159 |
| 160 // Accessors for inlined allocation in generated code. | 160 // Accessors for inlined allocation in generated code. |
| 161 uword TopAddress(); | 161 uword TopAddress(); |
| 162 uword EndAddress(); | 162 uword EndAddress(); |
| 163 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } | 163 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } |
| 164 | 164 |
| 165 // Initialize the heap and register it with the isolate. | 165 // Initialize the heap and register it with the isolate. |
| 166 static void Init(Isolate* isolate); | 166 static void Init(Isolate* isolate, |
| 167 intptr_t max_new_gen_words, |
| 168 intptr_t max_old_gen_words); |
| 167 | 169 |
| 168 // Verify that all pointers in the heap point to the heap. | 170 // Verify that all pointers in the heap point to the heap. |
| 169 bool Verify() const; | 171 bool Verify() const; |
| 170 | 172 |
| 171 // Print heap sizes. | 173 // Print heap sizes. |
| 172 void PrintSizes() const; | 174 void PrintSizes() const; |
| 173 | 175 |
| 174 // Return amount of memory used and capacity in a space, excluding external. | 176 // Return amount of memory used and capacity in a space, excluding external. |
| 175 intptr_t UsedInWords(Space space) const; | 177 intptr_t UsedInWords(Space space) const; |
| 176 intptr_t CapacityInWords(Space space) const; | 178 intptr_t CapacityInWords(Space space) const; |
| 177 intptr_t ExternalInWords(Space space) const; | 179 intptr_t ExternalInWords(Space space) const; |
| 178 // Return the amount of GCing in microseconds. | 180 // Return the amount of GCing in microseconds. |
| 179 int64_t GCTimeInMicros(Space space) const; | 181 int64_t GCTimeInMicros(Space space) const; |
| 180 | 182 |
| 181 intptr_t Collections(Space space) const; | 183 intptr_t Collections(Space space) const; |
| 182 // Returns the [lowest, highest) addresses in the heap. | |
| 183 void StartEndAddress(uword* start, uword* end) const; | |
| 184 | 184 |
| 185 ObjectSet* CreateAllocatedObjectSet() const; | 185 ObjectSet* CreateAllocatedObjectSet() const; |
| 186 | 186 |
| 187 static const char* GCReasonToString(GCReason gc_reason); | 187 static const char* GCReasonToString(GCReason gc_reason); |
| 188 | 188 |
| 189 // Associate a peer with an object. A non-existent peer is equal to NULL. | 189 // Associate a peer with an object. A non-existent peer is equal to NULL. |
| 190 void SetPeer(RawObject* raw_obj, void* peer) { | 190 void SetPeer(RawObject* raw_obj, void* peer) { |
| 191 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); | 191 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); |
| 192 } | 192 } |
| 193 void* GetPeer(RawObject* raw_obj) const { | 193 void* GetPeer(RawObject* raw_obj) const { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 Data after_; | 275 Data after_; |
| 276 int64_t times_[kDataEntries]; | 276 int64_t times_[kDataEntries]; |
| 277 intptr_t data_[kDataEntries]; | 277 intptr_t data_[kDataEntries]; |
| 278 | 278 |
| 279 private: | 279 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(GCStats); | 280 DISALLOW_COPY_AND_ASSIGN(GCStats); |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 static const intptr_t kNewAllocatableSize = 256 * KB; | 283 static const intptr_t kNewAllocatableSize = 256 * KB; |
| 284 | 284 |
| 285 Heap(); | 285 Heap(intptr_t max_new_gen_words, intptr_t max_old_gen_words); |
| 286 | 286 |
| 287 uword AllocateNew(intptr_t size); | 287 uword AllocateNew(intptr_t size); |
| 288 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 288 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
| 289 | 289 |
| 290 // GC stats collection. | 290 // GC stats collection. |
| 291 void RecordBeforeGC(Space space, GCReason reason); | 291 void RecordBeforeGC(Space space, GCReason reason); |
| 292 void RecordAfterGC(); | 292 void RecordAfterGC(); |
| 293 void PrintStats(); | 293 void PrintStats(); |
| 294 void UpdateClassHeapStatsBeforeGC(Heap::Space space); | 294 void UpdateClassHeapStatsBeforeGC(Heap::Space space); |
| 295 | 295 |
| 296 // If this heap is non-empty, updates start and end to the smallest range that |
| 297 // contains both the original [start, end) and the [lowest, highest) addresses |
| 298 // of this heap. |
| 299 void GetMergedAddressRange(uword* start, uword* end) const; |
| 300 |
| 296 // The different spaces used for allocation. | 301 // The different spaces used for allocation. |
| 297 Scavenger* new_space_; | 302 Scavenger* new_space_; |
| 298 PageSpace* old_space_; | 303 PageSpace* old_space_; |
| 299 | 304 |
| 300 WeakTable* new_weak_tables_[kNumWeakSelectors]; | 305 WeakTable* new_weak_tables_[kNumWeakSelectors]; |
| 301 WeakTable* old_weak_tables_[kNumWeakSelectors]; | 306 WeakTable* old_weak_tables_[kNumWeakSelectors]; |
| 302 | 307 |
| 303 // GC stats collection. | 308 // GC stats collection. |
| 304 GCStats stats_; | 309 GCStats stats_; |
| 305 | 310 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 NoHeapGrowthControlScope(); | 342 NoHeapGrowthControlScope(); |
| 338 ~NoHeapGrowthControlScope(); | 343 ~NoHeapGrowthControlScope(); |
| 339 private: | 344 private: |
| 340 bool current_growth_controller_state_; | 345 bool current_growth_controller_state_; |
| 341 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 346 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 342 }; | 347 }; |
| 343 | 348 |
| 344 } // namespace dart | 349 } // namespace dart |
| 345 | 350 |
| 346 #endif // VM_HEAP_H_ | 351 #endif // VM_HEAP_H_ |
| OLD | NEW |