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/g1/g1GCServicabilitySupport.hpp"
  26 #include "gc/g1/g1CollectedHeap.hpp"
  27 #include "gc/g1/g1MemoryPool.hpp"
  28 
  29 #include "services/memoryManager.hpp"
  30 
  31 class G1YoungGenMemoryManager : public GCMemoryManager {
  32 private:
  33 public:
  34   G1YoungGenMemoryManager() : GCMemoryManager() {}
  35 
  36   const char* name() { return "G1 Young Generation"; }
  37 };
  38 
  39 class G1OldGenMemoryManager : public GCMemoryManager {
  40 private:
  41 public:
  42   G1OldGenMemoryManager() : GCMemoryManager() {}
  43 
  44   const char* name() { return "G1 Old Generation"; }
  45 };
  46 
  47 
  48 GCMemoryManager* G1GCServicabilitySupport::create_minor_gc_manager() {
  49   return new G1YoungGenMemoryManager();
  50 }
  51 
  52 GCMemoryManager* G1GCServicabilitySupport::create_major_gc_manager() {
  53   return new G1OldGenMemoryManager();
  54 }
  55 
  56 void G1GCServicabilitySupport::add_memory_pools(GrowableArray<MemoryPool*>* pools_list,
  57                                                 GCMemoryManager* minor_mgr,
  58                                                 GCMemoryManager* major_mgr) {
  59 
  60   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  61   G1EdenPool* eden = new G1EdenPool(g1h);
  62   G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
  63   G1OldGenPool* old_gen = new G1OldGenPool(g1h);
  64 
  65   major_mgr->add_pool(eden);
  66   major_mgr->add_pool(survivor);
  67   major_mgr->add_pool(old_gen);
  68   minor_mgr->add_pool(eden);
  69   minor_mgr->add_pool(survivor);
  70   pools_list->append(eden);
  71   pools_list->append(survivor);
  72   pools_list->append(old_gen);
  73 }