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

Joel Sikström jsikstro at openjdk.org
Mon Jun 16 11:02:58 UTC 2025


On Mon, 16 Jun 2025 09:55:12 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 solution I propose adds a static-only interface called ZObjectAllocator, which interfaces with a number of statically allocated allocators of the class `ZObjectAllocatorImpl`. The ZObjectAllocatorImpl class is the combination of ZAllocator and ZObjectAllocator. The initialization of the static allocators is done via ZInitialize (calling into `ZObjectAllocator::initialize()`) instead of in the ZHeap constructor.
>> 
>> Instead of storing eden and relocation allocators separately, all allocators are now in a single array, which makes over all allocators more straightforward (when retiring pages for example). The allocators are only used in ZObjectAllocator.cpp, and can only be accessed from there, or externally via the static functions in ZObjectAllocator.
>> 
>> `allob_object` and `alloc_tlab` now have intermediate calls with checks in ZHeap, so that ZObjectAllocator only exposes an `alloc_object`. This makes the API in ZObjectAllocator very clean and straightforward to understand. As a side note, I've made `ZHeap::out_of_memory` const so that it can be called from `ZHeap::alloc_object`, which is also const.
>> 
>> The new ZObjectAllocator now stores two static constants: `NumAllocators` and `NumRelocationAllocators`, which replaces `ZAllocator::_relocation_allocators`. I plan on moving `NumRelocationAllocators` to a more sensible place in a future patch.
>> 
>> Testing:
>> * Oracle's tier 1-5
>
> Joel Sikström has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Private member variables in ZObjectAlloactorImpl

FYI: I updated the description of the PR to match the latest changes.

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

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


More information about the hotspot-gc-dev mailing list