RFR: 8358586: ZGC: Combine ZAllocator and ZObjectAllocator [v9]

Axel Boldt-Christmas aboldtch at openjdk.org
Wed Jun 25 13:49:31 UTC 2025


On Wed, 25 Jun 2025 08:00:20 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

>> Hello,
>> 
>> After [JDK-8353184](https://bugs.openjdk.org/browse/JDK-8353184), ZAllocator has essentially become a mirror of ZObjectAllocator, questioning the relevance of ZAllocator. The purpose of this RFE is to combine ZAllocator and ZObjectAllocator into a single class ZObjectAllocator.
>> 
>> The solution I propose moves the new ZObjectAllocator as a data member in ZHeap, and is accessed solely from ZHeap. ZObjectAllocator stores a number of allocators, one for each age. Instead of storing eden and relocation allocators separately, all allocators are now in a single array, which makes it more straightforward to iterate over all allocators (when retiring pages for example). Since the underlying allocator (called PerAge) needs to be constructed with different ages, we can't use the default constructor/initialization, so I have a solution in-place for dealing with this.
>> 
>> Undoing an object allocation has been moved in its entirety (not calling into ZObjectAllocator) to ZHeap, where it fits much better.
>> 
>> Testing:
>> * Oracle's tier 1-5
>
> Joel Sikström has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Copyright year
>  - Move definition of ZDeferredConstructed to inline header

Marked as reviewed by aboldtch (Reviewer).

src/hotspot/share/gc/z/zDeferredConstructed.hpp line 30:

> 28: #include "utilities/globalDefinitions.hpp"
> 29: 
> 30: template<typename T>

Suggestion:

template <typename T>

src/hotspot/share/gc/z/zDeferredConstructed.hpp line 53:

> 51:   const T* operator->() const;
> 52: 
> 53:   template<typename... Ts>

Suggestion:

  template <typename... Ts>

src/hotspot/share/gc/z/zDeferredConstructed.inline.hpp line 79:

> 77: 
> 78: template <typename T>
> 79: template<typename... Ts>

Suggestion:

template <typename... Ts>


We added a few of these without a space in 7e69b98e0548803b85b04b518929c073f8ffaf8c as well. Will have to clean them up at some point :)

src/hotspot/share/gc/z/zDeferredConstructed.inline.hpp line 82:

> 80: inline void ZDeferredConstructed<T>::initialize(Ts&&... args) {
> 81:   assert(!_initialized, "Double initialization forbidden");
> 82:   DEBUG_ONLY(_initialized = true;);

Suggestion:

  DEBUG_ONLY(_initialized = true;)

-------------

PR Review: https://git.openjdk.org/jdk/pull/25693#pullrequestreview-2958223558
PR Review Comment: https://git.openjdk.org/jdk/pull/25693#discussion_r2166761972
PR Review Comment: https://git.openjdk.org/jdk/pull/25693#discussion_r2166761520
PR Review Comment: https://git.openjdk.org/jdk/pull/25693#discussion_r2166759204
PR Review Comment: https://git.openjdk.org/jdk/pull/25693#discussion_r2166759490


More information about the hotspot-gc-dev mailing list