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/serial/defNewGeneration.hpp" 26 #include "gc/serial/serialGCServicabilitySupport.hpp" 27 #include "gc/shared/genCollectedHeap.hpp" 28 #include "services/memoryManager.hpp" 29 #include "services/memoryPool.hpp" 30 31 class CopyMemoryManager : public GCMemoryManager { 32 private: 33 public: 34 CopyMemoryManager() : GCMemoryManager() {} 35 36 const char* name() { return "Copy"; } 37 }; 38 39 class MSCMemoryManager : public GCMemoryManager { 40 private: 41 public: 42 MSCMemoryManager() : GCMemoryManager() {} 43 44 const char* name() { return "MarkSweepCompact"; } 45 }; 46 47 GCMemoryManager* SerialGCServicabilitySupport::create_minor_gc_manager() { 48 return new CopyMemoryManager(); 49 } 50 51 GCMemoryManager* SerialGCServicabilitySupport::create_major_gc_manager() { 52 return new MSCMemoryManager(); 53 } 54 55 void SerialGCServicabilitySupport::add_memory_pools(GrowableArray<MemoryPool*>* pools_list, 56 GCMemoryManager* minor_mgr, 57 GCMemoryManager* major_mgr) { 58 GenCollectedHeap* heap = GenCollectedHeap::heap(); 59 DefNewGeneration* young_gen = (DefNewGeneration*) heap->young_gen(); 60 61 // Add a memory pool for each space and young gen doesn't 62 // support low memory detection as it is expected to get filled up. 63 MemoryPool* eden = new ContiguousSpacePool(young_gen->eden(), 64 "Eden Space", 65 MemoryPool::Heap, 66 young_gen->max_eden_size(), 67 false /* support_usage_threshold */); 68 MemoryPool* survivor = new SurvivorContiguousSpacePool(young_gen, 69 "Survivor Space", 70 MemoryPool::Heap, 71 young_gen->max_survivor_size(), 72 false /* support_usage_threshold */); 73 GenerationPool* old = new GenerationPool(heap->old_gen(), "Tenured Gen", MemoryPool::Heap, true); 74 75 pools_list->append(eden); 76 pools_list->append(survivor); 77 pools_list->append(old); 78 79 minor_mgr->add_pool(eden); 80 minor_mgr->add_pool(survivor); 81 82 major_mgr->add_pool(eden); 83 major_mgr->add_pool(survivor); 84 major_mgr->add_pool(old); 85 }