RFR: 8275162: Replace 'def' macros in mutexLocker.cpp

Coleen Phillimore coleenp at openjdk.java.net
Fri Oct 22 13:37:09 UTC 2021


On Fri, 22 Oct 2021 07:13:58 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> This patch removes the 'def' macros from mutexLocker.cpp so it can use the default values for _allow_vm_block when possible and no more macro.
>> Tested with tier1-3 with product and debug builds.
>
> src/hotspot/share/runtime/mutexLocker.cpp line 203:
> 
>> 201:     G1DetachedRefinementStats_lock = new PaddedMutex(Mutex::nosafepoint-2, "G1DetachedRefinementStats_lock");
>> 202: 
>> 203:     FreeList_lock              = new PaddedMutex(Mutex::service-1, "FreeList_lock");
> 
> This makes the code more verbose. You have to type FreeList_lock twice, and there's no guarantee that you didn't have a typo in the quoted string.
> 
> If your goal is to use the default value for the `true` parameter, this can be done with VARARG macros, like
> 
> 
>    def(FreeList_lock,        PaddedMutex, service-1);
>    def(ExceptionCache_lock , PaddedMutex, safepoint, false);
> 
> 
> You can also avoid using `Mutex::` everywhere by doing this first:
> 
> 
>   const Mutex::Rank service = Mutex::service;
>   const Mutex::Rank nosafepoint = Mutex::nosafepoint;

Thanks Ioi.

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

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


More information about the hotspot-runtime-dev mailing list