OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_GC_SWEEPER_H_ | 5 #ifndef VM_GC_SWEEPER_H_ |
6 #define VM_GC_SWEEPER_H_ | 6 #define VM_GC_SWEEPER_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 // Forward declarations. | 12 // Forward declarations. |
13 class FreeList; | 13 class FreeList; |
14 class Heap; | 14 class Heap; |
15 class HeapPage; | 15 class HeapPage; |
16 class Isolate; | 16 class Isolate; |
17 class PageSpace; | 17 class PageSpace; |
18 | 18 |
19 // The class GCSweeper is used to visit the heap after marking to reclaim unused | 19 // The class GCSweeper is used to visit the heap after marking to reclaim unused |
20 // memory. | 20 // memory. |
21 class GCSweeper { | 21 class GCSweeper { |
22 public: | 22 public: |
23 explicit GCSweeper(Heap* heap) : heap_(heap) {} | 23 GCSweeper() {} |
24 ~GCSweeper() {} | 24 ~GCSweeper() {} |
25 | 25 |
26 // Sweep the memory area for the page while clearing the mark bits and adding | 26 // Sweep the memory area for the page while clearing the mark bits and adding |
27 // all the unmarked objects to the pre-locked freelist. | 27 // all the unmarked objects to the pre-locked freelist. |
28 // Returns true if the page is in use. | 28 // Returns true if the page is in use. |
29 bool SweepPage(HeapPage* page, FreeList* freelist); | 29 bool SweepPage(HeapPage* page, FreeList* freelist); |
30 | 30 |
31 // Returns the number of words from page->object_start() to the end of the | 31 // Returns the number of words from page->object_start() to the end of the |
32 // last marked object. | 32 // last marked object. |
33 intptr_t SweepLargePage(HeapPage* page); | 33 intptr_t SweepLargePage(HeapPage* page); |
34 | 34 |
35 // Sweep the regular sized data pages between first and last inclusive. | 35 // Sweep the regular sized data pages between first and last inclusive. |
36 static void SweepConcurrent(Isolate* isolate, | 36 static void SweepConcurrent(Isolate* isolate, |
37 HeapPage* first, | 37 HeapPage* first, |
38 HeapPage* last, | 38 HeapPage* last, |
39 FreeList* freelist); | 39 FreeList* freelist); |
40 | |
41 private: | |
42 Heap* heap_; | |
43 | |
44 DISALLOW_IMPLICIT_CONSTRUCTORS(GCSweeper); | |
45 }; | 40 }; |
46 | 41 |
47 } // namespace dart | 42 } // namespace dart |
48 | 43 |
49 #endif // VM_GC_SWEEPER_H_ | 44 #endif // VM_GC_SWEEPER_H_ |
OLD | NEW |