J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 1 | /* |
Per Lidén | 4dc240f | 2015-05-13 15:16:06 +0200 | [diff] [blame] | 2 | * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 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 | * |
Erik Trimble | ba7c173 | 2010-05-27 19:08:38 -0700 | [diff] [blame] | 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. |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 22 | * |
| 23 | */ |
| 24 | |
Stefan Karlsson | 8006fe8 | 2010-11-23 13:22:55 -0800 | [diff] [blame] | 25 | #ifndef SHARE_VM_SERVICES_PSMEMORYPOOL_HPP |
| 26 | #define SHARE_VM_SERVICES_PSMEMORYPOOL_HPP |
| 27 | |
Joseph Provino | 698fba9 | 2013-01-23 13:02:39 -0500 | [diff] [blame] | 28 | #include "utilities/macros.hpp" |
| 29 | #if INCLUDE_ALL_GCS |
Per Lidén | 4dc240f | 2015-05-13 15:16:06 +0200 | [diff] [blame] | 30 | #include "gc/parallel/mutableSpace.hpp" |
| 31 | #include "gc/parallel/psOldGen.hpp" |
| 32 | #include "gc/parallel/psYoungGen.hpp" |
| 33 | #include "gc/serial/defNewGeneration.hpp" |
| 34 | #include "gc/shared/space.hpp" |
Stefan Karlsson | 8006fe8 | 2010-11-23 13:22:55 -0800 | [diff] [blame] | 35 | #include "memory/heap.hpp" |
Stefan Karlsson | 8006fe8 | 2010-11-23 13:22:55 -0800 | [diff] [blame] | 36 | #include "services/memoryPool.hpp" |
| 37 | #include "services/memoryUsage.hpp" |
Joseph Provino | 698fba9 | 2013-01-23 13:02:39 -0500 | [diff] [blame] | 38 | #endif // INCLUDE_ALL_GCS |
Stefan Karlsson | 8006fe8 | 2010-11-23 13:22:55 -0800 | [diff] [blame] | 39 | |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 40 | class PSGenerationPool : public CollectedMemoryPool { |
| 41 | private: |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 42 | PSOldGen* _old_gen; |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 43 | |
| 44 | public: |
| 45 | PSGenerationPool(PSOldGen* pool, const char* name, PoolType type, bool support_usage_threshold); |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 46 | |
| 47 | MemoryUsage get_memory_usage(); |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 48 | size_t used_in_bytes() { return _old_gen->used_in_bytes(); } |
| 49 | size_t max_size() const { return _old_gen->reserved().byte_size(); } |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | class EdenMutableSpacePool : public CollectedMemoryPool { |
| 53 | private: |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 54 | PSYoungGen* _young_gen; |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 55 | MutableSpace* _space; |
| 56 | |
| 57 | public: |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 58 | EdenMutableSpacePool(PSYoungGen* young_gen, |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 59 | MutableSpace* space, |
| 60 | const char* name, |
| 61 | PoolType type, |
| 62 | bool support_usage_threshold); |
| 63 | |
| 64 | MutableSpace* space() { return _space; } |
| 65 | MemoryUsage get_memory_usage(); |
| 66 | size_t used_in_bytes() { return space()->used_in_bytes(); } |
| 67 | size_t max_size() const { |
| 68 | // Eden's max_size = max_size of Young Gen - the current committed size of survivor spaces |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 69 | return _young_gen->max_size() - _young_gen->from_space()->capacity_in_bytes() - _young_gen->to_space()->capacity_in_bytes(); |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 70 | } |
| 71 | }; |
| 72 | |
| 73 | class SurvivorMutableSpacePool : public CollectedMemoryPool { |
| 74 | private: |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 75 | PSYoungGen* _young_gen; |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 76 | |
| 77 | public: |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 78 | SurvivorMutableSpacePool(PSYoungGen* young_gen, |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 79 | const char* name, |
| 80 | PoolType type, |
| 81 | bool support_usage_threshold); |
| 82 | |
| 83 | MemoryUsage get_memory_usage(); |
| 84 | |
| 85 | size_t used_in_bytes() { |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 86 | return _young_gen->from_space()->used_in_bytes(); |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 87 | } |
| 88 | size_t committed_in_bytes() { |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 89 | return _young_gen->from_space()->capacity_in_bytes(); |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 90 | } |
| 91 | size_t max_size() const { |
| 92 | // Return current committed size of the from-space |
Jesper Wilhelmsson | 49fb914 | 2015-08-18 21:32:21 +0200 | [diff] [blame] | 93 | return _young_gen->from_space()->capacity_in_bytes(); |
J. Duke | 8153779 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 94 | } |
| 95 | }; |
Stefan Karlsson | 8006fe8 | 2010-11-23 13:22:55 -0800 | [diff] [blame] | 96 | |
| 97 | #endif // SHARE_VM_SERVICES_PSMEMORYPOOL_HPP |