Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "vm/freelist.h" | 10 #include "vm/freelist.h" |
| 9 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 10 #include "vm/virtual_memory.h" | 12 #include "vm/virtual_memory.h" |
| 11 | 13 |
| 12 namespace dart { | 14 namespace dart { |
| 13 | 15 |
| 14 // Forward declarations. | 16 // Forward declarations. |
| 15 class Heap; | 17 class Heap; |
| 16 class ObjectPointerVisitor; | 18 class ObjectPointerVisitor; |
| 17 | 19 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 return result; | 54 return result; |
| 53 } | 55 } |
| 54 | 56 |
| 55 void VisitObjects(ObjectVisitor* visitor) const; | 57 void VisitObjects(ObjectVisitor* visitor) const; |
| 56 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 58 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 57 | 59 |
| 58 RawObject* FindObject(FindObjectVisitor* visitor) const; | 60 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 59 | 61 |
| 60 void WriteProtect(bool read_only); | 62 void WriteProtect(bool read_only); |
| 61 | 63 |
| 64 void SetPeer(RawObject* raw_obj, void* peer); | |
| 65 | |
| 62 private: | 66 private: |
| 63 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); | 67 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); |
| 64 static HeapPage* Allocate(intptr_t size, bool is_executable); | 68 static HeapPage* Allocate(intptr_t size, bool is_executable); |
| 65 | 69 |
| 66 // Deallocate the virtual memory backing this page. The page pointer to this | 70 // Deallocate the virtual memory backing this page. The page pointer to this |
| 67 // page becomes immediately inaccessible. | 71 // page becomes immediately inaccessible. |
| 68 void Deallocate(); | 72 void Deallocate(); |
| 69 | 73 |
| 70 VirtualMemory* memory_; | 74 VirtualMemory* memory_; |
| 71 HeapPage* next_; | 75 HeapPage* next_; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 } | 198 } |
| 195 | 199 |
| 196 void StartEndAddress(uword* start, uword* end) const; | 200 void StartEndAddress(uword* start, uword* end) const; |
| 197 | 201 |
| 198 void EnableGrowthControl() { | 202 void EnableGrowthControl() { |
| 199 page_space_controller_.Enable(); | 203 page_space_controller_.Enable(); |
| 200 } | 204 } |
| 201 | 205 |
| 202 void WriteProtect(bool read_only); | 206 void WriteProtect(bool read_only); |
| 203 | 207 |
| 208 void SetPeer(RawObject* raw_obj, void* peer); | |
| 209 | |
| 210 void* GetPeer(RawObject* raw_obj); | |
| 211 | |
| 212 int64_t PeerCount() const; | |
| 213 | |
| 204 private: | 214 private: |
| 205 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); | 215 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); |
| 206 | 216 |
| 207 void AllocatePage(); | 217 void AllocatePage(); |
| 208 void FreePage(HeapPage* page, HeapPage* previous_page); | 218 void FreePage(HeapPage* page, HeapPage* previous_page); |
| 209 HeapPage* AllocateLargePage(intptr_t size); | 219 HeapPage* AllocateLargePage(intptr_t size); |
| 210 void FreeLargePage(HeapPage* page, HeapPage* previous_page); | 220 void FreeLargePage(HeapPage* page, HeapPage* previous_page); |
| 211 void FreePages(HeapPage* pages); | 221 void FreePages(HeapPage* pages); |
| 212 | 222 |
| 213 static intptr_t LargePageSizeFor(intptr_t size); | 223 static intptr_t LargePageSizeFor(intptr_t size); |
| 214 | 224 |
| 215 bool CanIncreaseCapacity(intptr_t increase) { | 225 bool CanIncreaseCapacity(intptr_t increase) { |
| 216 ASSERT(capacity_ <= max_capacity_); | 226 ASSERT(capacity_ <= max_capacity_); |
| 217 return increase <= (max_capacity_ - capacity_); | 227 return increase <= (max_capacity_ - capacity_); |
| 218 } | 228 } |
| 219 | 229 |
| 220 uword TryBumpAllocate(intptr_t size); | 230 uword TryBumpAllocate(intptr_t size); |
| 221 | 231 |
| 222 FreeList freelist_; | 232 FreeList freelist_; |
| 223 | 233 |
| 224 Heap* heap_; | 234 Heap* heap_; |
| 225 | 235 |
| 226 HeapPage* pages_; | 236 HeapPage* pages_; |
| 227 HeapPage* pages_tail_; | 237 HeapPage* pages_tail_; |
| 228 HeapPage* large_pages_; | 238 HeapPage* large_pages_; |
| 229 | 239 |
| 240 std::map<RawObject*, void*> peer_; | |
|
siva
2012/09/14 00:03:46
Call this peer_table_ or peer_map_;
cshapiro
2012/09/15 01:23:41
Done.
| |
| 241 | |
| 230 // Page being used for bump allocation. | 242 // Page being used for bump allocation. |
| 231 // The value has different meanings: | 243 // The value has different meanings: |
| 232 // NULL: Still bump allocating from last allocated fresh page. | 244 // NULL: Still bump allocating from last allocated fresh page. |
| 233 // !NULL: Last page that had enough room to bump allocate, when we reach the | 245 // !NULL: Last page that had enough room to bump allocate, when we reach the |
| 234 // tail page, we give up bump allocating. | 246 // tail page, we give up bump allocating. |
| 235 HeapPage* bump_page_; | 247 HeapPage* bump_page_; |
| 236 | 248 |
| 237 // Various sizes being tracked for this generation. | 249 // Various sizes being tracked for this generation. |
| 238 intptr_t max_capacity_; | 250 intptr_t max_capacity_; |
| 239 intptr_t capacity_; | 251 intptr_t capacity_; |
| 240 intptr_t in_use_; | 252 intptr_t in_use_; |
| 241 | 253 |
| 242 // Old-gen GC cycle count. | 254 // Old-gen GC cycle count. |
| 243 int count_; | 255 int count_; |
| 244 | 256 |
| 245 bool is_executable_; | 257 bool is_executable_; |
| 246 | 258 |
| 247 // Keep track whether a MarkSweep is currently running. | 259 // Keep track whether a MarkSweep is currently running. |
| 248 bool sweeping_; | 260 bool sweeping_; |
| 249 | 261 |
| 250 PageSpaceController page_space_controller_; | 262 PageSpaceController page_space_controller_; |
| 251 | 263 |
| 252 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 264 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 253 }; | 265 }; |
| 254 | 266 |
| 255 } // namespace dart | 267 } // namespace dart |
| 256 | 268 |
| 257 #endif // VM_PAGES_H_ | 269 #endif // VM_PAGES_H_ |
| OLD | NEW |