src/share/vm/gc_implementation/g1/heapRegionSet.cpp

Mon, 02 Jul 2012 13:11:28 -0400

author
coleenp
date
Mon, 02 Jul 2012 13:11:28 -0400
changeset 3901
24b9c7f4cae6
parent 3713
720b6a76dd9d
child 3955
d42fe3c3001d
permissions
-rw-r--r--

Merge

tonyp@2472 1 /*
tonyp@3713 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
tonyp@2472 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@2472 4 *
tonyp@2472 5 * This code is free software; you can redistribute it and/or modify it
tonyp@2472 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@2472 7 * published by the Free Software Foundation.
tonyp@2472 8 *
tonyp@2472 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@2472 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@2472 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@2472 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@2472 13 * accompanied this code).
tonyp@2472 14 *
tonyp@2472 15 * You should have received a copy of the GNU General Public License version
tonyp@2472 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@2472 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@2472 18 *
tonyp@2472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@2472 20 * or visit www.oracle.com if you need additional information or have any
tonyp@2472 21 * questions.
tonyp@2472 22 *
tonyp@2472 23 */
tonyp@2472 24
tonyp@2472 25 #include "precompiled.hpp"
tonyp@2472 26 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
tonyp@2472 27
tonyp@3713 28 uint HeapRegionSetBase::_unrealistically_long_length = 0;
tonyp@3268 29 HRSPhase HeapRegionSetBase::_phase = HRSPhaseNone;
tonyp@2472 30
tonyp@2472 31 //////////////////// HeapRegionSetBase ////////////////////
tonyp@2472 32
tonyp@3713 33 void HeapRegionSetBase::set_unrealistically_long_length(uint len) {
tonyp@2472 34 guarantee(_unrealistically_long_length == 0, "should only be set once");
tonyp@2472 35 _unrealistically_long_length = len;
tonyp@2472 36 }
tonyp@2472 37
tonyp@3713 38 uint HeapRegionSetBase::calculate_region_num(HeapRegion* hr) {
tonyp@2472 39 assert(hr->startsHumongous(), "pre-condition");
tonyp@2472 40 assert(hr->capacity() % HeapRegion::GrainBytes == 0, "invariant");
tonyp@3713 41 uint region_num = (uint) (hr->capacity() >> HeapRegion::LogOfHRGrainBytes);
tonyp@2472 42 assert(region_num > 0, "sanity");
tonyp@2472 43 return region_num;
tonyp@2472 44 }
tonyp@2472 45
tonyp@2643 46 void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) {
tonyp@3713 47 msg->append("[%s] %s ln: %u rn: %u cy: "SIZE_FORMAT" ud: "SIZE_FORMAT,
tonyp@2472 48 name(), message, length(), region_num(),
tonyp@2472 49 total_capacity_bytes(), total_used_bytes());
tonyp@2472 50 fill_in_ext_msg_extra(msg);
tonyp@2472 51 }
tonyp@2472 52
tonyp@2472 53 bool HeapRegionSetBase::verify_region(HeapRegion* hr,
tonyp@2472 54 HeapRegionSetBase* expected_containing_set) {
tonyp@2472 55 const char* error_message = NULL;
tonyp@2472 56
tonyp@2472 57 if (!regions_humongous()) {
tonyp@2472 58 if (hr->isHumongous()) {
tonyp@2472 59 error_message = "the region should not be humongous";
tonyp@2472 60 }
tonyp@2472 61 } else {
tonyp@2472 62 if (!hr->isHumongous() || !hr->startsHumongous()) {
tonyp@2472 63 error_message = "the region should be 'starts humongous'";
tonyp@2472 64 }
tonyp@2472 65 }
tonyp@2472 66
tonyp@2472 67 if (!regions_empty()) {
tonyp@2472 68 if (hr->is_empty()) {
tonyp@2472 69 error_message = "the region should not be empty";
tonyp@2472 70 }
tonyp@2472 71 } else {
tonyp@2472 72 if (!hr->is_empty()) {
tonyp@2472 73 error_message = "the region should be empty";
tonyp@2472 74 }
tonyp@2472 75 }
tonyp@2472 76
tonyp@2472 77 #ifdef ASSERT
tonyp@2472 78 // The _containing_set field is only available when ASSERT is defined.
tonyp@2472 79 if (hr->containing_set() != expected_containing_set) {
tonyp@2472 80 error_message = "inconsistent containing set found";
tonyp@2472 81 }
tonyp@2472 82 #endif // ASSERT
tonyp@2472 83
tonyp@2472 84 const char* extra_error_message = verify_region_extra(hr);
tonyp@2472 85 if (extra_error_message != NULL) {
tonyp@2472 86 error_message = extra_error_message;
tonyp@2472 87 }
tonyp@2472 88
tonyp@2472 89 if (error_message != NULL) {
tonyp@2472 90 outputStream* out = tty;
tonyp@2472 91 out->cr();
tonyp@2472 92 out->print_cr("## [%s] %s", name(), error_message);
tonyp@2472 93 out->print_cr("## Offending Region: "PTR_FORMAT, hr);
tonyp@2472 94 out->print_cr(" "HR_FORMAT, HR_FORMAT_PARAMS(hr));
tonyp@2472 95 #ifdef ASSERT
tonyp@2472 96 out->print_cr(" containing set: "PTR_FORMAT, hr->containing_set());
tonyp@2472 97 #endif // ASSERT
tonyp@2472 98 out->print_cr("## Offending Region Set: "PTR_FORMAT, this);
tonyp@2472 99 print_on(out);
tonyp@2472 100 return false;
tonyp@2472 101 } else {
tonyp@2472 102 return true;
tonyp@2472 103 }
tonyp@2472 104 }
tonyp@2472 105
tonyp@2472 106 void HeapRegionSetBase::verify() {
tonyp@2472 107 // It's important that we also observe the MT safety protocol even
tonyp@2472 108 // for the verification calls. If we do verification without the
tonyp@2472 109 // appropriate locks and the set changes underneath our feet
tonyp@2472 110 // verification might fail and send us on a wild goose chase.
tonyp@2643 111 hrs_assert_mt_safety_ok(this);
tonyp@2472 112
tonyp@2472 113 guarantee(( is_empty() && length() == 0 && region_num() == 0 &&
tonyp@2472 114 total_used_bytes() == 0 && total_capacity_bytes() == 0) ||
tonyp@2472 115 (!is_empty() && length() >= 0 && region_num() >= 0 &&
tonyp@2472 116 total_used_bytes() >= 0 && total_capacity_bytes() >= 0),
tonyp@2643 117 hrs_ext_msg(this, "invariant"));
tonyp@2472 118
tonyp@2472 119 guarantee((!regions_humongous() && region_num() == length()) ||
tonyp@2472 120 ( regions_humongous() && region_num() >= length()),
tonyp@2643 121 hrs_ext_msg(this, "invariant"));
tonyp@2472 122
tonyp@2472 123 guarantee(!regions_empty() || total_used_bytes() == 0,
tonyp@2643 124 hrs_ext_msg(this, "invariant"));
tonyp@2472 125
tonyp@2472 126 guarantee(total_used_bytes() <= total_capacity_bytes(),
tonyp@2643 127 hrs_ext_msg(this, "invariant"));
tonyp@2472 128 }
tonyp@2472 129
tonyp@2472 130 void HeapRegionSetBase::verify_start() {
tonyp@2472 131 // See comment in verify() about MT safety and verification.
tonyp@2643 132 hrs_assert_mt_safety_ok(this);
tonyp@2472 133 assert(!_verify_in_progress,
tonyp@2643 134 hrs_ext_msg(this, "verification should not be in progress"));
tonyp@2472 135
tonyp@2472 136 // Do the basic verification first before we do the checks over the regions.
tonyp@2472 137 HeapRegionSetBase::verify();
tonyp@2472 138
tonyp@2472 139 _calc_length = 0;
tonyp@2472 140 _calc_region_num = 0;
tonyp@2472 141 _calc_total_capacity_bytes = 0;
tonyp@2472 142 _calc_total_used_bytes = 0;
tonyp@2472 143 _verify_in_progress = true;
tonyp@2472 144 }
tonyp@2472 145
tonyp@2472 146 void HeapRegionSetBase::verify_next_region(HeapRegion* hr) {
tonyp@2472 147 // See comment in verify() about MT safety and verification.
tonyp@2643 148 hrs_assert_mt_safety_ok(this);
tonyp@2472 149 assert(_verify_in_progress,
tonyp@2643 150 hrs_ext_msg(this, "verification should be in progress"));
tonyp@2472 151
tonyp@2643 152 guarantee(verify_region(hr, this), hrs_ext_msg(this, "region verification"));
tonyp@2472 153
tonyp@2472 154 _calc_length += 1;
tonyp@2472 155 if (!hr->isHumongous()) {
tonyp@2472 156 _calc_region_num += 1;
tonyp@2472 157 } else {
tonyp@2472 158 _calc_region_num += calculate_region_num(hr);
tonyp@2472 159 }
tonyp@2472 160 _calc_total_capacity_bytes += hr->capacity();
tonyp@2472 161 _calc_total_used_bytes += hr->used();
tonyp@2472 162 }
tonyp@2472 163
tonyp@2472 164 void HeapRegionSetBase::verify_end() {
tonyp@2472 165 // See comment in verify() about MT safety and verification.
tonyp@2643 166 hrs_assert_mt_safety_ok(this);
tonyp@2472 167 assert(_verify_in_progress,
tonyp@2643 168 hrs_ext_msg(this, "verification should be in progress"));
tonyp@2472 169
tonyp@2472 170 guarantee(length() == _calc_length,
tonyp@3713 171 hrs_err_msg("[%s] length: %u should be == calc length: %u",
tonyp@2472 172 name(), length(), _calc_length));
tonyp@2472 173
tonyp@2472 174 guarantee(region_num() == _calc_region_num,
tonyp@3713 175 hrs_err_msg("[%s] region num: %u should be == calc region num: %u",
tonyp@2472 176 name(), region_num(), _calc_region_num));
tonyp@2472 177
tonyp@2472 178 guarantee(total_capacity_bytes() == _calc_total_capacity_bytes,
tonyp@2643 179 hrs_err_msg("[%s] capacity bytes: "SIZE_FORMAT" should be == "
tonyp@2472 180 "calc capacity bytes: "SIZE_FORMAT,
tonyp@2472 181 name(),
tonyp@2472 182 total_capacity_bytes(), _calc_total_capacity_bytes));
tonyp@2472 183
tonyp@2472 184 guarantee(total_used_bytes() == _calc_total_used_bytes,
tonyp@2643 185 hrs_err_msg("[%s] used bytes: "SIZE_FORMAT" should be == "
tonyp@2472 186 "calc used bytes: "SIZE_FORMAT,
tonyp@2472 187 name(), total_used_bytes(), _calc_total_used_bytes));
tonyp@2472 188
tonyp@2472 189 _verify_in_progress = false;
tonyp@2472 190 }
tonyp@2472 191
tonyp@3268 192 void HeapRegionSetBase::clear_phase() {
tonyp@3268 193 assert(_phase != HRSPhaseNone, "pre-condition");
tonyp@3268 194 _phase = HRSPhaseNone;
tonyp@3268 195 }
tonyp@3268 196
tonyp@3268 197 void HeapRegionSetBase::set_phase(HRSPhase phase) {
tonyp@3268 198 assert(_phase == HRSPhaseNone, "pre-condition");
tonyp@3268 199 assert(phase != HRSPhaseNone, "pre-condition");
tonyp@3268 200 _phase = phase;
tonyp@3268 201 }
tonyp@3268 202
tonyp@2472 203 void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) {
tonyp@2472 204 out->cr();
tonyp@2472 205 out->print_cr("Set: %s ("PTR_FORMAT")", name(), this);
tonyp@2472 206 out->print_cr(" Region Assumptions");
tonyp@2472 207 out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous()));
tonyp@2472 208 out->print_cr(" empty : %s", BOOL_TO_STR(regions_empty()));
tonyp@2472 209 out->print_cr(" Attributes");
tonyp@3713 210 out->print_cr(" length : %14u", length());
tonyp@3713 211 out->print_cr(" region num : %14u", region_num());
tonyp@2472 212 out->print_cr(" total capacity : "SIZE_FORMAT_W(14)" bytes",
tonyp@2472 213 total_capacity_bytes());
tonyp@2472 214 out->print_cr(" total used : "SIZE_FORMAT_W(14)" bytes",
tonyp@2472 215 total_used_bytes());
tonyp@2472 216 }
tonyp@2472 217
tonyp@2472 218 void HeapRegionSetBase::clear() {
tonyp@2472 219 _length = 0;
tonyp@2472 220 _region_num = 0;
tonyp@2472 221 _total_used_bytes = 0;
tonyp@2472 222 }
tonyp@2472 223
tonyp@2472 224 HeapRegionSetBase::HeapRegionSetBase(const char* name)
tonyp@2472 225 : _name(name), _verify_in_progress(false),
tonyp@2472 226 _calc_length(0), _calc_region_num(0),
tonyp@2472 227 _calc_total_capacity_bytes(0), _calc_total_used_bytes(0) { }
tonyp@2472 228
tonyp@2472 229 //////////////////// HeapRegionSet ////////////////////
tonyp@2472 230
tonyp@2472 231 void HeapRegionSet::update_from_proxy(HeapRegionSet* proxy_set) {
tonyp@2643 232 hrs_assert_mt_safety_ok(this);
tonyp@2643 233 hrs_assert_mt_safety_ok(proxy_set);
tonyp@2643 234 hrs_assert_sets_match(this, proxy_set);
tonyp@2472 235
tonyp@2472 236 verify_optional();
tonyp@2472 237 proxy_set->verify_optional();
tonyp@2472 238
tonyp@2472 239 if (proxy_set->is_empty()) return;
tonyp@2472 240
tonyp@2472 241 assert(proxy_set->length() <= _length,
tonyp@3713 242 hrs_err_msg("[%s] proxy set length: %u should be <= length: %u",
tonyp@2472 243 name(), proxy_set->length(), _length));
tonyp@2472 244 _length -= proxy_set->length();
tonyp@2472 245
tonyp@2472 246 assert(proxy_set->region_num() <= _region_num,
tonyp@3713 247 hrs_err_msg("[%s] proxy set region num: %u should be <= region num: %u",
tonyp@2472 248 name(), proxy_set->region_num(), _region_num));
tonyp@2472 249 _region_num -= proxy_set->region_num();
tonyp@2472 250
tonyp@2472 251 assert(proxy_set->total_used_bytes() <= _total_used_bytes,
tonyp@2643 252 hrs_err_msg("[%s] proxy set used bytes: "SIZE_FORMAT" "
tonyp@2472 253 "should be <= used bytes: "SIZE_FORMAT,
tonyp@2472 254 name(), proxy_set->total_used_bytes(),
tonyp@2472 255 _total_used_bytes));
tonyp@2472 256 _total_used_bytes -= proxy_set->total_used_bytes();
tonyp@2472 257
tonyp@2472 258 proxy_set->clear();
tonyp@2472 259
tonyp@2472 260 verify_optional();
tonyp@2472 261 proxy_set->verify_optional();
tonyp@2472 262 }
tonyp@2472 263
tonyp@2472 264 //////////////////// HeapRegionLinkedList ////////////////////
tonyp@2472 265
tonyp@2643 266 void HeapRegionLinkedList::fill_in_ext_msg_extra(hrs_ext_msg* msg) {
tonyp@2472 267 msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, head(), tail());
tonyp@2472 268 }
tonyp@2472 269
tonyp@2714 270 void HeapRegionLinkedList::add_as_head(HeapRegionLinkedList* from_list) {
tonyp@2714 271 hrs_assert_mt_safety_ok(this);
tonyp@2714 272 hrs_assert_mt_safety_ok(from_list);
tonyp@2714 273
tonyp@2714 274 verify_optional();
tonyp@2714 275 from_list->verify_optional();
tonyp@2714 276
tonyp@2714 277 if (from_list->is_empty()) return;
tonyp@2714 278
tonyp@2714 279 #ifdef ASSERT
tonyp@2714 280 HeapRegionLinkedListIterator iter(from_list);
tonyp@2714 281 while (iter.more_available()) {
tonyp@2714 282 HeapRegion* hr = iter.get_next();
tonyp@2714 283 // In set_containing_set() we check that we either set the value
tonyp@2714 284 // from NULL to non-NULL or vice versa to catch bugs. So, we have
tonyp@2714 285 // to NULL it first before setting it to the value.
tonyp@2714 286 hr->set_containing_set(NULL);
tonyp@2714 287 hr->set_containing_set(this);
tonyp@2714 288 }
tonyp@2714 289 #endif // ASSERT
tonyp@2714 290
tonyp@2714 291 if (_head != NULL) {
tonyp@2714 292 assert(length() > 0 && _tail != NULL, hrs_ext_msg(this, "invariant"));
tonyp@2714 293 from_list->_tail->set_next(_head);
tonyp@2714 294 } else {
tonyp@2714 295 assert(length() == 0 && _head == NULL, hrs_ext_msg(this, "invariant"));
tonyp@2714 296 _tail = from_list->_tail;
tonyp@2714 297 }
tonyp@2714 298 _head = from_list->_head;
tonyp@2714 299
tonyp@2714 300 _length += from_list->length();
tonyp@2714 301 _region_num += from_list->region_num();
tonyp@2714 302 _total_used_bytes += from_list->total_used_bytes();
tonyp@2714 303 from_list->clear();
tonyp@2714 304
tonyp@2714 305 verify_optional();
tonyp@2714 306 from_list->verify_optional();
tonyp@2714 307 }
tonyp@2714 308
tonyp@2472 309 void HeapRegionLinkedList::add_as_tail(HeapRegionLinkedList* from_list) {
tonyp@2643 310 hrs_assert_mt_safety_ok(this);
tonyp@2643 311 hrs_assert_mt_safety_ok(from_list);
tonyp@2472 312
tonyp@2472 313 verify_optional();
tonyp@2472 314 from_list->verify_optional();
tonyp@2472 315
tonyp@2472 316 if (from_list->is_empty()) return;
tonyp@2472 317
tonyp@2472 318 #ifdef ASSERT
tonyp@2472 319 HeapRegionLinkedListIterator iter(from_list);
tonyp@2472 320 while (iter.more_available()) {
tonyp@2472 321 HeapRegion* hr = iter.get_next();
tonyp@2472 322 // In set_containing_set() we check that we either set the value
tonyp@2472 323 // from NULL to non-NULL or vice versa to catch bugs. So, we have
tonyp@2472 324 // to NULL it first before setting it to the value.
tonyp@2472 325 hr->set_containing_set(NULL);
tonyp@2472 326 hr->set_containing_set(this);
tonyp@2472 327 }
tonyp@2472 328 #endif // ASSERT
tonyp@2472 329
tonyp@2472 330 if (_tail != NULL) {
tonyp@2643 331 assert(length() > 0 && _head != NULL, hrs_ext_msg(this, "invariant"));
tonyp@2472 332 _tail->set_next(from_list->_head);
tonyp@2472 333 } else {
tonyp@2643 334 assert(length() == 0 && _head == NULL, hrs_ext_msg(this, "invariant"));
tonyp@2472 335 _head = from_list->_head;
tonyp@2472 336 }
tonyp@2472 337 _tail = from_list->_tail;
tonyp@2472 338
tonyp@2472 339 _length += from_list->length();
tonyp@2472 340 _region_num += from_list->region_num();
tonyp@2472 341 _total_used_bytes += from_list->total_used_bytes();
tonyp@2472 342 from_list->clear();
tonyp@2472 343
tonyp@2472 344 verify_optional();
tonyp@2472 345 from_list->verify_optional();
tonyp@2472 346 }
tonyp@2472 347
tonyp@2472 348 void HeapRegionLinkedList::remove_all() {
tonyp@2643 349 hrs_assert_mt_safety_ok(this);
tonyp@2472 350 verify_optional();
tonyp@2472 351
tonyp@2472 352 HeapRegion* curr = _head;
tonyp@2472 353 while (curr != NULL) {
tonyp@2643 354 hrs_assert_region_ok(this, curr, this);
tonyp@2472 355
tonyp@2472 356 HeapRegion* next = curr->next();
tonyp@2472 357 curr->set_next(NULL);
tonyp@2472 358 curr->set_containing_set(NULL);
tonyp@2472 359 curr = next;
tonyp@2472 360 }
tonyp@2472 361 clear();
tonyp@2472 362
tonyp@2472 363 verify_optional();
tonyp@2472 364 }
tonyp@2472 365
tonyp@3713 366 void HeapRegionLinkedList::remove_all_pending(uint target_count) {
tonyp@2643 367 hrs_assert_mt_safety_ok(this);
tonyp@2643 368 assert(target_count > 1, hrs_ext_msg(this, "pre-condition"));
tonyp@2643 369 assert(!is_empty(), hrs_ext_msg(this, "pre-condition"));
tonyp@2472 370
tonyp@2472 371 verify_optional();
tonyp@3713 372 DEBUG_ONLY(uint old_length = length();)
tonyp@2472 373
tonyp@2472 374 HeapRegion* curr = _head;
tonyp@2472 375 HeapRegion* prev = NULL;
tonyp@3713 376 uint count = 0;
tonyp@2472 377 while (curr != NULL) {
tonyp@2643 378 hrs_assert_region_ok(this, curr, this);
tonyp@2472 379 HeapRegion* next = curr->next();
tonyp@2472 380
tonyp@2472 381 if (curr->pending_removal()) {
tonyp@2472 382 assert(count < target_count,
tonyp@2643 383 hrs_err_msg("[%s] should not come across more regions "
tonyp@3713 384 "pending for removal than target_count: %u",
tonyp@2472 385 name(), target_count));
tonyp@2472 386
tonyp@2472 387 if (prev == NULL) {
tonyp@2643 388 assert(_head == curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 389 _head = next;
tonyp@2472 390 } else {
tonyp@2643 391 assert(_head != curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 392 prev->set_next(next);
tonyp@2472 393 }
tonyp@2472 394 if (next == NULL) {
tonyp@2643 395 assert(_tail == curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 396 _tail = prev;
tonyp@2472 397 } else {
tonyp@2643 398 assert(_tail != curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 399 }
tonyp@2472 400
tonyp@2472 401 curr->set_next(NULL);
tonyp@2472 402 remove_internal(curr);
tonyp@2472 403 curr->set_pending_removal(false);
tonyp@2472 404
tonyp@2472 405 count += 1;
tonyp@2472 406
tonyp@2472 407 // If we have come across the target number of regions we can
tonyp@2472 408 // just bail out. However, for debugging purposes, we can just
tonyp@2472 409 // carry on iterating to make sure there are not more regions
tonyp@2472 410 // tagged with pending removal.
tonyp@2472 411 DEBUG_ONLY(if (count == target_count) break;)
tonyp@2472 412 } else {
tonyp@2472 413 prev = curr;
tonyp@2472 414 }
tonyp@2472 415 curr = next;
tonyp@2472 416 }
tonyp@2472 417
tonyp@2472 418 assert(count == target_count,
tonyp@3713 419 hrs_err_msg("[%s] count: %u should be == target_count: %u",
tonyp@3713 420 name(), count, target_count));
tonyp@2472 421 assert(length() + target_count == old_length,
tonyp@2643 422 hrs_err_msg("[%s] new length should be consistent "
tonyp@3713 423 "new length: %u old length: %u target_count: %u",
tonyp@2472 424 name(), length(), old_length, target_count));
tonyp@2472 425
tonyp@2472 426 verify_optional();
tonyp@2472 427 }
tonyp@2472 428
tonyp@2472 429 void HeapRegionLinkedList::verify() {
tonyp@2472 430 // See comment in HeapRegionSetBase::verify() about MT safety and
tonyp@2472 431 // verification.
tonyp@2643 432 hrs_assert_mt_safety_ok(this);
tonyp@2472 433
tonyp@2472 434 // This will also do the basic verification too.
tonyp@2472 435 verify_start();
tonyp@2472 436
tonyp@2472 437 HeapRegion* curr = _head;
tonyp@2472 438 HeapRegion* prev1 = NULL;
tonyp@2472 439 HeapRegion* prev0 = NULL;
tonyp@3713 440 uint count = 0;
tonyp@2472 441 while (curr != NULL) {
tonyp@2472 442 verify_next_region(curr);
tonyp@2472 443
tonyp@2472 444 count += 1;
tonyp@2472 445 guarantee(count < _unrealistically_long_length,
tonyp@3713 446 hrs_err_msg("[%s] the calculated length: %u "
tonyp@2472 447 "seems very long, is there maybe a cycle? "
tonyp@2472 448 "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" "
tonyp@3713 449 "prev1: "PTR_FORMAT" length: %u",
tonyp@2472 450 name(), count, curr, prev0, prev1, length()));
tonyp@2472 451
tonyp@2472 452 prev1 = prev0;
tonyp@2472 453 prev0 = curr;
tonyp@2472 454 curr = curr->next();
tonyp@2472 455 }
tonyp@2472 456
tonyp@2643 457 guarantee(_tail == prev0, hrs_ext_msg(this, "post-condition"));
tonyp@2472 458
tonyp@2472 459 verify_end();
tonyp@2472 460 }
tonyp@2472 461
tonyp@2472 462 void HeapRegionLinkedList::clear() {
tonyp@2472 463 HeapRegionSetBase::clear();
tonyp@2472 464 _head = NULL;
tonyp@2472 465 _tail = NULL;
tonyp@2472 466 }
tonyp@2472 467
tonyp@2472 468 void HeapRegionLinkedList::print_on(outputStream* out, bool print_contents) {
tonyp@2472 469 HeapRegionSetBase::print_on(out, print_contents);
tonyp@2472 470 out->print_cr(" Linking");
tonyp@2472 471 out->print_cr(" head : "PTR_FORMAT, _head);
tonyp@2472 472 out->print_cr(" tail : "PTR_FORMAT, _tail);
tonyp@2472 473
tonyp@2472 474 if (print_contents) {
tonyp@2472 475 out->print_cr(" Contents");
tonyp@2472 476 HeapRegionLinkedListIterator iter(this);
tonyp@2472 477 while (iter.more_available()) {
tonyp@2472 478 HeapRegion* hr = iter.get_next();
tonyp@2472 479 hr->print_on(out);
tonyp@2472 480 }
tonyp@2472 481 }
tonyp@2472 482 }

mercurial