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

Side by Side Diff: vm/pages.h

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
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 #ifndef VM_PAGES_H_ 5 #ifndef VM_PAGES_H_
6 #define VM_PAGES_H_ 6 #define VM_PAGES_H_
7 7
8 #include "vm/freelist.h"
8 #include "vm/globals.h" 9 #include "vm/globals.h"
9 #include "vm/virtual_memory.h" 10 #include "vm/virtual_memory.h"
10 11
11 namespace dart { 12 namespace dart {
12 13
13 // Forward declarations. 14 // Forward declarations.
14 class Heap; 15 class Heap;
15 class ObjectPointerVisitor; 16 class ObjectPointerVisitor;
16 17
17 // An aligned page containing old generation objects. Alignment is used to be 18 // An aligned page containing old generation objects. Alignment is used to be
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 82 }
82 static intptr_t IsPageAllocatableSize(intptr_t size) { 83 static intptr_t IsPageAllocatableSize(intptr_t size) {
83 return size <= kAllocatablePageSize; 84 return size <= kAllocatablePageSize;
84 } 85 }
85 86
86 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 87 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
87 88
88 // Collect the garbage in the page space using mark-sweep. 89 // Collect the garbage in the page space using mark-sweep.
89 void MarkSweep(); 90 void MarkSweep();
90 91
92 static HeapPage* PageFor(RawObject* raw_obj) {
93 return reinterpret_cast<HeapPage*>(
94 RawObject::ToAddr(raw_obj) & ~(kPageSize -1));
95 }
96
91 private: 97 private:
92 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); 98 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage);
93 99
94 void AllocatePage(); 100 void AllocatePage();
95 HeapPage* AllocateLargePage(intptr_t size); 101 HeapPage* AllocateLargePage(intptr_t size);
102 void FreeLargePage(HeapPage* page, HeapPage* previous_page);
96 void FreePages(HeapPage* pages); 103 void FreePages(HeapPage* pages);
97 104
98 uword TryBumpAllocate(intptr_t size); 105 uword TryBumpAllocate(intptr_t size);
99 106
107 FreeList freelist_;
108
100 Heap* heap_; 109 Heap* heap_;
101 110
102 HeapPage* pages_; 111 HeapPage* pages_;
103 HeapPage* pages_tail_; 112 HeapPage* pages_tail_;
104 HeapPage* large_pages_; 113 HeapPage* large_pages_;
105 114
106 // Various sizes being tracked for this generation. 115 // Various sizes being tracked for this generation.
107 intptr_t max_capacity_; 116 intptr_t max_capacity_;
108 intptr_t capacity_; 117 intptr_t capacity_;
109 intptr_t in_use_; 118 intptr_t in_use_;
110 119
111 // Old-gen GC cycle count. 120 // Old-gen GC cycle count.
112 int count_; 121 int count_;
113 122
114 bool is_executable_; 123 bool is_executable_;
115 124
116 // Keep track whether a MarkSweep is currently running. 125 // Keep track whether a MarkSweep is currently running.
117 bool sweeping_; 126 bool sweeping_;
118 127
119 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 128 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
120 }; 129 };
121 130
122 } // namespace dart 131 } // namespace dart
123 132
124 #endif // VM_PAGES_H_ 133 #endif // VM_PAGES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698