< prev index next >

src/hotspot/share/gc/cms/cmsHeap.cpp

Print this page
rev 48000 : [mq]: open.patch
rev 48001 : [mq]: 8191564-diff.patch


  48                                bool support_usage_threshold) :
  49     CollectedMemoryPool(name, space->capacity(), max_size, support_usage_threshold),
  50     _space(space) {
  51   }
  52 
  53   MemoryUsage get_memory_usage() {
  54     size_t max_heap_size   = (available_for_allocation() ? max_size() : 0);
  55     size_t used      = used_in_bytes();
  56     size_t committed = _space->capacity();
  57 
  58     return MemoryUsage(initial_size(), used, committed, max_heap_size);
  59   }
  60 
  61   size_t used_in_bytes() {
  62     return _space->used();
  63   }
  64 };
  65 
  66 CMSHeap::CMSHeap(GenCollectorPolicy *policy) :
  67   GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) {
  68   _young_manager = new GCMemoryManager("ParNew", "end of minor GC");
  69   _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC");
  70 
  71   _workers = new WorkGang("GC Thread", ParallelGCThreads,
  72                           /* are_GC_task_threads */true,
  73                           /* are_ConcurrentGC_threads */false);
  74   _workers->initialize_workers();
  75 }
  76 
  77 jint CMSHeap::initialize() {
  78   jint status = GenCollectedHeap::initialize();
  79   if (status != JNI_OK) return status;
  80 
  81   // If we are running CMS, create the collector responsible
  82   // for collecting the CMS generations.
  83   assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy");
  84   if (!create_cms_collector()) {
  85     return JNI_ENOMEM;
  86   }
  87 







  88   ParNewGeneration* young = (ParNewGeneration*) young_gen();
  89   _eden_pool = new ContiguousSpacePool(young->eden(),
  90                                        "Par Eden Space",
  91                                        young->max_eden_size(),
  92                                        false);
  93 
  94   _survivor_pool = new SurvivorContiguousSpacePool(young,
  95                                                    "Par Survivor Space",
  96                                                    young->max_survivor_size(),
  97                                                    false);
  98 
  99   ConcurrentMarkSweepGeneration* old = (ConcurrentMarkSweepGeneration*) old_gen();
 100   _old_pool = new CompactibleFreeListSpacePool(old->cmsSpace(),
 101                                                "CMS Old Gen",
 102                                                old->reserved().byte_size(),
 103                                                true);
 104 
 105   _young_manager->add_pool(_eden_pool);
 106   _young_manager->add_pool(_survivor_pool);
 107   young->set_gc_manager(_young_manager);
 108 
 109   _old_manager->add_pool(_eden_pool);
 110   _old_manager->add_pool(_survivor_pool);
 111   _old_manager->add_pool(_old_pool);
 112   old ->set_gc_manager(_old_manager);
 113 
 114   return JNI_OK;
 115 }
 116 
 117 void CMSHeap::check_gen_kinds() {
 118   assert(young_gen()->kind() == Generation::ParNew,
 119          "Wrong youngest generation type");
 120   assert(old_gen()->kind() == Generation::ConcurrentMarkSweep,
 121          "Wrong generation kind");
 122 }
 123 
 124 CMSHeap* CMSHeap::heap() {
 125   CollectedHeap* heap = Universe::heap();
 126   assert(heap != NULL, "Uninitialized access to CMSHeap::heap()");
 127   assert(heap->kind() == CollectedHeap::CMSHeap, "Not a CMSHeap");
 128   return (CMSHeap*) heap;
 129 }
 130 
 131 void CMSHeap::gc_threads_do(ThreadClosure* tc) const {
 132   assert(workers() != NULL, "should have workers here");
 133   workers()->threads_do(tc);
 134   ConcurrentMarkSweepThread::threads_do(tc);




  48                                bool support_usage_threshold) :
  49     CollectedMemoryPool(name, space->capacity(), max_size, support_usage_threshold),
  50     _space(space) {
  51   }
  52 
  53   MemoryUsage get_memory_usage() {
  54     size_t max_heap_size   = (available_for_allocation() ? max_size() : 0);
  55     size_t used      = used_in_bytes();
  56     size_t committed = _space->capacity();
  57 
  58     return MemoryUsage(initial_size(), used, committed, max_heap_size);
  59   }
  60 
  61   size_t used_in_bytes() {
  62     return _space->used();
  63   }
  64 };
  65 
  66 CMSHeap::CMSHeap(GenCollectorPolicy *policy) :
  67   GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) {



  68   _workers = new WorkGang("GC Thread", ParallelGCThreads,
  69                           /* are_GC_task_threads */true,
  70                           /* are_ConcurrentGC_threads */false);
  71   _workers->initialize_workers();
  72 }
  73 
  74 jint CMSHeap::initialize() {
  75   jint status = GenCollectedHeap::initialize();
  76   if (status != JNI_OK) return status;
  77 
  78   // If we are running CMS, create the collector responsible
  79   // for collecting the CMS generations.
  80   assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy");
  81   if (!create_cms_collector()) {
  82     return JNI_ENOMEM;
  83   }
  84 
  85   return JNI_OK;
  86 }
  87 
  88 void CMSHeap::initialize_serviceability() {
  89   _young_manager = new GCMemoryManager("ParNew", "end of minor GC");
  90   _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC");
  91 
  92   ParNewGeneration* young = (ParNewGeneration*) young_gen();
  93   _eden_pool = new ContiguousSpacePool(young->eden(),
  94                                        "Par Eden Space",
  95                                        young->max_eden_size(),
  96                                        false);
  97 
  98   _survivor_pool = new SurvivorContiguousSpacePool(young,
  99                                                    "Par Survivor Space",
 100                                                    young->max_survivor_size(),
 101                                                    false);
 102 
 103   ConcurrentMarkSweepGeneration* old = (ConcurrentMarkSweepGeneration*) old_gen();
 104   _old_pool = new CompactibleFreeListSpacePool(old->cmsSpace(),
 105                                                "CMS Old Gen",
 106                                                old->reserved().byte_size(),
 107                                                true);
 108 
 109   _young_manager->add_pool(_eden_pool);
 110   _young_manager->add_pool(_survivor_pool);
 111   young->set_gc_manager(_young_manager);
 112 
 113   _old_manager->add_pool(_eden_pool);
 114   _old_manager->add_pool(_survivor_pool);
 115   _old_manager->add_pool(_old_pool);
 116   old ->set_gc_manager(_old_manager);
 117 

 118 }
 119 
 120 void CMSHeap::check_gen_kinds() {
 121   assert(young_gen()->kind() == Generation::ParNew,
 122          "Wrong youngest generation type");
 123   assert(old_gen()->kind() == Generation::ConcurrentMarkSweep,
 124          "Wrong generation kind");
 125 }
 126 
 127 CMSHeap* CMSHeap::heap() {
 128   CollectedHeap* heap = Universe::heap();
 129   assert(heap != NULL, "Uninitialized access to CMSHeap::heap()");
 130   assert(heap->kind() == CollectedHeap::CMSHeap, "Not a CMSHeap");
 131   return (CMSHeap*) heap;
 132 }
 133 
 134 void CMSHeap::gc_threads_do(ThreadClosure* tc) const {
 135   assert(workers() != NULL, "should have workers here");
 136   workers()->threads_do(tc);
 137   ConcurrentMarkSweepThread::threads_do(tc);


< prev index next >