RFR: 8307533: Use atomic bitset functions for metadata flags

Coleen Phillimore coleenp at openjdk.org
Mon May 8 13:22:25 UTC 2023


On Sat, 6 May 2023 05:34:18 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Replace the bit set copies from metadata to use the Atomic functions.
>> Tested with tier1-4.
>
> src/hotspot/share/oops/fieldInfo.inline.hpp line 160:
> 
>> 158: inline void FieldStatus::atomic_clear_bits(u1& flags, u1 mask) {
>> 159:   u1 val = (~mask);
>> 160:   Atomic::fetch_then_and(&flags, val);
> 
> u1 is not a supported type for Atomic bitops.  This only happens to work right now because all
> platforms are currently using a cmpxchg-based implementation and aren't enforcing the documented
> limitation of only providing support for size of an int or size of a pointer (if different).

But I need u1! I thought that was the point of having the templates?  Do I change this back to my own CAS loop?

> src/hotspot/share/oops/methodFlags.hpp line 91:
> 
>> 89:   int as_int() const { return _status; }
>> 90:   void atomic_set_bits(u4 bits)   { Atomic::fetch_then_or(&_status, bits); }
>> 91:   void atomic_clear_bits(u4 bits) { u4 val = (~bits); Atomic::fetch_then_and(&_status, val); }
> 
> Why introduce a new variable (and why the extra parens).  Just
> 
> Atomic::fetch_then_and(&_status, ~bits);

The template didn't like this, I suppose I could add some casting.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13843#discussion_r1187436769
PR Review Comment: https://git.openjdk.org/jdk/pull/13843#discussion_r1187437526


More information about the hotspot-dev mailing list