8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "memory/metaspace/chunkManager.hpp"
28 #include "memory/metaspace/counters.hpp"
29 #include "memory/metaspace/runningCounters.hpp"
30 #include "memory/metaspace/virtualSpaceList.hpp"
31
32 namespace metaspace {
33
34 SizeAtomicCounter RunningCounters::_used_class_counter;
35 SizeAtomicCounter RunningCounters::_used_nonclass_counter;
36
37 // Return reserved size, in words, for Metaspace
38 size_t RunningCounters::reserved_words() {
39 return reserved_words_class() + reserved_words_nonclass();
40 }
41
42 size_t RunningCounters::reserved_words_class() {
43 VirtualSpaceList* vs = VirtualSpaceList::vslist_class();
44 return vs != nullptr ? vs->reserved_words() : 0;
45 }
46
47 size_t RunningCounters::reserved_words_nonclass() {
48 assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
49 return VirtualSpaceList::vslist_nonclass()->reserved_words();
50 }
51
52 // Return total committed size, in words, for Metaspace
53 size_t RunningCounters::committed_words() {
54 return committed_words_class() + committed_words_nonclass();
55 }
56
57 size_t RunningCounters::committed_words_class() {
58 VirtualSpaceList* vs = VirtualSpaceList::vslist_class();
59 return vs != nullptr ? vs->committed_words() : 0;
60 }
61
62 size_t RunningCounters::committed_words_nonclass() {
63 assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
64 return VirtualSpaceList::vslist_nonclass()->committed_words();
65 }
66
67 // ---- used chunks -----
68
69 // Returns size, in words, used for metadata.
70 size_t RunningCounters::used_words() {
71 return used_words_class() + used_words_nonclass();
72 }
73
74 size_t RunningCounters::used_words_class() {
75 return _used_class_counter.get();
76 }
77
78 size_t RunningCounters::used_words_nonclass() {
79 return _used_nonclass_counter.get();
80 }
81
82 // ---- free chunks -----
83
84 // Returns size, in words, of all chunks in all freelists.
85 size_t RunningCounters::free_chunks_words() {
86 return free_chunks_words_class() + free_chunks_words_nonclass();
87 }
88
89 size_t RunningCounters::free_chunks_words_class() {
90 ChunkManager* cm = ChunkManager::chunkmanager_class();
91 return cm != nullptr ? cm->total_word_size() : 0;
92 }
93
94 size_t RunningCounters::free_chunks_words_nonclass() {
95 assert(ChunkManager::chunkmanager_nonclass() != nullptr, "Metaspace not yet initialized");
96 return ChunkManager::chunkmanager_nonclass()->total_word_size();
97 }
98
99 } // namespace metaspace
|
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "memory/metaspace/chunkManager.hpp"
28 #include "memory/metaspace/metaspaceContext.hpp"
29 #include "memory/metaspace/runningCounters.hpp"
30 #include "memory/metaspace/virtualSpaceList.hpp"
31
32 namespace metaspace {
33
34 // Return reserved size, in words, for Metaspace
35 size_t RunningCounters::reserved_words() {
36 return reserved_words_class() + reserved_words_nonclass();
37 }
38
39 size_t RunningCounters::reserved_words_class() {
40 VirtualSpaceList* vs = VirtualSpaceList::vslist_class();
41 return vs != nullptr ? vs->reserved_words() : 0;
42 }
43
44 size_t RunningCounters::reserved_words_nonclass() {
45 assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
46 return VirtualSpaceList::vslist_nonclass()->reserved_words();
47 }
48
49 // Return total committed size, in words, for Metaspace
50 size_t RunningCounters::committed_words() {
51 return committed_words_class() + committed_words_nonclass();
52 }
53
54 size_t RunningCounters::committed_words_class() {
55 VirtualSpaceList* vs = VirtualSpaceList::vslist_class();
56 return vs != nullptr ? vs->committed_words() : 0;
57 }
58
59 size_t RunningCounters::committed_words_nonclass() {
60 assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
61 return VirtualSpaceList::vslist_nonclass()->committed_words();
62 }
63
64 // ---- used chunks -----
65
66 // Returns size, in words, used for metadata.
67 size_t RunningCounters::used_words() {
68 return used_words_class() + used_words_nonclass();
69 }
70
71 size_t RunningCounters::used_words_class() {
72 const MetaspaceContext* context = MetaspaceContext::context_class();
73 return context != nullptr ? context->used_words() : 0;
74 }
75
76 size_t RunningCounters::used_words_nonclass() {
77 return MetaspaceContext::context_nonclass()->used_words();
78 }
79
80 // ---- free chunks -----
81
82 // Returns size, in words, of all chunks in all freelists.
83 size_t RunningCounters::free_chunks_words() {
84 return free_chunks_words_class() + free_chunks_words_nonclass();
85 }
86
87 size_t RunningCounters::free_chunks_words_class() {
88 ChunkManager* cm = ChunkManager::chunkmanager_class();
89 return cm != nullptr ? cm->total_word_size() : 0;
90 }
91
92 size_t RunningCounters::free_chunks_words_nonclass() {
93 assert(ChunkManager::chunkmanager_nonclass() != nullptr, "Metaspace not yet initialized");
94 return ChunkManager::chunkmanager_nonclass()->total_word_size();
95 }
96
97 } // namespace metaspace
|