comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 6629:c9814fadeb38

7041879: G1: introduce stress testing parameter to cause frequent evacuation failures Summary: Add the flags G1EvacuationFailureALot flag (and supporting flags) to force trigger evacuation failures. The support flags control how often to trigger an evacuation failure and during which types of evacuation pause. This functionality is analogous to that of PromotionFailureALot for the other collectors. Reviewed-by: brutisso
author johnc
date Tue, 28 Aug 2012 15:20:08 -0700
parents bb3f6194fedb
children da91efe96a93
comparison
equal deleted inserted replaced
6628:bb3f6194fedb 6629:c9814fadeb38
1943 _task_queues->register_queue(i, q); 1943 _task_queues->register_queue(i, q);
1944 } 1944 }
1945 1945
1946 clear_cset_start_regions(); 1946 clear_cset_start_regions();
1947 1947
1948 // Initialize the G1EvacuationFailureALot counters and flags.
1949 NOT_PRODUCT(reset_evacuation_should_fail();)
1950
1948 guarantee(_task_queues != NULL, "task_queues allocation failure."); 1951 guarantee(_task_queues != NULL, "task_queues allocation failure.");
1949 #ifdef SPARC 1952 #ifdef SPARC
1950 // Issue a stern warning, but allow use for experimentation and debugging. 1953 // Issue a stern warning, but allow use for experimentation and debugging.
1951 if (VM_Version::is_sun4v() && UseMemSetInBOT) { 1954 if (VM_Version::is_sun4v() && UseMemSetInBOT) {
1952 assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error"); 1955 assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
4562 int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age() 4565 int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age()
4563 : m->age(); 4566 : m->age();
4564 GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age, 4567 GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
4565 word_sz); 4568 word_sz);
4566 HeapWord* obj_ptr = _par_scan_state->allocate(alloc_purpose, word_sz); 4569 HeapWord* obj_ptr = _par_scan_state->allocate(alloc_purpose, word_sz);
4567 oop obj = oop(obj_ptr); 4570 #ifndef PRODUCT
4571 // Should this evacuation fail?
4572 if (_g1->evacuation_should_fail()) {
4573 if (obj_ptr != NULL) {
4574 _par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz);
4575 obj_ptr = NULL;
4576 }
4577 }
4578 #endif // !PRODUCT
4568 4579
4569 if (obj_ptr == NULL) { 4580 if (obj_ptr == NULL) {
4570 // This will either forward-to-self, or detect that someone else has 4581 // This will either forward-to-self, or detect that someone else has
4571 // installed a forwarding pointer. 4582 // installed a forwarding pointer.
4572 OopsInHeapRegionClosure* cl = _par_scan_state->evac_failure_closure(); 4583 OopsInHeapRegionClosure* cl = _par_scan_state->evac_failure_closure();
4573 return _g1->handle_evacuation_failure_par(cl, old); 4584 return _g1->handle_evacuation_failure_par(cl, old);
4574 } 4585 }
4586
4587 oop obj = oop(obj_ptr);
4575 4588
4576 // We're going to allocate linearly, so might as well prefetch ahead. 4589 // We're going to allocate linearly, so might as well prefetch ahead.
4577 Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes); 4590 Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);
4578 4591
4579 oop forward_ptr = old->forward_to_atomic(obj); 4592 oop forward_ptr = old->forward_to_atomic(obj);
5576 5589
5577 void G1CollectedHeap::evacuate_collection_set() { 5590 void G1CollectedHeap::evacuate_collection_set() {
5578 _expand_heap_after_alloc_failure = true; 5591 _expand_heap_after_alloc_failure = true;
5579 set_evacuation_failed(false); 5592 set_evacuation_failed(false);
5580 5593
5594 // Should G1EvacuationFailureALot be in effect for this GC?
5595 NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();)
5596
5581 g1_rem_set()->prepare_for_oops_into_collection_set_do(); 5597 g1_rem_set()->prepare_for_oops_into_collection_set_do();
5582 concurrent_g1_refine()->set_use_cache(false); 5598 concurrent_g1_refine()->set_use_cache(false);
5583 concurrent_g1_refine()->clear_hot_cache_claimed_index(); 5599 concurrent_g1_refine()->clear_hot_cache_claimed_index();
5584 5600
5585 uint n_workers; 5601 uint n_workers;
5667 5683
5668 finalize_for_evac_failure(); 5684 finalize_for_evac_failure();
5669 5685
5670 if (evacuation_failed()) { 5686 if (evacuation_failed()) {
5671 remove_self_forwarding_pointers(); 5687 remove_self_forwarding_pointers();
5688
5689 // Reset the G1EvacuationFailureALot counters and flags
5690 // Note: the values are reset only when an actual
5691 // evacuation failure occurs.
5692 NOT_PRODUCT(reset_evacuation_should_fail();)
5672 } 5693 }
5673 5694
5674 // Enqueue any remaining references remaining on the STW 5695 // Enqueue any remaining references remaining on the STW
5675 // reference processor's discovered lists. We need to do 5696 // reference processor's discovered lists. We need to do
5676 // this after the card table is cleaned (and verified) as 5697 // this after the card table is cleaned (and verified) as