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 ClassTable; |
13 class FreeList; | 14 class FreeList; |
14 class Heap; | 15 class Heap; |
15 class HeapPage; | 16 class HeapPage; |
16 class Isolate; | 17 class Isolate; |
17 class PageSpace; | 18 class PageSpace; |
18 | 19 |
19 // The class GCSweeper is used to visit the heap after marking to reclaim unused | 20 // The class GCSweeper is used to visit the heap after marking to reclaim unused |
20 // memory. | 21 // memory. |
21 class GCSweeper { | 22 class GCSweeper { |
22 public: | 23 public: |
23 GCSweeper() {} | 24 explicit GCSweeper(const ClassTable* class_table) |
| 25 : class_table_(class_table) {} |
24 ~GCSweeper() {} | 26 ~GCSweeper() {} |
25 | 27 |
26 // Sweep the memory area for the page while clearing the mark bits and adding | 28 // Sweep the memory area for the page while clearing the mark bits and adding |
27 // all the unmarked objects to the freelist. Whether the freelist is | 29 // all the unmarked objects to the freelist. Whether the freelist is |
28 // pre-locked is indicated by the locked parameter. | 30 // pre-locked is indicated by the locked parameter. |
29 // Returns true if the page is in use. Freelist is untouched if page is not | 31 // Returns true if the page is in use. Freelist is untouched if page is not |
30 // in use. | 32 // in use. |
31 bool SweepPage(HeapPage* page, FreeList* freelist, bool locked); | 33 bool SweepPage(HeapPage* page, FreeList* freelist, bool locked); |
32 | 34 |
33 // Returns the number of words from page->object_start() to the end of the | 35 // Returns the number of words from page->object_start() to the end of the |
34 // last marked object. | 36 // last marked object. |
35 intptr_t SweepLargePage(HeapPage* page); | 37 intptr_t SweepLargePage(HeapPage* page); |
36 | 38 |
37 // Sweep the regular sized data pages between first and last inclusive. | 39 // Sweep the regular sized data pages between first and last inclusive. |
38 static void SweepConcurrent(Isolate* isolate, | 40 static void SweepConcurrent(Isolate* isolate, |
39 HeapPage* first, | 41 HeapPage* first, |
40 HeapPage* last, | 42 HeapPage* last, |
41 FreeList* freelist); | 43 FreeList* freelist); |
| 44 |
| 45 private: |
| 46 const ClassTable* class_table_; |
42 }; | 47 }; |
43 | 48 |
44 } // namespace dart | 49 } // namespace dart |
45 | 50 |
46 #endif // VM_GC_SWEEPER_H_ | 51 #endif // VM_GC_SWEEPER_H_ |
OLD | NEW |