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

Side by Side Diff: vm/gc_sweeper.cc

Issue 11265026: - Consolidate code into the old generation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « vm/gc_marker.cc ('k') | vm/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "vm/gc_sweeper.h" 5 #include "vm/gc_sweeper.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/pages.h" 9 #include "vm/pages.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 intptr_t GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) { 13 intptr_t GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) {
14 // Keep track of the discovered live object sizes to be able to finish 14 // Keep track of the discovered live object sizes to be able to finish
15 // sweeping early. Reset the per page in_use count for the next marking phase. 15 // sweeping early. Reset the per page in_use count for the next marking phase.
16 intptr_t in_use_swept = 0; 16 intptr_t in_use_swept = 0;
17 intptr_t in_use = page->used(); 17 intptr_t in_use = page->used();
18 page->set_used(0); 18 page->set_used(0);
19 19
20 // Whole page is empty. Do not enter anything into the freelist. 20 // Whole page is empty. Do not enter anything into the freelist.
21 if (in_use == 0) { 21 if (in_use == 0) {
22 return 0; 22 return 0;
23 } 23 }
24 24
25 bool is_executable = (page->type() == HeapPage::kExecutable);
25 uword current = page->object_start(); 26 uword current = page->object_start();
26 uword end = page->object_end(); 27 uword end = page->object_end();
27 28
28 while (current < end) { 29 while (current < end) {
29 intptr_t obj_size; 30 intptr_t obj_size;
30 if (in_use_swept == in_use) { 31 if (in_use_swept == in_use) {
31 // No more marked objects will be found on this page. 32 // No more marked objects will be found on this page.
32 obj_size = end - current; 33 obj_size = end - current;
33 freelist->Free(current, obj_size); 34 freelist->Free(current, obj_size);
34 break; 35 break;
35 } 36 }
36 RawObject* raw_obj = RawObject::FromAddr(current); 37 RawObject* raw_obj = RawObject::FromAddr(current);
37 if (raw_obj->IsMarked()) { 38 if (raw_obj->IsMarked()) {
38 // Found marked object. Clear the mark bit and update swept bytes. 39 // Found marked object. Clear the mark bit and update swept bytes.
39 raw_obj->ClearMarkBit(); 40 raw_obj->ClearMarkBit();
40 obj_size = raw_obj->Size(); 41 obj_size = raw_obj->Size();
41 in_use_swept += obj_size; 42 in_use_swept += obj_size;
42 } else { 43 } else {
43 uword free_end = current + raw_obj->Size(); 44 uword free_end = current + raw_obj->Size();
44 while (free_end < end) { 45 while (free_end < end) {
45 RawObject* next_obj = RawObject::FromAddr(free_end); 46 RawObject* next_obj = RawObject::FromAddr(free_end);
46 if (next_obj->IsMarked()) { 47 if (next_obj->IsMarked()) {
47 // Reached the end of the free block. 48 // Reached the end of the free block.
48 break; 49 break;
49 } 50 }
50 // Expand the free block by the size of this object. 51 // Expand the free block by the size of this object.
51 free_end += next_obj->Size(); 52 free_end += next_obj->Size();
52 } 53 }
53 obj_size = free_end - current; 54 obj_size = free_end - current;
55 if (is_executable) {
56 memset(reinterpret_cast<void*>(current), 0xcc, obj_size);
cshapiro 2012/10/26 04:58:07 Can we put this behind an compile time flag, like
Ivan Posva 2012/10/26 05:00:45 I left this specifically in for now while this is
57 }
54 freelist->Free(current, obj_size); 58 freelist->Free(current, obj_size);
55 } 59 }
56 current += obj_size; 60 current += obj_size;
57 } 61 }
58 62
59 return in_use_swept; 63 return in_use_swept;
60 } 64 }
61 65
62 66
63 intptr_t GCSweeper::SweepLargePage(HeapPage* page) { 67 intptr_t GCSweeper::SweepLargePage(HeapPage* page) {
64 RawObject* raw_obj = RawObject::FromAddr(page->object_start()); 68 RawObject* raw_obj = RawObject::FromAddr(page->object_start());
65 if (!raw_obj->IsMarked()) { 69 if (!raw_obj->IsMarked()) {
66 // The large object was not marked. Used size is zero, which also tells the 70 // The large object was not marked. Used size is zero, which also tells the
67 // calling code that the large object page can be recycled. 71 // calling code that the large object page can be recycled.
68 return 0; 72 return 0;
69 } 73 }
70 raw_obj->ClearMarkBit(); 74 raw_obj->ClearMarkBit();
71 return raw_obj->Size(); 75 return raw_obj->Size();
72 } 76 }
73 77
74 } // namespace dart 78 } // namespace dart
OLDNEW
« no previous file with comments | « vm/gc_marker.cc ('k') | vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698