7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #ifndef SHARE_GC_Z_ZPHYSICALMEMORY_HPP 25 #define SHARE_GC_Z_ZPHYSICALMEMORY_HPP 26 27 #include "memory/allocation.hpp" 28 #include OS_HEADER(gc/z/zPhysicalMemoryBacking) 29 30 class ZPhysicalMemorySegment : public CHeapObj<mtGC> { 31 private: 32 uintptr_t _start; 33 uintptr_t _end; 34 35 public: 36 ZPhysicalMemorySegment(); 37 ZPhysicalMemorySegment(uintptr_t start, size_t size); 38 39 uintptr_t start() const; 40 uintptr_t end() const; 41 size_t size() const; 42 }; 43 44 class ZPhysicalMemory { 45 private: 46 size_t _nsegments; 47 ZPhysicalMemorySegment* _segments; 48 49 public: 50 ZPhysicalMemory(); 51 ZPhysicalMemory(const ZPhysicalMemorySegment& segment); 52 ZPhysicalMemory(const ZPhysicalMemory& pmem); 53 const ZPhysicalMemory& operator=(const ZPhysicalMemory& pmem); 54 ~ZPhysicalMemory(); 55 56 bool is_null() const; 57 size_t size() const; 58 59 size_t nsegments() const; 60 const ZPhysicalMemorySegment& segment(size_t index) const; 61 void add_segment(const ZPhysicalMemorySegment& segment); 62 63 ZPhysicalMemory split(size_t size); 64 }; 65 66 class ZPhysicalMemoryManager { 67 private: 68 ZPhysicalMemoryBacking _backing; 69 70 void nmt_commit(const ZPhysicalMemory& pmem, uintptr_t offset) const; 71 void nmt_uncommit(const ZPhysicalMemory& pmem, uintptr_t offset) const; 72 73 public: 74 bool is_initialized() const; 75 76 void warn_commit_limits(size_t max) const; 77 bool supports_uncommit(); 78 79 size_t commit(size_t size); 80 size_t uncommit(size_t size); 81 82 ZPhysicalMemory alloc(size_t size); 83 void free(const ZPhysicalMemory& pmem); 84 85 void pretouch(uintptr_t offset, size_t size) const; 86 87 void map(const ZPhysicalMemory& pmem, uintptr_t offset) const; 88 void unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; 89 90 void debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const; 91 void debug_unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; | 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #ifndef SHARE_GC_Z_ZPHYSICALMEMORY_HPP 25 #define SHARE_GC_Z_ZPHYSICALMEMORY_HPP 26 27 #include "gc/z/zMemory.hpp" 28 #include "memory/allocation.hpp" 29 #include OS_HEADER(gc/z/zBackingFile) 30 31 class ZPhysicalMemorySegment : public CHeapObj<mtGC> { 32 private: 33 uintptr_t _start; 34 uintptr_t _end; 35 36 public: 37 ZPhysicalMemorySegment(); 38 ZPhysicalMemorySegment(uintptr_t start, size_t size); 39 40 uintptr_t start() const; 41 uintptr_t end() const; 42 size_t size() const; 43 }; 44 45 class ZPhysicalMemory { 46 private: 47 size_t _nsegments; 48 ZPhysicalMemorySegment* _segments; 49 50 public: 51 ZPhysicalMemory(); 52 ZPhysicalMemory(const ZPhysicalMemorySegment& segment); 53 ZPhysicalMemory(const ZPhysicalMemory& pmem); 54 const ZPhysicalMemory& operator=(const ZPhysicalMemory& pmem); 55 ~ZPhysicalMemory(); 56 57 bool is_null() const; 58 size_t size() const; 59 60 size_t nsegments() const; 61 const ZPhysicalMemorySegment& segment(size_t index) const; 62 void add_segment(const ZPhysicalMemorySegment& segment); 63 64 ZPhysicalMemory split(size_t size); 65 }; 66 67 class ZPhysicalMemoryManager { 68 private: 69 ZBackingFile _backing; 70 ZMemoryManager _committed; 71 ZMemoryManager _uncommitted; 72 73 void nmt_commit(const ZPhysicalMemory& pmem, uintptr_t offset) const; 74 void nmt_uncommit(const ZPhysicalMemory& pmem, uintptr_t offset) const; 75 76 void pretouch_view(uintptr_t addr, size_t size) const; 77 void map_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; 78 void unmap_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; 79 80 public: 81 bool is_initialized() const; 82 83 void warn_commit_limits(size_t max) const; 84 bool supports_uncommit(); 85 86 size_t commit(size_t size); 87 size_t uncommit(size_t size); 88 89 ZPhysicalMemory alloc(size_t size); 90 void free(const ZPhysicalMemory& pmem); 91 92 void pretouch(uintptr_t offset, size_t size) const; 93 94 void map(const ZPhysicalMemory& pmem, uintptr_t offset) const; 95 void unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; 96 97 void debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const; 98 void debug_unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; |