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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_HEAP_SWEEPER_H_
6#define RUNTIME_VM_HEAP_SWEEPER_H_
7
8#include "vm/globals.h"
9
10namespace dart {
11
12// Forward declarations.
13class FreeList;
14class Heap;
15class OldPage;
16class IsolateGroup;
17class PageSpace;
18
19// The class GCSweeper is used to visit the heap after marking to reclaim unused
20// memory.
21class GCSweeper {
22 public:
23 GCSweeper() {}
24 ~GCSweeper() {}
25
26 // 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
28 // pre-locked is indicated by the locked parameter.
29 // Returns true if the page is in use. Freelist is untouched if page is not
30 // in use.
31 bool SweepPage(OldPage* page, FreeList* freelist, bool locked);
32
33 // Returns the number of words from page->object_start() to the end of the
34 // last marked object.
35 intptr_t SweepLargePage(OldPage* page);
36
37 // Sweep the regular sized data pages between first and last inclusive.
38 static void SweepConcurrent(IsolateGroup* isolate_group,
39 OldPage* first,
40 OldPage* last,
41 OldPage* large_first,
42 OldPage* large_last,
43 FreeList* freelist);
44};
45
46} // namespace dart
47
48#endif // RUNTIME_VM_HEAP_SWEEPER_H_
49