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: runtime/vm/gc_sweeper.cc

Issue 253493002: - Account for live size in marker. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months 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 | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('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/heap.h" 9 #include "vm/heap.h"
10 #include "vm/pages.h" 10 #include "vm/pages.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 intptr_t GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) { 14 bool GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) {
15 // Keep track of the discovered live object sizes to be able to finish 15 // Keep track whether this page is still in use.
16 // sweeping early. Reset the per page in_use count for the next marking phase. 16 bool in_use = false;
17 intptr_t in_use = 0;
18 17
19 bool is_executable = (page->type() == HeapPage::kExecutable); 18 bool is_executable = (page->type() == HeapPage::kExecutable);
20 uword start = page->object_start(); 19 uword start = page->object_start();
21 uword end = page->object_end(); 20 uword end = page->object_end();
22 uword current = start; 21 uword current = start;
23 22
24 while (current < end) { 23 while (current < end) {
25 intptr_t obj_size; 24 intptr_t obj_size;
26 RawObject* raw_obj = RawObject::FromAddr(current); 25 RawObject* raw_obj = RawObject::FromAddr(current);
27 if (raw_obj->IsMarked()) { 26 if (raw_obj->IsMarked()) {
28 // Found marked object. Clear the mark bit and update swept bytes. 27 // Found marked object. Clear the mark bit and update swept bytes.
29 raw_obj->ClearMarkBit(); 28 raw_obj->ClearMarkBit();
30 obj_size = raw_obj->Size(); 29 obj_size = raw_obj->Size();
31 in_use += obj_size; 30 in_use = true;
32 } else { 31 } else {
33 uword free_end = current + raw_obj->Size(); 32 uword free_end = current + raw_obj->Size();
34 while (free_end < end) { 33 while (free_end < end) {
35 RawObject* next_obj = RawObject::FromAddr(free_end); 34 RawObject* next_obj = RawObject::FromAddr(free_end);
36 if (next_obj->IsMarked()) { 35 if (next_obj->IsMarked()) {
37 // Reached the end of the free block. 36 // Reached the end of the free block.
38 break; 37 break;
39 } 38 }
40 // Expand the free block by the size of this object. 39 // Expand the free block by the size of this object.
41 free_end += next_obj->Size(); 40 free_end += next_obj->Size();
42 } 41 }
43 obj_size = free_end - current; 42 obj_size = free_end - current;
44 if (is_executable) { 43 if (is_executable) {
45 memset(reinterpret_cast<void*>(current), 0xcc, obj_size); 44 memset(reinterpret_cast<void*>(current), 0xcc, obj_size);
46 } 45 }
47 if ((current != start) || (free_end != end)) { 46 if ((current != start) || (free_end != end)) {
48 // Only add to the free list if not covering the whole page. 47 // Only add to the free list if not covering the whole page.
49 freelist->Free(current, obj_size); 48 freelist->Free(current, obj_size);
50 } 49 }
51 } 50 }
52 current += obj_size; 51 current += obj_size;
53 } 52 }
54 ASSERT(current == end); 53 ASSERT(current == end);
55 54
56 return in_use; 55 return in_use;
57 } 56 }
58 57
59 58
60 intptr_t GCSweeper::SweepLargePage(HeapPage* page) { 59 bool GCSweeper::SweepLargePage(HeapPage* page) {
61 RawObject* raw_obj = RawObject::FromAddr(page->object_start()); 60 RawObject* raw_obj = RawObject::FromAddr(page->object_start());
62 if (!raw_obj->IsMarked()) { 61 if (!raw_obj->IsMarked()) {
63 // The large object was not marked. Used size is zero, which also tells the 62 // The large object was not marked. Used size is zero, which also tells the
64 // calling code that the large object page can be recycled. 63 // calling code that the large object page can be recycled.
65 return 0; 64 return false;
66 } 65 }
67 raw_obj->ClearMarkBit(); 66 raw_obj->ClearMarkBit();
68 return raw_obj->Size(); 67 return true;
69 } 68 }
70 69
71 } // namespace dart 70 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698