RFR: 8255883: Avoid multiple GeneratedMethodAccessor for same NativeMethod… [v5]
Hui Shi
hshi at openjdk.java.net
Fri Nov 13 03:52:56 UTC 2020
On Thu, 12 Nov 2020 12:23:36 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> @AlanBateman
>>
>>> What is the reason for using an int? I remember there was a suggestion for three states but two states seems okay so curious why it was changed from boolean to int.
>>
>> shipilev suggested not to use sub-word CAS, so change compareAndSetBoolean to compareAndSetInt. Change field "generated" from boolean to int doesn't increase object size (no extra byte/boolean to fold into same word).
>>
>>> The restoring to 0 in the event of failure should probably be a volatile-write. Might be clearer to declare it as a volatile.
>>
>> "generated" field is read once and CAS once in this method. It doesn't likely cached and no visibiliy order required.
>
> okay, although I think it would be clearer for maintainers to declare it as volatile because it is set with CAS.
@AlanBateman
volatile attribute is added. As in common case, it only read and CAS at most once. And I see no regression on my testcase.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1070
More information about the core-libs-dev
mailing list