RFR: 8301403: Eliminate memory allocations in JVMFlag::printFlags during signal handling [v11]
Gerard Ziemski
gziemski at openjdk.org
Fri Jul 26 15:09:33 UTC 2024
On Fri, 26 Jul 2024 14:50:47 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:
>> Allocating memory while handling an error should be avoided, however `JVMFlag::printFlags()` is used by crash log and it allocates memory to print flags sorted (using qsort).
>>
>> We avoid memory allocation by using BitMapView (using stack storage for array of indices) for markers in a simple O(n^2) algorithm that lets us print in alphabetical order. Performance was measured and it's not an issue.
>>
>> Running MACH5 tests...
>
> Gerard Ziemski has updated the pull request incrementally with one additional commit since the last revision:
>
> need 32 bit version of LogBytesPerWord too
One way around the requirement for `constepxr` would be to dynamically allocate memory on stack using something like `alloca()` API.
Again, under the man page BUGS section it says:
` alloca() is machine and compiler dependent; its use is discouraged.
`
but then again we already use it in hotspot in a few places. Pick your poison I guess.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20202#issuecomment-2252962593
More information about the hotspot-runtime-dev
mailing list