| 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 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 17 matching lines...) Expand all Loading... |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 HeapPage* next() const { return next_; } | 30 HeapPage* next() const { return next_; } |
| 31 void set_next(HeapPage* next) { next_ = next; } | 31 void set_next(HeapPage* next) { next_ = next; } |
| 32 | 32 |
| 33 bool Contains(uword addr) { | 33 bool Contains(uword addr) { |
| 34 return memory_->Contains(addr); | 34 return memory_->Contains(addr); |
| 35 } | 35 } |
| 36 | 36 |
| 37 uword object_start() const { | 37 uword object_start() const { |
| 38 return (reinterpret_cast<uword>(this) + | 38 return (reinterpret_cast<uword>(this) + ObjectStartOffset()); |
| 39 Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment)); | |
| 40 } | 39 } |
| 41 uword object_end() const { | 40 uword object_end() const { |
| 42 return object_end_; | 41 return object_end_; |
| 43 } | 42 } |
| 44 | 43 |
| 45 void set_used(uword used) { used_ = used; } | 44 void set_used(uword used) { used_ = used; } |
| 46 uword used() const { return used_; } | 45 uword used() const { return used_; } |
| 47 void AddUsed(uword size) { | 46 void AddUsed(uword size) { |
| 48 used_ += size; | 47 used_ += size; |
| 49 } | 48 } |
| 50 | 49 |
| 51 PageType type() const { | 50 PageType type() const { |
| 52 return executable_ ? kExecutable : kData; | 51 return executable_ ? kExecutable : kData; |
| 53 } | 52 } |
| 54 | 53 |
| 55 void VisitObjects(ObjectVisitor* visitor) const; | 54 void VisitObjects(ObjectVisitor* visitor) const; |
| 56 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 55 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 57 | 56 |
| 58 RawObject* FindObject(FindObjectVisitor* visitor) const; | 57 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 59 | 58 |
| 60 void WriteProtect(bool read_only); | 59 void WriteProtect(bool read_only); |
| 61 | 60 |
| 61 static intptr_t ObjectStartOffset() { |
| 62 return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment); |
| 63 } |
| 64 |
| 62 private: | 65 private: |
| 63 void set_object_end(uword val) { | 66 void set_object_end(uword val) { |
| 64 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset); | 67 ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset); |
| 65 object_end_ = val; | 68 object_end_ = val; |
| 66 } | 69 } |
| 67 | 70 |
| 68 static HeapPage* Initialize(VirtualMemory* memory, PageType type); | 71 static HeapPage* Initialize(VirtualMemory* memory, PageType type); |
| 69 static HeapPage* Allocate(intptr_t size, PageType type); | 72 static HeapPage* Allocate(intptr_t size, PageType type); |
| 70 | 73 |
| 71 // Deallocate the virtual memory backing this page. The page pointer to this | 74 // Deallocate the virtual memory backing this page. The page pointer to this |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 PageSpaceController page_space_controller_; | 281 PageSpaceController page_space_controller_; |
| 279 | 282 |
| 280 friend class PageSpaceController; | 283 friend class PageSpaceController; |
| 281 | 284 |
| 282 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 285 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 283 }; | 286 }; |
| 284 | 287 |
| 285 } // namespace dart | 288 } // namespace dart |
| 286 | 289 |
| 287 #endif // VM_PAGES_H_ | 290 #endif // VM_PAGES_H_ |
| OLD | NEW |