--- old/src/hotspot/share/gc/z/zPhysicalMemory.hpp 2020-05-18 23:08:35.819867809 +0200 +++ new/src/hotspot/share/gc/z/zPhysicalMemory.hpp 2020-05-18 23:08:35.560859407 +0200 @@ -32,21 +32,30 @@ private: uintptr_t _start; uintptr_t _end; + bool _committed; public: ZPhysicalMemorySegment(); - ZPhysicalMemorySegment(uintptr_t start, size_t size); + ZPhysicalMemorySegment(uintptr_t start, size_t size, bool committed); uintptr_t start() const; uintptr_t end() const; size_t size() const; + + bool is_committed() const; + void set_committed(bool committed); }; class ZPhysicalMemory { private: - size_t _nsegments; + uint32_t _nsegments_max; + uint32_t _nsegments; ZPhysicalMemorySegment* _segments; + void insert_segment(uint32_t index, uintptr_t start, size_t size, bool committed); + void replace_segment(uint32_t index, uintptr_t start, size_t size, bool committed); + void remove_segment(uint32_t index); + public: ZPhysicalMemory(); ZPhysicalMemory(const ZPhysicalMemorySegment& segment); @@ -57,24 +66,30 @@ bool is_null() const; size_t size() const; - size_t nsegments() const; - const ZPhysicalMemorySegment& segment(size_t index) const; + uint32_t nsegments() const; + const ZPhysicalMemorySegment& segment(uint32_t index) const; + + void add_segments(const ZPhysicalMemory& pmem); + void transfer_segments(ZPhysicalMemory& pmem); + void add_segment(const ZPhysicalMemorySegment& segment); + bool commit_segment(uint32_t index, size_t size); + bool uncommit_segment(uint32_t index, size_t size); ZPhysicalMemory split(size_t size); + ZPhysicalMemory split_committed(); }; class ZPhysicalMemoryManager { private: ZPhysicalMemoryBacking _backing; - ZMemoryManager _committed; - ZMemoryManager _uncommitted; + ZMemoryManager _manager; void nmt_commit(const ZPhysicalMemory& pmem, uintptr_t offset) const; void nmt_uncommit(const ZPhysicalMemory& pmem, uintptr_t offset) const; void pretouch_view(uintptr_t addr, size_t size) const; - void map_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; + bool map_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; void unmap_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; public: @@ -82,18 +97,18 @@ bool is_initialized() const; - void warn_commit_limits(size_t max) const; - bool supports_uncommit(); - - size_t commit(size_t size); - size_t uncommit(size_t size); + void warn_commit_limits(size_t max_capacity) const; + bool should_enable_uncommit(size_t min_capacity, size_t max_capacity); - ZPhysicalMemory alloc(size_t size); + void alloc(ZPhysicalMemory& pmem, size_t size); void free(const ZPhysicalMemory& pmem); + bool commit(ZPhysicalMemory& pmem); + bool uncommit(ZPhysicalMemory& pmem); + void pretouch(uintptr_t offset, size_t size) const; - void map(const ZPhysicalMemory& pmem, uintptr_t offset) const; + bool map(const ZPhysicalMemory& pmem, uintptr_t offset) const; void unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; void debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const;