RFR: 8364128: Improve gathering of cpu feature names using stringStream [v4]

Johan Sjölen jsjolen at openjdk.org
Tue Aug 5 14:11:10 UTC 2025


On Wed, 30 Jul 2025 15:17:57 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:

>> This PR implements the code for cpu features names string using ~FormatBuffer~ stringStream. ~It also improves and extends FormatBuffer with an additional method that appends comma separated strings to the buffer.~ It also adds a method to stringStream that that appends separated strings separated by a delimiter to the buffer.  This is useful in creating the cpu features names string.
>> This code will also be useful in Leyden to implement cpu feature check for AOTCodeCache [0].
>> Platforms affected: x86-64 and aarch64
>> Other platforms can be done if and when Leyden changes are ported to them.
>> 
>> [0] https://github.com/openjdk/leyden/pull/84
>
> Ashutosh Mehra has updated the pull request incrementally with one additional commit since the last revision:
> 
>   More compile failure fix
>   
>   Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>

This looks good to me! Added a few comments on the `join` method.

src/hotspot/share/utilities/ostream.hpp line 170:

> 168: 
> 169:    // Append strings returned by gen, separating each with separator.
> 170:    // Stops when gen returns null or when buffer is out of space.

We never really stop when the buffer runs out of space.

src/hotspot/share/utilities/ostream.hpp line 172:

> 170:    // Stops when gen returns null or when buffer is out of space.
> 171:    template <typename Generator>
> 172:    void join(Generator gen, const char* separator) {

We can move this to the `outputStream` class instead!

src/hotspot/share/utilities/ostream.hpp line 181:

> 179:        str = gen();
> 180:      }
> 181:      return;

Let's delete this return

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

Marked as reviewed by jsjolen (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26515#pullrequestreview-3088470522
PR Review Comment: https://git.openjdk.org/jdk/pull/26515#discussion_r2254477968
PR Review Comment: https://git.openjdk.org/jdk/pull/26515#discussion_r2254478897
PR Review Comment: https://git.openjdk.org/jdk/pull/26515#discussion_r2254473839


More information about the hotspot-dev mailing list