|
1 /* |
|
2 * Copyright (c) 2019, SAP SE. All rights reserved. |
|
3 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
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/leftOverBins.inline.hpp" |
|
28 #include "utilities/globalDefinitions.hpp" |
|
29 #include "utilities/ostream.hpp" |
|
30 |
|
31 |
|
32 namespace metaspace { |
|
33 |
|
34 |
|
35 |
|
36 #ifdef ASSERT |
|
37 void LeftOverManager::verify() const { |
|
38 _very_small_bins.verify(); |
|
39 |
|
40 if (_large_block_reserve != NULL) { |
|
41 assert(_current != NULL, "Sanity"); |
|
42 } |
|
43 |
|
44 assert( (_current == NULL && _current_size == 0) || |
|
45 (_current != NULL && _current_size > 0), "Sanity"); |
|
46 |
|
47 for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
|
48 assert(b->size > 0 && b->size <= 4 * M, "Weird block size"); |
|
49 } |
|
50 |
|
51 } |
|
52 #endif |
|
53 |
|
54 void LeftOverManager::large_block_statistics(block_stats_t* stats) const { |
|
55 for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
|
56 stats->num_blocks ++; |
|
57 stats->word_size += b->size; |
|
58 } |
|
59 } |
|
60 |
|
61 void LeftOverManager::statistics(block_stats_t* stats) const { |
|
62 stats->num_blocks = 0; |
|
63 stats->word_size = 0; |
|
64 _very_small_bins.statistics(stats); |
|
65 if (_current != NULL) { |
|
66 stats->num_blocks ++; |
|
67 stats->word_size += _current_size; |
|
68 large_block_statistics(stats); |
|
69 } else { |
|
70 assert(_large_block_reserve == NULL, "Sanity"); |
|
71 } |
|
72 } |
|
73 |
|
74 void LeftOverManager::print(outputStream* st, bool detailed) const { |
|
75 |
|
76 block_stats_t s; |
|
77 |
|
78 if (_current != NULL) { |
|
79 st->print("current: " SIZE_FORMAT " words; ", _current_size); |
|
80 } |
|
81 |
|
82 s.num_blocks = 0; s.word_size = 0; |
|
83 large_block_statistics(&s); |
|
84 st->print("large blocks: %d blocks, " SIZE_FORMAT " words", s.num_blocks, s.word_size); |
|
85 if (detailed) { |
|
86 st->print(" ("); |
|
87 for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
|
88 st->print(SIZE_FORMAT "%s", b->size, b->next != NULL ? ", " : ""); |
|
89 } |
|
90 st->print(")"); |
|
91 } |
|
92 st->print("; "); |
|
93 |
|
94 s.num_blocks = 0; s.word_size = 0; |
|
95 _very_small_bins.statistics(&s); |
|
96 st->print("small blocks: %d blocks, " SIZE_FORMAT " words", s.num_blocks, s.word_size); |
|
97 if (detailed) { |
|
98 st->print(" ("); |
|
99 _very_small_bins.print(st); |
|
100 st->print(")"); |
|
101 } |
|
102 st->print("; "); |
|
103 } |
|
104 |
|
105 } // namespace metaspace |
|
106 |