| 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 19 matching lines...) Expand all Loading... |
| 30 public: | 30 public: |
| 31 enum PageType { kData = 0, kExecutable, kNumPageTypes }; | 31 enum PageType { kData = 0, kExecutable, kNumPageTypes }; |
| 32 | 32 |
| 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 uword used_in_bytes() const { return used_in_bytes_; } |
| 41 void set_used_in_bytes(uword value) { |
| 42 ASSERT(Utils::IsAligned(value, kObjectAlignment)); |
| 43 used_in_bytes_ = value; |
| 44 } |
| 40 | 45 |
| 41 PageType type() const { return type_; } | 46 PageType type() const { return type_; } |
| 42 | 47 |
| 43 bool is_image_page() const { return !memory_->vm_owns_region(); } | 48 bool is_image_page() const { return !memory_->vm_owns_region(); } |
| 44 | 49 |
| 45 void VisitObjects(ObjectVisitor* visitor) const; | 50 void VisitObjects(ObjectVisitor* visitor) const; |
| 46 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 51 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 47 | 52 |
| 48 RawObject* FindObject(FindObjectVisitor* visitor) const; | 53 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 49 | 54 |
| 50 void WriteProtect(bool read_only); | 55 void WriteProtect(bool read_only); |
| 51 | 56 |
| 52 static intptr_t ObjectStartOffset() { | 57 static intptr_t ObjectStartOffset() { |
| 53 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); | 58 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); |
| 54 } | 59 } |
| 55 | 60 |
| 56 private: | 61 private: |
| 57 void set_object_end(uword val) { | 62 void set_object_end(uword value) { |
| 58 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset); | 63 ASSERT((value & kObjectAlignmentMask) == kOldObjectAlignmentOffset); |
| 59 object_end_ = val; | 64 object_end_ = value; |
| 60 } | 65 } |
| 61 | 66 |
| 62 // These return NULL on OOM. | 67 // These return NULL on OOM. |
| 63 static HeapPage* Initialize(VirtualMemory* memory, | 68 static HeapPage* Initialize(VirtualMemory* memory, |
| 64 PageType type, | 69 PageType type, |
| 65 const char* name); | 70 const char* name); |
| 66 static HeapPage* Allocate(intptr_t size_in_words, | 71 static HeapPage* Allocate(intptr_t size_in_words, |
| 67 PageType type, | 72 PageType type, |
| 68 const char* name); | 73 const char* name); |
| 69 | 74 |
| 70 // Deallocate the virtual memory backing this page. The page pointer to this | 75 // Deallocate the virtual memory backing this page. The page pointer to this |
| 71 // page becomes immediately inaccessible. | 76 // page becomes immediately inaccessible. |
| 72 void Deallocate(); | 77 void Deallocate(); |
| 73 | 78 |
| 74 VirtualMemory* memory_; | 79 VirtualMemory* memory_; |
| 75 HeapPage* next_; | 80 HeapPage* next_; |
| 76 uword object_end_; | 81 uword object_end_; |
| 82 uword used_in_bytes_; |
| 77 PageType type_; | 83 PageType type_; |
| 78 | 84 |
| 79 friend class PageSpace; | 85 friend class PageSpace; |
| 80 | 86 |
| 81 DISALLOW_ALLOCATION(); | 87 DISALLOW_ALLOCATION(); |
| 82 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage); |
| 83 }; | 89 }; |
| 84 | 90 |
| 85 // The history holds the timing information of the last garbage collection | 91 // The history holds the timing information of the last garbage collection |
| 86 // runs. | 92 // runs. |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 friend class HeapIterationScope; | 435 friend class HeapIterationScope; |
| 430 friend class PageSpaceController; | 436 friend class PageSpaceController; |
| 431 friend class SweeperTask; | 437 friend class SweeperTask; |
| 432 | 438 |
| 433 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 439 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 434 }; | 440 }; |
| 435 | 441 |
| 436 } // namespace dart | 442 } // namespace dart |
| 437 | 443 |
| 438 #endif // RUNTIME_VM_PAGES_H_ | 444 #endif // RUNTIME_VM_PAGES_H_ |
| OLD | NEW |