RFR: 8255596: Mutex safepoint checking options and flags should be scoped enums

Kim Barrett kbarrett at openjdk.java.net
Fri Oct 30 14:29:59 UTC 2020


Please review this change to some enums in the Mutex class.
SafepointCheckFlag and SafepointCheckRequired are changed to scoped
enums.  Also removed the anonymous enum defining _allow_vm_block_flag
and _as_suspend_equivalent_flag, instead defining those as bool
constants.

To avoid changing all references to the SafepointCheckXXX enumerators
(due to the additional scoping introduced by using scoped enums), same
named constants are defined at Mutex class scope.  Some renaming might
be preferable in the long term, but I didn't want to do that just to
get the improved type checking.  An X-macro approach to defining the
enumerators and hoisting them into class scope could have been taken,
but the number of enumerators here doesn't seem to warrant the additional
infrastructure to do so.

Changing the enum types uncovered a few places in the implementation
of Mutex and MutexLocker where enum values were being implicitly
converted to bool, with associated assumptions about the order or
values of the enumerators.  Those have been fixed.

Testing:
tier1

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

Commit messages:
 - fix assert messages
 - use scoped enums

Changes: https://git.openjdk.java.net/jdk/pull/957/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=957&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8255596
  Stats: 23 lines in 3 files changed: 12 ins; 2 del; 9 mod
  Patch: https://git.openjdk.java.net/jdk/pull/957.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/957/head:pull/957

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


More information about the hotspot-dev mailing list