OLD | NEW |
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 RUNTIME_VM_PAGES_H_ | 5 #ifndef RUNTIME_VM_PAGES_H_ |
6 #define RUNTIME_VM_PAGES_H_ | 6 #define RUNTIME_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/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 HeapPage* next() const { return next_; } | 33 HeapPage* next() const { return next_; } |
34 void set_next(HeapPage* next) { next_ = next; } | 34 void set_next(HeapPage* next) { next_ = next; } |
35 | 35 |
36 bool Contains(uword addr) { return memory_->Contains(addr); } | 36 bool Contains(uword addr) { return memory_->Contains(addr); } |
37 | 37 |
38 uword object_start() const { return memory_->start() + ObjectStartOffset(); } | 38 uword object_start() const { return memory_->start() + ObjectStartOffset(); } |
39 uword object_end() const { return object_end_; } | 39 uword object_end() const { return object_end_; } |
40 | 40 |
41 PageType type() const { return type_; } | 41 PageType type() const { return type_; } |
42 | 42 |
43 bool embedder_allocated() const { return memory_->embedder_allocated(); } | 43 bool is_image_page() const { return !memory_->vm_owns_region(); } |
44 | 44 |
45 void VisitObjects(ObjectVisitor* visitor) const; | 45 void VisitObjects(ObjectVisitor* visitor) const; |
46 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 46 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
47 | 47 |
48 RawObject* FindObject(FindObjectVisitor* visitor) const; | 48 RawObject* FindObject(FindObjectVisitor* visitor) const; |
49 | 49 |
50 void WriteProtect(bool read_only); | 50 void WriteProtect(bool read_only); |
51 | 51 |
52 static intptr_t ObjectStartOffset() { | 52 static intptr_t ObjectStartOffset() { |
53 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); | 53 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 MutexLocker ml(pages_lock_); | 224 MutexLocker ml(pages_lock_); |
225 return usage_; | 225 return usage_; |
226 } | 226 } |
227 | 227 |
228 bool Contains(uword addr) const; | 228 bool Contains(uword addr) const; |
229 bool Contains(uword addr, HeapPage::PageType type) const; | 229 bool Contains(uword addr, HeapPage::PageType type) const; |
230 bool DataContains(uword addr) const; | 230 bool DataContains(uword addr) const; |
231 bool IsValidAddress(uword addr) const { return Contains(addr); } | 231 bool IsValidAddress(uword addr) const { return Contains(addr); } |
232 | 232 |
233 void VisitObjects(ObjectVisitor* visitor) const; | 233 void VisitObjects(ObjectVisitor* visitor) const; |
234 void VisitObjectsNoExternalPages(ObjectVisitor* visitor) const; | 234 void VisitObjectsNoImagePages(ObjectVisitor* visitor) const; |
235 void VisitObjectsExternalPages(ObjectVisitor* visitor) const; | 235 void VisitObjectsImagePages(ObjectVisitor* visitor) const; |
236 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 236 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
237 | 237 |
238 RawObject* FindObject(FindObjectVisitor* visitor, | 238 RawObject* FindObject(FindObjectVisitor* visitor, |
239 HeapPage::PageType type) const; | 239 HeapPage::PageType type) const; |
240 | 240 |
241 // Checks if enough time has elapsed since the last attempt to collect | 241 // Checks if enough time has elapsed since the last attempt to collect |
242 // code. | 242 // code. |
243 bool ShouldCollectCode(); | 243 bool ShouldCollectCode(); |
244 | 244 |
245 // Collect the garbage in the page space using mark-sweep. | 245 // Collect the garbage in the page space using mark-sweep. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 uword TryAllocateDataBumpLocked(intptr_t size, GrowthPolicy growth_policy); | 311 uword TryAllocateDataBumpLocked(intptr_t size, GrowthPolicy growth_policy); |
312 // Prefer small freelist blocks, then chip away at the bump block. | 312 // Prefer small freelist blocks, then chip away at the bump block. |
313 uword TryAllocatePromoLocked(intptr_t size, GrowthPolicy growth_policy); | 313 uword TryAllocatePromoLocked(intptr_t size, GrowthPolicy growth_policy); |
314 | 314 |
315 // Bump block allocation from generated code. | 315 // Bump block allocation from generated code. |
316 uword* TopAddress() { return &bump_top_; } | 316 uword* TopAddress() { return &bump_top_; } |
317 uword* EndAddress() { return &bump_end_; } | 317 uword* EndAddress() { return &bump_end_; } |
318 static intptr_t top_offset() { return OFFSET_OF(PageSpace, bump_top_); } | 318 static intptr_t top_offset() { return OFFSET_OF(PageSpace, bump_top_); } |
319 static intptr_t end_offset() { return OFFSET_OF(PageSpace, bump_end_); } | 319 static intptr_t end_offset() { return OFFSET_OF(PageSpace, bump_end_); } |
320 | 320 |
321 void SetupExternalPage(void* pointer, uword size, bool is_executable); | 321 void SetupImagePage(void* pointer, uword size, bool is_executable); |
322 | 322 |
323 private: | 323 private: |
324 // Ids for time and data records in Heap::GCStats. | 324 // Ids for time and data records in Heap::GCStats. |
325 enum { | 325 enum { |
326 // Time | 326 // Time |
327 kMarkObjects = 0, | 327 kMarkObjects = 0, |
328 kResetFreeLists = 1, | 328 kResetFreeLists = 1, |
329 kSweepPages = 2, | 329 kSweepPages = 2, |
330 kSweepLargePages = 3, | 330 kSweepLargePages = 3, |
331 // Data | 331 // Data |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 friend class HeapIterationScope; | 425 friend class HeapIterationScope; |
426 friend class PageSpaceController; | 426 friend class PageSpaceController; |
427 friend class SweeperTask; | 427 friend class SweeperTask; |
428 | 428 |
429 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 429 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
430 }; | 430 }; |
431 | 431 |
432 } // namespace dart | 432 } // namespace dart |
433 | 433 |
434 #endif // RUNTIME_VM_PAGES_H_ | 434 #endif // RUNTIME_VM_PAGES_H_ |
OLD | NEW |