182 { 183 GCTraceTime(Debug, gc, phases) trace("Phase 1: Weak Processing", scope()->timer()); 184 WeakProcessor::weak_oops_do(&_is_alive, &do_nothing_cl); 185 } 186 187 // Class unloading and cleanup. 188 if (ClassUnloading) { 189 GCTraceTime(Debug, gc, phases) debug("Phase 1: Class Unloading and Cleanup", scope()->timer()); 190 // Unload classes and purge the SystemDictionary. 191 bool purged_class = SystemDictionary::do_unloading(&_is_alive, scope()->timer()); 192 _heap->complete_cleaning(&_is_alive, purged_class); 193 } else { 194 GCTraceTime(Debug, gc, phases) debug("Phase 1: String and Symbol Tables Cleanup", scope()->timer()); 195 // If no class unloading just clean out strings and symbols. 196 _heap->partial_cleaning(&_is_alive, true, true, G1StringDedup::is_enabled()); 197 } 198 199 scope()->tracer()->report_object_count_after_gc(&_is_alive); 200 } 201 202 void G1FullCollector::prepare_compaction_common() { 203 G1FullGCPrepareTask task(this); 204 run_task(&task); 205 206 // To avoid OOM when there is memory left. 207 if (!task.has_freed_regions()) { 208 task.prepare_serial_compaction(); 209 } 210 } 211 212 void G1FullCollector::phase2_prepare_compaction() { 213 GCTraceTime(Info, gc, phases) info("Phase 2: Prepare for compaction", scope()->timer()); 214 prepare_compaction_ext(); // Will call prepare_compaction_common() above. 215 } 216 217 void G1FullCollector::phase3_adjust_pointers() { 218 // Adjust the pointers to reflect the new locations 219 GCTraceTime(Info, gc, phases) info("Phase 3: Adjust pointers and remembered sets", scope()->timer()); 220 221 G1FullGCAdjustTask task(this); 222 run_task(&task); 223 } 224 225 void G1FullCollector::phase4_do_compaction() { 226 // Compact the heap using the compaction queues created in phase 2. 227 GCTraceTime(Info, gc, phases) info("Phase 4: Compact heap", scope()->timer()); 228 G1FullGCCompactTask task(this); 229 run_task(&task); 230 231 // Serial compact to avoid OOM when very few free regions. 232 if (serial_compaction_point()->has_regions()) { 233 task.serial_compaction(); 234 } | 182 { 183 GCTraceTime(Debug, gc, phases) trace("Phase 1: Weak Processing", scope()->timer()); 184 WeakProcessor::weak_oops_do(&_is_alive, &do_nothing_cl); 185 } 186 187 // Class unloading and cleanup. 188 if (ClassUnloading) { 189 GCTraceTime(Debug, gc, phases) debug("Phase 1: Class Unloading and Cleanup", scope()->timer()); 190 // Unload classes and purge the SystemDictionary. 191 bool purged_class = SystemDictionary::do_unloading(&_is_alive, scope()->timer()); 192 _heap->complete_cleaning(&_is_alive, purged_class); 193 } else { 194 GCTraceTime(Debug, gc, phases) debug("Phase 1: String and Symbol Tables Cleanup", scope()->timer()); 195 // If no class unloading just clean out strings and symbols. 196 _heap->partial_cleaning(&_is_alive, true, true, G1StringDedup::is_enabled()); 197 } 198 199 scope()->tracer()->report_object_count_after_gc(&_is_alive); 200 } 201 202 void G1FullCollector::phase2_prepare_compaction() { 203 GCTraceTime(Info, gc, phases) info("Phase 2: Prepare for compaction", scope()->timer()); 204 G1FullGCPrepareTask task(this); 205 run_task(&task); 206 207 // To avoid OOM when there is memory left. 208 if (!task.has_freed_regions()) { 209 task.prepare_serial_compaction(); 210 } 211 } 212 213 void G1FullCollector::phase3_adjust_pointers() { 214 // Adjust the pointers to reflect the new locations 215 GCTraceTime(Info, gc, phases) info("Phase 3: Adjust pointers and remembered sets", scope()->timer()); 216 217 G1FullGCAdjustTask task(this); 218 run_task(&task); 219 } 220 221 void G1FullCollector::phase4_do_compaction() { 222 // Compact the heap using the compaction queues created in phase 2. 223 GCTraceTime(Info, gc, phases) info("Phase 4: Compact heap", scope()->timer()); 224 G1FullGCCompactTask task(this); 225 run_task(&task); 226 227 // Serial compact to avoid OOM when very few free regions. 228 if (serial_compaction_point()->has_regions()) { 229 task.serial_compaction(); 230 } |