changeset 10390:4766e03eaf19

8140600: Convert unnecessarily malloc'd Monitors to value members Summary: Change a malloc'd monitor into an embedded monitor. Reviewed-by: tschatzl, kbarrett
author drwhite
date Mon, 29 Feb 2016 11:32:12 -0500
parents 1af0e347a76e
children 2778191158c6
files src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp	Mon Feb 29 15:42:34 2016 +0000
+++ b/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp	Mon Feb 29 11:32:12 2016 -0500
@@ -57,21 +57,21 @@
   }
 }
 
-G1YoungRemSetSamplingThread::G1YoungRemSetSamplingThread() : ConcurrentGCThread() {
-  _monitor = new Monitor(Mutex::nonleaf,
-                         "G1YoungRemSetSamplingThread monitor",
-                         true,
-                         Monitor::_safepoint_check_never);
-
+G1YoungRemSetSamplingThread::G1YoungRemSetSamplingThread() :
+    ConcurrentGCThread(),
+    _monitor(Mutex::nonleaf,
+             "G1YoungRemSetSamplingThread monitor",
+             true,
+             Monitor::_safepoint_check_never) {
   set_name("G1 Young RemSet Sampling");
   create_and_start();
 }
 
 void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
-  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
+  MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
   if (!_should_terminate) {
     intx waitms = G1ConcRefinementServiceIntervalMillis; // 300, really should be?
-    _monitor->wait(Mutex::_no_safepoint_check_flag, waitms);
+    _monitor.wait(Mutex::_no_safepoint_check_flag, waitms);
   }
 }
 
@@ -92,8 +92,8 @@
 }
 
 void G1YoungRemSetSamplingThread::stop_service() {
-  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
-  _monitor->notify();
+  MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
+  _monitor.notify();
 }
 
 void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() {
--- a/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp	Mon Feb 29 15:42:34 2016 +0000
+++ b/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp	Mon Feb 29 11:32:12 2016 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -41,7 +41,7 @@
 // increase the young gen size to keep pause time length goal.
 class G1YoungRemSetSamplingThread: public ConcurrentGCThread {
 private:
-  Monitor* _monitor;
+  Monitor _monitor;
 
   void sample_young_list_rs_lengths();