RFR: 8296785: Use realloc for CHeap-allocated BitMaps [v3]
Axel Boldt-Christmas
aboldtch at openjdk.org
Thu Nov 17 14:03:21 UTC 2022
On Wed, 16 Nov 2022 17:03:21 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> Today CHeap allocated bitmaps don't resize with realloc. I'd like to change that by fixing that by adding support for realloc in the ArrayAllocator classes, and then use that when resizing the bitmaps.
>>
>> We've been using and testing one version of this patch in the Generational ZGC repository for a while now. That version is slightly different because of recent rewrites of the bitmaps, but in essence the same. See:
>> https://github.com/openjdk/zgc/commit/ca692f686bda8d86d3786c2afc782bfdc54fbdfc
>
> Stefan Karlsson has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
>
> - Fixes after merge
> - Merge remote-tracking branch 'upstream/master' into 8296785_bitmap_realloc
> - 8296785: Use realloc for CHeap-allocated BitMaps
> - Merge remote-tracking branch 'upstream/master' into 8296774_bitmap_stricter_construction
> - 8296774: Removed default MEMFLAGS value from CHeapBitMap
Lgtm.
A comment on MallocArrayAllocator. These are in general very dangerous to use (and our macors that use AllocateHeap directly) with regards to C++ types and lifetimes. Bitmap only uses this for primitive types which is generally safe.
In general construction and destruction of the objects must be handled explicitly and carefully. (Outside of MallocArrayAllocator, which only allocates some underlying memory, it does not create any C++ objects)
Reallocation is even harder, as it is (probably) impossible to statically determine if a type T is fine to reallocate via relocation. So users of MallocArrayAllocator<E>::reallocate must consider carefully if this is ok for the type E. (I mean ok in the sense that it will generate the correct behaviour on our supported compilers, not in the sense that it is ok w.r.t. C++ object lifetimes)
-------------
Marked as reviewed by aboldtch (Committer).
PR: https://git.openjdk.org/jdk/pull/11102
More information about the hotspot-dev
mailing list