RFR: 8301404: Replace os::malloc with os::realloc, so we only have 1 code path
Gerard Ziemski
gziemski at openjdk.org
Mon Feb 20 16:18:27 UTC 2023
On Fri, 17 Feb 2023 21:58:11 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> Not a big fan, tbh. I find your code harder to decipher than the original version.
The current code implements `realloc(NULL)` in terms of `malloc()`, I just turned it around and implemented `malloc()` on top of `realloc(NULL)`, which allowed us to remove an almost identical 2nd path for allocating the memory.
This resulted in net benefit of being able to remove 58 lines of code. That is 58 lines of code less for anyone who needs to parse the allocation code.
I have not written even one new line of code here, just rearranged the existing code. It will definitively look less familiar to those who tend to look/work with this area, like you. But for the others, who are new, it will certainly make it less effort to follow it.
> Malloc and realloc are different things, and having different code paths for them makes more sense than mixing them together.
I'm concerned here, it's totally possible that I missed something and misunderstood the code, but how are they different? Why would we want them different?
Isn't this enhancement a proof that they need not be different?
> I am currently revising NMTPreInit (see https://github.com/tstuefe/jdk/tree/make-nmt-preinit-cheaper-for-nmt-off) and plan to continue this work after my vacation in march; it would be nice if we could synchronize work then.
Absolutely can and will wait.
-------------
PR: https://git.openjdk.org/jdk/pull/12621
More information about the hotspot-runtime-dev
mailing list