Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/g1MemoryPool.hpp
32285 views
/*1* Copyright (c) 2007, 2013, 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#ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP25#define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP2627#include "utilities/macros.hpp"28#if INCLUDE_ALL_GCS29#include "gc_implementation/g1/g1MonitoringSupport.hpp"30#include "services/memoryPool.hpp"31#include "services/memoryUsage.hpp"32#endif // INCLUDE_ALL_GCS3334// This file contains the three classes that represent the memory35// pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and36// G1OldGenPool. In G1, unlike our other GCs, we do not have a37// physical space for each of those spaces. Instead, we allocate38// regions for all three spaces out of a single pool of regions (that39// pool basically covers the entire heap). As a result, the eden,40// survivor, and old gen are considered logical spaces in G1, as each41// is a set of non-contiguous regions. This is also reflected in the42// way we map them to memory pools here. The easiest way to have done43// this would have been to map the entire G1 heap to a single memory44// pool. However, it's helpful to show how large the eden and survivor45// get, as this does affect the performance and behavior of G1. Which46// is why we introduce the three memory pools implemented here.47//48// See comments in g1MonitoringSupport.hpp for additional details49// on this model.50//5152// This class is shared by the three G1 memory pool classes53// (G1EdenPool, G1SurvivorPool, G1OldGenPool).54class G1MemoryPoolSuper : public CollectedMemoryPool {55protected:56const static size_t _undefined_max = (size_t) -1;57G1MonitoringSupport* _g1mm;5859// Would only be called from subclasses.60G1MemoryPoolSuper(G1CollectedHeap* g1h,61const char* name,62size_t init_size,63size_t max_size,64bool support_usage_threshold);65};6667// Memory pool that represents the G1 eden.68class G1EdenPool : public G1MemoryPoolSuper {69public:70G1EdenPool(G1CollectedHeap* g1h);7172size_t used_in_bytes() {73return _g1mm->eden_space_used();74}75size_t max_size() const {76return _undefined_max;77}78MemoryUsage get_memory_usage();79};8081// Memory pool that represents the G1 survivor.82class G1SurvivorPool : public G1MemoryPoolSuper {83public:84G1SurvivorPool(G1CollectedHeap* g1h);8586size_t used_in_bytes() {87return _g1mm->survivor_space_used();88}89size_t max_size() const {90return _undefined_max;91}92MemoryUsage get_memory_usage();93};9495// Memory pool that represents the G1 old gen.96class G1OldGenPool : public G1MemoryPoolSuper {97public:98G1OldGenPool(G1CollectedHeap* g1h);99100size_t used_in_bytes() {101return _g1mm->old_space_used();102}103size_t max_size() const {104return _g1mm->old_gen_max();105}106MemoryUsage get_memory_usage();107};108109#endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP110111112