aoqi@0: /* aoqi@0: * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP aoqi@0: #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP aoqi@0: aoqi@0: #include "utilities/macros.hpp" aoqi@0: #if INCLUDE_ALL_GCS aoqi@0: #include "gc_implementation/g1/g1MonitoringSupport.hpp" aoqi@0: #include "services/memoryPool.hpp" aoqi@0: #include "services/memoryUsage.hpp" aoqi@0: #endif // INCLUDE_ALL_GCS aoqi@0: aoqi@0: // This file contains the three classes that represent the memory aoqi@0: // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and aoqi@0: // G1OldGenPool. In G1, unlike our other GCs, we do not have a aoqi@0: // physical space for each of those spaces. Instead, we allocate aoqi@0: // regions for all three spaces out of a single pool of regions (that aoqi@0: // pool basically covers the entire heap). As a result, the eden, aoqi@0: // survivor, and old gen are considered logical spaces in G1, as each aoqi@0: // is a set of non-contiguous regions. This is also reflected in the aoqi@0: // way we map them to memory pools here. The easiest way to have done aoqi@0: // this would have been to map the entire G1 heap to a single memory aoqi@0: // pool. However, it's helpful to show how large the eden and survivor aoqi@0: // get, as this does affect the performance and behavior of G1. Which aoqi@0: // is why we introduce the three memory pools implemented here. aoqi@0: // aoqi@0: // See comments in g1MonitoringSupport.hpp for additional details aoqi@0: // on this model. aoqi@0: // aoqi@0: aoqi@0: // This class is shared by the three G1 memory pool classes aoqi@0: // (G1EdenPool, G1SurvivorPool, G1OldGenPool). aoqi@0: class G1MemoryPoolSuper : public CollectedMemoryPool { aoqi@0: protected: aoqi@0: const static size_t _undefined_max = (size_t) -1; aoqi@0: G1MonitoringSupport* _g1mm; aoqi@0: aoqi@0: // Would only be called from subclasses. aoqi@0: G1MemoryPoolSuper(G1CollectedHeap* g1h, aoqi@0: const char* name, aoqi@0: size_t init_size, aoqi@0: size_t max_size, aoqi@0: bool support_usage_threshold); aoqi@0: }; aoqi@0: aoqi@0: // Memory pool that represents the G1 eden. aoqi@0: class G1EdenPool : public G1MemoryPoolSuper { aoqi@0: public: aoqi@0: G1EdenPool(G1CollectedHeap* g1h); aoqi@0: aoqi@0: size_t used_in_bytes() { aoqi@0: return _g1mm->eden_space_used(); aoqi@0: } aoqi@0: size_t max_size() const { aoqi@0: return _undefined_max; aoqi@0: } aoqi@0: MemoryUsage get_memory_usage(); aoqi@0: }; aoqi@0: aoqi@0: // Memory pool that represents the G1 survivor. aoqi@0: class G1SurvivorPool : public G1MemoryPoolSuper { aoqi@0: public: aoqi@0: G1SurvivorPool(G1CollectedHeap* g1h); aoqi@0: aoqi@0: size_t used_in_bytes() { aoqi@0: return _g1mm->survivor_space_used(); aoqi@0: } aoqi@0: size_t max_size() const { aoqi@0: return _undefined_max; aoqi@0: } aoqi@0: MemoryUsage get_memory_usage(); aoqi@0: }; aoqi@0: aoqi@0: // Memory pool that represents the G1 old gen. aoqi@0: class G1OldGenPool : public G1MemoryPoolSuper { aoqi@0: public: aoqi@0: G1OldGenPool(G1CollectedHeap* g1h); aoqi@0: aoqi@0: size_t used_in_bytes() { aoqi@0: return _g1mm->old_space_used(); aoqi@0: } aoqi@0: size_t max_size() const { aoqi@0: return _g1mm->old_gen_max(); aoqi@0: } aoqi@0: MemoryUsage get_memory_usage(); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP