/* * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
#ifndef PRODUCT void HeapRegionSetBase::verify_region(HeapRegion* hr) {
assert(hr->containing_set() == this, "Inconsistent containing set for %u", hr->hrm_index());
assert(!hr->is_young(), "Adding young region %u", hr->hrm_index()); // currently we don't use these sets for young regions
assert(_checker == NULL || _checker->is_correct_type(hr), "Wrong type of region %u (%s) and set %s",
hr->hrm_index(), hr->get_type_str(), name());
assert(!hr->is_free() || hr->is_empty(), "Free region %u is not empty for set %s", hr->hrm_index(), name());
assert(!hr->is_empty() || hr->is_free() || hr->is_archive(), "Empty region %u is not free or archive for set %s", hr->hrm_index(), name());
} #endif
void HeapRegionSetBase::verify() { // It's important that we also observe the MT safety protocol even // for the verification calls. If we do verification without the // appropriate locks and the set changes underneath our feet // verification might fail and send us on a wild goose chase.
check_mt_safety();
void HeapRegionSetBase::verify_start() { // See comment in verify() about MT safety and verification.
check_mt_safety();
assert_heap_region_set(!_verify_in_progress, "verification should not be in progress");
// Do the basic verification first before we do the checks over the regions.
HeapRegionSetBase::verify();
_verify_in_progress = true;
}
void HeapRegionSetBase::verify_end() { // See comment in verify() about MT safety and verification.
check_mt_safety();
assert_heap_region_set(_verify_in_progress, "verification should be in progress");
#ifdef ASSERT
FreeRegionListIterator iter(from_list); while (iter.more_available()) {
HeapRegion* hr = iter.get_next(); // In set_containing_set() we check that we either set the value // from NULL to non-NULL or vice versa to catch bugs. So, we have // to NULL it first before setting it to the value.
hr->set_containing_set(NULL);
hr->set_containing_set(this);
} #endif// ASSERT
}
if (is_empty()) { // Make from_list the current list.
assert_free_region_list(length() == 0 && _tail == NULL, "invariant");
_head = from_list->_head;
_tail = from_list->_tail;
} else { // Add the from_list to the end of the current list.
assert(_tail->hrm_index() < from_list->_head->hrm_index(), "Should be sorted %u < %u",
_tail->hrm_index(), from_list->_head->hrm_index());
while (curr_from != NULL) { while (curr_to != NULL && curr_to->hrm_index() < curr_from->hrm_index()) {
curr_to = curr_to->next();
}
if (curr_to == NULL) { // The rest of the from list should be added as tail
_tail->set_next(curr_from);
curr_from->set_prev(_tail);
curr_from = NULL;
} else {
HeapRegion* next_from = curr_from->next();
// prev points to the node right before first or null when first == _head
HeapRegion* const prev = first->prev(); // next points to the node right after first or null when first == _tail, // and after the while loop below, next should point to the next node right // after the removed sublist, or null if the sublist contains _tail.
HeapRegion* next = first->next();
HeapRegion* curr = first;
uint count = 0; while (count < num_regions) {
verify_region(curr);
next = curr->next();
verify_region_to_remove(curr, next);
guarantee(_tail == prev0, "Expected %s to end with %u but it ended with %u.", name(), _tail->hrm_index(), prev0->hrm_index());
guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next");
guarantee(length() == count, "%s count mismatch. Expected %u, actual %u.", name(), length(), count);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.