RFR: 8337563: NMT: rename MEMFLAGS to MemFlag
Thomas Stuefe
stuefe at openjdk.org
Fri Aug 30 07:22:21 UTC 2024
On Wed, 7 Aug 2024 17:13:06 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:
> Please review this cleanup, where we rename `MEMFLAGS` to `MemType`.
>
> `MEMFLAGS` implies that we can use more than one at the same time, but those are exclusive values, so `MemType` is much more suitable name.
>
> There is a bunch of other related cleanup that we can do, but I will leave for follow up issues such as [NMT: rename NMTUtil::flag to NMTUtil::type](https://bugs.openjdk.org/browse/JDK-8337836)
I am not against moving NMT into a namespace, but we should be sure that is what we want. Introducing a new namespace is a larger scope than just renaming a single type.
For example: should the whole of NMT, including its outside-facing interface, including the enum values itself, go into the new NMT namespace? So, do we do this now:
NMT::MemFlag flag = NMT::mtGC;
NMT::MemTracker::record_malloc(p, l, flag);
NMT::MemTracker::report();
? If yes, that affects more than just the type name.
Do we omit the namespace qualifier when inside NMT?
When outside NMT, do we sprinkle `using NMT` around to avoid getting RSI from typing "NMT::"? That is possible, but now we get:
MemFlag flag = mtGC;
MemTracker::record_malloc(p, l, flag);
so the "NMT" prefix is gone. And we have both NMT::MemFlag and MemFlag, so people grepping for stuff need to look for both variants.
Or do you plan to just put this single enum into the namespace? As in
namespace NMT { enum MEMFLAGS ... };
?
But having a namespace and keeping 99% of associated code outside of that namespace would be a very weird choice. And the enum values would have to be in that namespace in any case, so we wont get around having to qualify all "mtXXX" flags NMT::mtXXX.
---
None of these are hard reasons to avoid namespaces. I used namespace "metaspace" back when doing Elastic Metaspace, and I have argued for their selective use in the past. But changes like these tend to fan out a bit more than one initially thinks.
I also really prefer namespaces to be lowercase, since that is the usual way they are written ("std", "boost" etc)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20497#issuecomment-2320312099
More information about the shenandoah-dev
mailing list