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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Move external size from new to old space. Does not by itself trigger GC. | 86 // Move external size from new to old space. Does not by itself trigger GC. |
87 void PromoteExternal(intptr_t size); | 87 void PromoteExternal(intptr_t size); |
88 | 88 |
89 // Heap contains the specified address. | 89 // Heap contains the specified address. |
90 bool Contains(uword addr) const; | 90 bool Contains(uword addr) const; |
91 bool NewContains(uword addr) const; | 91 bool NewContains(uword addr) const; |
92 bool OldContains(uword addr) const; | 92 bool OldContains(uword addr) const; |
93 bool CodeContains(uword addr) const; | 93 bool CodeContains(uword addr) const; |
94 bool DataContains(uword addr) const; | 94 bool DataContains(uword addr) const; |
95 | 95 |
96 void IterateObjects(ObjectVisitor* visitor) const; | |
97 void IterateOldObjects(ObjectVisitor* visitor) const; | |
98 void IterateOldObjectsNoImagePages(ObjectVisitor* visitor) const; | |
99 void IterateObjectPointers(ObjectVisitor* visitor) const; | |
100 | |
101 // Find an object by visiting all pointers in the specified heap space, | 96 // Find an object by visiting all pointers in the specified heap space, |
102 // the 'visitor' is used to determine if an object is found or not. | 97 // the 'visitor' is used to determine if an object is found or not. |
103 // The 'visitor' function should be set up to return true if the | 98 // The 'visitor' function should be set up to return true if the |
104 // object is found, traversal through the heap space stops at that | 99 // object is found, traversal through the heap space stops at that |
105 // point. | 100 // point. |
106 // The 'visitor' function should return false if the object is not found, | 101 // The 'visitor' function should return false if the object is not found, |
107 // traversal through the heap space continues. | 102 // traversal through the heap space continues. |
108 // Returns null object if nothing is found. | 103 // Returns null object if nothing is found. |
109 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; | 104 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; |
110 RawObject* FindOldObject(FindObjectVisitor* visitor) const; | 105 RawObject* FindOldObject(FindObjectVisitor* visitor) const; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // This heap is in read-only mode: No allocation is allowed. | 348 // This heap is in read-only mode: No allocation is allowed. |
354 bool read_only_; | 349 bool read_only_; |
355 | 350 |
356 // GC on the heap is in progress. | 351 // GC on the heap is in progress. |
357 Monitor gc_in_progress_monitor_; | 352 Monitor gc_in_progress_monitor_; |
358 bool gc_new_space_in_progress_; | 353 bool gc_new_space_in_progress_; |
359 bool gc_old_space_in_progress_; | 354 bool gc_old_space_in_progress_; |
360 | 355 |
361 friend class Become; // VisitObjectPointers | 356 friend class Become; // VisitObjectPointers |
362 friend class Precompiler; // VisitObjects | 357 friend class Precompiler; // VisitObjects |
363 friend class ObjectGraph; // VisitObjects | |
364 friend class Unmarker; // VisitObjects | 358 friend class Unmarker; // VisitObjects |
365 friend class ServiceEvent; | 359 friend class ServiceEvent; |
366 friend class PageSpace; // VerifyGC | 360 friend class PageSpace; // VerifyGC |
367 friend class IsolateReloadContext; // VisitObjects | 361 friend class IsolateReloadContext; // VisitObjects |
368 friend class ClassFinalizer; // VisitObjects | 362 friend class ClassFinalizer; // VisitObjects |
| 363 friend class HeapIterationScope; // VisitObjects |
369 | 364 |
370 DISALLOW_COPY_AND_ASSIGN(Heap); | 365 DISALLOW_COPY_AND_ASSIGN(Heap); |
371 }; | 366 }; |
372 | 367 |
373 class HeapIterationScope : public StackResource { | 368 class HeapIterationScope : public StackResource { |
374 public: | 369 public: |
375 explicit HeapIterationScope(bool writable = false); | 370 explicit HeapIterationScope(bool writable = false); |
376 ~HeapIterationScope(); | 371 ~HeapIterationScope(); |
377 | 372 |
| 373 void IterateObjects(ObjectVisitor* visitor) const; |
| 374 void IterateObjectsNoImagePages(ObjectVisitor* visitor) const; |
| 375 void IterateOldObjects(ObjectVisitor* visitor) const; |
| 376 void IterateOldObjectsNoImagePages(ObjectVisitor* visitor) const; |
| 377 |
| 378 void IterateVMIsolateObjects(ObjectVisitor* visitor) const; |
| 379 |
| 380 void IterateObjectPointers(ObjectPointerVisitor* visitor, |
| 381 bool validate_frames); |
| 382 void IterateStackPointers(ObjectPointerVisitor* visitor, |
| 383 bool validate_frames); |
| 384 |
378 private: | 385 private: |
379 NoSafepointScope no_safepoint_scope_; | 386 Heap* heap_; |
380 PageSpace* old_space_; | 387 PageSpace* old_space_; |
381 bool writable_; | 388 bool writable_; |
382 | 389 |
383 DISALLOW_COPY_AND_ASSIGN(HeapIterationScope); | 390 DISALLOW_COPY_AND_ASSIGN(HeapIterationScope); |
384 }; | 391 }; |
385 | 392 |
386 class NoHeapGrowthControlScope : public StackResource { | 393 class NoHeapGrowthControlScope : public StackResource { |
387 public: | 394 public: |
388 NoHeapGrowthControlScope(); | 395 NoHeapGrowthControlScope(); |
389 ~NoHeapGrowthControlScope(); | 396 ~NoHeapGrowthControlScope(); |
390 | 397 |
391 private: | 398 private: |
392 bool current_growth_controller_state_; | 399 bool current_growth_controller_state_; |
393 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 400 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
394 }; | 401 }; |
395 | 402 |
396 // Note: During this scope, the code pages are non-executable. | 403 // Note: During this scope, the code pages are non-executable. |
397 class WritableVMIsolateScope : StackResource { | 404 class WritableVMIsolateScope : StackResource { |
398 public: | 405 public: |
399 explicit WritableVMIsolateScope(Thread* thread); | 406 explicit WritableVMIsolateScope(Thread* thread); |
400 ~WritableVMIsolateScope(); | 407 ~WritableVMIsolateScope(); |
401 }; | 408 }; |
402 | 409 |
403 } // namespace dart | 410 } // namespace dart |
404 | 411 |
405 #endif // RUNTIME_VM_HEAP_H_ | 412 #endif // RUNTIME_VM_HEAP_H_ |
OLD | NEW |