59 bool clear_all_softrefs) { 60 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); 61 62 SharedHeap* sh = SharedHeap::heap(); 63 #ifdef ASSERT 64 if (sh->collector_policy()->should_clear_all_soft_refs()) { 65 assert(clear_all_softrefs, "Policy should have been checked earler"); 66 } 67 #endif 68 // hook up weak ref data so it can be used during Mark-Sweep 69 assert(GenMarkSweep::ref_processor() == NULL, "no stomping"); 70 assert(rp != NULL, "should be non-NULL"); 71 assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition"); 72 73 GenMarkSweep::_ref_processor = rp; 74 rp->setup_policy(clear_all_softrefs); 75 76 // When collecting the permanent generation Method*s may be moving, 77 // so we either have to flush all bcp data or convert it into bci. 78 CodeCache::gc_prologue(); 79 Threads::gc_prologue(); 80 81 bool marked_for_unloading = false; 82 83 allocate_stacks(); 84 85 // We should save the marks of the currently locked biased monitors. 86 // The marking doesn't preserve the marks of biased objects. 87 BiasedLocking::preserve_marks(); 88 89 mark_sweep_phase1(marked_for_unloading, clear_all_softrefs); 90 91 mark_sweep_phase2(); 92 93 // Don't add any more derived pointers during phase3 94 COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); 95 96 mark_sweep_phase3(); 97 98 mark_sweep_phase4(); 99 100 GenMarkSweep::restore_marks(); 101 BiasedLocking::restore_marks(); 102 GenMarkSweep::deallocate_stacks(); 103 104 // "free at last gc" is calculated from these. 105 // CHF: cheating for now!!! 106 // Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity()); 107 // Universe::set_heap_used_at_last_gc(Universe::heap()->used()); 108 109 Threads::gc_epilogue(); 110 CodeCache::gc_epilogue(); 111 JvmtiExport::gc_epilogue(); 112 113 // refs processing: clean slate 114 GenMarkSweep::_ref_processor = NULL; 115 } 116 117 118 void G1MarkSweep::allocate_stacks() { 119 GenMarkSweep::_preserved_count_max = 0; 120 GenMarkSweep::_preserved_marks = NULL; 121 GenMarkSweep::_preserved_count = 0; 122 } 123 124 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, 125 bool clear_all_softrefs) { 126 // Recursively traverse all live objects and mark them 127 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 128 GenMarkSweep::trace(" 1"); 129 | 59 bool clear_all_softrefs) { 60 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); 61 62 SharedHeap* sh = SharedHeap::heap(); 63 #ifdef ASSERT 64 if (sh->collector_policy()->should_clear_all_soft_refs()) { 65 assert(clear_all_softrefs, "Policy should have been checked earler"); 66 } 67 #endif 68 // hook up weak ref data so it can be used during Mark-Sweep 69 assert(GenMarkSweep::ref_processor() == NULL, "no stomping"); 70 assert(rp != NULL, "should be non-NULL"); 71 assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition"); 72 73 GenMarkSweep::_ref_processor = rp; 74 rp->setup_policy(clear_all_softrefs); 75 76 // When collecting the permanent generation Method*s may be moving, 77 // so we either have to flush all bcp data or convert it into bci. 78 CodeCache::gc_prologue(); 79 80 bool marked_for_unloading = false; 81 82 allocate_stacks(); 83 84 // We should save the marks of the currently locked biased monitors. 85 // The marking doesn't preserve the marks of biased objects. 86 BiasedLocking::preserve_marks(); 87 88 mark_sweep_phase1(marked_for_unloading, clear_all_softrefs); 89 90 mark_sweep_phase2(); 91 92 // Don't add any more derived pointers during phase3 93 COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); 94 95 mark_sweep_phase3(); 96 97 mark_sweep_phase4(); 98 99 GenMarkSweep::restore_marks(); 100 BiasedLocking::restore_marks(); 101 GenMarkSweep::deallocate_stacks(); 102 103 // "free at last gc" is calculated from these. 104 // CHF: cheating for now!!! 105 // Universe::set_heap_capacity_at_last_gc(Universe::heap()->capacity()); 106 // Universe::set_heap_used_at_last_gc(Universe::heap()->used()); 107 108 CodeCache::gc_epilogue(); 109 JvmtiExport::gc_epilogue(); 110 111 // refs processing: clean slate 112 GenMarkSweep::_ref_processor = NULL; 113 } 114 115 116 void G1MarkSweep::allocate_stacks() { 117 GenMarkSweep::_preserved_count_max = 0; 118 GenMarkSweep::_preserved_marks = NULL; 119 GenMarkSweep::_preserved_count = 0; 120 } 121 122 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, 123 bool clear_all_softrefs) { 124 // Recursively traverse all live objects and mark them 125 GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 126 GenMarkSweep::trace(" 1"); 127 |