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

Thu, 19 Jun 2014 13:31:14 +0200

author
brutisso
date
Thu, 19 Jun 2014 13:31:14 +0200
changeset 6904
0982ec23da03
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 7050
6701abbc4441
permissions
-rw-r--r--

8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
Reviewed-by: jwilhelm, ehelin, tschatzl

tonyp@2472 1 /*
jwilhelm@6422 2 * Copyright (c) 2011, 2014, 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"
brutisso@6385 26 #include "gc_implementation/g1/heapRegionRemSet.hpp"
tonyp@2472 27 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
tonyp@2472 28
drchase@6680 29 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
drchase@6680 30
brutisso@6385 31 uint FreeRegionList::_unrealistically_long_length = 0;
tonyp@2472 32
tonyp@2643 33 void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) {
brutisso@6385 34 msg->append("[%s] %s ln: %u cy: "SIZE_FORMAT,
brutisso@6385 35 name(), message, length(), total_capacity_bytes());
tonyp@2472 36 fill_in_ext_msg_extra(msg);
tonyp@2472 37 }
tonyp@2472 38
brutisso@6385 39 #ifndef PRODUCT
brutisso@6385 40 void HeapRegionSetBase::verify_region(HeapRegion* hr) {
brutisso@6385 41 assert(hr->containing_set() == this, err_msg("Inconsistent containing set for %u", hr->hrs_index()));
brutisso@6385 42 assert(!hr->is_young(), err_msg("Adding young region %u", hr->hrs_index())); // currently we don't use these sets for young regions
brutisso@6385 43 assert(hr->isHumongous() == regions_humongous(), err_msg("Wrong humongous state for region %u and set %s", hr->hrs_index(), name()));
brutisso@6385 44 assert(hr->is_empty() == regions_empty(), err_msg("Wrong empty state for region %u and set %s", hr->hrs_index(), name()));
brutisso@6385 45 assert(hr->rem_set()->verify_ready_for_par_iteration(), err_msg("Wrong iteration state %u", hr->hrs_index()));
tonyp@2472 46 }
brutisso@6385 47 #endif
tonyp@2472 48
tonyp@2472 49 void HeapRegionSetBase::verify() {
tonyp@2472 50 // It's important that we also observe the MT safety protocol even
tonyp@2472 51 // for the verification calls. If we do verification without the
tonyp@2472 52 // appropriate locks and the set changes underneath our feet
tonyp@2472 53 // verification might fail and send us on a wild goose chase.
brutisso@6385 54 check_mt_safety();
tonyp@2472 55
brutisso@6385 56 guarantee(( is_empty() && length() == 0 && total_capacity_bytes() == 0) ||
brutisso@6385 57 (!is_empty() && length() >= 0 && total_capacity_bytes() >= 0),
tonyp@2643 58 hrs_ext_msg(this, "invariant"));
tonyp@2472 59 }
tonyp@2472 60
tonyp@2472 61 void HeapRegionSetBase::verify_start() {
tonyp@2472 62 // See comment in verify() about MT safety and verification.
brutisso@6385 63 check_mt_safety();
tonyp@2472 64 assert(!_verify_in_progress,
tonyp@2643 65 hrs_ext_msg(this, "verification should not be in progress"));
tonyp@2472 66
tonyp@2472 67 // Do the basic verification first before we do the checks over the regions.
tonyp@2472 68 HeapRegionSetBase::verify();
tonyp@2472 69
tonyp@2472 70 _verify_in_progress = true;
tonyp@2472 71 }
tonyp@2472 72
tonyp@2472 73 void HeapRegionSetBase::verify_end() {
tonyp@2472 74 // See comment in verify() about MT safety and verification.
brutisso@6385 75 check_mt_safety();
tonyp@2472 76 assert(_verify_in_progress,
tonyp@2643 77 hrs_ext_msg(this, "verification should be in progress"));
tonyp@2472 78
tonyp@2472 79 _verify_in_progress = false;
tonyp@2472 80 }
tonyp@2472 81
tonyp@2472 82 void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) {
tonyp@2472 83 out->cr();
tonyp@2472 84 out->print_cr("Set: %s ("PTR_FORMAT")", name(), this);
tonyp@2472 85 out->print_cr(" Region Assumptions");
tonyp@2472 86 out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous()));
tonyp@2472 87 out->print_cr(" empty : %s", BOOL_TO_STR(regions_empty()));
tonyp@2472 88 out->print_cr(" Attributes");
tonyp@3713 89 out->print_cr(" length : %14u", length());
tonyp@2472 90 out->print_cr(" total capacity : "SIZE_FORMAT_W(14)" bytes",
tonyp@2472 91 total_capacity_bytes());
tonyp@2472 92 }
tonyp@2472 93
brutisso@6385 94 HeapRegionSetBase::HeapRegionSetBase(const char* name, bool humongous, bool empty, HRSMtSafeChecker* mt_safety_checker)
brutisso@6385 95 : _name(name), _verify_in_progress(false),
brutisso@6385 96 _is_humongous(humongous), _is_empty(empty), _mt_safety_checker(mt_safety_checker),
brutisso@6385 97 _count()
brutisso@6385 98 { }
brutisso@6385 99
brutisso@6385 100 void FreeRegionList::set_unrealistically_long_length(uint len) {
brutisso@6385 101 guarantee(_unrealistically_long_length == 0, "should only be set once");
brutisso@6385 102 _unrealistically_long_length = len;
tonyp@2472 103 }
tonyp@2472 104
brutisso@6385 105 void FreeRegionList::fill_in_ext_msg_extra(hrs_ext_msg* msg) {
tonyp@2472 106 msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, head(), tail());
tonyp@2472 107 }
tonyp@2472 108
brutisso@6385 109 void FreeRegionList::add_as_head_or_tail(FreeRegionList* from_list, bool as_head) {
brutisso@6385 110 check_mt_safety();
brutisso@6385 111 from_list->check_mt_safety();
tonyp@2714 112
tonyp@2714 113 verify_optional();
tonyp@2714 114 from_list->verify_optional();
tonyp@2714 115
brutisso@6385 116 if (from_list->is_empty()) {
brutisso@6385 117 return;
brutisso@6385 118 }
tonyp@2714 119
tonyp@2714 120 #ifdef ASSERT
brutisso@6385 121 FreeRegionListIterator iter(from_list);
tonyp@2714 122 while (iter.more_available()) {
tonyp@2714 123 HeapRegion* hr = iter.get_next();
tonyp@2714 124 // In set_containing_set() we check that we either set the value
tonyp@2714 125 // from NULL to non-NULL or vice versa to catch bugs. So, we have
tonyp@2714 126 // to NULL it first before setting it to the value.
tonyp@2714 127 hr->set_containing_set(NULL);
tonyp@2714 128 hr->set_containing_set(this);
tonyp@2714 129 }
tonyp@2714 130 #endif // ASSERT
tonyp@2714 131
brutisso@6385 132 if (_head == NULL) {
brutisso@6385 133 assert(length() == 0 && _tail == NULL, hrs_ext_msg(this, "invariant"));
brutisso@6385 134 _head = from_list->_head;
brutisso@6385 135 _tail = from_list->_tail;
tonyp@2714 136 } else {
brutisso@6385 137 assert(length() > 0 && _tail != NULL, hrs_ext_msg(this, "invariant"));
brutisso@6385 138 if (as_head) {
brutisso@6385 139 from_list->_tail->set_next(_head);
jwilhelm@6422 140 _head->set_prev(from_list->_tail);
brutisso@6385 141 _head = from_list->_head;
brutisso@6385 142 } else {
brutisso@6385 143 _tail->set_next(from_list->_head);
jwilhelm@6422 144 from_list->_head->set_prev(_tail);
brutisso@6385 145 _tail = from_list->_tail;
brutisso@6385 146 }
tonyp@2714 147 }
tonyp@2714 148
brutisso@6385 149 _count.increment(from_list->length(), from_list->total_capacity_bytes());
tonyp@2714 150 from_list->clear();
tonyp@2714 151
tonyp@2714 152 verify_optional();
tonyp@2714 153 from_list->verify_optional();
tonyp@2714 154 }
tonyp@2714 155
brutisso@6385 156 void FreeRegionList::add_as_head(FreeRegionList* from_list) {
brutisso@6385 157 add_as_head_or_tail(from_list, true /* as_head */);
tonyp@2472 158 }
tonyp@2472 159
brutisso@6385 160 void FreeRegionList::add_as_tail(FreeRegionList* from_list) {
brutisso@6385 161 add_as_head_or_tail(from_list, false /* as_head */);
brutisso@6385 162 }
brutisso@6385 163
brutisso@6385 164 void FreeRegionList::remove_all() {
brutisso@6385 165 check_mt_safety();
tonyp@2472 166 verify_optional();
tonyp@2472 167
tonyp@2472 168 HeapRegion* curr = _head;
tonyp@2472 169 while (curr != NULL) {
brutisso@6385 170 verify_region(curr);
tonyp@2472 171
tonyp@2472 172 HeapRegion* next = curr->next();
tonyp@2472 173 curr->set_next(NULL);
jwilhelm@6422 174 curr->set_prev(NULL);
tonyp@2472 175 curr->set_containing_set(NULL);
tonyp@2472 176 curr = next;
tonyp@2472 177 }
tonyp@2472 178 clear();
tonyp@2472 179
tonyp@2472 180 verify_optional();
tonyp@2472 181 }
tonyp@2472 182
jwilhelm@6422 183 void FreeRegionList::add_ordered(FreeRegionList* from_list) {
jwilhelm@6422 184 check_mt_safety();
jwilhelm@6422 185 from_list->check_mt_safety();
jwilhelm@6422 186
jwilhelm@6422 187 verify_optional();
jwilhelm@6422 188 from_list->verify_optional();
jwilhelm@6422 189
jwilhelm@6422 190 if (from_list->is_empty()) {
jwilhelm@6422 191 return;
jwilhelm@6422 192 }
jwilhelm@6422 193
jwilhelm@6422 194 if (is_empty()) {
jwilhelm@6422 195 add_as_head(from_list);
jwilhelm@6422 196 return;
jwilhelm@6422 197 }
jwilhelm@6422 198
jwilhelm@6422 199 #ifdef ASSERT
jwilhelm@6422 200 FreeRegionListIterator iter(from_list);
jwilhelm@6422 201 while (iter.more_available()) {
jwilhelm@6422 202 HeapRegion* hr = iter.get_next();
jwilhelm@6422 203 // In set_containing_set() we check that we either set the value
jwilhelm@6422 204 // from NULL to non-NULL or vice versa to catch bugs. So, we have
jwilhelm@6422 205 // to NULL it first before setting it to the value.
jwilhelm@6422 206 hr->set_containing_set(NULL);
jwilhelm@6422 207 hr->set_containing_set(this);
jwilhelm@6422 208 }
jwilhelm@6422 209 #endif // ASSERT
jwilhelm@6422 210
jwilhelm@6422 211 HeapRegion* curr_to = _head;
jwilhelm@6422 212 HeapRegion* curr_from = from_list->_head;
jwilhelm@6422 213
jwilhelm@6422 214 while (curr_from != NULL) {
jwilhelm@6422 215 while (curr_to != NULL && curr_to->hrs_index() < curr_from->hrs_index()) {
jwilhelm@6422 216 curr_to = curr_to->next();
jwilhelm@6422 217 }
jwilhelm@6422 218
jwilhelm@6422 219 if (curr_to == NULL) {
jwilhelm@6422 220 // The rest of the from list should be added as tail
jwilhelm@6422 221 _tail->set_next(curr_from);
jwilhelm@6422 222 curr_from->set_prev(_tail);
jwilhelm@6422 223 curr_from = NULL;
jwilhelm@6422 224 } else {
jwilhelm@6422 225 HeapRegion* next_from = curr_from->next();
jwilhelm@6422 226
jwilhelm@6422 227 curr_from->set_next(curr_to);
jwilhelm@6422 228 curr_from->set_prev(curr_to->prev());
jwilhelm@6422 229 if (curr_to->prev() == NULL) {
jwilhelm@6422 230 _head = curr_from;
jwilhelm@6422 231 } else {
jwilhelm@6422 232 curr_to->prev()->set_next(curr_from);
jwilhelm@6422 233 }
jwilhelm@6422 234 curr_to->set_prev(curr_from);
jwilhelm@6422 235
jwilhelm@6422 236 curr_from = next_from;
jwilhelm@6422 237 }
jwilhelm@6422 238 }
jwilhelm@6422 239
jwilhelm@6422 240 if (_tail->hrs_index() < from_list->_tail->hrs_index()) {
jwilhelm@6422 241 _tail = from_list->_tail;
jwilhelm@6422 242 }
jwilhelm@6422 243
jwilhelm@6422 244 _count.increment(from_list->length(), from_list->total_capacity_bytes());
jwilhelm@6422 245 from_list->clear();
jwilhelm@6422 246
jwilhelm@6422 247 verify_optional();
jwilhelm@6422 248 from_list->verify_optional();
jwilhelm@6422 249 }
jwilhelm@6422 250
brutisso@6385 251 void FreeRegionList::remove_all_pending(uint target_count) {
brutisso@6385 252 check_mt_safety();
tonyp@2643 253 assert(target_count > 1, hrs_ext_msg(this, "pre-condition"));
tonyp@2643 254 assert(!is_empty(), hrs_ext_msg(this, "pre-condition"));
tonyp@2472 255
tonyp@2472 256 verify_optional();
tonyp@3713 257 DEBUG_ONLY(uint old_length = length();)
tonyp@2472 258
tonyp@2472 259 HeapRegion* curr = _head;
tonyp@3713 260 uint count = 0;
tonyp@2472 261 while (curr != NULL) {
brutisso@6385 262 verify_region(curr);
tonyp@2472 263 HeapRegion* next = curr->next();
jwilhelm@6422 264 HeapRegion* prev = curr->prev();
tonyp@2472 265
tonyp@2472 266 if (curr->pending_removal()) {
tonyp@2472 267 assert(count < target_count,
tonyp@2643 268 hrs_err_msg("[%s] should not come across more regions "
tonyp@3713 269 "pending for removal than target_count: %u",
tonyp@2472 270 name(), target_count));
tonyp@2472 271
tonyp@2472 272 if (prev == NULL) {
tonyp@2643 273 assert(_head == curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 274 _head = next;
tonyp@2472 275 } else {
tonyp@2643 276 assert(_head != curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 277 prev->set_next(next);
tonyp@2472 278 }
tonyp@2472 279 if (next == NULL) {
tonyp@2643 280 assert(_tail == curr, hrs_ext_msg(this, "invariant"));
tonyp@2472 281 _tail = prev;
tonyp@2472 282 } else {
tonyp@2643 283 assert(_tail != curr, hrs_ext_msg(this, "invariant"));
jwilhelm@6422 284 next->set_prev(prev);
jwilhelm@6422 285 }
jwilhelm@6422 286 if (_last = curr) {
jwilhelm@6422 287 _last = NULL;
tonyp@2472 288 }
tonyp@2472 289
tonyp@2472 290 curr->set_next(NULL);
jwilhelm@6422 291 curr->set_prev(NULL);
brutisso@6385 292 remove(curr);
tonyp@2472 293 curr->set_pending_removal(false);
tonyp@2472 294
tonyp@2472 295 count += 1;
tonyp@2472 296
tonyp@2472 297 // If we have come across the target number of regions we can
tonyp@2472 298 // just bail out. However, for debugging purposes, we can just
tonyp@2472 299 // carry on iterating to make sure there are not more regions
tonyp@2472 300 // tagged with pending removal.
tonyp@2472 301 DEBUG_ONLY(if (count == target_count) break;)
tonyp@2472 302 }
tonyp@2472 303 curr = next;
tonyp@2472 304 }
tonyp@2472 305
tonyp@2472 306 assert(count == target_count,
tonyp@3713 307 hrs_err_msg("[%s] count: %u should be == target_count: %u",
tonyp@3713 308 name(), count, target_count));
tonyp@2472 309 assert(length() + target_count == old_length,
tonyp@2643 310 hrs_err_msg("[%s] new length should be consistent "
tonyp@3713 311 "new length: %u old length: %u target_count: %u",
tonyp@2472 312 name(), length(), old_length, target_count));
tonyp@2472 313
tonyp@2472 314 verify_optional();
tonyp@2472 315 }
tonyp@2472 316
brutisso@6385 317 void FreeRegionList::verify() {
tonyp@2472 318 // See comment in HeapRegionSetBase::verify() about MT safety and
tonyp@2472 319 // verification.
brutisso@6385 320 check_mt_safety();
tonyp@2472 321
tonyp@2472 322 // This will also do the basic verification too.
tonyp@2472 323 verify_start();
tonyp@2472 324
brutisso@6385 325 verify_list();
tonyp@2472 326
tonyp@2472 327 verify_end();
tonyp@2472 328 }
tonyp@2472 329
brutisso@6385 330 void FreeRegionList::clear() {
brutisso@6385 331 _count = HeapRegionSetCount();
tonyp@2472 332 _head = NULL;
tonyp@2472 333 _tail = NULL;
jwilhelm@6422 334 _last = NULL;
tonyp@2472 335 }
tonyp@2472 336
brutisso@6385 337 void FreeRegionList::print_on(outputStream* out, bool print_contents) {
tonyp@2472 338 HeapRegionSetBase::print_on(out, print_contents);
tonyp@2472 339 out->print_cr(" Linking");
tonyp@2472 340 out->print_cr(" head : "PTR_FORMAT, _head);
tonyp@2472 341 out->print_cr(" tail : "PTR_FORMAT, _tail);
tonyp@2472 342
tonyp@2472 343 if (print_contents) {
tonyp@2472 344 out->print_cr(" Contents");
brutisso@6385 345 FreeRegionListIterator iter(this);
tonyp@2472 346 while (iter.more_available()) {
tonyp@2472 347 HeapRegion* hr = iter.get_next();
tonyp@2472 348 hr->print_on(out);
tonyp@2472 349 }
tonyp@2472 350 }
tonyp@2472 351 }
brutisso@6386 352
brutisso@6386 353 void FreeRegionList::verify_list() {
brutisso@6386 354 HeapRegion* curr = head();
brutisso@6386 355 HeapRegion* prev1 = NULL;
brutisso@6386 356 HeapRegion* prev0 = NULL;
brutisso@6386 357 uint count = 0;
brutisso@6386 358 size_t capacity = 0;
jwilhelm@6422 359 uint last_index = 0;
jwilhelm@6422 360
jwilhelm@6422 361 guarantee(_head == NULL || _head->prev() == NULL, "_head should not have a prev");
brutisso@6386 362 while (curr != NULL) {
brutisso@6386 363 verify_region(curr);
brutisso@6386 364
brutisso@6386 365 count++;
brutisso@6386 366 guarantee(count < _unrealistically_long_length,
brutisso@6386 367 hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " "prev1: "PTR_FORMAT" length: %u", name(), count, curr, prev0, prev1, length()));
brutisso@6386 368
jwilhelm@6422 369 if (curr->next() != NULL) {
jwilhelm@6422 370 guarantee(curr->next()->prev() == curr, "Next or prev pointers messed up");
jwilhelm@6422 371 }
jwilhelm@6422 372 guarantee(curr->hrs_index() == 0 || curr->hrs_index() > last_index, "List should be sorted");
jwilhelm@6422 373 last_index = curr->hrs_index();
jwilhelm@6422 374
brutisso@6386 375 capacity += curr->capacity();
brutisso@6386 376
brutisso@6386 377 prev1 = prev0;
brutisso@6386 378 prev0 = curr;
brutisso@6386 379 curr = curr->next();
brutisso@6386 380 }
brutisso@6386 381
brutisso@6386 382 guarantee(tail() == prev0, err_msg("Expected %s to end with %u but it ended with %u.", name(), tail()->hrs_index(), prev0->hrs_index()));
jwilhelm@6422 383 guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next");
brutisso@6386 384 guarantee(length() == count, err_msg("%s count mismatch. Expected %u, actual %u.", name(), length(), count));
brutisso@6386 385 guarantee(total_capacity_bytes() == capacity, err_msg("%s capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT,
brutisso@6386 386 name(), total_capacity_bytes(), capacity));
brutisso@6386 387 }
brutisso@6386 388
brutisso@6386 389 // Note on the check_mt_safety() methods below:
brutisso@6386 390 //
brutisso@6386 391 // Verification of the "master" heap region sets / lists that are
brutisso@6386 392 // maintained by G1CollectedHeap is always done during a STW pause and
brutisso@6386 393 // by the VM thread at the start / end of the pause. The standard
brutisso@6386 394 // verification methods all assert check_mt_safety(). This is
brutisso@6386 395 // important as it ensures that verification is done without
brutisso@6386 396 // concurrent updates taking place at the same time. It follows, that,
brutisso@6386 397 // for the "master" heap region sets / lists, the check_mt_safety()
brutisso@6386 398 // method should include the VM thread / STW case.
brutisso@6386 399
brutisso@6386 400 void MasterFreeRegionListMtSafeChecker::check() {
brutisso@6386 401 // Master Free List MT safety protocol:
brutisso@6386 402 // (a) If we're at a safepoint, operations on the master free list
brutisso@6386 403 // should be invoked by either the VM thread (which will serialize
brutisso@6386 404 // them) or by the GC workers while holding the
brutisso@6386 405 // FreeList_lock.
brutisso@6386 406 // (b) If we're not at a safepoint, operations on the master free
brutisso@6386 407 // list should be invoked while holding the Heap_lock.
brutisso@6386 408
brutisso@6386 409 if (SafepointSynchronize::is_at_safepoint()) {
brutisso@6386 410 guarantee(Thread::current()->is_VM_thread() ||
brutisso@6386 411 FreeList_lock->owned_by_self(), "master free list MT safety protocol at a safepoint");
brutisso@6386 412 } else {
brutisso@6386 413 guarantee(Heap_lock->owned_by_self(), "master free list MT safety protocol outside a safepoint");
brutisso@6386 414 }
brutisso@6386 415 }
brutisso@6386 416
brutisso@6386 417 void SecondaryFreeRegionListMtSafeChecker::check() {
brutisso@6386 418 // Secondary Free List MT safety protocol:
brutisso@6386 419 // Operations on the secondary free list should always be invoked
brutisso@6386 420 // while holding the SecondaryFreeList_lock.
brutisso@6386 421
brutisso@6386 422 guarantee(SecondaryFreeList_lock->owned_by_self(), "secondary free list MT safety protocol");
brutisso@6386 423 }
brutisso@6386 424
brutisso@6386 425 void OldRegionSetMtSafeChecker::check() {
brutisso@6386 426 // Master Old Set MT safety protocol:
brutisso@6386 427 // (a) If we're at a safepoint, operations on the master old set
brutisso@6386 428 // should be invoked:
brutisso@6386 429 // - by the VM thread (which will serialize them), or
brutisso@6386 430 // - by the GC workers while holding the FreeList_lock, if we're
brutisso@6386 431 // at a safepoint for an evacuation pause (this lock is taken
brutisso@6386 432 // anyway when an GC alloc region is retired so that a new one
brutisso@6386 433 // is allocated from the free list), or
brutisso@6386 434 // - by the GC workers while holding the OldSets_lock, if we're at a
brutisso@6386 435 // safepoint for a cleanup pause.
brutisso@6386 436 // (b) If we're not at a safepoint, operations on the master old set
brutisso@6386 437 // should be invoked while holding the Heap_lock.
brutisso@6386 438
brutisso@6386 439 if (SafepointSynchronize::is_at_safepoint()) {
brutisso@6386 440 guarantee(Thread::current()->is_VM_thread()
brutisso@6386 441 || FreeList_lock->owned_by_self() || OldSets_lock->owned_by_self(),
brutisso@6386 442 "master old set MT safety protocol at a safepoint");
brutisso@6386 443 } else {
brutisso@6386 444 guarantee(Heap_lock->owned_by_self(), "master old set MT safety protocol outside a safepoint");
brutisso@6386 445 }
brutisso@6386 446 }
brutisso@6386 447
brutisso@6386 448 void HumongousRegionSetMtSafeChecker::check() {
brutisso@6386 449 // Humongous Set MT safety protocol:
brutisso@6386 450 // (a) If we're at a safepoint, operations on the master humongous
brutisso@6386 451 // set should be invoked by either the VM thread (which will
brutisso@6386 452 // serialize them) or by the GC workers while holding the
brutisso@6386 453 // OldSets_lock.
brutisso@6386 454 // (b) If we're not at a safepoint, operations on the master
brutisso@6386 455 // humongous set should be invoked while holding the Heap_lock.
brutisso@6386 456
brutisso@6386 457 if (SafepointSynchronize::is_at_safepoint()) {
brutisso@6386 458 guarantee(Thread::current()->is_VM_thread() ||
brutisso@6386 459 OldSets_lock->owned_by_self(),
brutisso@6386 460 "master humongous set MT safety protocol at a safepoint");
brutisso@6386 461 } else {
brutisso@6386 462 guarantee(Heap_lock->owned_by_self(),
brutisso@6386 463 "master humongous set MT safety protocol outside a safepoint");
brutisso@6386 464 }
brutisso@6386 465 }

mercurial