src/share/vm/services/gcNotifier.cpp

Print this page




 162   JavaCallArguments constructor_args(16);
 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 


 162   JavaCallArguments constructor_args(16);
 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 class NotificationMark : public StackObj {
 183   // This class is used in GCNitifer::sendNotification to ensure that the
 184   // GCNotificationRequest object is properly cleaned up, whatever path
 185   // is used to exit the method.
 186   GCNotificationRequest* _request;
 187 public:
 188   NotificationMark(GCNotificationRequest* r) {
 189     _request = r;
 190   }
 191   ~NotificationMark() {
 192     assert(_request != NULL, "Sanity check");
 193     delete _request;
 194   }
 195 };
 196 
 197 void GCNotifier::sendNotification(TRAPS) {
 198   ResourceMark rm(THREAD);
 199   HandleMark hm(THREAD);
 200   GCNotificationRequest *request = getRequest();
 201   if(request != NULL) {
 202     NotificationMark nm(request);
 203     Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo, CHECK);
 204 
 205     Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
 206     Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
 207     Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
 208 
 209     klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
 210     instanceKlassHandle gc_mbean_klass(THREAD, k);
 211 
 212     instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(CHECK);
 213     instanceHandle gc_mbean_h(THREAD, gc_mbean);
 214     if (!gc_mbean_h->is_a(k)) {
 215       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 216                 "This GCMemoryManager doesn't have a GarbageCollectorMXBean");
 217     }
 218 
 219     JavaValue result(T_VOID);
 220     JavaCallArguments args(gc_mbean_h);
 221     args.push_long(request->timestamp);
 222     args.push_oop(objName);
 223     args.push_oop(objAction);
 224     args.push_oop(objCause);
 225     args.push_oop(objGcInfo);
 226 
 227     JavaCalls::call_virtual(&result,
 228                             gc_mbean_klass,
 229                             vmSymbols::createGCNotification_name(),
 230                             vmSymbols::createGCNotification_signature(),
 231                             &args,
 232                             CHECK);


 233   }



 234 }
 235