OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #ifndef SRC_VM_OBJECT_MEMORY_H_ | 5 #ifndef SRC_VM_OBJECT_MEMORY_H_ |
6 #define SRC_VM_OBJECT_MEMORY_H_ | 6 #define SRC_VM_OBJECT_MEMORY_H_ |
7 | 7 |
8 #include "src/shared/globals.h" | 8 #include "src/shared/globals.h" |
9 #include "src/shared/platform.h" | 9 #include "src/shared/platform.h" |
10 #include "src/shared/utils.h" | 10 #include "src/shared/utils.h" |
11 | 11 |
12 namespace fletch { | 12 namespace dartino { |
13 | 13 |
14 class FreeList; | 14 class FreeList; |
15 class Heap; | 15 class Heap; |
16 class HeapObject; | 16 class HeapObject; |
17 class HeapObjectVisitor; | 17 class HeapObjectVisitor; |
18 class PointerVisitor; | 18 class PointerVisitor; |
19 class ProgramHeapRelocator; | 19 class ProgramHeapRelocator; |
20 class PromotedTrack; | 20 class PromotedTrack; |
21 class Space; | 21 class Space; |
22 | 22 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 class PageDirectory { | 333 class PageDirectory { |
334 public: | 334 public: |
335 void Clear(); | 335 void Clear(); |
336 void Delete(); | 336 void Delete(); |
337 | 337 |
338 PageTable* Get(int index) const { return tables_[index]; } | 338 PageTable* Get(int index) const { return tables_[index]; } |
339 void Set(int index, PageTable* table) { tables_[index] = table; } | 339 void Set(int index, PageTable* table) { tables_[index] = table; } |
340 | 340 |
341 private: | 341 private: |
342 #ifdef FLETCH32 | 342 #ifdef DARTINO32 |
343 PageTable* tables_[1 << 10]; | 343 PageTable* tables_[1 << 10]; |
344 #else | 344 #else |
345 PageTable* tables_[1 << 13]; | 345 PageTable* tables_[1 << 13]; |
346 #endif | 346 #endif |
347 }; | 347 }; |
348 | 348 |
349 // ObjectMemory controls all memory used by object heaps. | 349 // ObjectMemory controls all memory used by object heaps. |
350 class ObjectMemory { | 350 class ObjectMemory { |
351 public: | 351 public: |
352 // Allocate a new chunk for a given space. All chunk sizes are | 352 // Allocate a new chunk for a given space. All chunk sizes are |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 private: | 399 private: |
400 // Low-level access to the page table associated with a given | 400 // Low-level access to the page table associated with a given |
401 // address. | 401 // address. |
402 static PageTable* GetPageTable(uword address); | 402 static PageTable* GetPageTable(uword address); |
403 static void SetPageTable(uword address, PageTable* table); | 403 static void SetPageTable(uword address, PageTable* table); |
404 | 404 |
405 // Associate a range of pages with a given space. | 405 // Associate a range of pages with a given space. |
406 static void SetSpaceForPages(uword base, uword limit, Space* space); | 406 static void SetSpaceForPages(uword base, uword limit, Space* space); |
407 | 407 |
408 #ifdef FLETCH32 | 408 #ifdef DARTINO32 |
409 static PageDirectory page_directory_; | 409 static PageDirectory page_directory_; |
410 #else | 410 #else |
411 static PageDirectory* page_directories_[1 << 13]; | 411 static PageDirectory* page_directories_[1 << 13]; |
412 #endif | 412 #endif |
413 static Mutex* mutex_; // Mutex used for synchronized chunk allocation. | 413 static Mutex* mutex_; // Mutex used for synchronized chunk allocation. |
414 | 414 |
415 static Atomic<uword> allocated_; | 415 static Atomic<uword> allocated_; |
416 | 416 |
417 friend class Space; | 417 friend class Space; |
418 friend class SemiSpace; | 418 friend class SemiSpace; |
419 }; | 419 }; |
420 | 420 |
421 inline bool Space::Includes(uword address) const { | 421 inline bool Space::Includes(uword address) const { |
422 return ObjectMemory::IsAddressInSpace(address, this); | 422 return ObjectMemory::IsAddressInSpace(address, this); |
423 } | 423 } |
424 | 424 |
425 } // namespace fletch | 425 } // namespace dartino |
426 | 426 |
427 #endif // SRC_VM_OBJECT_MEMORY_H_ | 427 #endif // SRC_VM_OBJECT_MEMORY_H_ |
OLD | NEW |