RFR: 8301404: Factor out os::malloc with os::realloc common code, so that we only have 1 code path [v7]

Stefan Karlsson stefank at openjdk.org
Tue Apr 1 15:43:19 UTC 2025


On Tue, 1 Apr 2025 13:18:37 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:

> > I took a deeper look at the proposed patch and I'm still not convinced that this is a net positive cleanup. The added shared code now contains new branches to sort out the difference between malloc and realloc.
> > FWIW, I poked around at the original code to see what it would look to go the other way. Push NMT-specific code deeper down so that the higher-level functions get clearer and maybe easier to maintain. If you want to take a look, I've a branch for that here: [master...stefank:jdk:24189_alternative](https://github.com/openjdk/jdk/compare/master...stefank:jdk:24189_alternative)
> 
> I see what you were looking for - you have split and shuffled the code around into logical units. It is definitively an improvement over the existing code and I do like it, but it is not addressing at all the reason I personally started to look into this, which was to share as much code as possible between realloc and malloc (or just outright implement malloc in terms of realloc), so that any NMT interaction could be reduced to just one common path.
> 
> Still, I think this is a definite improvement and I would personally take it.
> 
> Thank you for all your work! Can we get this into a PR please?

Sure. But let's see what other people delving into this area think.

> 
> Also, one thing in your PR would be to change either:
> 
> `realloc_impl` --> `realloc_inner`
> 
> or:
> 
> `malloc_inner` --> `malloc_impl`

Thanks for finding that. I went back-and-forth between the two names and ended up using both.

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

PR Comment: https://git.openjdk.org/jdk/pull/24189#issuecomment-2769787148


More information about the hotspot-runtime-dev mailing list