RFR: 8339492: StackMapDecoder::writeFrames makes lots of allocations [v2]

Claes Redestad redestad at openjdk.org
Wed Sep 4 13:11:22 UTC 2024


On Tue, 3 Sep 2024 17:33:37 GMT, David M. Lloyd <duke at openjdk.org> wrote:

>> Please review this change, which reduces the number of allocations in `StackMapDecoder::writeFrames` by using a sorted array instead of a `TreeMap<Integer, ...>` to sort and uniquify entries before writing. It also adds a validation missed by the original implementation.
>> 
>> Tested using `StackMapsTest`.
>
> David M. Lloyd has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review feedback: reject duplicate stack map entries

LGTM

AFAICT before this we'd only call `DirectCodeBuilder::labelToBci` once per label, but now we'll do so roughly `2*n*log(n) + n` times. I would assume getting rid of the `TreeMap` and `Integer` key allocations more than makes up for this, though. Do we have any JMH tests where `writeFrames` is a significant contributor we could check?

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

Marked as reviewed by redestad (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20841#pullrequestreview-2280151482


More information about the core-libs-dev mailing list