RFR: 8224878: Use JVMFlag parameters instead of name strings
Stefan Karlsson
stefan.karlsson at oracle.com
Tue May 28 11:35:25 UTC 2019
Hi all,
Please review this patch to use JVMFlag parameters instead of name
strings in the JVM flag handling code.
https://bugs.openjdk.java.net/browse/JDK-8224878
The intention is to reduce the places where the API uses "const char*
name" parameters to describe a JVM flag, and instead use a JVMFlag* when
performing various flag handling code. The places where we translate
from "const char* name" to JVMFlag* has been pushed to the outer layers
of the code, which explicitly uses the JVMFlag::find_flag functions.
This allows us to replace strcmp with simple JVMFlag pointer equality
checks in jvmFlagRangeList.cpp and jvmFlagConstraintList.cpp.
This gets rid of the need to store a typed pointer to the flag in
jvmFlagRangeList.cpp and jvmFlagConstraintList.cpp.
This gets rid of the the need to propagate the 'allow_locked' and
'return_flag' parameters down the call chain. For example, see the
changes to JVMFlag::<type>At and JVMFlag::<type>AtPut:
- static JVMFlag::Error intAt(const char* name, int* value, bool
allow_locked = false, bool return_flag = false) { return
intAt(name, strlen(name), value, allow_locked, return_flag); }
+ static JVMFlag::Error intAt(const JVMFlag* flag, int* value);
static JVMFlag::Error intAtPut(JVMFlag* flag, int* value,
JVMFlag::Flags origin);
- static JVMFlag::Error intAtPut(const char* name, size_t len, int*
value, JVMFlag::Flags origin);
- static JVMFlag::Error intAtPut(const char* name, int* value,
JVMFlag::Flags origin) { return intAtPut(name, strlen(name), value,
origin); }
It changes the JVMFlag::find_flag API. The way it uses default values
have a surprising effect for users of those functions. find_flag(name)
searches among all flags (even locked and constants), while
find_flag(name, strlen(name)) doesn't return locked or constants flags.
To make it less likely to accidentally call the wrong version, this has
been changed to the following:
* JVMFlag::find_flag(name) - Fetches the flag if it is available
(unlocked and not constant).
* JVMFlag::find_flag_unrestricted(name) - Fetches the flag even if it is
locked or a constant.
Removed the unused JVMFlag::wasSetOnCmdline.
Small cleanups
- Renamed address_of_flag to flag_from_enum
- Renamed local JVMFlag* variable from results to flag
- Use initializer lists
- Removed superfluous semicolons
I don't mind splitting patch up into more than one RFE, if that seems
more appropriate.
Tested with:
- test/hotspot/jtreg/runtime/CommandLine
- tier1 (tier2-3 80% done)
Suggestions on other testing is appreciated.
Thanks,
StefanK
More information about the hotspot-runtime-dev
mailing list