| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 // Verify that all pointers in the heap point to the heap. | 159 // Verify that all pointers in the heap point to the heap. |
| 160 bool Verify() const; | 160 bool Verify() const; |
| 161 | 161 |
| 162 // Print heap sizes. | 162 // Print heap sizes. |
| 163 void PrintSizes() const; | 163 void PrintSizes() const; |
| 164 | 164 |
| 165 // Return amount of memory used and capacity in a space. | 165 // Return amount of memory used and capacity in a space. |
| 166 intptr_t UsedInWords(Space space) const; | 166 intptr_t UsedInWords(Space space) const; |
| 167 intptr_t CapacityInWords(Space space) const; | 167 intptr_t CapacityInWords(Space space) const; |
| 168 // Return the amount of GCing in microseconds. |
| 169 int64_t GCTimeInMicros(Space space) const; |
| 168 | 170 |
| 171 intptr_t Collections(Space space) const; |
| 169 // Returns the [lowest, highest) addresses in the heap. | 172 // Returns the [lowest, highest) addresses in the heap. |
| 170 void StartEndAddress(uword* start, uword* end) const; | 173 void StartEndAddress(uword* start, uword* end) const; |
| 171 | 174 |
| 172 ObjectSet* CreateAllocatedObjectSet() const; | 175 ObjectSet* CreateAllocatedObjectSet() const; |
| 173 | 176 |
| 174 static const char* GCReasonToString(GCReason gc_reason); | 177 static const char* GCReasonToString(GCReason gc_reason); |
| 175 | 178 |
| 176 // Associate a peer with an object. A non-existent peer is equal to NULL. | 179 // Associate a peer with an object. A non-existent peer is equal to NULL. |
| 177 void SetPeer(RawObject* raw_obj, void* peer) { | 180 void SetPeer(RawObject* raw_obj, void* peer) { |
| 178 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); | 181 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); | 225 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); |
| 223 stats_.data_[id] = value; | 226 stats_.data_[id] = value; |
| 224 } | 227 } |
| 225 | 228 |
| 226 bool gc_in_progress() const { return gc_in_progress_; } | 229 bool gc_in_progress() const { return gc_in_progress_; } |
| 227 | 230 |
| 228 static bool IsAllocatableInNewSpace(intptr_t size) { | 231 static bool IsAllocatableInNewSpace(intptr_t size) { |
| 229 return size <= kNewAllocatableSize; | 232 return size <= kNewAllocatableSize; |
| 230 } | 233 } |
| 231 | 234 |
| 235 void PrintToJSONObject(Space space, JSONObject* object) const; |
| 236 |
| 232 private: | 237 private: |
| 233 class GCStats : public ValueObject { | 238 class GCStats : public ValueObject { |
| 234 public: | 239 public: |
| 235 GCStats() {} | 240 GCStats() {} |
| 236 intptr_t num_; | 241 intptr_t num_; |
| 237 Heap::Space space_; | 242 Heap::Space space_; |
| 238 Heap::GCReason reason_; | 243 Heap::GCReason reason_; |
| 239 | 244 |
| 240 class Data : public ValueObject { | 245 class Data : public ValueObject { |
| 241 public: | 246 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 267 Heap(); | 272 Heap(); |
| 268 | 273 |
| 269 uword AllocateNew(intptr_t size); | 274 uword AllocateNew(intptr_t size); |
| 270 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 275 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
| 271 | 276 |
| 272 // GC stats collection. | 277 // GC stats collection. |
| 273 void RecordBeforeGC(Space space, GCReason reason); | 278 void RecordBeforeGC(Space space, GCReason reason); |
| 274 void RecordAfterGC(); | 279 void RecordAfterGC(); |
| 275 void PrintStats(); | 280 void PrintStats(); |
| 276 void UpdateObjectHistogram(); | 281 void UpdateObjectHistogram(); |
| 282 void UpdateClassHeapStatsBeforeGC(Heap::Space space); |
| 277 | 283 |
| 278 // The different spaces used for allocation. | 284 // The different spaces used for allocation. |
| 279 Scavenger* new_space_; | 285 Scavenger* new_space_; |
| 280 PageSpace* old_space_; | 286 PageSpace* old_space_; |
| 281 | 287 |
| 282 WeakTable* new_weak_tables_[kNumWeakSelectors]; | 288 WeakTable* new_weak_tables_[kNumWeakSelectors]; |
| 283 WeakTable* old_weak_tables_[kNumWeakSelectors]; | 289 WeakTable* old_weak_tables_[kNumWeakSelectors]; |
| 284 | 290 |
| 285 // GC stats collection. | 291 // GC stats collection. |
| 286 GCStats stats_; | 292 GCStats stats_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 NoHeapGrowthControlScope(); | 325 NoHeapGrowthControlScope(); |
| 320 ~NoHeapGrowthControlScope(); | 326 ~NoHeapGrowthControlScope(); |
| 321 private: | 327 private: |
| 322 bool current_growth_controller_state_; | 328 bool current_growth_controller_state_; |
| 323 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 329 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 324 }; | 330 }; |
| 325 | 331 |
| 326 } // namespace dart | 332 } // namespace dart |
| 327 | 333 |
| 328 #endif // VM_HEAP_H_ | 334 #endif // VM_HEAP_H_ |
| OLD | NEW |