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

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, 7 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
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 of the discovered live object sizes to be able to finish
koda 2014/04/24 23:09:56 Update comment; we are not tracking sizes here.
Ivan Posva 2014/04/24 23:17:50 Done.
16 // sweeping early. Reset the per page in_use count for the next marking phase. 16 // sweeping early.
17 intptr_t in_use = 0; 17 bool in_use = false;
18 18
19 bool is_executable = (page->type() == HeapPage::kExecutable); 19 bool is_executable = (page->type() == HeapPage::kExecutable);
20 uword start = page->object_start(); 20 uword start = page->object_start();
21 uword end = page->object_end(); 21 uword end = page->object_end();
22 uword current = start; 22 uword current = start;
23 23
24 while (current < end) { 24 while (current < end) {
25 intptr_t obj_size; 25 intptr_t obj_size;
26 RawObject* raw_obj = RawObject::FromAddr(current); 26 RawObject* raw_obj = RawObject::FromAddr(current);
27 if (raw_obj->IsMarked()) { 27 if (raw_obj->IsMarked()) {
28 // Found marked object. Clear the mark bit and update swept bytes. 28 // Found marked object. Clear the mark bit and update swept bytes.
29 raw_obj->ClearMarkBit(); 29 raw_obj->ClearMarkBit();
30 obj_size = raw_obj->Size(); 30 obj_size = raw_obj->Size();
31 in_use += obj_size; 31 in_use = true;
32 } else { 32 } else {
33 uword free_end = current + raw_obj->Size(); 33 uword free_end = current + raw_obj->Size();
34 while (free_end < end) { 34 while (free_end < end) {
35 RawObject* next_obj = RawObject::FromAddr(free_end); 35 RawObject* next_obj = RawObject::FromAddr(free_end);
36 if (next_obj->IsMarked()) { 36 if (next_obj->IsMarked()) {
37 // Reached the end of the free block. 37 // Reached the end of the free block.
38 break; 38 break;
39 } 39 }
40 // Expand the free block by the size of this object. 40 // Expand the free block by the size of this object.
41 free_end += next_obj->Size(); 41 free_end += next_obj->Size();
42 } 42 }
43 obj_size = free_end - current; 43 obj_size = free_end - current;
44 if (is_executable) { 44 if (is_executable) {
45 memset(reinterpret_cast<void*>(current), 0xcc, obj_size); 45 memset(reinterpret_cast<void*>(current), 0xcc, obj_size);
46 } 46 }
47 if ((current != start) || (free_end != end)) { 47 if ((current != start) || (free_end != end)) {
48 // Only add to the free list if not covering the whole page. 48 // Only add to the free list if not covering the whole page.
49 freelist->Free(current, obj_size); 49 freelist->Free(current, obj_size);
50 } 50 }
51 } 51 }
52 current += obj_size; 52 current += obj_size;
53 } 53 }
54 ASSERT(current == end); 54 ASSERT(current == end);
55 55
56 return in_use; 56 return in_use;
57 } 57 }
58 58
59 59
60 intptr_t GCSweeper::SweepLargePage(HeapPage* page) { 60 bool GCSweeper::SweepLargePage(HeapPage* page) {
61 RawObject* raw_obj = RawObject::FromAddr(page->object_start()); 61 RawObject* raw_obj = RawObject::FromAddr(page->object_start());
62 if (!raw_obj->IsMarked()) { 62 if (!raw_obj->IsMarked()) {
63 // The large object was not marked. Used size is zero, which also tells the 63 // 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. 64 // calling code that the large object page can be recycled.
65 return 0; 65 return false;
66 } 66 }
67 raw_obj->ClearMarkBit(); 67 raw_obj->ClearMarkBit();
68 return raw_obj->Size(); 68 return true;
69 } 69 }
70 70
71 } // namespace dart 71 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('j') | runtime/vm/pages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698