Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/serviceThread.cpp @ 3356:78542e2b5e35
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
Summary: Add a notification to the GarbageCollectorMXBeans
Reviewed-by: acorn, mchung
author | fparain |
---|---|
date | Thu, 12 May 2011 10:30:11 -0700 |
parents | 216d916d5c12 |
children | 31a4e55f8c9d |
comparison
equal
deleted
inserted
replaced
3355:f1cbbee6713b | 3356:78542e2b5e35 |
---|---|
26 #include "runtime/interfaceSupport.hpp" | 26 #include "runtime/interfaceSupport.hpp" |
27 #include "runtime/javaCalls.hpp" | 27 #include "runtime/javaCalls.hpp" |
28 #include "runtime/serviceThread.hpp" | 28 #include "runtime/serviceThread.hpp" |
29 #include "runtime/mutexLocker.hpp" | 29 #include "runtime/mutexLocker.hpp" |
30 #include "prims/jvmtiImpl.hpp" | 30 #include "prims/jvmtiImpl.hpp" |
31 #include "services/gcNotifier.hpp" | |
31 | 32 |
32 ServiceThread* ServiceThread::_instance = NULL; | 33 ServiceThread* ServiceThread::_instance = NULL; |
33 | 34 |
34 void ServiceThread::initialize() { | 35 void ServiceThread::initialize() { |
35 EXCEPTION_MARK; | 36 EXCEPTION_MARK; |
79 | 80 |
80 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { | 81 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { |
81 while (true) { | 82 while (true) { |
82 bool sensors_changed = false; | 83 bool sensors_changed = false; |
83 bool has_jvmti_events = false; | 84 bool has_jvmti_events = false; |
85 bool has_gc_notification_event = false; | |
84 JvmtiDeferredEvent jvmti_event; | 86 JvmtiDeferredEvent jvmti_event; |
85 { | 87 { |
86 // Need state transition ThreadBlockInVM so that this thread | 88 // Need state transition ThreadBlockInVM so that this thread |
87 // will be handled by safepoint correctly when this thread is | 89 // will be handled by safepoint correctly when this thread is |
88 // notified at a safepoint. | 90 // notified at a safepoint. |
93 | 95 |
94 ThreadBlockInVM tbivm(jt); | 96 ThreadBlockInVM tbivm(jt); |
95 | 97 |
96 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); | 98 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); |
97 while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) && | 99 while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) && |
98 !(has_jvmti_events = JvmtiDeferredEventQueue::has_events())) { | 100 !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) && |
101 !(has_gc_notification_event = GCNotifier::has_event())) { | |
99 // wait until one of the sensors has pending requests, or there is a | 102 // wait until one of the sensors has pending requests, or there is a |
100 // pending JVMTI event to post | 103 // pending JVMTI event or JMX GC notification to post |
101 Service_lock->wait(Mutex::_no_safepoint_check_flag); | 104 Service_lock->wait(Mutex::_no_safepoint_check_flag); |
102 } | 105 } |
103 | 106 |
104 if (has_jvmti_events) { | 107 if (has_jvmti_events) { |
105 jvmti_event = JvmtiDeferredEventQueue::dequeue(); | 108 jvmti_event = JvmtiDeferredEventQueue::dequeue(); |
111 } | 114 } |
112 | 115 |
113 if (sensors_changed) { | 116 if (sensors_changed) { |
114 LowMemoryDetector::process_sensor_changes(jt); | 117 LowMemoryDetector::process_sensor_changes(jt); |
115 } | 118 } |
119 | |
120 if(has_gc_notification_event) { | |
121 GCNotifier::sendNotification(CHECK); | |
122 } | |
116 } | 123 } |
117 } | 124 } |
118 | 125 |
119 bool ServiceThread::is_service_thread(Thread* thread) { | 126 bool ServiceThread::is_service_thread(Thread* thread) { |
120 return thread == _instance; | 127 return thread == _instance; |