| File: | jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp |
| Warning: | line 362, column 3 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* | |||
| 2 | * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. | |||
| 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 | * | |||
| 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. | |||
| 22 | * | |||
| 23 | */ | |||
| 24 | ||||
| 25 | #include "precompiled.hpp" | |||
| 26 | #include "gc/g1/g1CollectedHeap.inline.hpp" | |||
| 27 | #include "gc/g1/g1NUMA.hpp" | |||
| 28 | #include "gc/g1/heapRegionRemSet.inline.hpp" | |||
| 29 | #include "gc/g1/heapRegionSet.inline.hpp" | |||
| 30 | ||||
| 31 | uint FreeRegionList::_unrealistically_long_length = 0; | |||
| 32 | ||||
| 33 | #ifndef PRODUCT | |||
| 34 | void HeapRegionSetBase::verify_region(HeapRegion* hr) { | |||
| 35 | assert(hr->containing_set() == this, "Inconsistent containing set for %u", hr->hrm_index())do { if (!(hr->containing_set() == this)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 35, "assert(" "hr->containing_set() == this" ") failed", "Inconsistent containing set for %u", hr->hrm_index()); :: breakpoint(); } } while (0); | |||
| 36 | assert(!hr->is_young(), "Adding young region %u", hr->hrm_index())do { if (!(!hr->is_young())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 36, "assert(" "!hr->is_young()" ") failed", "Adding young region %u" , hr->hrm_index()); ::breakpoint(); } } while (0); // currently we don't use these sets for young regions | |||
| 37 | assert(_checker == NULL || _checker->is_correct_type(hr), "Wrong type of region %u (%s) and set %s",do { if (!(_checker == __null || _checker->is_correct_type (hr))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 38, "assert(" "_checker == __null || _checker->is_correct_type(hr)" ") failed", "Wrong type of region %u (%s) and set %s", hr-> hrm_index(), hr->get_type_str(), name()); ::breakpoint(); } } while (0) | |||
| 38 | hr->hrm_index(), hr->get_type_str(), name())do { if (!(_checker == __null || _checker->is_correct_type (hr))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 38, "assert(" "_checker == __null || _checker->is_correct_type(hr)" ") failed", "Wrong type of region %u (%s) and set %s", hr-> hrm_index(), hr->get_type_str(), name()); ::breakpoint(); } } while (0); | |||
| 39 | assert(!hr->is_free() || hr->is_empty(), "Free region %u is not empty for set %s", hr->hrm_index(), name())do { if (!(!hr->is_free() || hr->is_empty())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 39, "assert(" "!hr->is_free() || hr->is_empty()" ") failed" , "Free region %u is not empty for set %s", hr->hrm_index( ), name()); ::breakpoint(); } } while (0); | |||
| 40 | assert(!hr->is_empty() || hr->is_free() || hr->is_archive(),do { if (!(!hr->is_empty() || hr->is_free() || hr->is_archive ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 41, "assert(" "!hr->is_empty() || hr->is_free() || hr->is_archive()" ") failed", "Empty region %u is not free or archive for set %s" , hr->hrm_index(), name()); ::breakpoint(); } } while (0) | |||
| 41 | "Empty region %u is not free or archive for set %s", hr->hrm_index(), name())do { if (!(!hr->is_empty() || hr->is_free() || hr->is_archive ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 41, "assert(" "!hr->is_empty() || hr->is_free() || hr->is_archive()" ") failed", "Empty region %u is not free or archive for set %s" , hr->hrm_index(), name()); ::breakpoint(); } } while (0); | |||
| 42 | } | |||
| 43 | #endif | |||
| 44 | ||||
| 45 | void HeapRegionSetBase::verify() { | |||
| 46 | // It's important that we also observe the MT safety protocol even | |||
| 47 | // for the verification calls. If we do verification without the | |||
| 48 | // appropriate locks and the set changes underneath our feet | |||
| 49 | // verification might fail and send us on a wild goose chase. | |||
| 50 | check_mt_safety(); | |||
| 51 | ||||
| 52 | guarantee_heap_region_set(( is_empty() && length() == 0) ||do { do { if (!((( is_empty() && length() == 0) || (! is_empty() && length() > 0)))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 54, "guarantee(" "(( is_empty() && length() == 0) || (!is_empty() && length() > 0))" ") failed", "[%s] %s ln: %u", name(), "invariant", length()) ; ::breakpoint(); } } while (0); } while (0) | |||
| 53 | (!is_empty() && length() > 0),do { do { if (!((( is_empty() && length() == 0) || (! is_empty() && length() > 0)))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 54, "guarantee(" "(( is_empty() && length() == 0) || (!is_empty() && length() > 0))" ") failed", "[%s] %s ln: %u", name(), "invariant", length()) ; ::breakpoint(); } } while (0); } while (0) | |||
| 54 | "invariant")do { do { if (!((( is_empty() && length() == 0) || (! is_empty() && length() > 0)))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 54, "guarantee(" "(( is_empty() && length() == 0) || (!is_empty() && length() > 0))" ") failed", "[%s] %s ln: %u", name(), "invariant", length()) ; ::breakpoint(); } } while (0); } while (0); | |||
| 55 | } | |||
| 56 | ||||
| 57 | void HeapRegionSetBase::verify_start() { | |||
| 58 | // See comment in verify() about MT safety and verification. | |||
| 59 | check_mt_safety(); | |||
| 60 | assert_heap_region_set(!_verify_in_progress, "verification should not be in progress")do { do { if (!((!_verify_in_progress))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 60, "assert(" "(!_verify_in_progress)" ") failed", "[%s] %s ln: %u" , name(), "verification should not be in progress", length()) ; ::breakpoint(); } } while (0); } while (0); | |||
| 61 | ||||
| 62 | // Do the basic verification first before we do the checks over the regions. | |||
| 63 | HeapRegionSetBase::verify(); | |||
| 64 | ||||
| 65 | _verify_in_progress = true; | |||
| 66 | } | |||
| 67 | ||||
| 68 | void HeapRegionSetBase::verify_end() { | |||
| 69 | // See comment in verify() about MT safety and verification. | |||
| 70 | check_mt_safety(); | |||
| 71 | assert_heap_region_set(_verify_in_progress, "verification should be in progress")do { do { if (!((_verify_in_progress))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 71, "assert(" "(_verify_in_progress)" ") failed", "[%s] %s ln: %u" , name(), "verification should be in progress", length()); :: breakpoint(); } } while (0); } while (0); | |||
| 72 | ||||
| 73 | _verify_in_progress = false; | |||
| 74 | } | |||
| 75 | ||||
| 76 | void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) { | |||
| 77 | out->cr(); | |||
| 78 | out->print_cr("Set: %s (" PTR_FORMAT"0x%016" "l" "x" ")", name(), p2i(this)); | |||
| 79 | out->print_cr(" Region Type : %s", _checker->get_description()); | |||
| 80 | out->print_cr(" Length : %14u", length()); | |||
| 81 | } | |||
| 82 | ||||
| 83 | HeapRegionSetBase::HeapRegionSetBase(const char* name, HeapRegionSetChecker* checker) | |||
| 84 | : _checker(checker), _length(0), _name(name), _verify_in_progress(false) | |||
| 85 | { | |||
| 86 | } | |||
| 87 | ||||
| 88 | void FreeRegionList::set_unrealistically_long_length(uint len) { | |||
| 89 | guarantee(_unrealistically_long_length == 0, "should only be set once")do { if (!(_unrealistically_long_length == 0)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 89, "guarantee(" "_unrealistically_long_length == 0" ") failed" , "should only be set once"); ::breakpoint(); } } while (0); | |||
| 90 | _unrealistically_long_length = len; | |||
| 91 | } | |||
| 92 | ||||
| 93 | void FreeRegionList::abandon() { | |||
| 94 | check_mt_safety(); | |||
| 95 | clear(); | |||
| 96 | verify_optional(); | |||
| 97 | } | |||
| 98 | ||||
| 99 | void FreeRegionList::remove_all() { | |||
| 100 | check_mt_safety(); | |||
| 101 | verify_optional(); | |||
| 102 | ||||
| 103 | HeapRegion* curr = _head; | |||
| 104 | while (curr != NULL__null) { | |||
| 105 | verify_region(curr); | |||
| 106 | ||||
| 107 | HeapRegion* next = curr->next(); | |||
| 108 | curr->set_next(NULL__null); | |||
| 109 | curr->set_prev(NULL__null); | |||
| 110 | curr->set_containing_set(NULL__null); | |||
| 111 | ||||
| 112 | decrease_length(curr->node_index()); | |||
| 113 | ||||
| 114 | curr = next; | |||
| 115 | } | |||
| 116 | clear(); | |||
| 117 | ||||
| 118 | verify_optional(); | |||
| 119 | } | |||
| 120 | ||||
| 121 | void FreeRegionList::add_list_common_start(FreeRegionList* from_list) { | |||
| 122 | check_mt_safety(); | |||
| 123 | from_list->check_mt_safety(); | |||
| 124 | verify_optional(); | |||
| 125 | from_list->verify_optional(); | |||
| 126 | ||||
| 127 | if (from_list->is_empty()) { | |||
| 128 | return; | |||
| 129 | } | |||
| 130 | ||||
| 131 | if (_node_info != NULL__null && from_list->_node_info != NULL__null) { | |||
| 132 | _node_info->add(from_list->_node_info); | |||
| 133 | } | |||
| 134 | ||||
| 135 | #ifdef ASSERT1 | |||
| 136 | FreeRegionListIterator iter(from_list); | |||
| 137 | while (iter.more_available()) { | |||
| 138 | HeapRegion* hr = iter.get_next(); | |||
| 139 | // In set_containing_set() we check that we either set the value | |||
| 140 | // from NULL to non-NULL or vice versa to catch bugs. So, we have | |||
| 141 | // to NULL it first before setting it to the value. | |||
| 142 | hr->set_containing_set(NULL__null); | |||
| 143 | hr->set_containing_set(this); | |||
| 144 | } | |||
| 145 | #endif // ASSERT | |||
| 146 | } | |||
| 147 | ||||
| 148 | void FreeRegionList::add_list_common_end(FreeRegionList* from_list) { | |||
| 149 | _length += from_list->length(); | |||
| 150 | from_list->clear(); | |||
| 151 | ||||
| 152 | verify_optional(); | |||
| 153 | from_list->verify_optional(); | |||
| 154 | } | |||
| 155 | ||||
| 156 | void FreeRegionList::append_ordered(FreeRegionList* from_list) { | |||
| 157 | add_list_common_start(from_list); | |||
| 158 | ||||
| 159 | if (from_list->is_empty()) { | |||
| 160 | return; | |||
| 161 | } | |||
| 162 | ||||
| 163 | if (is_empty()) { | |||
| 164 | // Make from_list the current list. | |||
| 165 | assert_free_region_list(length() == 0 && _tail == NULL, "invariant")do { do { if (!((length() == 0 && _tail == __null))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 165, "assert(" "(length() == 0 && _tail == __null)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant", length(), p2i(_head), p2i(_tail )); ::breakpoint(); } } while (0); } while (0); | |||
| 166 | _head = from_list->_head; | |||
| 167 | _tail = from_list->_tail; | |||
| 168 | } else { | |||
| 169 | // Add the from_list to the end of the current list. | |||
| 170 | assert(_tail->hrm_index() < from_list->_head->hrm_index(), "Should be sorted %u < %u",do { if (!(_tail->hrm_index() < from_list->_head-> hrm_index())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 171, "assert(" "_tail->hrm_index() < from_list->_head->hrm_index()" ") failed", "Should be sorted %u < %u", _tail->hrm_index (), from_list->_head->hrm_index()); ::breakpoint(); } } while (0) | |||
| 171 | _tail->hrm_index(), from_list->_head->hrm_index())do { if (!(_tail->hrm_index() < from_list->_head-> hrm_index())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 171, "assert(" "_tail->hrm_index() < from_list->_head->hrm_index()" ") failed", "Should be sorted %u < %u", _tail->hrm_index (), from_list->_head->hrm_index()); ::breakpoint(); } } while (0); | |||
| 172 | ||||
| 173 | _tail->set_next(from_list->_head); | |||
| 174 | from_list->_head->set_prev(_tail); | |||
| 175 | _tail = from_list->_tail; | |||
| 176 | } | |||
| 177 | ||||
| 178 | add_list_common_end(from_list); | |||
| 179 | } | |||
| 180 | ||||
| 181 | void FreeRegionList::add_ordered(FreeRegionList* from_list) { | |||
| 182 | add_list_common_start(from_list); | |||
| 183 | ||||
| 184 | if (from_list->is_empty()) { | |||
| 185 | return; | |||
| 186 | } | |||
| 187 | ||||
| 188 | if (is_empty()) { | |||
| 189 | assert_free_region_list(length() == 0 && _tail == NULL, "invariant")do { do { if (!((length() == 0 && _tail == __null))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 189, "assert(" "(length() == 0 && _tail == __null)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant", length(), p2i(_head), p2i(_tail )); ::breakpoint(); } } while (0); } while (0); | |||
| 190 | _head = from_list->_head; | |||
| 191 | _tail = from_list->_tail; | |||
| 192 | } else { | |||
| 193 | HeapRegion* curr_to = _head; | |||
| 194 | HeapRegion* curr_from = from_list->_head; | |||
| 195 | ||||
| 196 | while (curr_from != NULL__null) { | |||
| 197 | while (curr_to != NULL__null && curr_to->hrm_index() < curr_from->hrm_index()) { | |||
| 198 | curr_to = curr_to->next(); | |||
| 199 | } | |||
| 200 | ||||
| 201 | if (curr_to == NULL__null) { | |||
| 202 | // The rest of the from list should be added as tail | |||
| 203 | _tail->set_next(curr_from); | |||
| 204 | curr_from->set_prev(_tail); | |||
| 205 | curr_from = NULL__null; | |||
| 206 | } else { | |||
| 207 | HeapRegion* next_from = curr_from->next(); | |||
| 208 | ||||
| 209 | curr_from->set_next(curr_to); | |||
| 210 | curr_from->set_prev(curr_to->prev()); | |||
| 211 | if (curr_to->prev() == NULL__null) { | |||
| 212 | _head = curr_from; | |||
| 213 | } else { | |||
| 214 | curr_to->prev()->set_next(curr_from); | |||
| 215 | } | |||
| 216 | curr_to->set_prev(curr_from); | |||
| 217 | ||||
| 218 | curr_from = next_from; | |||
| 219 | } | |||
| 220 | } | |||
| 221 | ||||
| 222 | if (_tail->hrm_index() < from_list->_tail->hrm_index()) { | |||
| 223 | _tail = from_list->_tail; | |||
| 224 | } | |||
| 225 | } | |||
| 226 | ||||
| 227 | add_list_common_end(from_list); | |||
| 228 | } | |||
| 229 | ||||
| 230 | #ifdef ASSERT1 | |||
| 231 | void FreeRegionList::verify_region_to_remove(HeapRegion* curr, HeapRegion* next) { | |||
| 232 | assert_free_region_list(_head != next, "invariant")do { do { if (!((_head != next))) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 232, "assert(" "(_head != next)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 233 | if (next != NULL__null) { | |||
| 234 | assert_free_region_list(next->prev() == curr, "invariant")do { do { if (!((next->prev() == curr))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 234, "assert(" "(next->prev() == curr)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 235 | assert_free_region_list(_tail != curr, "invariant")do { do { if (!((_tail != curr))) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 235, "assert(" "(_tail != curr)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 236 | } else { | |||
| 237 | assert_free_region_list(_tail == curr, "invariant")do { do { if (!((_tail == curr))) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 237, "assert(" "(_tail == curr)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 238 | } | |||
| 239 | HeapRegion* prev = curr->prev(); | |||
| 240 | if (prev == NULL__null) { | |||
| 241 | assert_free_region_list(_head == curr, "invariant")do { do { if (!((_head == curr))) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 241, "assert(" "(_head == curr)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 242 | } else { | |||
| 243 | assert_free_region_list(_head != curr, "invariant")do { do { if (!((_head != curr))) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 243, "assert(" "(_head != curr)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "invariant" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 244 | } | |||
| 245 | } | |||
| 246 | #endif | |||
| 247 | ||||
| 248 | void FreeRegionList::remove_starting_at(HeapRegion* first, uint num_regions) { | |||
| 249 | check_mt_safety(); | |||
| 250 | assert_free_region_list(num_regions >= 1, "pre-condition")do { do { if (!((num_regions >= 1))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 250, "assert(" "(num_regions >= 1)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "pre-condition" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 251 | assert_free_region_list(!is_empty(), "pre-condition")do { do { if (!((!is_empty()))) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 251, "assert(" "(!is_empty())" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "pre-condition" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 252 | assert_free_region_list(length() >= num_regions, "pre-condition")do { do { if (!((length() >= num_regions))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 252, "assert(" "(length() >= num_regions)" ") failed", "[%s] %s ln: %u hd: " "0x%016" "l" "x" " tl: " "0x%016" "l" "x", name(), "pre-condition" , length(), p2i(_head), p2i(_tail)); ::breakpoint(); } } while (0); } while (0); | |||
| 253 | ||||
| 254 | verify_optional(); | |||
| 255 | DEBUG_ONLY(uint old_length = length();)uint old_length = length(); | |||
| 256 | ||||
| 257 | // prev points to the node right before first or null when first == _head | |||
| 258 | HeapRegion* const prev = first->prev(); | |||
| 259 | // next points to the node right after first or null when first == _tail, | |||
| 260 | // and after the while loop below, next should point to the next node right | |||
| 261 | // after the removed sublist, or null if the sublist contains _tail. | |||
| 262 | HeapRegion* next = first->next(); | |||
| 263 | ||||
| 264 | HeapRegion* curr = first; | |||
| 265 | uint count = 0; | |||
| 266 | while (count < num_regions) { | |||
| 267 | verify_region(curr); | |||
| 268 | next = curr->next(); | |||
| 269 | verify_region_to_remove(curr, next); | |||
| 270 | ||||
| 271 | if (_last == curr) { | |||
| 272 | _last = NULL__null; | |||
| 273 | } | |||
| 274 | ||||
| 275 | curr->set_next(NULL__null); | |||
| 276 | curr->set_prev(NULL__null); | |||
| 277 | remove(curr); | |||
| 278 | ||||
| 279 | count++; | |||
| 280 | ||||
| 281 | decrease_length(curr->node_index()); | |||
| 282 | ||||
| 283 | curr = next; | |||
| 284 | } | |||
| 285 | ||||
| 286 | if (prev == NULL__null) { | |||
| 287 | _head = next; | |||
| 288 | } else { | |||
| 289 | prev->set_next(next); | |||
| 290 | } | |||
| 291 | if (next == NULL__null) { | |||
| 292 | _tail = prev; | |||
| 293 | } else { | |||
| 294 | next->set_prev(prev); | |||
| 295 | } | |||
| 296 | ||||
| 297 | assert(count == num_regions,do { if (!(count == num_regions)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 299, "assert(" "count == num_regions" ") failed", "[%s] count: %u should be == num_regions: %u" , name(), count, num_regions); ::breakpoint(); } } while (0) | |||
| 298 | "[%s] count: %u should be == num_regions: %u",do { if (!(count == num_regions)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 299, "assert(" "count == num_regions" ") failed", "[%s] count: %u should be == num_regions: %u" , name(), count, num_regions); ::breakpoint(); } } while (0) | |||
| 299 | name(), count, num_regions)do { if (!(count == num_regions)) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 299, "assert(" "count == num_regions" ") failed", "[%s] count: %u should be == num_regions: %u" , name(), count, num_regions); ::breakpoint(); } } while (0); | |||
| 300 | assert(length() + num_regions == old_length,do { if (!(length() + num_regions == old_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 303, "assert(" "length() + num_regions == old_length" ") failed" , "[%s] new length should be consistent " "new length: %u old length: %u num_regions: %u" , name(), length(), old_length, num_regions); ::breakpoint(); } } while (0) | |||
| 301 | "[%s] new length should be consistent "do { if (!(length() + num_regions == old_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 303, "assert(" "length() + num_regions == old_length" ") failed" , "[%s] new length should be consistent " "new length: %u old length: %u num_regions: %u" , name(), length(), old_length, num_regions); ::breakpoint(); } } while (0) | |||
| 302 | "new length: %u old length: %u num_regions: %u",do { if (!(length() + num_regions == old_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 303, "assert(" "length() + num_regions == old_length" ") failed" , "[%s] new length should be consistent " "new length: %u old length: %u num_regions: %u" , name(), length(), old_length, num_regions); ::breakpoint(); } } while (0) | |||
| 303 | name(), length(), old_length, num_regions)do { if (!(length() + num_regions == old_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 303, "assert(" "length() + num_regions == old_length" ") failed" , "[%s] new length should be consistent " "new length: %u old length: %u num_regions: %u" , name(), length(), old_length, num_regions); ::breakpoint(); } } while (0); | |||
| 304 | ||||
| 305 | verify_optional(); | |||
| 306 | } | |||
| 307 | ||||
| 308 | void FreeRegionList::verify() { | |||
| 309 | // See comment in HeapRegionSetBase::verify() about MT safety and | |||
| 310 | // verification. | |||
| 311 | check_mt_safety(); | |||
| 312 | ||||
| 313 | // This will also do the basic verification too. | |||
| 314 | verify_start(); | |||
| 315 | ||||
| 316 | verify_list(); | |||
| ||||
| 317 | ||||
| 318 | verify_end(); | |||
| 319 | } | |||
| 320 | ||||
| 321 | void FreeRegionList::clear() { | |||
| 322 | _length = 0; | |||
| 323 | _head = NULL__null; | |||
| 324 | _tail = NULL__null; | |||
| 325 | _last = NULL__null; | |||
| 326 | ||||
| 327 | if (_node_info!= NULL__null) { | |||
| 328 | _node_info->clear(); | |||
| 329 | } | |||
| 330 | } | |||
| 331 | ||||
| 332 | void FreeRegionList::verify_list() { | |||
| 333 | HeapRegion* curr = _head; | |||
| 334 | HeapRegion* prev1 = NULL__null; | |||
| 335 | HeapRegion* prev0 = NULL__null; | |||
| 336 | uint count = 0; | |||
| 337 | size_t capacity = 0; | |||
| 338 | uint last_index = 0; | |||
| 339 | ||||
| 340 | guarantee(_head == NULL || _head->prev() == NULL, "_head should not have a prev")do { if (!(_head == __null || _head->prev() == __null)) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 340, "guarantee(" "_head == NULL || _head->prev() == NULL" ") failed", "_head should not have a prev"); ::breakpoint(); } } while (0); | |||
| 341 | while (curr != NULL__null) { | |||
| 342 | verify_region(curr); | |||
| 343 | ||||
| 344 | count++; | |||
| 345 | guarantee(count < _unrealistically_long_length,do { if (!(count < _unrealistically_long_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 347, "guarantee(" "count < _unrealistically_long_length" ") failed", "[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: " "0x%016" "l" "x" " prev0: " "0x%016" "l" "x" " " "prev1: " "0x%016" "l" "x" " length: %u", name(), count, p2i(curr), p2i(prev0), p2i(prev1), length()); ::breakpoint(); } } while (0) | |||
| 346 | "[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: " PTR_FORMAT " prev0: " PTR_FORMAT " " "prev1: " PTR_FORMAT " length: %u",do { if (!(count < _unrealistically_long_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 347, "guarantee(" "count < _unrealistically_long_length" ") failed", "[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: " "0x%016" "l" "x" " prev0: " "0x%016" "l" "x" " " "prev1: " "0x%016" "l" "x" " length: %u", name(), count, p2i(curr), p2i(prev0), p2i(prev1), length()); ::breakpoint(); } } while (0) | |||
| 347 | name(), count, p2i(curr), p2i(prev0), p2i(prev1), length())do { if (!(count < _unrealistically_long_length)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 347, "guarantee(" "count < _unrealistically_long_length" ") failed", "[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: " "0x%016" "l" "x" " prev0: " "0x%016" "l" "x" " " "prev1: " "0x%016" "l" "x" " length: %u", name(), count, p2i(curr), p2i(prev0), p2i(prev1), length()); ::breakpoint(); } } while (0); | |||
| 348 | ||||
| 349 | if (curr->next() != NULL__null) { | |||
| 350 | guarantee(curr->next()->prev() == curr, "Next or prev pointers messed up")do { if (!(curr->next()->prev() == curr)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 350, "guarantee(" "curr->next()->prev() == curr" ") failed" , "Next or prev pointers messed up"); ::breakpoint(); } } while (0); | |||
| 351 | } | |||
| 352 | guarantee(curr->hrm_index() == 0 || curr->hrm_index() > last_index, "List should be sorted")do { if (!(curr->hrm_index() == 0 || curr->hrm_index() > last_index)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 352, "guarantee(" "curr->hrm_index() == 0 || curr->hrm_index() > last_index" ") failed", "List should be sorted"); ::breakpoint(); } } while (0); | |||
| 353 | last_index = curr->hrm_index(); | |||
| 354 | ||||
| 355 | capacity += curr->capacity(); | |||
| 356 | ||||
| 357 | prev1 = prev0; | |||
| 358 | prev0 = curr; | |||
| 359 | curr = curr->next(); | |||
| 360 | } | |||
| 361 | ||||
| 362 | guarantee(_tail == prev0, "Expected %s to end with %u but it ended with %u.", name(), _tail->hrm_index(), prev0->hrm_index())do { if (!(_tail == prev0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 362, "guarantee(" "_tail == prev0" ") failed", "Expected %s to end with %u but it ended with %u." , name(), _tail->hrm_index(), prev0->hrm_index()); ::breakpoint (); } } while (0); | |||
| ||||
| 363 | guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next")do { if (!(_tail == __null || _tail->next() == __null)) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 363, "guarantee(" "_tail == NULL || _tail->next() == NULL" ") failed", "_tail should not have a next"); ::breakpoint(); } } while (0); | |||
| 364 | guarantee(length() == count, "%s count mismatch. Expected %u, actual %u.", name(), length(), count)do { if (!(length() == count)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 364, "guarantee(" "length() == count" ") failed", "%s count mismatch. Expected %u, actual %u." , name(), length(), count); ::breakpoint(); } } while (0); | |||
| 365 | } | |||
| 366 | ||||
| 367 | ||||
| 368 | FreeRegionList::FreeRegionList(const char* name, HeapRegionSetChecker* checker): | |||
| 369 | HeapRegionSetBase(name, checker), | |||
| 370 | _node_info(G1NUMA::numa()->is_enabled() ? new NodeInfo() : NULL__null) { | |||
| 371 | ||||
| 372 | clear(); | |||
| 373 | } | |||
| 374 | ||||
| 375 | FreeRegionList::~FreeRegionList() { | |||
| 376 | if (_node_info != NULL__null) { | |||
| 377 | delete _node_info; | |||
| 378 | } | |||
| 379 | } | |||
| 380 | ||||
| 381 | FreeRegionList::NodeInfo::NodeInfo() : _numa(G1NUMA::numa()), _length_of_node(NULL__null), | |||
| 382 | _num_nodes(_numa->num_active_nodes()) { | |||
| 383 | assert(UseNUMA, "Invariant")do { if (!(UseNUMA)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/heapRegionSet.cpp" , 383, "assert(" "UseNUMA" ") failed", "Invariant"); ::breakpoint (); } } while (0); | |||
| 384 | ||||
| 385 | _length_of_node = NEW_C_HEAP_ARRAY(uint, _num_nodes, mtGC)(uint*) (AllocateHeap((_num_nodes) * sizeof(uint), mtGC)); | |||
| 386 | } | |||
| 387 | ||||
| 388 | FreeRegionList::NodeInfo::~NodeInfo() { | |||
| 389 | FREE_C_HEAP_ARRAY(uint, _length_of_node)FreeHeap((char*)(_length_of_node)); | |||
| 390 | } | |||
| 391 | ||||
| 392 | void FreeRegionList::NodeInfo::clear() { | |||
| 393 | for (uint i = 0; i < _num_nodes; ++i) { | |||
| 394 | _length_of_node[i] = 0; | |||
| 395 | } | |||
| 396 | } | |||
| 397 | ||||
| 398 | void FreeRegionList::NodeInfo::add(NodeInfo* info) { | |||
| 399 | for (uint i = 0; i < _num_nodes; ++i) { | |||
| 400 | _length_of_node[i] += info->_length_of_node[i]; | |||
| 401 | } | |||
| 402 | } | |||
| 403 |