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

Side by Side Diff: runtime/vm/pages.h

Issue 70993002: - Convert heap sizes to words from bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « runtime/vm/find_code_object_test.cc ('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 #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/freelist.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/virtual_memory.h" 10 #include "vm/virtual_memory.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 DECLARE_FLAG(bool, collect_code); 14 DECLARE_FLAG(bool, collect_code);
15 DECLARE_FLAG(bool, log_code_drop); 15 DECLARE_FLAG(bool, log_code_drop);
16 16
17 // Forward declarations. 17 // Forward declarations.
18 class Heap; 18 class Heap;
19 class ObjectPointerVisitor; 19 class ObjectPointerVisitor;
20 20
21 // An aligned page containing old generation objects. Alignment is used to be 21 // A page containing old generation objects.
22 // able to get to a HeapPage header quickly based on a pointer to an object.
23 class HeapPage { 22 class HeapPage {
24 public: 23 public:
25 enum PageType { 24 enum PageType {
26 kData = 0, 25 kData = 0,
27 kExecutable, 26 kExecutable,
28 kNumPageTypes 27 kNumPageTypes
29 }; 28 };
30 29
31 HeapPage* next() const { return next_; } 30 HeapPage* next() const { return next_; }
32 void set_next(HeapPage* next) { next_ = next; } 31 void set_next(HeapPage* next) { next_ = next; }
(...skipping 24 matching lines...) Expand all
57 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); 56 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment);
58 } 57 }
59 58
60 private: 59 private:
61 void set_object_end(uword val) { 60 void set_object_end(uword val) {
62 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset); 61 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
63 object_end_ = val; 62 object_end_ = val;
64 } 63 }
65 64
66 static HeapPage* Initialize(VirtualMemory* memory, PageType type); 65 static HeapPage* Initialize(VirtualMemory* memory, PageType type);
67 static HeapPage* Allocate(intptr_t size, PageType type); 66 static HeapPage* Allocate(intptr_t size_in_words, PageType type);
68 67
69 // Deallocate the virtual memory backing this page. The page pointer to this 68 // Deallocate the virtual memory backing this page. The page pointer to this
70 // page becomes immediately inaccessible. 69 // page becomes immediately inaccessible.
71 void Deallocate(); 70 void Deallocate();
72 71
73 VirtualMemory* memory_; 72 VirtualMemory* memory_;
74 HeapPage* next_; 73 HeapPage* next_;
75 uword object_end_; 74 uword object_end_;
76 bool executable_; 75 bool executable_;
77 76
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 163
165 PageSpaceGarbageCollectionHistory history_; 164 PageSpaceGarbageCollectionHistory history_;
166 165
167 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController); 166 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController);
168 }; 167 };
169 168
170 169
171 class PageSpace { 170 class PageSpace {
172 public: 171 public:
173 // TODO(iposva): Determine heap sizes and tune the page size accordingly. 172 // TODO(iposva): Determine heap sizes and tune the page size accordingly.
174 static const intptr_t kPageSize = 256 * KB; 173 static const intptr_t kPageSizeInWords = 256 * KBInWords;
175 static const intptr_t kPageAlignment = kPageSize;
176 174
177 enum GrowthPolicy { 175 enum GrowthPolicy {
178 kControlGrowth, 176 kControlGrowth,
179 kForceGrowth 177 kForceGrowth
180 }; 178 };
181 179
182 PageSpace(Heap* heap, intptr_t max_capacity_in_words); 180 PageSpace(Heap* heap, intptr_t max_capacity_in_words);
183 ~PageSpace(); 181 ~PageSpace();
184 182
185 uword TryAllocate(intptr_t size, 183 uword TryAllocate(intptr_t size,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 }; 234 };
237 235
238 static const intptr_t kAllocatablePageSize = 64 * KB; 236 static const intptr_t kAllocatablePageSize = 64 * KB;
239 237
240 HeapPage* AllocatePage(HeapPage::PageType type); 238 HeapPage* AllocatePage(HeapPage::PageType type);
241 void FreePage(HeapPage* page, HeapPage* previous_page); 239 void FreePage(HeapPage* page, HeapPage* previous_page);
242 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type); 240 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type);
243 void FreeLargePage(HeapPage* page, HeapPage* previous_page); 241 void FreeLargePage(HeapPage* page, HeapPage* previous_page);
244 void FreePages(HeapPage* pages); 242 void FreePages(HeapPage* pages);
245 243
246 static intptr_t LargePageSizeFor(intptr_t size); 244 static intptr_t LargePageSizeInWordsFor(intptr_t size);
247 245
248 bool CanIncreaseCapacityInWords(intptr_t increase_in_words) { 246 bool CanIncreaseCapacityInWords(intptr_t increase_in_words) {
249 ASSERT(capacity_in_words_ <= max_capacity_in_words_); 247 ASSERT(capacity_in_words_ <= max_capacity_in_words_);
250 return increase_in_words <= (max_capacity_in_words_ - capacity_in_words_); 248 return increase_in_words <= (max_capacity_in_words_ - capacity_in_words_);
251 } 249 }
252 250
253 FreeList freelist_[HeapPage::kNumPageTypes]; 251 FreeList freelist_[HeapPage::kNumPageTypes];
254 252
255 Heap* heap_; 253 Heap* heap_;
256 254
(...skipping 12 matching lines...) Expand all
269 PageSpaceController page_space_controller_; 267 PageSpaceController page_space_controller_;
270 268
271 friend class PageSpaceController; 269 friend class PageSpaceController;
272 270
273 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 271 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
274 }; 272 };
275 273
276 } // namespace dart 274 } // namespace dart
277 275
278 #endif // VM_PAGES_H_ 276 #endif // VM_PAGES_H_
OLDNEW
« no previous file with comments | « runtime/vm/find_code_object_test.cc ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698