src/share/vm/services/gcNotifier.cpp

Print this page




 163   constructor_args.push_oop(gcInfo_instance);
 164   constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
 165   constructor_args.push_long(gcStatInfo->gc_index());
 166   constructor_args.push_long(gcStatInfo->start_time());
 167   constructor_args.push_long(gcStatInfo->end_time());
 168   constructor_args.push_oop(usage_before_gc_ah);
 169   constructor_args.push_oop(usage_after_gc_ah);
 170   constructor_args.push_oop(extra_array);
 171 
 172   JavaCalls::call_special(&constructor_result,
 173                           ik,
 174                           vmSymbols::object_initializer_name(),
 175                           vmSymbols::com_sun_management_GcInfo_constructor_signature(),
 176                           &constructor_args,
 177                           CHECK_NH);
 178 
 179   return Handle(gcInfo_instance());
 180 }
 181 
 182 void GCNotifier::sendNotification(TRAPS) {
























 183   ResourceMark rm(THREAD);

 184   GCNotificationRequest *request = getRequest();
 185   if(request != NULL) {
 186     Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo,THREAD);

 187 
 188     Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
 189     Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
 190     Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
 191 
 192     klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
 193     instanceKlassHandle gc_mbean_klass (THREAD, k);
 194 
 195     instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
 196     instanceHandle gc_mbean_h(THREAD, gc_mbean);
 197     if (!gc_mbean_h->is_a(k)) {
 198       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 199                 "This GCMemoryManager doesn't have a GarbageCollectorMXBean");
 200     }
 201 
 202     JavaValue result(T_VOID);
 203     JavaCallArguments args(gc_mbean_h);
 204     args.push_long(request->timestamp);
 205     args.push_oop(objName);
 206     args.push_oop(objAction);
 207     args.push_oop(objCause);
 208     args.push_oop(objGcInfo);
 209 
 210     JavaCalls::call_virtual(&result,
 211                             gc_mbean_klass,
 212                             vmSymbols::createGCNotification_name(),
 213                             vmSymbols::createGCNotification_signature(),
 214                             &args,
 215                             CHECK);
 216     if (HAS_PENDING_EXCEPTION) {
 217       CLEAR_PENDING_EXCEPTION;
 218     }
 219 
 220     delete request;
 221   }
 222 }
 223 


 163   constructor_args.push_oop(gcInfo_instance);
 164   constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
 165   constructor_args.push_long(gcStatInfo->gc_index());
 166   constructor_args.push_long(gcStatInfo->start_time());
 167   constructor_args.push_long(gcStatInfo->end_time());
 168   constructor_args.push_oop(usage_before_gc_ah);
 169   constructor_args.push_oop(usage_after_gc_ah);
 170   constructor_args.push_oop(extra_array);
 171 
 172   JavaCalls::call_special(&constructor_result,
 173                           ik,
 174                           vmSymbols::object_initializer_name(),
 175                           vmSymbols::com_sun_management_GcInfo_constructor_signature(),
 176                           &constructor_args,
 177                           CHECK_NH);
 178 
 179   return Handle(gcInfo_instance());
 180 }
 181 
 182 void GCNotifier::sendNotification(TRAPS) {
 183   GCNotifier::sendNotificationInternal(THREAD);
 184   // Clearing pending exception to avoid premature termination of
 185   // the service thread
 186   if (HAS_PENDING_EXCEPTION) {
 187     CLEAR_PENDING_EXCEPTION;
 188   }
 189 }
 190 
 191 class NotificationMark : public StackObj {
 192   // This class is used in GCNotifier::sendNotificationInternal to ensure that
 193   // the GCNotificationRequest object is properly cleaned up, whatever path
 194   // is used to exit the method.
 195   GCNotificationRequest* _request;
 196 public:
 197   NotificationMark(GCNotificationRequest* r) {
 198     _request = r;
 199   }
 200   ~NotificationMark() {
 201     assert(_request != NULL, "Sanity check");
 202     delete _request;
 203   }
 204 };
 205 
 206 void GCNotifier::sendNotificationInternal(TRAPS) {
 207   ResourceMark rm(THREAD);
 208   HandleMark hm(THREAD);
 209   GCNotificationRequest *request = getRequest();
 210   if(request != NULL) {
 211     NotificationMark nm(request);
 212     Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo, THREAD);
 213 
 214     Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
 215     Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
 216     Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
 217 
 218     klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
 219     instanceKlassHandle gc_mbean_klass(THREAD, k);
 220 
 221     instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
 222     instanceHandle gc_mbean_h(THREAD, gc_mbean);
 223     if (!gc_mbean_h->is_a(k)) {
 224       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 225                 "This GCMemoryManager doesn't have a GarbageCollectorMXBean");
 226     }
 227 
 228     JavaValue result(T_VOID);
 229     JavaCallArguments args(gc_mbean_h);
 230     args.push_long(request->timestamp);
 231     args.push_oop(objName);
 232     args.push_oop(objAction);
 233     args.push_oop(objCause);
 234     args.push_oop(objGcInfo);
 235 
 236     JavaCalls::call_virtual(&result,
 237                             gc_mbean_klass,
 238                             vmSymbols::createGCNotification_name(),
 239                             vmSymbols::createGCNotification_signature(),
 240                             &args,
 241                             CHECK);


 242   }



 243 }
 244