| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_VIRTUAL_MEMORY_H_ | 5 #ifndef RUNTIME_VM_VIRTUAL_MEMORY_H_ | 
| 6 #define RUNTIME_VM_VIRTUAL_MEMORY_H_ | 6 #define RUNTIME_VM_VIRTUAL_MEMORY_H_ | 
| 7 | 7 | 
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" | 
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" | 
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57   static bool InSamePage(uword address0, uword address1); | 57   static bool InSamePage(uword address0, uword address1); | 
| 58 | 58 | 
| 59   // Truncate this virtual memory segment. If try_unmap is false, the | 59   // Truncate this virtual memory segment. If try_unmap is false, the | 
| 60   // memory beyond the new end is still accessible, but will be returned | 60   // memory beyond the new end is still accessible, but will be returned | 
| 61   // upon destruction. | 61   // upon destruction. | 
| 62   void Truncate(intptr_t new_size, bool try_unmap = true); | 62   void Truncate(intptr_t new_size, bool try_unmap = true); | 
| 63 | 63 | 
| 64   // Commit a reserved memory area, so that the memory can be accessed. | 64   // Commit a reserved memory area, so that the memory can be accessed. | 
| 65   bool Commit(uword addr, intptr_t size, bool is_executable); | 65   bool Commit(uword addr, intptr_t size, bool is_executable); | 
| 66 | 66 | 
| 67   bool embedder_allocated() const { return embedder_allocated_; } | 67   bool vm_owns_region() const { return vm_owns_region_; } | 
| 68 | 68 | 
| 69   static VirtualMemory* ForExternalPage(void* pointer, uword size); | 69   static VirtualMemory* ForImagePage(void* pointer, uword size); | 
| 70 | 70 | 
| 71  private: | 71  private: | 
| 72   static VirtualMemory* ReserveInternal(intptr_t size); | 72   static VirtualMemory* ReserveInternal(intptr_t size); | 
| 73 | 73 | 
| 74   // Free a sub segment. On operating systems that support it this | 74   // Free a sub segment. On operating systems that support it this | 
| 75   // can give back the virtual memory to the system. Returns true on success. | 75   // can give back the virtual memory to the system. Returns true on success. | 
| 76   static bool FreeSubSegment(int32_t handle, void* address, intptr_t size); | 76   static bool FreeSubSegment(int32_t handle, void* address, intptr_t size); | 
| 77 | 77 | 
| 78   // This constructor is only used internally when reserving new virtual spaces. | 78   // This constructor is only used internally when reserving new virtual spaces. | 
| 79   // It does not reserve any virtual address space on its own. | 79   // It does not reserve any virtual address space on its own. | 
| 80   explicit VirtualMemory(const MemoryRegion& region, int32_t handle = 0) | 80   explicit VirtualMemory(const MemoryRegion& region, int32_t handle = 0) | 
| 81       : region_(region.pointer(), region.size()), | 81       : region_(region.pointer(), region.size()), | 
| 82         reserved_size_(region.size()), | 82         reserved_size_(region.size()), | 
| 83         handle_(handle), | 83         handle_(handle), | 
| 84         embedder_allocated_(false) {} | 84         vm_owns_region_(true) {} | 
| 85 | 85 | 
| 86   MemoryRegion region_; | 86   MemoryRegion region_; | 
| 87 | 87 | 
| 88   // The size of the underlying reservation not yet given back to the OS. | 88   // The size of the underlying reservation not yet given back to the OS. | 
| 89   // Its start coincides with region_, but its size might not, due to Truncate. | 89   // Its start coincides with region_, but its size might not, due to Truncate. | 
| 90   intptr_t reserved_size_; | 90   intptr_t reserved_size_; | 
| 91 | 91 | 
| 92   int32_t handle_; | 92   int32_t handle_; | 
| 93 | 93 | 
| 94   static uword page_size_; | 94   static uword page_size_; | 
| 95 | 95 | 
| 96   // True for a region provided by the embedder. | 96   // False for a part of a snapshot added directly to the Dart heap, which | 
| 97   bool embedder_allocated_; | 97   // belongs to the the embedder and must not be deallocated or have its | 
|  | 98   // protection status changed by the VM. | 
|  | 99   bool vm_owns_region_; | 
| 98 | 100 | 
| 99   DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory); | 101   DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory); | 
| 100 }; | 102 }; | 
| 101 | 103 | 
| 102 }  // namespace dart | 104 }  // namespace dart | 
| 103 | 105 | 
| 104 #endif  // RUNTIME_VM_VIRTUAL_MEMORY_H_ | 106 #endif  // RUNTIME_VM_VIRTUAL_MEMORY_H_ | 
| OLD | NEW | 
|---|