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

Joel Sikström jsikstro at openjdk.org
Wed Jun 11 10:22:28 UTC 2025


On Wed, 11 Jun 2025 09:46:21 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

>> Hello,
>> 
>> The main purpose of this RFE is to merge the ZAllocator class into ZObjectAllocator. After [JDK-8353184](https://bugs.openjdk.org/browse/JDK-8353184), ZAllocator has essentially become a mirror of ZObjectAllocator, with a few tweaks for different behavior for eden or relocation allocations. The goal is to make the code a bit easier to follow and generalise the different paths for eden and relocation allocations to a shared path.
>> 
>> The storage of the static allocators for each ZPageAge has been moved from ZHeap into ZObjectAllocator, and initilization is done via ZInitialize (calling into `ZObjectAllocator::initialize()`) instead of in the ZHeap constructor.
>> 
>> Instead of storing eden and relocation allocators separately, they are now in a single array, which makes iterating over the allocators more straightforward (when retiring pages for example). I have opted to keep the getter for the eden allocator (`ZObjectAllocator::eden()`), but it can be swapped to `ZObjectAllocator::allocator(ZPageAge::eden)` if we prefer that instead.
>> 
>> `ZObjectAllocator::{alloc_object, alloc_object_for_relocation}` have been merged into a single `ZObjectAllocator::alloc_object()`, with a check to add a non-blocking flag or not. The null-check for eden allocation has been moved to its single caller in zCollectedHeap.cpp. This makes the API in ZObjectAllocator more general and we don't have to track methods for both eden and relocation allocations.
>> 
>> `_relocation_allocators` has been moved from ZAllocator to ZObjectAllocator and renamed to `NumRelocationAllocators` to be more consistent with the naming style in ZGC.
>> 
>> Testing:
>> * Oracle's tier 1-5
>
> Joel Sikström has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - -Wconversion fixes
>  - Intermediate alloc_object in ZHeap

I fixed some offline feedback from @xmas92 on keeping the callsite in ZCollectedHeap clean and delegating the actual work (the null-check and out-of-memory accounting) to ZHeap.

I also fixed some -Wconversion warnings in zObjectAllocator.inline.hpp.

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

PR Comment: https://git.openjdk.org/jdk/pull/25693#issuecomment-2962092262


More information about the hotspot-gc-dev mailing list