Skip to content

Commit

Permalink
Automatic merge of jdk:master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Nov 2, 2020
2 parents 9528670 + 69f5235 commit ee40896
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/hotspot/share/runtime/mutex.cpp
Expand Up @@ -50,8 +50,8 @@ void Mutex::check_safepoint_state(Thread* thread) {
// If the JavaThread checks for safepoint, verify that the lock wasn't created with safepoint_check_never.
if (thread->is_active_Java_thread()) {
assert(_safepoint_check_required != _safepoint_check_never,
"This lock should %s have a safepoint check for Java threads: %s",
_safepoint_check_required ? "always" : "never", name());
"This lock should never have a safepoint check for Java threads: %s",
name());

// Also check NoSafepointVerifier, and thread state is _thread_in_vm
thread->check_for_valid_safepoint_state();
Expand All @@ -65,8 +65,8 @@ void Mutex::check_safepoint_state(Thread* thread) {
void Mutex::check_no_safepoint_state(Thread* thread) {
check_block_state(thread);
assert(!thread->is_active_Java_thread() || _safepoint_check_required != _safepoint_check_always,
"This lock should %s have a safepoint check for Java threads: %s",
_safepoint_check_required ? "always" : "never", name());
"This lock should always have a safepoint check for Java threads: %s",
name());
}
#endif // ASSERT

Expand Down
22 changes: 16 additions & 6 deletions src/hotspot/share/runtime/mutex.hpp
Expand Up @@ -99,10 +99,8 @@ class Mutex : public CHeapObj<mtSynchronizer> {
void no_safepoint_verifier (Thread* thread, bool enable) NOT_DEBUG_RETURN;

public:
enum {
_allow_vm_block_flag = true,
_as_suspend_equivalent_flag = true
};
static const bool _allow_vm_block_flag = true;
static const bool _as_suspend_equivalent_flag = true;

// Locks can be acquired with or without a safepoint check. NonJavaThreads do not follow
// the safepoint protocol when acquiring locks.
Expand All @@ -124,12 +122,17 @@ class Mutex : public CHeapObj<mtSynchronizer> {
// deadlock can occur. We should check this by noting which
// locks are shared, and walk held locks during safepoint checking.

enum SafepointCheckFlag {
enum class SafepointCheckFlag {
_safepoint_check_flag,
_no_safepoint_check_flag
};
// Bring the enumerator names into class scope.
static const SafepointCheckFlag _safepoint_check_flag =
SafepointCheckFlag::_safepoint_check_flag;
static const SafepointCheckFlag _no_safepoint_check_flag =
SafepointCheckFlag::_no_safepoint_check_flag;

enum SafepointCheckRequired {
enum class SafepointCheckRequired {
_safepoint_check_never, // Mutexes with this value will cause errors
// when acquired by a JavaThread with a safepoint check.
_safepoint_check_sometimes, // A couple of special locks are acquired by JavaThreads sometimes
Expand All @@ -138,6 +141,13 @@ class Mutex : public CHeapObj<mtSynchronizer> {
_safepoint_check_always // Mutexes with this value will cause errors
// when acquired by a JavaThread without a safepoint check.
};
// Bring the enumerator names into class scope.
static const SafepointCheckRequired _safepoint_check_never =
SafepointCheckRequired::_safepoint_check_never;
static const SafepointCheckRequired _safepoint_check_sometimes =
SafepointCheckRequired::_safepoint_check_sometimes;
static const SafepointCheckRequired _safepoint_check_always =
SafepointCheckRequired::_safepoint_check_always;

NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;)

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/mutexLocker.hpp
Expand Up @@ -298,7 +298,7 @@ class MutexUnlocker: StackObj {
public:
MutexUnlocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex),
_no_safepoint_check(flag) {
_no_safepoint_check(flag == Mutex::_no_safepoint_check_flag) {
_mutex->unlock();
}

Expand Down

0 comments on commit ee40896

Please sign in to comment.