RFR: JDK-8312453: GrowableArray should assert for length overflow on append
Thomas Stuefe
stuefe at openjdk.org
Thu Jul 20 16:09:43 UTC 2023
On Thu, 20 Jul 2023 15:41:56 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> Trivial change to assert that we don't overflow on append.
>
> src/hotspot/share/utilities/growableArray.hpp line 390:
>
>> 388: public:
>> 389: int append(const E& elem) {
>> 390: assert(this->_len != INT_MAX, "Overflow");
>
> This isn't needed. `grow` (via `next_power_of_2`) already does the appropriate overflow checking.
Then we rely on the underlying growth algorithm to always work in power-of-2-steps? What if I want to plug in a different allocator with a different growth cadence?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14951#discussion_r1269679356
More information about the hotspot-dev
mailing list