1 /*
   2  * Copyright (c) 2016, 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  *
  23  */
  24 
  25 #include "gc/parallel/parallelGCServicabilitySupport.hpp"
  26 #include "gc/parallel/parallelScavengeHeap.hpp"
  27 #include "gc/parallel/psMemoryPool.hpp"
  28 
  29 #include "services/memoryManager.hpp"
  30 
  31 class PSScavengeMemoryManager : public GCMemoryManager {
  32 private:
  33 public:
  34   PSScavengeMemoryManager() : GCMemoryManager() {}
  35 
  36   const char* name() { return "PS Scavenge"; }
  37 };
  38 
  39 class PSMarkSweepMemoryManager : public GCMemoryManager {
  40 private:
  41 public:
  42   PSMarkSweepMemoryManager() : GCMemoryManager() {}
  43 
  44   const char* name() { return "PS MarkSweep"; }
  45 };
  46 
  47 GCMemoryManager* ParallelGCServicabilitySupport::create_minor_gc_manager() {
  48   return new PSScavengeMemoryManager();
  49 }
  50 
  51 GCMemoryManager* ParallelGCServicabilitySupport::create_major_gc_manager() {
  52   return new PSMarkSweepMemoryManager();
  53 }
  54 
  55 void ParallelGCServicabilitySupport::add_memory_pools(GrowableArray<MemoryPool*>* pools_list,
  56                                                       GCMemoryManager* minor_mgr,
  57                                                       GCMemoryManager* major_mgr) {
  58   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
  59   PSYoungGen* young_gen = heap->young_gen();
  60   EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen,
  61                                                         young_gen->eden_space(),
  62                                                         "PS Eden Space",
  63                                                         MemoryPool::Heap,
  64                                                         false /* support_usage_threshold */);
  65 
  66   SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen,
  67                                                                     "PS Survivor Space",
  68                                                                     MemoryPool::Heap,
  69                                                                     false /* support_usage_threshold */);
  70 
  71   PSGenerationPool* old_gen_pool = new PSGenerationPool(heap->old_gen(),
  72                                                        "PS Old Gen",
  73                                                        MemoryPool::Heap,
  74                                                        true /* support_usage_threshold */);
  75 
  76   major_mgr->add_pool(eden);
  77   major_mgr->add_pool(survivor);
  78   major_mgr->add_pool(old_gen_pool);
  79 
  80   minor_mgr->add_pool(eden);
  81   minor_mgr->add_pool(survivor);
  82 
  83   pools_list->append(eden);
  84   pools_list->append(survivor);
  85   pools_list->append(old_gen_pool);
  86 
  87 }