| File: | jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp |
| Warning: | line 73, column 10 Value stored to 'uncommitted' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
| 3 | * Copyright (c) 2020 SAP SE. 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/freeChunkList.hpp" |
| 28 | #include "utilities/debug.hpp" |
| 29 | #include "utilities/globalDefinitions.hpp" |
| 30 | #include "utilities/ostream.hpp" |
| 31 | |
| 32 | namespace metaspace { |
| 33 | |
| 34 | // Calculates total number of committed words over all chunks (walks chunks). |
| 35 | size_t FreeChunkList::calc_committed_word_size() const { |
| 36 | size_t s = 0; |
| 37 | for (const Metachunk* c = _first; c != NULL__null; c = c->next()) { |
| 38 | s += c->committed_words(); |
| 39 | } |
| 40 | return s; |
| 41 | } |
| 42 | |
| 43 | void FreeChunkList::print_on(outputStream* st) const { |
| 44 | if (_num_chunks.get() > 0) { |
| 45 | for (const Metachunk* c = _first; c != NULL__null; c = c->next()) { |
| 46 | st->print(" - <"); |
| 47 | c->print_on(st); |
| 48 | st->print(">"); |
| 49 | } |
| 50 | st->print(" - total : %d chunks.", _num_chunks.get()); |
| 51 | } else { |
| 52 | st->print("empty"); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | #ifdef ASSERT1 |
| 57 | |
| 58 | bool FreeChunkList::contains(const Metachunk* c) const { |
| 59 | for (Metachunk* c2 = _first; c2 != NULL__null; c2 = c2->next()) { |
| 60 | if (c2 == c) { |
| 61 | return true; |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | void FreeChunkList::verify() const { |
| 68 | if (_first == NULL__null) { |
| 69 | assert(_last == NULL, "Sanity")do { if (!(_last == __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 69, "assert(" "_last == __null" ") failed", "Sanity"); ::breakpoint (); } } while (0); |
| 70 | } else { |
| 71 | assert(_last != NULL, "Sanity")do { if (!(_last != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 71, "assert(" "_last != __null" ") failed", "Sanity"); ::breakpoint (); } } while (0); |
| 72 | int num = 0; |
| 73 | bool uncommitted = (_first->committed_words() == 0); |
Value stored to 'uncommitted' during its initialization is never read | |
| 74 | for (Metachunk* c = _first; c != NULL__null; c = c->next()) { |
| 75 | assert(c->is_free(), "Chunks in freelist should be free")do { if (!(c->is_free())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 75, "assert(" "c->is_free()" ") failed", "Chunks in freelist should be free" ); ::breakpoint(); } } while (0); |
| 76 | assert(c->used_words() == 0, "Chunk in freelist should have not used words.")do { if (!(c->used_words() == 0)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 76, "assert(" "c->used_words() == 0" ") failed", "Chunk in freelist should have not used words." ); ::breakpoint(); } } while (0); |
| 77 | assert(c->level() == _first->level(), "wrong level")do { if (!(c->level() == _first->level())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 77, "assert(" "c->level() == _first->level()" ") failed" , "wrong level"); ::breakpoint(); } } while (0); |
| 78 | assert(c->next() == NULL || c->next()->prev() == c, "front link broken")do { if (!(c->next() == __null || c->next()->prev() == c)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 78, "assert(" "c->next() == __null || c->next()->prev() == c" ") failed", "front link broken"); ::breakpoint(); } } while ( 0); |
| 79 | assert(c->prev() == NULL || c->prev()->next() == c, "back link broken")do { if (!(c->prev() == __null || c->prev()->next() == c)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 79, "assert(" "c->prev() == __null || c->prev()->next() == c" ") failed", "back link broken"); ::breakpoint(); } } while ( 0); |
| 80 | assert(c != c->prev() && c != c->next(), "circle")do { if (!(c != c->prev() && c != c->next())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 80, "assert(" "c != c->prev() && c != c->next()" ") failed", "circle"); ::breakpoint(); } } while (0); |
| 81 | c->verify(); |
| 82 | num++; |
| 83 | } |
| 84 | _num_chunks.check(num); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | #endif // ASSERT |
| 89 | |
| 90 | // Returns total size in all lists (regardless of commit state of underlying memory) |
| 91 | size_t FreeChunkListVector::word_size() const { |
| 92 | size_t sum = 0; |
| 93 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 94 | sum += list_for_level(l)->num_chunks() * chunklevel::word_size_for_level(l); |
| 95 | } |
| 96 | return sum; |
| 97 | } |
| 98 | |
| 99 | // Calculates total number of committed words over all chunks (walks chunks). |
| 100 | size_t FreeChunkListVector::calc_committed_word_size() const { |
| 101 | size_t sum = 0; |
| 102 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 103 | sum += calc_committed_word_size_at_level(l); |
| 104 | } |
| 105 | return sum; |
| 106 | } |
| 107 | |
| 108 | size_t FreeChunkListVector::calc_committed_word_size_at_level(chunklevel_t lvl) const { |
| 109 | return list_for_level(lvl)->calc_committed_word_size(); |
| 110 | } |
| 111 | |
| 112 | // Returns total committed size in all lists |
| 113 | int FreeChunkListVector::num_chunks() const { |
| 114 | int n = 0; |
| 115 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 116 | n += list_for_level(l)->num_chunks(); |
| 117 | } |
| 118 | return n; |
| 119 | } |
| 120 | |
| 121 | // Look for a chunk: starting at level, up to and including max_level, |
| 122 | // return the first chunk whose committed words >= min_committed_words. |
| 123 | // Return NULL if no such chunk was found. |
| 124 | Metachunk* FreeChunkListVector::search_chunk_ascending(chunklevel_t level, chunklevel_t max_level, size_t min_committed_words) { |
| 125 | assert(min_committed_words <= chunklevel::word_size_for_level(max_level),do { if (!(min_committed_words <= chunklevel::word_size_for_level (max_level))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 126, "assert(" "min_committed_words <= chunklevel::word_size_for_level(max_level)" ") failed", "min chunk size too small to hold min_committed_words" ); ::breakpoint(); } } while (0) |
| 126 | "min chunk size too small to hold min_committed_words")do { if (!(min_committed_words <= chunklevel::word_size_for_level (max_level))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp" , 126, "assert(" "min_committed_words <= chunklevel::word_size_for_level(max_level)" ") failed", "min chunk size too small to hold min_committed_words" ); ::breakpoint(); } } while (0); |
| 127 | for (chunklevel_t l = level; l <= max_level; l++) { |
| 128 | FreeChunkList* list = list_for_level(l); |
| 129 | Metachunk* c = list->first_minimally_committed(min_committed_words); |
| 130 | if (c != NULL__null) { |
| 131 | list->remove(c); |
| 132 | return c; |
| 133 | } |
| 134 | } |
| 135 | return NULL__null; |
| 136 | } |
| 137 | |
| 138 | // Look for a chunk: starting at level, down to (including) the root chunk level, |
| 139 | // return the first chunk whose committed words >= min_committed_words. |
| 140 | // Return NULL if no such chunk was found. |
| 141 | Metachunk* FreeChunkListVector::search_chunk_descending(chunklevel_t level, size_t min_committed_words) { |
| 142 | for (chunklevel_t l = level; l >= chunklevel::LOWEST_CHUNK_LEVEL; l --) { |
| 143 | FreeChunkList* list = list_for_level(l); |
| 144 | Metachunk* c = list->first_minimally_committed(min_committed_words); |
| 145 | if (c != NULL__null) { |
| 146 | list->remove(c); |
| 147 | return c; |
| 148 | } |
| 149 | } |
| 150 | return NULL__null; |
| 151 | } |
| 152 | |
| 153 | void FreeChunkListVector::print_on(outputStream* st) const { |
| 154 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 155 | st->print("-- List[" CHKLVL_FORMAT"lv%.2d" "]: ", l); |
| 156 | list_for_level(l)->print_on(st); |
| 157 | st->cr(); |
| 158 | } |
| 159 | st->print_cr("total chunks: %d, total word size: " SIZE_FORMAT"%" "l" "u" ".", |
| 160 | num_chunks(), word_size()); |
| 161 | } |
| 162 | |
| 163 | #ifdef ASSERT1 |
| 164 | |
| 165 | void FreeChunkListVector::verify() const { |
| 166 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 167 | list_for_level(l)->verify(); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | bool FreeChunkListVector::contains(const Metachunk* c) const { |
| 172 | for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) { |
| 173 | if (list_for_level(l)->contains(c)) { |
| 174 | return true; |
| 175 | } |
| 176 | } |
| 177 | return false; |
| 178 | } |
| 179 | |
| 180 | #endif // ASSERT |
| 181 | |
| 182 | } // namespace metaspace |
| 183 |