Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: vm/gc_sweeper.cc

Issue 8898034: - Implement the old sweeper. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 #include "vm/gc_sweeper.h"
6
7 #include "vm/freelist.h"
8 #include "vm/globals.h"
9 #include "vm/pages.h"
10 #include "vm/object.h"
siva 2011/12/14 16:20:13 list vm/object.h before vm/pages.h
Ivan Posva 2011/12/15 22:29:19 object.h was only needed for testing. Removed.
11
12 namespace dart {
13
14 intptr_t GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) {
15 // Keep track of the discovered live object sizes to be able to finish
16 // sweeping early. Reset the per page in_use count for the next marking phase.
17 intptr_t in_use_swept = 0;
18 intptr_t in_use = page->used();
siva 2011/12/14 16:20:13 ASERT(in_use != 0); ?
Ivan Posva 2011/12/15 22:29:19 That would be an incorrect ASSERT for totally empt
19 page->set_used(0);
20
21 uword current = page->first_object_start();
22 uword top = page->top();
23
24 while (current < top) {
25 if (in_use_swept == in_use) {
26 // No more marked objects will be found on this page.
27 page->set_top(current);
28 break;
29 }
30 RawObject* raw_obj = RawObject::FromAddr(current);
31 intptr_t obj_size;
32 if (raw_obj->IsMarked()) {
33 // Found marked object. Clear the mark bit and update swept bytes.
34 raw_obj->ClearMarkBit();
35 obj_size = raw_obj->Size();
36 in_use_swept += obj_size;
37 } else {
38 uword free_end = current + raw_obj->Size();
cshapiro 2011/12/14 18:48:11 How does this interact with FreeList elements? Fr
Ivan Posva 2011/12/15 22:29:19 FreeListElements are coalesced and added to the co
39 while (free_end < top) {
40 RawObject* next_obj = RawObject::FromAddr(free_end);
41 if (next_obj->IsMarked()) {
42 // Reached the end of the free block.
43 break;
44 }
45 // Expand the free block by the size of this object.
46 free_end += next_obj->Size();
47 }
48 obj_size = free_end - current;
49 if ((current + obj_size) == top) {
50 page->set_top(current);
51 break;
52 } else {
53 freelist->Free(current, obj_size);
54 }
55 }
56 current += obj_size;
57 }
58
59 return in_use_swept;
60 }
61
62
63 intptr_t GCSweeper::SweepLargePage(HeapPage* page) {
64 UNIMPLEMENTED();
65 return 0;
66 }
67
68 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698