blob: f1a900caa0f36bd443a536fa5a6f4474c75d149c [file] [log] [blame]
J. Duke81537792007-12-01 00:00:00 +00001/*
Per Lidén4dc240f2015-05-13 15:16:06 +02002 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
J. Duke81537792007-12-01 00:00:00 +00003 * 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 Trimbleba7c1732010-05-27 19:08:38 -070019 * 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. Duke81537792007-12-01 00:00:00 +000022 *
23 */
24
Stefan Karlsson8006fe82010-11-23 13:22:55 -080025#ifndef SHARE_VM_SERVICES_PSMEMORYPOOL_HPP
26#define SHARE_VM_SERVICES_PSMEMORYPOOL_HPP
27
Joseph Provino698fba92013-01-23 13:02:39 -050028#include "utilities/macros.hpp"
29#if INCLUDE_ALL_GCS
Per Lidén4dc240f2015-05-13 15:16:06 +020030#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 Karlsson8006fe82010-11-23 13:22:55 -080035#include "memory/heap.hpp"
Stefan Karlsson8006fe82010-11-23 13:22:55 -080036#include "services/memoryPool.hpp"
37#include "services/memoryUsage.hpp"
Joseph Provino698fba92013-01-23 13:02:39 -050038#endif // INCLUDE_ALL_GCS
Stefan Karlsson8006fe82010-11-23 13:22:55 -080039
J. Duke81537792007-12-01 00:00:00 +000040class PSGenerationPool : public CollectedMemoryPool {
41private:
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020042 PSOldGen* _old_gen;
J. Duke81537792007-12-01 00:00:00 +000043
44public:
45 PSGenerationPool(PSOldGen* pool, const char* name, PoolType type, bool support_usage_threshold);
J. Duke81537792007-12-01 00:00:00 +000046
47 MemoryUsage get_memory_usage();
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020048 size_t used_in_bytes() { return _old_gen->used_in_bytes(); }
49 size_t max_size() const { return _old_gen->reserved().byte_size(); }
J. Duke81537792007-12-01 00:00:00 +000050};
51
52class EdenMutableSpacePool : public CollectedMemoryPool {
53private:
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020054 PSYoungGen* _young_gen;
J. Duke81537792007-12-01 00:00:00 +000055 MutableSpace* _space;
56
57public:
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020058 EdenMutableSpacePool(PSYoungGen* young_gen,
J. Duke81537792007-12-01 00:00:00 +000059 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 Wilhelmsson49fb9142015-08-18 21:32:21 +020069 return _young_gen->max_size() - _young_gen->from_space()->capacity_in_bytes() - _young_gen->to_space()->capacity_in_bytes();
J. Duke81537792007-12-01 00:00:00 +000070 }
71};
72
73class SurvivorMutableSpacePool : public CollectedMemoryPool {
74private:
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020075 PSYoungGen* _young_gen;
J. Duke81537792007-12-01 00:00:00 +000076
77public:
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020078 SurvivorMutableSpacePool(PSYoungGen* young_gen,
J. Duke81537792007-12-01 00:00:00 +000079 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 Wilhelmsson49fb9142015-08-18 21:32:21 +020086 return _young_gen->from_space()->used_in_bytes();
J. Duke81537792007-12-01 00:00:00 +000087 }
88 size_t committed_in_bytes() {
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020089 return _young_gen->from_space()->capacity_in_bytes();
J. Duke81537792007-12-01 00:00:00 +000090 }
91 size_t max_size() const {
92 // Return current committed size of the from-space
Jesper Wilhelmsson49fb9142015-08-18 21:32:21 +020093 return _young_gen->from_space()->capacity_in_bytes();
J. Duke81537792007-12-01 00:00:00 +000094 }
95};
Stefan Karlsson8006fe82010-11-23 13:22:55 -080096
97#endif // SHARE_VM_SERVICES_PSMEMORYPOOL_HPP