RFR: 8297718: Make NMT free:ing protocol more granular [v2]

Thomas Stuefe stuefe at openjdk.org
Thu Dec 8 07:43:03 UTC 2022


On Thu, 8 Dec 2022 02:37:11 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > I quickly find this more complex than another line of plain code at the call site would be.
> 
> My concern with the latter is the breaking of encapsulation and pollution of the callsite with details it has no business knowing about. To some extent some knowledge has to leak to the callsite to know either which API to call, or which flag parameters to pass, but that should be minimised and as generic as possible.

Okay, I see your point (and @gerard-ziemski ). But having to know when to pass false, and what false does, also breaks encapsulation. 

A good encapsulation would be breaking MemTracker::record_free into three clearly named APIs then, without demanding knowledge about what they do:


opaque_thingy MemTracker::prepare_free(void* payload);
void MemTracker::commit_free(opaque_thingy);
void MemTracker::rollback_free(opaque_thingy);

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

PR: https://git.openjdk.org/jdk/pull/11390


More information about the hotspot-runtime-dev mailing list