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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 bool embedder_allocated() const { return embedder_allocated_; } | 67 bool embedder_allocated() const { return embedder_allocated_; } |
68 | 68 |
69 static VirtualMemory* ForExternalPage(void* pointer, uword size); | 69 static VirtualMemory* ForExternalPage(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(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 embedder_allocated_(false) {} |
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 // True for a region provided by the embedder. |
97 bool embedder_allocated_; | 97 bool embedder_allocated_; |
98 | 98 |
99 DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory); | 99 DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace dart | 102 } // namespace dart |
103 | 103 |
104 #endif // RUNTIME_VM_VIRTUAL_MEMORY_H_ | 104 #endif // RUNTIME_VM_VIRTUAL_MEMORY_H_ |
OLD | NEW |