63 #include "gc/shared/gcTimer.hpp" |
63 #include "gc/shared/gcTimer.hpp" |
64 #include "gc/shared/gcTrace.hpp" |
64 #include "gc/shared/gcTrace.hpp" |
65 #include "gc/shared/gcTraceTime.inline.hpp" |
65 #include "gc/shared/gcTraceTime.inline.hpp" |
66 #include "gc/shared/generationSpec.hpp" |
66 #include "gc/shared/generationSpec.hpp" |
67 #include "gc/shared/isGCActiveMark.hpp" |
67 #include "gc/shared/isGCActiveMark.hpp" |
|
68 #include "gc/shared/preservedMarks.inline.hpp" |
68 #include "gc/shared/referenceProcessor.inline.hpp" |
69 #include "gc/shared/referenceProcessor.inline.hpp" |
69 #include "gc/shared/taskqueue.inline.hpp" |
70 #include "gc/shared/taskqueue.inline.hpp" |
70 #include "logging/log.hpp" |
71 #include "logging/log.hpp" |
71 #include "memory/allocation.hpp" |
72 #include "memory/allocation.hpp" |
72 #include "memory/iterator.hpp" |
73 #include "memory/iterator.hpp" |
1757 _ref_processor_stw(NULL), |
1758 _ref_processor_stw(NULL), |
1758 _bot(NULL), |
1759 _bot(NULL), |
1759 _cg1r(NULL), |
1760 _cg1r(NULL), |
1760 _g1mm(NULL), |
1761 _g1mm(NULL), |
1761 _refine_cte_cl(NULL), |
1762 _refine_cte_cl(NULL), |
|
1763 _preserved_marks_set(true /* in_c_heap */), |
1762 _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()), |
1764 _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()), |
1763 _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()), |
1765 _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()), |
1764 _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()), |
1766 _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()), |
1765 _humongous_reclaim_candidates(), |
1767 _humongous_reclaim_candidates(), |
1766 _has_humongous_reclaim_candidates(false), |
1768 _has_humongous_reclaim_candidates(false), |
1987 vm_shutdown_during_initialization("Failed to allocate initial heap."); |
1989 vm_shutdown_during_initialization("Failed to allocate initial heap."); |
1988 return JNI_ENOMEM; |
1990 return JNI_ENOMEM; |
1989 } |
1991 } |
1990 |
1992 |
1991 // Perform any initialization actions delegated to the policy. |
1993 // Perform any initialization actions delegated to the policy. |
1992 g1_policy()->init(); |
1994 g1_policy()->init(this, &_collection_set); |
1993 |
1995 |
1994 JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, |
1996 JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, |
1995 SATB_Q_FL_lock, |
1997 SATB_Q_FL_lock, |
1996 G1SATBProcessCompletedThreshold, |
1998 G1SATBProcessCompletedThreshold, |
1997 Shared_SATB_Q_lock); |
1999 Shared_SATB_Q_lock); |
2032 // values in the heap have been properly initialized. |
2034 // values in the heap have been properly initialized. |
2033 _g1mm = new G1MonitoringSupport(this); |
2035 _g1mm = new G1MonitoringSupport(this); |
2034 |
2036 |
2035 G1StringDedup::initialize(); |
2037 G1StringDedup::initialize(); |
2036 |
2038 |
2037 _preserved_objs = NEW_C_HEAP_ARRAY(OopAndMarkOopStack, ParallelGCThreads, mtGC); |
2039 _preserved_marks_set.init(ParallelGCThreads); |
2038 for (uint i = 0; i < ParallelGCThreads; i++) { |
|
2039 new (&_preserved_objs[i]) OopAndMarkOopStack(); |
|
2040 } |
|
2041 |
2040 |
2042 return JNI_OK; |
2041 return JNI_OK; |
2043 } |
2042 } |
2044 |
2043 |
2045 void G1CollectedHeap::stop() { |
2044 void G1CollectedHeap::stop() { |
2056 size_t G1CollectedHeap::conservative_max_heap_alignment() { |
2055 size_t G1CollectedHeap::conservative_max_heap_alignment() { |
2057 return HeapRegion::max_region_size(); |
2056 return HeapRegion::max_region_size(); |
2058 } |
2057 } |
2059 |
2058 |
2060 void G1CollectedHeap::post_initialize() { |
2059 void G1CollectedHeap::post_initialize() { |
2061 CollectedHeap::post_initialize(); |
|
2062 ref_processing_init(); |
2060 ref_processing_init(); |
2063 } |
2061 } |
2064 |
2062 |
2065 void G1CollectedHeap::ref_processing_init() { |
2063 void G1CollectedHeap::ref_processing_init() { |
2066 // Reference processing in G1 currently works as follows: |
2064 // Reference processing in G1 currently works as follows: |
3526 } |
3524 } |
3527 |
3525 |
3528 return true; |
3526 return true; |
3529 } |
3527 } |
3530 |
3528 |
3531 void G1CollectedHeap::restore_preserved_marks() { |
|
3532 G1RestorePreservedMarksTask rpm_task(_preserved_objs); |
|
3533 workers()->run_task(&rpm_task); |
|
3534 } |
|
3535 |
|
3536 void G1CollectedHeap::remove_self_forwarding_pointers() { |
3529 void G1CollectedHeap::remove_self_forwarding_pointers() { |
3537 G1ParRemoveSelfForwardPtrsTask rsfp_task; |
3530 G1ParRemoveSelfForwardPtrsTask rsfp_task; |
3538 workers()->run_task(&rsfp_task); |
3531 workers()->run_task(&rsfp_task); |
3539 } |
3532 } |
3540 |
3533 |
3541 void G1CollectedHeap::restore_after_evac_failure() { |
3534 void G1CollectedHeap::restore_after_evac_failure() { |
3542 double remove_self_forwards_start = os::elapsedTime(); |
3535 double remove_self_forwards_start = os::elapsedTime(); |
3543 |
3536 |
3544 remove_self_forwarding_pointers(); |
3537 remove_self_forwarding_pointers(); |
3545 restore_preserved_marks(); |
3538 _preserved_marks_set.restore(workers()); |
3546 |
3539 |
3547 g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0); |
3540 g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0); |
3548 } |
3541 } |
3549 |
3542 |
3550 void G1CollectedHeap::preserve_mark_during_evac_failure(uint worker_id, oop obj, markOop m) { |
3543 void G1CollectedHeap::preserve_mark_during_evac_failure(uint worker_id, oop obj, markOop m) { |
3551 if (!_evacuation_failed) { |
3544 if (!_evacuation_failed) { |
3552 _evacuation_failed = true; |
3545 _evacuation_failed = true; |
3553 } |
3546 } |
3554 |
3547 |
3555 _evacuation_failed_info_array[worker_id].register_copy_failure(obj->size()); |
3548 _evacuation_failed_info_array[worker_id].register_copy_failure(obj->size()); |
3556 |
3549 _preserved_marks_set.get(worker_id)->push_if_necessary(obj, m); |
3557 // We want to call the "for_promotion_failure" version only in the |
|
3558 // case of a promotion failure. |
|
3559 if (m->must_be_preserved_for_promotion_failure(obj)) { |
|
3560 OopAndMarkOop elem(obj, m); |
|
3561 _preserved_objs[worker_id].push(elem); |
|
3562 } |
|
3563 } |
3550 } |
3564 |
3551 |
3565 bool G1ParEvacuateFollowersClosure::offer_termination() { |
3552 bool G1ParEvacuateFollowersClosure::offer_termination() { |
3566 G1ParScanThreadState* const pss = par_scan_state(); |
3553 G1ParScanThreadState* const pss = par_scan_state(); |
3567 start_term_time(); |
3554 start_term_time(); |
4580 G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); |
4567 G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); |
4581 hot_card_cache->reset_hot_cache_claimed_index(); |
4568 hot_card_cache->reset_hot_cache_claimed_index(); |
4582 hot_card_cache->set_use_cache(false); |
4569 hot_card_cache->set_use_cache(false); |
4583 |
4570 |
4584 g1_rem_set()->prepare_for_oops_into_collection_set_do(); |
4571 g1_rem_set()->prepare_for_oops_into_collection_set_do(); |
|
4572 _preserved_marks_set.assert_empty(); |
4585 } |
4573 } |
4586 |
4574 |
4587 void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) { |
4575 void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) { |
4588 // Should G1EvacuationFailureALot be in effect for this GC? |
4576 // Should G1EvacuationFailureALot be in effect for this GC? |
4589 NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();) |
4577 NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();) |
4656 // Reset the G1EvacuationFailureALot counters and flags |
4644 // Reset the G1EvacuationFailureALot counters and flags |
4657 // Note: the values are reset only when an actual |
4645 // Note: the values are reset only when an actual |
4658 // evacuation failure occurs. |
4646 // evacuation failure occurs. |
4659 NOT_PRODUCT(reset_evacuation_should_fail();) |
4647 NOT_PRODUCT(reset_evacuation_should_fail();) |
4660 } |
4648 } |
|
4649 |
|
4650 _preserved_marks_set.assert_empty(); |
4661 |
4651 |
4662 // Enqueue any remaining references remaining on the STW |
4652 // Enqueue any remaining references remaining on the STW |
4663 // reference processor's discovered lists. We need to do |
4653 // reference processor's discovered lists. We need to do |
4664 // this after the card table is cleaned (and verified) as |
4654 // this after the card table is cleaned (and verified) as |
4665 // the act of enqueueing entries on to the pending list |
4655 // the act of enqueueing entries on to the pending list |
5326 HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, |
5316 HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, |
5327 bool force) { |
5317 bool force) { |
5328 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); |
5318 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); |
5329 assert(!force || g1_policy()->can_expand_young_list(), |
5319 assert(!force || g1_policy()->can_expand_young_list(), |
5330 "if force is true we should be able to expand the young list"); |
5320 "if force is true we should be able to expand the young list"); |
5331 bool young_list_full = g1_policy()->is_young_list_full(); |
5321 bool should_allocate = g1_policy()->should_allocate_mutator_region(); |
5332 if (force || !young_list_full) { |
5322 if (force || should_allocate) { |
5333 HeapRegion* new_alloc_region = new_region(word_size, |
5323 HeapRegion* new_alloc_region = new_region(word_size, |
5334 false /* is_old */, |
5324 false /* is_old */, |
5335 false /* do_expand */); |
5325 false /* do_expand */); |
5336 if (new_alloc_region != NULL) { |
5326 if (new_alloc_region != NULL) { |
5337 set_region_short_lived_locked(new_alloc_region); |
5327 set_region_short_lived_locked(new_alloc_region); |
5338 _hr_printer.alloc(new_alloc_region, young_list_full); |
5328 _hr_printer.alloc(new_alloc_region, !should_allocate); |
5339 _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region); |
5329 _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region); |
5340 return new_alloc_region; |
5330 return new_alloc_region; |
5341 } |
5331 } |
5342 } |
5332 } |
5343 return NULL; |
5333 return NULL; |