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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Move external size from new to old space. Does not by itself trigger GC. | 98 // Move external size from new to old space. Does not by itself trigger GC. |
99 void PromoteExternal(intptr_t size); | 99 void PromoteExternal(intptr_t size); |
100 | 100 |
101 // Heap contains the specified address. | 101 // Heap contains the specified address. |
102 bool Contains(uword addr) const; | 102 bool Contains(uword addr) const; |
103 bool NewContains(uword addr) const; | 103 bool NewContains(uword addr) const; |
104 bool OldContains(uword addr) const; | 104 bool OldContains(uword addr) const; |
105 bool CodeContains(uword addr) const; | 105 bool CodeContains(uword addr) const; |
106 bool StubCodeContains(uword addr) const; | 106 bool StubCodeContains(uword addr) const; |
107 | 107 |
108 // Visit all pointers. Caller must ensure concurrent sweeper is not running, | 108 void IterateObjects(ObjectVisitor* visitor) const; |
109 // and the visitor must not allocate (see issue 21620). | 109 void IterateOldObjects(ObjectVisitor* visitor) const; |
110 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 110 void IterateObjectPointers(ObjectVisitor* visitor) const; |
111 | |
112 // Visit all objects, including FreeListElement "objects". Caller must ensure | |
113 // concurrent sweeper is not running, and the visitor must not allocate (see | |
114 // issue 21620). | |
115 void VisitObjects(ObjectVisitor* visitor) const; | |
116 | 111 |
117 // Find an object by visiting all pointers in the specified heap space, | 112 // Find an object by visiting all pointers in the specified heap space, |
118 // the 'visitor' is used to determine if an object is found or not. | 113 // the 'visitor' is used to determine if an object is found or not. |
119 // The 'visitor' function should be set up to return true if the | 114 // The 'visitor' function should be set up to return true if the |
120 // object is found, traversal through the heap space stops at that | 115 // object is found, traversal through the heap space stops at that |
121 // point. | 116 // point. |
122 // The 'visitor' function should return false if the object is not found, | 117 // The 'visitor' function should return false if the object is not found, |
123 // traversal through the heap space continues. | 118 // traversal through the heap space continues. |
124 // Returns null object if nothing is found. Must be called within a | 119 // Returns null object if nothing is found. |
125 // NoSafepointScope. | |
126 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; | 120 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; |
127 RawObject* FindOldObject(FindObjectVisitor* visitor) const; | 121 RawObject* FindOldObject(FindObjectVisitor* visitor) const; |
128 RawObject* FindNewObject(FindObjectVisitor* visitor) const; | 122 RawObject* FindNewObject(FindObjectVisitor* visitor) const; |
129 RawObject* FindObject(FindObjectVisitor* visitor) const; | 123 RawObject* FindObject(FindObjectVisitor* visitor) const; |
130 | 124 |
131 void CollectGarbage(Space space); | 125 void CollectGarbage(Space space); |
132 void CollectGarbage(Space space, ApiCallbacks api_callbacks, GCReason reason); | 126 void CollectGarbage(Space space, ApiCallbacks api_callbacks, GCReason reason); |
133 void CollectAllGarbage(); | 127 void CollectAllGarbage(); |
134 | 128 |
135 // Enables growth control on the page space heaps. This should be | 129 // Enables growth control on the page space heaps. This should be |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 271 |
278 Heap(Isolate* isolate, | 272 Heap(Isolate* isolate, |
279 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. | 273 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. |
280 intptr_t max_old_gen_words, | 274 intptr_t max_old_gen_words, |
281 intptr_t max_external_words); | 275 intptr_t max_external_words); |
282 | 276 |
283 uword AllocateNew(intptr_t size); | 277 uword AllocateNew(intptr_t size); |
284 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 278 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
285 uword AllocatePretenured(intptr_t size); | 279 uword AllocatePretenured(intptr_t size); |
286 | 280 |
| 281 // Visit all pointers. Caller must ensure concurrent sweeper is not running, |
| 282 // and the visitor must not allocate. |
| 283 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 284 |
| 285 // Visit all objects, including FreeListElement "objects". Caller must ensure |
| 286 // concurrent sweeper is not running, and the visitor must not allocate. |
| 287 void VisitObjects(ObjectVisitor* visitor) const; |
| 288 |
| 289 // Like Verify, but does not wait for concurrent sweeper, so caller must |
| 290 // ensure thread-safety. |
| 291 bool VerifyGC(MarkExpectation mark_expectation = kForbidMarked) const; |
| 292 |
287 // GC stats collection. | 293 // GC stats collection. |
288 void RecordBeforeGC(Space space, GCReason reason); | 294 void RecordBeforeGC(Space space, GCReason reason); |
289 void RecordAfterGC(); | 295 void RecordAfterGC(); |
290 void PrintStats(); | 296 void PrintStats(); |
291 void UpdateClassHeapStatsBeforeGC(Heap::Space space); | 297 void UpdateClassHeapStatsBeforeGC(Heap::Space space); |
292 void UpdatePretenurePolicy(); | 298 void UpdatePretenurePolicy(); |
293 | 299 |
294 // If this heap is non-empty, updates start and end to the smallest range that | 300 // If this heap is non-empty, updates start and end to the smallest range that |
295 // contains both the original [start, end) and the [lowest, highest) addresses | 301 // contains both the original [start, end) and the [lowest, highest) addresses |
296 // of this heap. | 302 // of this heap. |
(...skipping 14 matching lines...) Expand all Loading... |
311 // This heap is in read-only mode: No allocation is allowed. | 317 // This heap is in read-only mode: No allocation is allowed. |
312 bool read_only_; | 318 bool read_only_; |
313 | 319 |
314 // GC on the heap is in progress. | 320 // GC on the heap is in progress. |
315 bool gc_in_progress_; | 321 bool gc_in_progress_; |
316 | 322 |
317 int pretenure_policy_; | 323 int pretenure_policy_; |
318 | 324 |
319 friend class ServiceEvent; | 325 friend class ServiceEvent; |
320 friend class GCTestHelper; | 326 friend class GCTestHelper; |
| 327 friend class PageSpace; // VerifyGC |
321 DISALLOW_COPY_AND_ASSIGN(Heap); | 328 DISALLOW_COPY_AND_ASSIGN(Heap); |
322 }; | 329 }; |
323 | 330 |
324 | 331 |
325 // Within a NoSafepointScope, the thread must not reach any safepoint. Used | 332 // Within a NoSafepointScope, the thread must not reach any safepoint. Used |
326 // around code that manipulates raw object pointers directly without handles. | 333 // around code that manipulates raw object pointers directly without handles. |
327 #if defined(DEBUG) | 334 #if defined(DEBUG) |
328 class NoSafepointScope : public StackResource { | 335 class NoSafepointScope : public StackResource { |
329 public: | 336 public: |
330 NoSafepointScope(); | 337 NoSafepointScope(); |
331 ~NoSafepointScope(); | 338 ~NoSafepointScope(); |
332 private: | 339 private: |
333 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); | 340 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
334 }; | 341 }; |
335 #else // defined(DEBUG) | 342 #else // defined(DEBUG) |
336 class NoSafepointScope : public ValueObject { | 343 class NoSafepointScope : public ValueObject { |
337 public: | 344 public: |
338 NoSafepointScope() {} | 345 NoSafepointScope() {} |
339 private: | 346 private: |
340 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); | 347 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
341 }; | 348 }; |
342 #endif // defined(DEBUG) | 349 #endif // defined(DEBUG) |
343 | 350 |
344 | 351 |
| 352 class HeapIterationScope : public StackResource { |
| 353 public: |
| 354 HeapIterationScope(); |
| 355 ~HeapIterationScope(); |
| 356 private: |
| 357 NoSafepointScope no_safepoint_scope_; |
| 358 PageSpace* old_space_; |
| 359 |
| 360 DISALLOW_COPY_AND_ASSIGN(HeapIterationScope); |
| 361 }; |
| 362 |
| 363 |
345 class NoHeapGrowthControlScope : public StackResource { | 364 class NoHeapGrowthControlScope : public StackResource { |
346 public: | 365 public: |
347 NoHeapGrowthControlScope(); | 366 NoHeapGrowthControlScope(); |
348 ~NoHeapGrowthControlScope(); | 367 ~NoHeapGrowthControlScope(); |
349 private: | 368 private: |
350 bool current_growth_controller_state_; | 369 bool current_growth_controller_state_; |
351 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 370 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
352 }; | 371 }; |
353 | 372 |
354 } // namespace dart | 373 } // namespace dart |
355 | 374 |
356 #endif // VM_HEAP_H_ | 375 #endif // VM_HEAP_H_ |
OLD | NEW |