RFR: 8262328: Templatize JVMFlag boilerplate access methods [v3]

Gerard Ziemski gziemski at openjdk.java.net
Fri Apr 9 16:21:17 UTC 2021


On Tue, 6 Apr 2021 03:56:50 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 one additional commit since the last revision:
> 
>   reinstated JVMFlagAccess::set_{bool,int,uint,...} functions for better readability

Very nice! With all this reduction and "templatization" effort, soon we will be left with one line of a template code at this rate :-)

The only feedback I have is that I wish we could replace `int type_enum` with `FlagType type_enum`

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

Marked as reviewed by gziemski (Committer).

PR: https://git.openjdk.java.net/jdk/pull/3318


More information about the hotspot-dev mailing list