RFR: 8358586: ZGC: Combine ZAllocator and ZObjectAllocator [v4]
Joel Sikström
jsikstro at openjdk.org
Thu Jun 12 13:17:19 UTC 2025
> 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 one additional commit since the last revision:
Friend class ValueObjBlock
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/25693/files
- new: https://git.openjdk.org/jdk/pull/25693/files/9412bae5..12a3b140
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=25693&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=25693&range=02-03
Stats: 4 lines in 1 file changed: 3 ins; 1 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/25693.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25693/head:pull/25693
PR: https://git.openjdk.org/jdk/pull/25693
More information about the hotspot-gc-dev
mailing list