src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
changeset 51497 ec014e5694ec
parent 51332 c25572739e7c
child 51498 9a5200b84046
equal deleted inserted replaced
51496:bf6b66fa8bdf 51497:ec014e5694ec
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/g1/g1CollectedHeap.inline.hpp"
    26 #include "gc/g1/g1CollectedHeap.inline.hpp"
    27 #include "gc/g1/g1MonitoringSupport.hpp"
    27 #include "gc/g1/g1MonitoringSupport.hpp"
    28 #include "gc/g1/g1Policy.hpp"
    28 #include "gc/g1/g1Policy.hpp"
    29 #include "gc/shared/collectorCounters.hpp"
    29 #include "gc/g1/g1MemoryPool.hpp"
    30 #include "gc/shared/hSpaceCounters.hpp"
    30 #include "gc/shared/hSpaceCounters.hpp"
    31 #include "memory/metaspaceCounters.hpp"
    31 #include "memory/metaspaceCounters.hpp"
       
    32 #include "services/memoryPool.hpp"
    32 
    33 
    33 G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
    34 G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
    34                                            const char* name,
    35                                            const char* name,
    35                                            int ordinal, int spaces,
    36                                            int ordinal, int spaces,
    36                                            size_t min_capacity,
    37                                            size_t min_capacity,
    75   _current_size->set_value(committed);
    76   _current_size->set_value(committed);
    76 }
    77 }
    77 
    78 
    78 G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
    79 G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
    79   _g1h(g1h),
    80   _g1h(g1h),
       
    81   _memory_manager("G1 Young Generation", "end of minor GC"),
       
    82   _full_gc_memory_manager("G1 Old Generation", "end of major GC"),
       
    83   _eden_pool(NULL),
       
    84   _survivor_pool(NULL),
       
    85   _old_pool(NULL),
    80   _incremental_collection_counters(NULL),
    86   _incremental_collection_counters(NULL),
    81   _full_collection_counters(NULL),
    87   _full_collection_counters(NULL),
    82   _conc_collection_counters(NULL),
    88   _conc_collection_counters(NULL),
    83   _young_collection_counters(NULL),
    89   _young_collection_counters(NULL),
    84   _old_collection_counters(NULL),
    90   _old_collection_counters(NULL),
   181     // worry about updating it again later.
   187     // worry about updating it again later.
   182     _from_counters->update_used(0);
   188     _from_counters->update_used(0);
   183   }
   189   }
   184 }
   190 }
   185 
   191 
       
   192 G1MonitoringSupport::~G1MonitoringSupport() {
       
   193   delete _eden_pool;
       
   194   delete _survivor_pool;
       
   195   delete _old_pool;
       
   196 }
       
   197 
       
   198 void G1MonitoringSupport::initialize_serviceability() {
       
   199   _eden_pool = new G1EdenPool(_g1h);
       
   200   _survivor_pool = new G1SurvivorPool(_g1h);
       
   201   _old_pool = new G1OldGenPool(_g1h);
       
   202 
       
   203   _full_gc_memory_manager.add_pool(_eden_pool);
       
   204   _full_gc_memory_manager.add_pool(_survivor_pool);
       
   205   _full_gc_memory_manager.add_pool(_old_pool);
       
   206 
       
   207   _memory_manager.add_pool(_eden_pool);
       
   208   _memory_manager.add_pool(_survivor_pool);
       
   209   _memory_manager.add_pool(_old_pool, false /* always_affected_by_gc */);
       
   210 }
       
   211 
       
   212 GrowableArray<GCMemoryManager*> G1MonitoringSupport::memory_managers() {
       
   213   GrowableArray<GCMemoryManager*> memory_managers(2);
       
   214   memory_managers.append(&_memory_manager);
       
   215   memory_managers.append(&_full_gc_memory_manager);
       
   216   return memory_managers;
       
   217 }
       
   218 
       
   219 GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
       
   220   GrowableArray<MemoryPool*> memory_pools(3);
       
   221   memory_pools.append(_eden_pool);
       
   222   memory_pools.append(_survivor_pool);
       
   223   memory_pools.append(_old_pool);
       
   224   return memory_pools;
       
   225 }
       
   226 
   186 void G1MonitoringSupport::recalculate_sizes() {
   227 void G1MonitoringSupport::recalculate_sizes() {
   187   // Recalculate all the sizes from scratch. We assume that this is
   228   // Recalculate all the sizes from scratch. We assume that this is
   188   // called at a point where no concurrent updates to the various
   229   // called at a point where no concurrent updates to the various
   189   // values we read here are possible (i.e., at a STW phase at the end
   230   // values we read here are possible (i.e., at a STW phase at the end
   190   // of a GC).
   231   // of a GC).
   259 }
   300 }
   260 
   301 
   261 void G1MonitoringSupport::update_sizes() {
   302 void G1MonitoringSupport::update_sizes() {
   262   recalculate_sizes();
   303   recalculate_sizes();
   263   if (UsePerfData) {
   304   if (UsePerfData) {
   264     eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
   305     _eden_counters->update_capacity(pad_capacity(eden_space_committed()));
   265     eden_counters()->update_used(eden_space_used());
   306     _eden_counters->update_used(eden_space_used());
   266     // only the to survivor space (s1) is active, so we don't need to
   307     // only the "to" survivor space is active, so we don't need to
   267     // update the counters for the from survivor space (s0)
   308     // update the counters for the "from" survivor space
   268     to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
   309     _to_counters->update_capacity(pad_capacity(survivor_space_committed()));
   269     to_counters()->update_used(survivor_space_used());
   310     _to_counters->update_used(survivor_space_used());
   270     old_space_counters()->update_capacity(pad_capacity(old_space_committed()));
   311     _old_space_counters->update_capacity(pad_capacity(old_space_committed()));
   271     old_space_counters()->update_used(old_space_used());
   312     _old_space_counters->update_used(old_space_used());
   272     old_collection_counters()->update_all();
   313     _old_collection_counters->update_all();
   273     young_collection_counters()->update_all();
   314     _young_collection_counters->update_all();
   274     MetaspaceCounters::update_performance_counters();
   315     MetaspaceCounters::update_performance_counters();
   275     CompressedClassSpaceCounters::update_performance_counters();
   316     CompressedClassSpaceCounters::update_performance_counters();
   276   }
   317   }
   277 }
   318 }
   278 
   319 
   279 void G1MonitoringSupport::update_eden_size() {
   320 void G1MonitoringSupport::update_eden_size() {
   280   recalculate_eden_size();
   321   recalculate_eden_size();
   281   if (UsePerfData) {
   322   if (UsePerfData) {
   282     eden_counters()->update_used(eden_space_used());
   323     _eden_counters->update_used(eden_space_used());
   283   }
   324   }
   284 }
   325 }
       
   326 
       
   327 G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected) :
       
   328   _tcs(full_gc ? g1mm->_full_collection_counters : g1mm->_incremental_collection_counters),
       
   329   _tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_memory_manager,
       
   330        G1CollectedHeap::heap()->gc_cause(), all_memory_pools_affected) {
       
   331 }