< prev index next >

src/hotspot/share/services/gcNotifier.cpp

Print this page
   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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  *


 116     Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
 117     Handle after_usage;
 118 
 119     MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
 120     if (u.max_size() == 0 && u.used() > 0) {
 121       // If max size == 0, this pool is a survivor space.
 122       // Set max size = -1 since the pools will be swapped after GC.
 123       MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
 124       after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
 125     } else {
 126         after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
 127     }
 128     usage_before_gc_ah->obj_at_put(i, before_usage());
 129     usage_after_gc_ah->obj_at_put(i, after_usage());
 130   }
 131 
 132   // Current implementation only has 1 attribute (number of GC threads)
 133   // The type is 'I'
 134   objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
 135   objArrayHandle extra_array (THREAD, extra_args_array);
 136   InstanceKlass* intK = SystemDictionary::Integer_klass();
 137 
 138   instanceHandle extra_arg_val = intK->allocate_instance_handle(CHECK_NH);
 139 
 140   {
 141     JavaValue res(T_VOID);
 142     JavaCallArguments argsInt;
 143     argsInt.push_oop(extra_arg_val);
 144     argsInt.push_int(gcManager->num_gc_threads());
 145 
 146     JavaCalls::call_special(&res,
 147                             intK,
 148                             vmSymbols::object_initializer_name(),
 149                             vmSymbols::int_void_signature(),
 150                             &argsInt,
 151                             CHECK_NH);
 152   }
 153   extra_array->obj_at_put(0,extra_arg_val());
 154 
 155   InstanceKlass* gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
 156 
 157   Handle gcInfo_instance = gcInfoklass->allocate_instance_handle(CHECK_NH);
 158 
 159   JavaValue constructor_result(T_VOID);
 160   JavaCallArguments constructor_args(16);
 161   constructor_args.push_oop(gcInfo_instance);
 162   constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
 163   constructor_args.push_long(gcStatInfo->gc_index());
 164   constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->start_time()));
 165   constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->end_time()));
 166   constructor_args.push_oop(usage_before_gc_ah);
 167   constructor_args.push_oop(usage_after_gc_ah);
 168   constructor_args.push_oop(extra_array);
 169 
 170   JavaCalls::call_special(&constructor_result,
 171                           gcInfoklass,
 172                           vmSymbols::object_initializer_name(),
 173                           vmSymbols::com_sun_management_GcInfo_constructor_signature(),
 174                           &constructor_args,
 175                           CHECK_NH);
 176 
 177   return Handle(THREAD, gcInfo_instance());
 178 }
 179 
 180 void GCNotifier::sendNotification(TRAPS) {
 181   GCNotifier::sendNotificationInternal(THREAD);
 182   // Clearing pending exception to avoid premature termination of
 183   // the service thread
 184   if (HAS_PENDING_EXCEPTION) {
 185     CLEAR_PENDING_EXCEPTION;
 186   }
 187 }
 188 
 189 class NotificationMark : public StackObj {
 190   // This class is used in GCNotifier::sendNotificationInternal to ensure that
 191   // the GCNotificationRequest object is properly cleaned up, whatever path
 192   // is used to exit the method.
 193   GCNotificationRequest* _request;
 194 public:
 195   NotificationMark(GCNotificationRequest* r) {
 196     _request = r;
 197   }


   1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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  *


 116     Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
 117     Handle after_usage;
 118 
 119     MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
 120     if (u.max_size() == 0 && u.used() > 0) {
 121       // If max size == 0, this pool is a survivor space.
 122       // Set max size = -1 since the pools will be swapped after GC.
 123       MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
 124       after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
 125     } else {
 126         after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
 127     }
 128     usage_before_gc_ah->obj_at_put(i, before_usage());
 129     usage_after_gc_ah->obj_at_put(i, after_usage());
 130   }
 131 
 132   // Current implementation only has 1 attribute (number of GC threads)
 133   // The type is 'I'
 134   objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
 135   objArrayHandle extra_array (THREAD, extra_args_array);

 136 




 137   JavaCallArguments argsInt;

 138   argsInt.push_int(gcManager->num_gc_threads());
 139   Handle extra_arg_val = JavaCalls::construct_new_instance(
 140                             SystemDictionary::Integer_klass(),


 141                             vmSymbols::int_void_signature(),
 142                             &argsInt,
 143                             CHECK_NH);
 144 
 145   extra_array->obj_at_put(0,extra_arg_val());
 146 
 147   InstanceKlass* gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
 148 



 149   JavaCallArguments constructor_args(16);

 150   constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
 151   constructor_args.push_long(gcStatInfo->gc_index());
 152   constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->start_time()));
 153   constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->end_time()));
 154   constructor_args.push_oop(usage_before_gc_ah);
 155   constructor_args.push_oop(usage_after_gc_ah);
 156   constructor_args.push_oop(extra_array);
 157 
 158   return JavaCalls::construct_new_instance(
 159                           gcInfoklass,

 160                           vmSymbols::com_sun_management_GcInfo_constructor_signature(),
 161                           &constructor_args,
 162                           CHECK_NH);


 163 }
 164 
 165 void GCNotifier::sendNotification(TRAPS) {
 166   GCNotifier::sendNotificationInternal(THREAD);
 167   // Clearing pending exception to avoid premature termination of
 168   // the service thread
 169   if (HAS_PENDING_EXCEPTION) {
 170     CLEAR_PENDING_EXCEPTION;
 171   }
 172 }
 173 
 174 class NotificationMark : public StackObj {
 175   // This class is used in GCNotifier::sendNotificationInternal to ensure that
 176   // the GCNotificationRequest object is properly cleaned up, whatever path
 177   // is used to exit the method.
 178   GCNotificationRequest* _request;
 179 public:
 180   NotificationMark(GCNotificationRequest* r) {
 181     _request = r;
 182   }


< prev index next >