386 }
387
388 void HumongousRegionSetMtSafeChecker::check() {
389 // Humongous Set MT safety protocol:
390 // (a) If we're at a safepoint, operations on the master humongous
391 // set should be invoked by either the VM thread (which will
392 // serialize them) or by the GC workers while holding the
393 // OldSets_lock.
394 // (b) If we're not at a safepoint, operations on the master
395 // humongous set should be invoked while holding the Heap_lock.
396
397 if (SafepointSynchronize::is_at_safepoint()) {
398 guarantee(Thread::current()->is_VM_thread() ||
399 OldSets_lock->owned_by_self(),
400 "master humongous set MT safety protocol at a safepoint");
401 } else {
402 guarantee(Heap_lock->owned_by_self(),
403 "master humongous set MT safety protocol outside a safepoint");
404 }
405 }
|
386 }
387
388 void HumongousRegionSetMtSafeChecker::check() {
389 // Humongous Set MT safety protocol:
390 // (a) If we're at a safepoint, operations on the master humongous
391 // set should be invoked by either the VM thread (which will
392 // serialize them) or by the GC workers while holding the
393 // OldSets_lock.
394 // (b) If we're not at a safepoint, operations on the master
395 // humongous set should be invoked while holding the Heap_lock.
396
397 if (SafepointSynchronize::is_at_safepoint()) {
398 guarantee(Thread::current()->is_VM_thread() ||
399 OldSets_lock->owned_by_self(),
400 "master humongous set MT safety protocol at a safepoint");
401 } else {
402 guarantee(Heap_lock->owned_by_self(),
403 "master humongous set MT safety protocol outside a safepoint");
404 }
405 }
406
407 void FreeRegionList_test() {
408 FreeRegionList l("test");
409
410 const uint num_regions_in_test = 5;
411 // Create a fake heap. It does not need to be valid, as the HeapRegion constructor
412 // does not access it.
413 MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);
414 // Allocate a fake BOT because the HeapRegion constructor initializes
415 // the BOT.
416 size_t bot_size = G1BlockOffsetSharedArray::compute_size(heap.word_size());
417 HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
418 ReservedSpace bot_rs(G1BlockOffsetSharedArray::compute_size(heap.word_size()));
419 G1RegionToSpaceMapper* bot_storage =
420 G1RegionToSpaceMapper::create_mapper(bot_rs,
421 os::vm_page_size(),
422 HeapRegion::GrainBytes,
423 G1BlockOffsetSharedArray::N_bytes,
424 mtGC);
425 G1BlockOffsetSharedArray oa(heap, bot_storage);
426 bot_storage->commit_regions(0, num_regions_in_test);
427 HeapRegion hr0(0, &oa, heap);
428 HeapRegion hr1(1, &oa, heap);
429 HeapRegion hr2(2, &oa, heap);
430 HeapRegion hr3(3, &oa, heap);
431 HeapRegion hr4(4, &oa, heap);
432 l.add_ordered(&hr1);
433 l.add_ordered(&hr0);
434 l.add_ordered(&hr3);
435 l.add_ordered(&hr4);
436 l.add_ordered(&hr2);
437 assert(l.length() == num_regions_in_test, "wrong length");
438 l.verify_list();
439
440 bot_storage->uncommit_regions(0, num_regions_in_test);
441 delete bot_storage;
442 FREE_C_HEAP_ARRAY(HeapWord, bot_data, mtGC);
443 }
|