Skip to content
Permalink
Browse files
8264146: Make Mutex point to rather than embed _name
Reviewed-by: redestad, dholmes
  • Loading branch information
coleenp committed Mar 25, 2021
1 parent f69afba commit a1e717f13ec040e4e1490f70ba465b405471e4ff
Showing 2 changed files with 4 additions and 14 deletions.
@@ -281,14 +281,9 @@ bool is_sometimes_ok(const char* name) {
}

Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
SafepointCheckRequired safepoint_check_required) : _owner(NULL) {
SafepointCheckRequired safepoint_check_required) : _owner(NULL), _name(name) {
assert(os::mutex_init_done(), "Too early!");
if (name == NULL) {
strcpy(_name, "UNKNOWN");
} else {
strncpy(_name, name, MUTEX_NAME_LEN - 1);
_name[MUTEX_NAME_LEN - 1] = '\0';
}
assert(name != NULL, "Mutex requires a name");
#ifdef ASSERT
_allow_vm_block = allow_vm_block;
_rank = Rank;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,11 +39,6 @@
// The underlying PlatformMutex may support recursive locking but this is not exposed
// and we account for that possibility in try_lock.

// The default length of mutex name was originally chosen to be 64 to avoid
// false sharing. Now, PaddedMutex and PaddedMonitor are available for this purpose.
// TODO: Check if _name[MUTEX_NAME_LEN] should better get replaced by const char*.
static const int MUTEX_NAME_LEN = 64;

class Mutex : public CHeapObj<mtSynchronizer> {

public:
@@ -91,7 +86,7 @@ class Mutex : public CHeapObj<mtSynchronizer> {

protected: // Monitor-Mutex metadata
os::PlatformMonitor _lock; // Native monitor implementation
char _name[MUTEX_NAME_LEN]; // Name of mutex/monitor
const char* _name; // Name of mutex/monitor

// Debugging fields for naming, deadlock detection, etc. (some only used in debug mode)
#ifndef PRODUCT

0 comments on commit a1e717f

Please sign in to comment.