comparison src/share/vm/gc_implementation/g1/heapRegionSet.cpp @ 17737:0d2ce7411240

8037407: G1: Remove heapRegionSets.cpp Reviewed-by: tschatzl, pliden
author brutisso
date Mon, 17 Mar 2014 13:42:16 +0100
parents 58fc1b1523dc
children 8ee855b4e667
comparison
equal deleted inserted replaced
17736:58fc1b1523dc 17737:0d2ce7411240
270 HeapRegion* hr = iter.get_next(); 270 HeapRegion* hr = iter.get_next();
271 hr->print_on(out); 271 hr->print_on(out);
272 } 272 }
273 } 273 }
274 } 274 }
275
276 void FreeRegionList::verify_list() {
277 HeapRegion* curr = head();
278 HeapRegion* prev1 = NULL;
279 HeapRegion* prev0 = NULL;
280 uint count = 0;
281 size_t capacity = 0;
282 while (curr != NULL) {
283 verify_region(curr);
284
285 count++;
286 guarantee(count < _unrealistically_long_length,
287 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()));
288
289 capacity += curr->capacity();
290
291 prev1 = prev0;
292 prev0 = curr;
293 curr = curr->next();
294 }
295
296 guarantee(tail() == prev0, err_msg("Expected %s to end with %u but it ended with %u.", name(), tail()->hrs_index(), prev0->hrs_index()));
297
298 guarantee(length() == count, err_msg("%s count mismatch. Expected %u, actual %u.", name(), length(), count));
299 guarantee(total_capacity_bytes() == capacity, err_msg("%s capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT,
300 name(), total_capacity_bytes(), capacity));
301 }
302
303 // Note on the check_mt_safety() methods below:
304 //
305 // Verification of the "master" heap region sets / lists that are
306 // maintained by G1CollectedHeap is always done during a STW pause and
307 // by the VM thread at the start / end of the pause. The standard
308 // verification methods all assert check_mt_safety(). This is
309 // important as it ensures that verification is done without
310 // concurrent updates taking place at the same time. It follows, that,
311 // for the "master" heap region sets / lists, the check_mt_safety()
312 // method should include the VM thread / STW case.
313
314 void MasterFreeRegionListMtSafeChecker::check() {
315 // Master Free List MT safety protocol:
316 // (a) If we're at a safepoint, operations on the master free list
317 // should be invoked by either the VM thread (which will serialize
318 // them) or by the GC workers while holding the
319 // FreeList_lock.
320 // (b) If we're not at a safepoint, operations on the master free
321 // list should be invoked while holding the Heap_lock.
322
323 if (SafepointSynchronize::is_at_safepoint()) {
324 guarantee(Thread::current()->is_VM_thread() ||
325 FreeList_lock->owned_by_self(), "master free list MT safety protocol at a safepoint");
326 } else {
327 guarantee(Heap_lock->owned_by_self(), "master free list MT safety protocol outside a safepoint");
328 }
329 }
330
331 void SecondaryFreeRegionListMtSafeChecker::check() {
332 // Secondary Free List MT safety protocol:
333 // Operations on the secondary free list should always be invoked
334 // while holding the SecondaryFreeList_lock.
335
336 guarantee(SecondaryFreeList_lock->owned_by_self(), "secondary free list MT safety protocol");
337 }
338
339 void OldRegionSetMtSafeChecker::check() {
340 // Master Old Set MT safety protocol:
341 // (a) If we're at a safepoint, operations on the master old set
342 // should be invoked:
343 // - by the VM thread (which will serialize them), or
344 // - by the GC workers while holding the FreeList_lock, if we're
345 // at a safepoint for an evacuation pause (this lock is taken
346 // anyway when an GC alloc region is retired so that a new one
347 // is allocated from the free list), or
348 // - by the GC workers while holding the OldSets_lock, if we're at a
349 // safepoint for a cleanup pause.
350 // (b) If we're not at a safepoint, operations on the master old set
351 // should be invoked while holding the Heap_lock.
352
353 if (SafepointSynchronize::is_at_safepoint()) {
354 guarantee(Thread::current()->is_VM_thread()
355 || FreeList_lock->owned_by_self() || OldSets_lock->owned_by_self(),
356 "master old set MT safety protocol at a safepoint");
357 } else {
358 guarantee(Heap_lock->owned_by_self(), "master old set MT safety protocol outside a safepoint");
359 }
360 }
361
362 void HumongousRegionSetMtSafeChecker::check() {
363 // Humongous Set MT safety protocol:
364 // (a) If we're at a safepoint, operations on the master humongous
365 // set should be invoked by either the VM thread (which will
366 // serialize them) or by the GC workers while holding the
367 // OldSets_lock.
368 // (b) If we're not at a safepoint, operations on the master
369 // humongous set should be invoked while holding the Heap_lock.
370
371 if (SafepointSynchronize::is_at_safepoint()) {
372 guarantee(Thread::current()->is_VM_thread() ||
373 OldSets_lock->owned_by_self(),
374 "master humongous set MT safety protocol at a safepoint");
375 } else {
376 guarantee(Heap_lock->owned_by_self(),
377 "master humongous set MT safety protocol outside a safepoint");
378 }
379 }