8229208: Remove Monitor::ClearMonitor
authorcoleenp
Wed, 07 Aug 2019 08:10:45 -0400
changeset 57668 33b160ef735c
parent 57667 79036e5e744b
child 57669 18f189e69b29
8229208: Remove Monitor::ClearMonitor Reviewed-by: dholmes
src/hotspot/share/runtime/mutex.cpp
src/hotspot/share/runtime/mutex.hpp
--- a/src/hotspot/share/runtime/mutex.cpp	Wed Aug 07 13:00:57 2019 +0100
+++ b/src/hotspot/share/runtime/mutex.cpp	Wed Aug 07 08:10:45 2019 -0400
@@ -264,35 +264,24 @@
   assert_owner(NULL);
 }
 
-void Monitor::ClearMonitor(Monitor * m, const char *name) {
-  m->_owner             = NULL;
-  if (name == NULL) {
-    strcpy(m->_name, "UNKNOWN");
-  } else {
-    strncpy(m->_name, name, MONITOR_NAME_LEN - 1);
-    m->_name[MONITOR_NAME_LEN - 1] = '\0';
-  }
-}
-
-Monitor::Monitor() {
-  assert(os::mutex_init_done(), "Too early!");
-  ClearMonitor(this);
-}
-
-
 // Only Threads_lock, Heap_lock and SR_lock may be safepoint_check_sometimes.
 bool is_sometimes_ok(const char* name) {
   return (strcmp(name, "Threads_lock") == 0 || strcmp(name, "Heap_lock") == 0 || strcmp(name, "SR_lock") == 0);
 }
 
 Monitor::Monitor(int Rank, const char * name, bool allow_vm_block,
-                 SafepointCheckRequired safepoint_check_required) {
+                 SafepointCheckRequired safepoint_check_required) : _owner(NULL) {
   assert(os::mutex_init_done(), "Too early!");
-  ClearMonitor(this, name);
+  if (name == NULL) {
+    strcpy(_name, "UNKNOWN");
+  } else {
+    strncpy(_name, name, MONITOR_NAME_LEN - 1);
+    _name[MONITOR_NAME_LEN - 1] = '\0';
+  }
 #ifdef ASSERT
   _allow_vm_block  = allow_vm_block;
   _rank            = Rank;
-  NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
+  _safepoint_check_required = safepoint_check_required;
 
   assert(_safepoint_check_required != Monitor::_safepoint_check_sometimes || is_sometimes_ok(name),
          "Lock has _safepoint_check_sometimes %s", name);
@@ -300,17 +289,8 @@
 }
 
 Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
-             SafepointCheckRequired safepoint_check_required) {
-  ClearMonitor((Monitor *) this, name);
-#ifdef ASSERT
-  _allow_vm_block   = allow_vm_block;
-  _rank             = Rank;
-  NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
-
-  assert(_safepoint_check_required != Monitor::_safepoint_check_sometimes || is_sometimes_ok(name),
-         "Lock has _safepoint_check_sometimes %s", name);
-#endif
-}
+             SafepointCheckRequired safepoint_check_required) :
+  Monitor(Rank, name, allow_vm_block, safepoint_check_required) {}
 
 bool Monitor::owned_by_self() const {
   return _owner == Thread::current();
--- a/src/hotspot/share/runtime/mutex.hpp	Wed Aug 07 13:00:57 2019 +0100
+++ b/src/hotspot/share/runtime/mutex.hpp	Wed Aug 07 08:10:45 2019 -0400
@@ -139,10 +139,6 @@
 
   NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;)
 
- protected:
-   static void ClearMonitor (Monitor * m, const char* name = NULL) ;
-   Monitor() ;
-
  public:
   Monitor(int rank, const char *name, bool allow_vm_block = false,
           SafepointCheckRequired safepoint_check_required = _safepoint_check_always);