< prev index next >

src/hotspot/share/services/memoryManager.cpp

Print this page




  77 
  78 GCMemoryManager* MemoryManager::get_psScavenge_memory_manager() {
  79   return (GCMemoryManager*) new PSScavengeMemoryManager();
  80 }
  81 
  82 GCMemoryManager* MemoryManager::get_psMarkSweep_memory_manager() {
  83   return (GCMemoryManager*) new PSMarkSweepMemoryManager();
  84 }
  85 
  86 GCMemoryManager* MemoryManager::get_g1YoungGen_memory_manager() {
  87   return (GCMemoryManager*) new G1YoungGenMemoryManager();
  88 }
  89 
  90 GCMemoryManager* MemoryManager::get_g1OldGen_memory_manager() {
  91   return (GCMemoryManager*) new G1OldGenMemoryManager();
  92 }
  93 
  94 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) {
  95   // Must do an acquire so as to force ordering of subsequent
  96   // loads from anything _memory_mgr_obj points to or implies.
  97   instanceOop mgr_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_mgr_obj);
  98   if (mgr_obj == NULL) {
  99     // It's ok for more than one thread to execute the code up to the locked region.
 100     // Extra manager instances will just be gc'ed.
 101     Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0);
 102 
 103     Handle mgr_name = java_lang_String::create_from_str(name(), CHECK_0);
 104 
 105     JavaValue result(T_OBJECT);
 106     JavaCallArguments args;
 107     args.push_oop(mgr_name);    // Argument 1
 108 
 109     Symbol* method_name = NULL;
 110     Symbol* signature = NULL;
 111     if (is_gc_memory_manager()) {
 112       Klass* extKlass = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_0);
 113       // com.sun.management.GarbageCollectorMXBean is in jdk.management module which may not be present.
 114       if (extKlass != NULL) {
 115         k = extKlass;
 116       }
 117 


 130                            ik,
 131                            method_name,
 132                            signature,
 133                            &args,
 134                            CHECK_0);
 135 
 136     instanceOop m = (instanceOop) result.get_jobject();
 137     instanceHandle mgr(THREAD, m);
 138 
 139     {
 140       // Get lock before setting _memory_mgr_obj
 141       // since another thread may have created the instance
 142       MutexLocker ml(Management_lock);
 143 
 144       // Check if another thread has created the management object.  We reload
 145       // _memory_mgr_obj here because some other thread may have initialized
 146       // it while we were executing the code before the lock.
 147       //
 148       // The lock has done an acquire, so the load can't float above it, but
 149       // we need to do a load_acquire as above.
 150       mgr_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_mgr_obj);
 151       if (mgr_obj != NULL) {
 152          return mgr_obj;
 153       }
 154 
 155       // Get the address of the object we created via call_special.
 156       mgr_obj = mgr();
 157 
 158       // Use store barrier to make sure the memory accesses associated
 159       // with creating the management object are visible before publishing
 160       // its address.  The unlock will publish the store to _memory_mgr_obj
 161       // because it does a release first.
 162       OrderAccess::release_store_ptr(&_memory_mgr_obj, mgr_obj);
 163     }
 164   }
 165 
 166   return mgr_obj;
 167 }
 168 
 169 void MemoryManager::oops_do(OopClosure* f) {
 170   f->do_oop((oop*) &_memory_mgr_obj);
 171 }
 172 
 173 GCStatInfo::GCStatInfo(int num_pools) {
 174   // initialize the arrays for memory usage
 175   _before_gc_usage_array = (MemoryUsage*) NEW_C_HEAP_ARRAY(MemoryUsage, num_pools, mtInternal);
 176   _after_gc_usage_array  = (MemoryUsage*) NEW_C_HEAP_ARRAY(MemoryUsage, num_pools, mtInternal);
 177   _usage_array_size = num_pools;
 178   clear();
 179 }
 180 
 181 GCStatInfo::~GCStatInfo() {
 182   FREE_C_HEAP_ARRAY(MemoryUsage*, _before_gc_usage_array);




  77 
  78 GCMemoryManager* MemoryManager::get_psScavenge_memory_manager() {
  79   return (GCMemoryManager*) new PSScavengeMemoryManager();
  80 }
  81 
  82 GCMemoryManager* MemoryManager::get_psMarkSweep_memory_manager() {
  83   return (GCMemoryManager*) new PSMarkSweepMemoryManager();
  84 }
  85 
  86 GCMemoryManager* MemoryManager::get_g1YoungGen_memory_manager() {
  87   return (GCMemoryManager*) new G1YoungGenMemoryManager();
  88 }
  89 
  90 GCMemoryManager* MemoryManager::get_g1OldGen_memory_manager() {
  91   return (GCMemoryManager*) new G1OldGenMemoryManager();
  92 }
  93 
  94 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) {
  95   // Must do an acquire so as to force ordering of subsequent
  96   // loads from anything _memory_mgr_obj points to or implies.
  97   instanceOop mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj);
  98   if (mgr_obj == NULL) {
  99     // It's ok for more than one thread to execute the code up to the locked region.
 100     // Extra manager instances will just be gc'ed.
 101     Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0);
 102 
 103     Handle mgr_name = java_lang_String::create_from_str(name(), CHECK_0);
 104 
 105     JavaValue result(T_OBJECT);
 106     JavaCallArguments args;
 107     args.push_oop(mgr_name);    // Argument 1
 108 
 109     Symbol* method_name = NULL;
 110     Symbol* signature = NULL;
 111     if (is_gc_memory_manager()) {
 112       Klass* extKlass = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_0);
 113       // com.sun.management.GarbageCollectorMXBean is in jdk.management module which may not be present.
 114       if (extKlass != NULL) {
 115         k = extKlass;
 116       }
 117 


 130                            ik,
 131                            method_name,
 132                            signature,
 133                            &args,
 134                            CHECK_0);
 135 
 136     instanceOop m = (instanceOop) result.get_jobject();
 137     instanceHandle mgr(THREAD, m);
 138 
 139     {
 140       // Get lock before setting _memory_mgr_obj
 141       // since another thread may have created the instance
 142       MutexLocker ml(Management_lock);
 143 
 144       // Check if another thread has created the management object.  We reload
 145       // _memory_mgr_obj here because some other thread may have initialized
 146       // it while we were executing the code before the lock.
 147       //
 148       // The lock has done an acquire, so the load can't float above it, but
 149       // we need to do a load_acquire as above.
 150       mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj);
 151       if (mgr_obj != NULL) {
 152          return mgr_obj;
 153       }
 154 
 155       // Get the address of the object we created via call_special.
 156       mgr_obj = mgr();
 157 
 158       // Use store barrier to make sure the memory accesses associated
 159       // with creating the management object are visible before publishing
 160       // its address.  The unlock will publish the store to _memory_mgr_obj
 161       // because it does a release first.
 162       OrderAccess::release_store(&_memory_mgr_obj, mgr_obj);
 163     }
 164   }
 165 
 166   return mgr_obj;
 167 }
 168 
 169 void MemoryManager::oops_do(OopClosure* f) {
 170   f->do_oop((oop*) &_memory_mgr_obj);
 171 }
 172 
 173 GCStatInfo::GCStatInfo(int num_pools) {
 174   // initialize the arrays for memory usage
 175   _before_gc_usage_array = (MemoryUsage*) NEW_C_HEAP_ARRAY(MemoryUsage, num_pools, mtInternal);
 176   _after_gc_usage_array  = (MemoryUsage*) NEW_C_HEAP_ARRAY(MemoryUsage, num_pools, mtInternal);
 177   _usage_array_size = num_pools;
 178   clear();
 179 }
 180 
 181 GCStatInfo::~GCStatInfo() {
 182   FREE_C_HEAP_ARRAY(MemoryUsage*, _before_gc_usage_array);


< prev index next >