RFR: 8262328: Templatize JVMFlag boilerplate access methods [v2]
David Holmes
dholmes at openjdk.java.net
Tue Apr 6 02:24:24 UTC 2021
On Mon, 5 Apr 2021 17:42:49 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> We have a bunch of boilerplate method like:
>>
>> JVMFlagAccess::boolAtPut (JVMFlag* f, bool* v, JVMFlagOrigin origin)
>> JVMFlagAccess::intAtPut (JVMFlag* f, int* v, JVMFlagOrigin origin)
>> JVMFlagAccess::uintAtPut (JVMFlag* f, uint* v, JVMFlagOrigin origin)
>> ...
>>
>> Similarly, we also have 8 different functions: JVMFlag::{set_bool, set_int, set_intx, ...}
>>
>> We should replace such patterns with
>>
>> template <typename T>
>> JVMFlagAccess::set(JVMFlag* f, T* value, JVMFlagOrigin origin)
>>
>> This would allow us to templatize the 8x boilerplate functions in writeableFlags.cpp.
>>
>> The flag access code in whitebox.cpp can also be improved.
>
> Ioi Lam has updated the pull request incrementally with two additional commits since the last revision:
>
> - removed unnecessary #include
> - Restored <JVM_FLAG_TYPE(type)> in templates so we can require exact types (i.e., cannot mix size_t and uintx even they might be the same type of some platforms)
Hi Ioi,
In terms of readability and writeability I prefer <type>AtPut() over set<JVM_FLAG_TYPE(type)>(). Is there any way to push the JVM_FLAG_TYPE down a level so it doesn't shout at you when reading the code? set<type>() would look much much better.
Thanks,
David
-------------
PR: https://git.openjdk.java.net/jdk/pull/3318
More information about the hotspot-dev
mailing list