| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void IterateNewObjects(ObjectVisitor* visitor) const; | 118 void IterateNewObjects(ObjectVisitor* visitor) const; |
| 119 void IterateOldObjects(ObjectVisitor* visitor) const; | 119 void IterateOldObjects(ObjectVisitor* visitor) const; |
| 120 | 120 |
| 121 // Find an object by visiting all pointers in the specified heap space, | 121 // Find an object by visiting all pointers in the specified heap space, |
| 122 // the 'visitor' is used to determine if an object is found or not. | 122 // the 'visitor' is used to determine if an object is found or not. |
| 123 // The 'visitor' function should be set up to return true if the | 123 // The 'visitor' function should be set up to return true if the |
| 124 // object is found, traversal through the heap space stops at that | 124 // object is found, traversal through the heap space stops at that |
| 125 // point. | 125 // point. |
| 126 // The 'visitor' function should return false if the object is not found, | 126 // The 'visitor' function should return false if the object is not found, |
| 127 // traversal through the heap space continues. | 127 // traversal through the heap space continues. |
| 128 // Returns null object if nothing is found. Must be called within a NoGCScope. | 128 // Returns null object if nothing is found. Must be called within a |
| 129 // NoSafepointScope. |
| 129 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; | 130 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; |
| 130 RawObject* FindOldObject(FindObjectVisitor* visitor) const; | 131 RawObject* FindOldObject(FindObjectVisitor* visitor) const; |
| 131 RawObject* FindNewObject(FindObjectVisitor* visitor) const; | 132 RawObject* FindNewObject(FindObjectVisitor* visitor) const; |
| 132 RawObject* FindObject(FindObjectVisitor* visitor) const; | 133 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 133 | 134 |
| 134 void CollectGarbage(Space space); | 135 void CollectGarbage(Space space); |
| 135 void CollectGarbage(Space space, ApiCallbacks api_callbacks, GCReason reason); | 136 void CollectGarbage(Space space, ApiCallbacks api_callbacks, GCReason reason); |
| 136 void CollectAllGarbage(); | 137 void CollectAllGarbage(); |
| 137 | 138 |
| 138 // Enables growth control on the page space heaps. This should be | 139 // Enables growth control on the page space heaps. This should be |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 class GCEvent { | 329 class GCEvent { |
| 329 public: | 330 public: |
| 330 explicit GCEvent(const Heap::GCStats& stats) | 331 explicit GCEvent(const Heap::GCStats& stats) |
| 331 : stats_(stats) {} | 332 : stats_(stats) {} |
| 332 void PrintJSON(JSONStream* js) const; | 333 void PrintJSON(JSONStream* js) const; |
| 333 private: | 334 private: |
| 334 const Heap::GCStats& stats_; | 335 const Heap::GCStats& stats_; |
| 335 }; | 336 }; |
| 336 | 337 |
| 337 | 338 |
| 339 // Within a NoSafepointScope, the thread must not reach any safepoint. Used |
| 340 // around code that manipulates raw object pointers directly without handles. |
| 338 #if defined(DEBUG) | 341 #if defined(DEBUG) |
| 339 class NoGCScope : public StackResource { | 342 class NoSafepointScope : public StackResource { |
| 340 public: | 343 public: |
| 341 NoGCScope(); | 344 NoSafepointScope(); |
| 342 ~NoGCScope(); | 345 ~NoSafepointScope(); |
| 343 private: | 346 private: |
| 344 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 347 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
| 345 }; | 348 }; |
| 346 #else // defined(DEBUG) | 349 #else // defined(DEBUG) |
| 347 class NoGCScope : public ValueObject { | 350 class NoSafepointScope : public ValueObject { |
| 348 public: | 351 public: |
| 349 NoGCScope() {} | 352 NoSafepointScope() {} |
| 350 private: | 353 private: |
| 351 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 354 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
| 352 }; | 355 }; |
| 353 #endif // defined(DEBUG) | 356 #endif // defined(DEBUG) |
| 354 | 357 |
| 355 | 358 |
| 356 class NoHeapGrowthControlScope : public StackResource { | 359 class NoHeapGrowthControlScope : public StackResource { |
| 357 public: | 360 public: |
| 358 NoHeapGrowthControlScope(); | 361 NoHeapGrowthControlScope(); |
| 359 ~NoHeapGrowthControlScope(); | 362 ~NoHeapGrowthControlScope(); |
| 360 private: | 363 private: |
| 361 bool current_growth_controller_state_; | 364 bool current_growth_controller_state_; |
| 362 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 365 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 363 }; | 366 }; |
| 364 | 367 |
| 365 } // namespace dart | 368 } // namespace dart |
| 366 | 369 |
| 367 #endif // VM_HEAP_H_ | 370 #endif // VM_HEAP_H_ |
| OLD | NEW |