< prev index next >

src/hotspot/share/runtime/serviceThread.cpp

Print this page
rev 48959 : 8198420: Remove unused extension point AllocationContextStats
Reviewed-by:


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "runtime/interfaceSupport.hpp"
  27 #include "runtime/javaCalls.hpp"
  28 #include "runtime/serviceThread.hpp"
  29 #include "runtime/mutexLocker.hpp"
  30 #include "runtime/os.hpp"
  31 #include "prims/jvmtiImpl.hpp"
  32 #include "services/allocationContextService.hpp"
  33 #include "services/diagnosticArgument.hpp"
  34 #include "services/diagnosticFramework.hpp"
  35 #include "services/gcNotifier.hpp"
  36 #include "services/lowMemoryDetector.hpp"
  37 
  38 ServiceThread* ServiceThread::_instance = NULL;
  39 
  40 void ServiceThread::initialize() {
  41   EXCEPTION_MARK;
  42 
  43   InstanceKlass* klass = SystemDictionary::Thread_klass();
  44   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
  45 
  46   const char* name = "Service Thread";
  47 
  48   Handle string = java_lang_String::create_from_str(name, CHECK);
  49 
  50   // Initialize thread_oop to put it into the system threadGroup
  51   Handle thread_group (THREAD, Universe::system_thread_group());
  52   JavaValue result(T_VOID);


  88     bool has_jvmti_events = false;
  89     bool has_gc_notification_event = false;
  90     bool has_dcmd_notification_event = false;
  91     bool acs_notify = false;
  92     JvmtiDeferredEvent jvmti_event;
  93     {
  94       // Need state transition ThreadBlockInVM so that this thread
  95       // will be handled by safepoint correctly when this thread is
  96       // notified at a safepoint.
  97 
  98       // This ThreadBlockInVM object is not also considered to be
  99       // suspend-equivalent because ServiceThread is not visible to
 100       // external suspension.
 101 
 102       ThreadBlockInVM tbivm(jt);
 103 
 104       MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
 105       while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
 106              !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
 107               !(has_gc_notification_event = GCNotifier::has_event()) &&
 108               !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) &&
 109              !(acs_notify = AllocationContextService::should_notify())) {
 110         // wait until one of the sensors has pending requests, or there is a
 111         // pending JVMTI event or JMX GC notification to post
 112         Service_lock->wait(Mutex::_no_safepoint_check_flag);
 113       }
 114 
 115       if (has_jvmti_events) {
 116         jvmti_event = JvmtiDeferredEventQueue::dequeue();
 117       }
 118     }
 119 
 120     if (has_jvmti_events) {
 121       jvmti_event.post();
 122     }
 123 
 124     if (sensors_changed) {
 125       LowMemoryDetector::process_sensor_changes(jt);
 126     }
 127 
 128     if(has_gc_notification_event) {
 129         GCNotifier::sendNotification(CHECK);
 130     }
 131 
 132     if(has_dcmd_notification_event) {
 133       DCmdFactory::send_notification(CHECK);
 134     }
 135 
 136     if (acs_notify) {
 137       AllocationContextService::notify(CHECK);
 138     }
 139   }
 140 }
 141 
 142 bool ServiceThread::is_service_thread(Thread* thread) {
 143   return thread == _instance;
 144 }


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "runtime/interfaceSupport.hpp"
  27 #include "runtime/javaCalls.hpp"
  28 #include "runtime/serviceThread.hpp"
  29 #include "runtime/mutexLocker.hpp"
  30 #include "runtime/os.hpp"
  31 #include "prims/jvmtiImpl.hpp"

  32 #include "services/diagnosticArgument.hpp"
  33 #include "services/diagnosticFramework.hpp"
  34 #include "services/gcNotifier.hpp"
  35 #include "services/lowMemoryDetector.hpp"
  36 
  37 ServiceThread* ServiceThread::_instance = NULL;
  38 
  39 void ServiceThread::initialize() {
  40   EXCEPTION_MARK;
  41 
  42   InstanceKlass* klass = SystemDictionary::Thread_klass();
  43   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
  44 
  45   const char* name = "Service Thread";
  46 
  47   Handle string = java_lang_String::create_from_str(name, CHECK);
  48 
  49   // Initialize thread_oop to put it into the system threadGroup
  50   Handle thread_group (THREAD, Universe::system_thread_group());
  51   JavaValue result(T_VOID);


  87     bool has_jvmti_events = false;
  88     bool has_gc_notification_event = false;
  89     bool has_dcmd_notification_event = false;
  90     bool acs_notify = false;
  91     JvmtiDeferredEvent jvmti_event;
  92     {
  93       // Need state transition ThreadBlockInVM so that this thread
  94       // will be handled by safepoint correctly when this thread is
  95       // notified at a safepoint.
  96 
  97       // This ThreadBlockInVM object is not also considered to be
  98       // suspend-equivalent because ServiceThread is not visible to
  99       // external suspension.
 100 
 101       ThreadBlockInVM tbivm(jt);
 102 
 103       MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
 104       while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
 105              !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
 106               !(has_gc_notification_event = GCNotifier::has_event()) &&
 107               !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification())) {

 108         // wait until one of the sensors has pending requests, or there is a
 109         // pending JVMTI event or JMX GC notification to post
 110         Service_lock->wait(Mutex::_no_safepoint_check_flag);
 111       }
 112 
 113       if (has_jvmti_events) {
 114         jvmti_event = JvmtiDeferredEventQueue::dequeue();
 115       }
 116     }
 117 
 118     if (has_jvmti_events) {
 119       jvmti_event.post();
 120     }
 121 
 122     if (sensors_changed) {
 123       LowMemoryDetector::process_sensor_changes(jt);
 124     }
 125 
 126     if(has_gc_notification_event) {
 127         GCNotifier::sendNotification(CHECK);
 128     }
 129 
 130     if(has_dcmd_notification_event) {
 131       DCmdFactory::send_notification(CHECK);




 132     }
 133   }
 134 }
 135 
 136 bool ServiceThread::is_service_thread(Thread* thread) {
 137   return thread == _instance;
 138 }
< prev index next >