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

Side by Side Diff: vm/pages.h

Issue 11186013: - Do not bump allocate in old-space pages. Always use (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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 | « vm/gc_sweeper.cc ('k') | 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 #ifndef VM_PAGES_H_ 5 #ifndef VM_PAGES_H_
6 #define VM_PAGES_H_ 6 #define VM_PAGES_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "vm/freelist.h" 10 #include "vm/freelist.h"
(...skipping 10 matching lines...) Expand all
21 // able to get to a HeapPage header quickly based on a pointer to an object. 21 // able to get to a HeapPage header quickly based on a pointer to an object.
22 class HeapPage { 22 class HeapPage {
23 public: 23 public:
24 HeapPage* next() const { return next_; } 24 HeapPage* next() const { return next_; }
25 void set_next(HeapPage* next) { next_ = next; } 25 void set_next(HeapPage* next) { next_ = next; }
26 26
27 bool Contains(uword addr) { 27 bool Contains(uword addr) {
28 return memory_->Contains(addr); 28 return memory_->Contains(addr);
29 } 29 }
30 30
31 uword start() const { return reinterpret_cast<uword>(this); } 31 uword object_start() const {
32 uword end() const { return memory_->end(); }
33
34 uword top() const { return top_; }
35 void set_top(uword top) { top_ = top; }
36
37 uword first_object_start() const {
38 return (reinterpret_cast<uword>(this) + sizeof(HeapPage)); 32 return (reinterpret_cast<uword>(this) + sizeof(HeapPage));
39 } 33 }
34 uword object_end() const {
35 return object_end_;
36 }
40 37
41 void set_used(uword used) { used_ = used; } 38 void set_used(uword used) { used_ = used; }
42 uword used() const { return used_; } 39 uword used() const { return used_; }
43 void AddUsed(uword size) { 40 void AddUsed(uword size) {
44 used_ += size; 41 used_ += size;
45 } 42 }
46 43
47 uword TryBumpAllocate(intptr_t size) {
48 uword result = top();
49 intptr_t remaining_space = end() - result;
50 if (remaining_space < size) {
51 return 0;
52 }
53 set_top(result + size);
54 return result;
55 }
56
57 void VisitObjects(ObjectVisitor* visitor) const; 44 void VisitObjects(ObjectVisitor* visitor) const;
58 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 45 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
59 46
60 RawObject* FindObject(FindObjectVisitor* visitor) const; 47 RawObject* FindObject(FindObjectVisitor* visitor) const;
61 48
62 void WriteProtect(bool read_only); 49 void WriteProtect(bool read_only);
63 50
64 private: 51 private:
52 void set_object_end(uword val) {
53 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
54 object_end_ = val;
55 }
56
65 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); 57 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable);
66 static HeapPage* Allocate(intptr_t size, bool is_executable); 58 static HeapPage* Allocate(intptr_t size, bool is_executable);
67 59
68 // Deallocate the virtual memory backing this page. The page pointer to this 60 // Deallocate the virtual memory backing this page. The page pointer to this
69 // page becomes immediately inaccessible. 61 // page becomes immediately inaccessible.
70 void Deallocate(); 62 void Deallocate();
71 63
72 VirtualMemory* memory_; 64 VirtualMemory* memory_;
73 HeapPage* next_; 65 HeapPage* next_;
74 uword used_; 66 uword used_;
75 uword top_; 67 uword object_end_;
76 68
77 friend class PageSpace; 69 friend class PageSpace;
78 70
79 DISALLOW_ALLOCATION(); 71 DISALLOW_ALLOCATION();
80 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage); 72 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage);
81 }; 73 };
82 74
83 75
84 // The history holds the timing information of the last garbage collection 76 // The history holds the timing information of the last garbage collection
85 // runs. 77 // runs.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 201
210 void* GetPeer(RawObject* raw_obj); 202 void* GetPeer(RawObject* raw_obj);
211 203
212 int64_t PeerCount() const; 204 int64_t PeerCount() const;
213 205
214 PeerTable* GetPeerTable() { return &peer_table_; } 206 PeerTable* GetPeerTable() { return &peer_table_; }
215 207
216 private: 208 private:
217 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); 209 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage);
218 210
219 void AllocatePage(); 211 HeapPage* AllocatePage();
220 void FreePage(HeapPage* page, HeapPage* previous_page); 212 void FreePage(HeapPage* page, HeapPage* previous_page);
221 HeapPage* AllocateLargePage(intptr_t size); 213 HeapPage* AllocateLargePage(intptr_t size);
222 void FreeLargePage(HeapPage* page, HeapPage* previous_page); 214 void FreeLargePage(HeapPage* page, HeapPage* previous_page);
223 void FreePages(HeapPage* pages); 215 void FreePages(HeapPage* pages);
224 216
225 static intptr_t LargePageSizeFor(intptr_t size); 217 static intptr_t LargePageSizeFor(intptr_t size);
226 218
227 bool CanIncreaseCapacity(intptr_t increase) { 219 bool CanIncreaseCapacity(intptr_t increase) {
228 ASSERT(capacity_ <= max_capacity_); 220 ASSERT(capacity_ <= max_capacity_);
229 return increase <= (max_capacity_ - capacity_); 221 return increase <= (max_capacity_ - capacity_);
230 } 222 }
231 223
232 uword TryBumpAllocate(intptr_t size);
233
234 FreeList freelist_; 224 FreeList freelist_;
235 225
236 Heap* heap_; 226 Heap* heap_;
237 227
238 HeapPage* pages_; 228 HeapPage* pages_;
239 HeapPage* pages_tail_; 229 HeapPage* pages_tail_;
240 HeapPage* large_pages_; 230 HeapPage* large_pages_;
241 231
242 PeerTable peer_table_; 232 PeerTable peer_table_;
243 233
244 // Page being used for bump allocation.
245 // The value has different meanings:
246 // NULL: Still bump allocating from last allocated fresh page.
247 // !NULL: Last page that had enough room to bump allocate, when we reach the
248 // tail page, we give up bump allocating.
249 HeapPage* bump_page_;
250
251 // Various sizes being tracked for this generation. 234 // Various sizes being tracked for this generation.
252 intptr_t max_capacity_; 235 intptr_t max_capacity_;
253 intptr_t capacity_; 236 intptr_t capacity_;
254 intptr_t in_use_; 237 intptr_t in_use_;
255 238
256 // Old-gen GC cycle count. 239 // Old-gen GC cycle count.
257 int count_; 240 int count_;
258 241
259 bool is_executable_; 242 bool is_executable_;
260 243
261 // Keep track whether a MarkSweep is currently running. 244 // Keep track whether a MarkSweep is currently running.
262 bool sweeping_; 245 bool sweeping_;
263 246
264 PageSpaceController page_space_controller_; 247 PageSpaceController page_space_controller_;
265 248
266 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 249 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
267 }; 250 };
268 251
269 } // namespace dart 252 } // namespace dart
270 253
271 #endif // VM_PAGES_H_ 254 #endif // VM_PAGES_H_
OLDNEW
« no previous file with comments | « vm/gc_sweeper.cc ('k') | vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698