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/zPhysicalMemoryBacking) 30 31 class ZPhysicalMemorySegment : public CHeapObj<mtGC> { 32 private: 33 uintptr_t _start; 34 uintptr_t _end; 35 bool _committed; 36 37 public: 38 ZPhysicalMemorySegment(); 39 ZPhysicalMemorySegment(uintptr_t start, size_t size, bool committed); 40 41 uintptr_t start() const; 42 uintptr_t end() const; 43 size_t size() const; 44 45 bool is_committed() const; 46 void set_committed(bool committed); 47 }; 48 49 class ZPhysicalMemory { 50 private: 51 uint32_t _nsegments_max; 52 uint32_t _nsegments; 53 ZPhysicalMemorySegment* _segments; 54 55 void insert_segment(uint32_t index, uintptr_t start, size_t size, bool committed); 56 void replace_segment(uint32_t index, uintptr_t start, size_t size, bool committed); 57 void remove_segment(uint32_t index); 58 59 public: 60 ZPhysicalMemory(); 61 ZPhysicalMemory(const ZPhysicalMemorySegment& segment); 62 ZPhysicalMemory(const ZPhysicalMemory& pmem); 63 const ZPhysicalMemory& operator=(const ZPhysicalMemory& pmem); 64 ~ZPhysicalMemory(); 65 66 bool is_null() const; 67 size_t size() const; 68 69 uint32_t nsegments() const; 70 const ZPhysicalMemorySegment& segment(uint32_t index) const; 71 72 void add_segments(const ZPhysicalMemory& pmem); 73 void remove_segments(); 74 75 void add_segment(const ZPhysicalMemorySegment& segment); 76 bool commit_segment(uint32_t index, size_t size); 77 bool uncommit_segment(uint32_t index, size_t size); 78 79 ZPhysicalMemory split(size_t size); 80 ZPhysicalMemory split_committed(); 81 }; 82 83 class ZPhysicalMemoryManager { 84 private: 85 ZPhysicalMemoryBacking _backing; 86 ZMemoryManager _manager; 87 88 void nmt_commit(uintptr_t offset, size_t size) const; 89 void nmt_uncommit(uintptr_t offset, size_t size) const; 90 91 void pretouch_view(uintptr_t addr, size_t size) const; 92 void map_view(uintptr_t addr, const ZPhysicalMemory& pmem) const; 93 void unmap_view(uintptr_t addr, size_t size) const; 94 95 public: 96 ZPhysicalMemoryManager(size_t max_capacity); 97 | 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/zArray.hpp" 28 #include "gc/z/zMemory.hpp" 29 #include "memory/allocation.hpp" 30 #include OS_HEADER(gc/z/zPhysicalMemoryBacking) 31 32 class ZPhysicalMemorySegment : public CHeapObj<mtGC> { 33 private: 34 uintptr_t _start; 35 uintptr_t _end; 36 bool _committed; 37 38 public: 39 ZPhysicalMemorySegment(); 40 ZPhysicalMemorySegment(uintptr_t start, size_t size, bool committed); 41 42 uintptr_t start() const; 43 uintptr_t end() const; 44 size_t size() const; 45 46 bool is_committed() const; 47 void set_committed(bool committed); 48 }; 49 50 class ZPhysicalMemory { 51 private: 52 ZArray<ZPhysicalMemorySegment> _segments; 53 54 void insert_segment(int index, uintptr_t start, size_t size, bool committed); 55 void replace_segment(int index, uintptr_t start, size_t size, bool committed); 56 void remove_segment(int index); 57 58 public: 59 ZPhysicalMemory(); 60 ZPhysicalMemory(const ZPhysicalMemorySegment& segment); 61 ZPhysicalMemory(const ZPhysicalMemory& pmem); 62 const ZPhysicalMemory& operator=(const ZPhysicalMemory& pmem); 63 64 bool is_null() const; 65 size_t size() const; 66 67 int nsegments() const; 68 const ZPhysicalMemorySegment& segment(int index) const; 69 70 void add_segments(const ZPhysicalMemory& pmem); 71 void remove_segments(); 72 73 void add_segment(const ZPhysicalMemorySegment& segment); 74 bool commit_segment(int index, size_t size); 75 bool uncommit_segment(int index, size_t size); 76 77 ZPhysicalMemory split(size_t size); 78 ZPhysicalMemory split_committed(); 79 }; 80 81 class ZPhysicalMemoryManager { 82 private: 83 ZPhysicalMemoryBacking _backing; 84 ZMemoryManager _manager; 85 86 void nmt_commit(uintptr_t offset, size_t size) const; 87 void nmt_uncommit(uintptr_t offset, size_t size) const; 88 89 void pretouch_view(uintptr_t addr, size_t size) const; 90 void map_view(uintptr_t addr, const ZPhysicalMemory& pmem) const; 91 void unmap_view(uintptr_t addr, size_t size) const; 92 93 public: 94 ZPhysicalMemoryManager(size_t max_capacity); 95 |