RFR: 8319709: Make GrowableArrayCHeap copyable [v2]

Emanuel Peter epeter at openjdk.org
Tue Nov 28 08:44:09 UTC 2023


On Thu, 9 Nov 2023 07:17:32 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> What is the motivation for this? Please add something to JBS. Also see query below.
>> 
>> Thanks
>
>> What is the motivation for this? Please add something to JBS. Also see query below.
>> 
>> Thanks
> 
> I need this feature because I want to store `GrowableArray` s within `GrowableArray`s without an unnecessary pointer indirection. I'll add this justification to JBS.

@jdksjolen have you checked all use cases where `GrowableArrayCHeap` is copied? I don't know the state of `GrowableArrayCHeap`, but for `GrowableArray`, there are lots of cases where we actually just would like to "swap" or "move" over the data, and not really duplicate/clone the data. It would just be nice to avoid the overhead of more allocations.

I guess that is the drawback of the copy-constructor: you can very easily miss heavy allocations.

Might it be better to forbid the assignment operator and the copy constructor, and make the copying explicit, i.e. with a `copy_from` method?

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

PR Comment: https://git.openjdk.org/jdk/pull/16559#issuecomment-1829345350


More information about the hotspot-dev mailing list