/* * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "gc/serial/defNewGeneration.hpp" #include "gc/serial/serialHeap.hpp" #include "services/memoryManager.hpp" #include "services/memoryPool.hpp" SerialHeap::SerialHeap(GenCollectorPolicy* policy) : GenCollectedHeap(policy) {} void SerialHeap::check_gen_kinds() { assert(young_gen()->kind() == Generation::DefNew, "Wrong youngest generation type"); assert(old_gen()->kind() == Generation::MarkSweepCompact, "Wrong generation kind"); } class CopyMemoryManager : public GCMemoryManager { private: public: CopyMemoryManager() : GCMemoryManager() {} const char* name() { return "Copy"; } }; class MSCMemoryManager : public GCMemoryManager { private: public: MSCMemoryManager() : GCMemoryManager() {} const char* name() { return "MarkSweepCompact"; } }; GrowableArray SerialHeap::memory_managers() { _minor_mgr = new CopyMemoryManager(); _major_mgr = new MSCMemoryManager(); GrowableArray mem_mgrs; mem_mgrs.append(_minor_mgr); mem_mgrs.append(_major_mgr); return mem_mgrs; } GrowableArray SerialHeap::memory_pools() { DefNewGeneration* young = (DefNewGeneration*) young_gen(); // Add a memory pool for each space and young gen doesn't // support low memory detection as it is expected to get filled up. MemoryPool* eden = new ContiguousSpacePool(young->eden(), "Eden Space", MemoryPool::Heap, young->max_eden_size(), false /* support_usage_threshold */); MemoryPool* survivor = new SurvivorContiguousSpacePool(young, "Survivor Space", MemoryPool::Heap, young->max_survivor_size(), false /* support_usage_threshold */); GenerationPool* old = new GenerationPool(old_gen(), "Tenured Gen", MemoryPool::Heap, true); GrowableArray mem_pools; mem_pools.append(eden); mem_pools.append(survivor); mem_pools.append(old); _minor_mgr->add_pool(eden); _minor_mgr->add_pool(survivor); _major_mgr->add_pool(eden); _major_mgr->add_pool(survivor); _major_mgr->add_pool(old); return mem_pools; }