Path: blob/master/src/hotspot/share/gc/serial/serialHeap.cpp
41152 views
/*1* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/serial/defNewGeneration.inline.hpp"26#include "gc/serial/serialHeap.hpp"27#include "gc/serial/tenuredGeneration.inline.hpp"28#include "gc/shared/genMemoryPools.hpp"29#include "gc/shared/strongRootsScope.hpp"30#include "memory/universe.hpp"31#include "services/memoryManager.hpp"3233SerialHeap* SerialHeap::heap() {34return named_heap<SerialHeap>(CollectedHeap::Serial);35}3637SerialHeap::SerialHeap() :38GenCollectedHeap(Generation::DefNew,39Generation::MarkSweepCompact,40"Copy:MSC"),41_eden_pool(NULL),42_survivor_pool(NULL),43_old_pool(NULL) {44_young_manager = new GCMemoryManager("Copy", "end of minor GC");45_old_manager = new GCMemoryManager("MarkSweepCompact", "end of major GC");46}4748void SerialHeap::initialize_serviceability() {4950DefNewGeneration* young = young_gen();5152// Add a memory pool for each space and young gen doesn't53// support low memory detection as it is expected to get filled up.54_eden_pool = new ContiguousSpacePool(young->eden(),55"Eden Space",56young->max_eden_size(),57false /* support_usage_threshold */);58_survivor_pool = new SurvivorContiguousSpacePool(young,59"Survivor Space",60young->max_survivor_size(),61false /* support_usage_threshold */);62TenuredGeneration* old = old_gen();63_old_pool = new GenerationPool(old, "Tenured Gen", true);6465_young_manager->add_pool(_eden_pool);66_young_manager->add_pool(_survivor_pool);67young->set_gc_manager(_young_manager);6869_old_manager->add_pool(_eden_pool);70_old_manager->add_pool(_survivor_pool);71_old_manager->add_pool(_old_pool);72old->set_gc_manager(_old_manager);7374}7576GrowableArray<GCMemoryManager*> SerialHeap::memory_managers() {77GrowableArray<GCMemoryManager*> memory_managers(2);78memory_managers.append(_young_manager);79memory_managers.append(_old_manager);80return memory_managers;81}8283GrowableArray<MemoryPool*> SerialHeap::memory_pools() {84GrowableArray<MemoryPool*> memory_pools(3);85memory_pools.append(_eden_pool);86memory_pools.append(_survivor_pool);87memory_pools.append(_old_pool);88return memory_pools;89}9091void SerialHeap::young_process_roots(OopIterateClosure* root_closure,92OopIterateClosure* old_gen_closure,93CLDClosure* cld_closure) {94MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);9596process_roots(SO_ScavengeCodeCache, root_closure,97cld_closure, cld_closure, &mark_code_closure);9899old_gen()->younger_refs_iterate(old_gen_closure);100}101102103