1169 // Statistics
1170 double now = os::elapsedTime();
1171 _remark_mark_times.add((mark_work_end - start) * 1000.0);
1172 _remark_weak_ref_times.add((now - mark_work_end) * 1000.0);
1173 _remark_times.add((now - start) * 1000.0);
1174
1175 g1p->record_concurrent_mark_remark_end();
1176 }
1177
1178 class G1CleanupTask : public AbstractGangTask {
1179 // Per-region work during the Cleanup pause.
1180 class G1CleanupRegionsClosure : public HeapRegionClosure {
1181 G1CollectedHeap* _g1h;
1182 size_t _freed_bytes;
1183 FreeRegionList* _local_cleanup_list;
1184 uint _old_regions_removed;
1185 uint _humongous_regions_removed;
1186 HRRSCleanupTask* _hrrs_cleanup_task;
1187
1188 public:
1189 G1CleanupRegionsClosure(G1CollectedHeap* g1,
1190 FreeRegionList* local_cleanup_list,
1191 HRRSCleanupTask* hrrs_cleanup_task) :
1192 _g1h(g1),
1193 _freed_bytes(0),
1194 _local_cleanup_list(local_cleanup_list),
1195 _old_regions_removed(0),
1196 _humongous_regions_removed(0),
1197 _hrrs_cleanup_task(hrrs_cleanup_task) { }
1198
1199 size_t freed_bytes() { return _freed_bytes; }
1200 const uint old_regions_removed() { return _old_regions_removed; }
1201 const uint humongous_regions_removed() { return _humongous_regions_removed; }
1202
1203 bool do_heap_region(HeapRegion *hr) {
1204 if (hr->used() > 0 && hr->max_live_bytes() == 0 && !hr->is_young() && !hr->is_archive()) {
1205 _freed_bytes += hr->used();
1206 hr->set_containing_set(NULL);
1207 if (hr->is_humongous()) {
1208 _humongous_regions_removed++;
1209 _g1h->free_humongous_region(hr, _local_cleanup_list);
1210 } else {
1211 _old_regions_removed++;
1212 _g1h->free_region(hr, _local_cleanup_list, false /* skip_remset */, false /* skip_hcc */, true /* locked */);
1653 }
1654
1655 assert(_global_mark_stack.is_empty(), "Marking should have completed");
1656
1657 // Unload Klasses, String, Symbols, Code Cache, etc.
1658 if (ClassUnloadingWithConcurrentMark) {
1659 GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
1660 bool purged_classes = SystemDictionary::do_unloading(&g1_is_alive, _gc_timer_cm, false /* Defer cleaning */);
1661 _g1h->complete_cleaning(&g1_is_alive, purged_classes);
1662 } else {
1663 GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
1664 // No need to clean string table and symbol table as they are treated as strong roots when
1665 // class unloading is disabled.
1666 _g1h->partial_cleaning(&g1_is_alive, false, false, G1StringDedup::is_enabled());
1667 }
1668 }
1669
1670 // When sampling object counts, we already swapped the mark bitmaps, so we need to use
1671 // the prev bitmap determining liveness.
1672 class G1ObjectCountIsAliveClosure: public BoolObjectClosure {
1673 G1CollectedHeap* _g1;
1674 public:
1675 G1ObjectCountIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
1676
1677 bool do_object_b(oop obj) {
1678 HeapWord* addr = (HeapWord*)obj;
1679 return addr != NULL &&
1680 (!_g1->is_in_g1_reserved(addr) || !_g1->is_obj_dead(obj));
1681 }
1682 };
1683
1684 void G1ConcurrentMark::report_object_count(bool mark_completed) {
1685 // Depending on the completion of the marking liveness needs to be determined
1686 // using either the next or prev bitmap.
1687 G1ObjectCountIsAliveClosure is_alive_prev(_g1h);
1688 G1CMIsAliveClosure is_alive_next(_g1h);
1689 BoolObjectClosure* is_alive;
1690 if (mark_completed) {
1691 is_alive = &is_alive_prev;
1692 } else {
1693 is_alive = &is_alive_next;
1694 }
1695 _gc_tracer_cm->report_object_count_after_gc(is_alive);
1696 }
1697
1698
1699 void G1ConcurrentMark::swap_mark_bitmaps() {
1700 G1CMBitMap* temp = _prev_mark_bitmap;
|
1169 // Statistics
1170 double now = os::elapsedTime();
1171 _remark_mark_times.add((mark_work_end - start) * 1000.0);
1172 _remark_weak_ref_times.add((now - mark_work_end) * 1000.0);
1173 _remark_times.add((now - start) * 1000.0);
1174
1175 g1p->record_concurrent_mark_remark_end();
1176 }
1177
1178 class G1CleanupTask : public AbstractGangTask {
1179 // Per-region work during the Cleanup pause.
1180 class G1CleanupRegionsClosure : public HeapRegionClosure {
1181 G1CollectedHeap* _g1h;
1182 size_t _freed_bytes;
1183 FreeRegionList* _local_cleanup_list;
1184 uint _old_regions_removed;
1185 uint _humongous_regions_removed;
1186 HRRSCleanupTask* _hrrs_cleanup_task;
1187
1188 public:
1189 G1CleanupRegionsClosure(G1CollectedHeap* g1h,
1190 FreeRegionList* local_cleanup_list,
1191 HRRSCleanupTask* hrrs_cleanup_task) :
1192 _g1h(g1h),
1193 _freed_bytes(0),
1194 _local_cleanup_list(local_cleanup_list),
1195 _old_regions_removed(0),
1196 _humongous_regions_removed(0),
1197 _hrrs_cleanup_task(hrrs_cleanup_task) { }
1198
1199 size_t freed_bytes() { return _freed_bytes; }
1200 const uint old_regions_removed() { return _old_regions_removed; }
1201 const uint humongous_regions_removed() { return _humongous_regions_removed; }
1202
1203 bool do_heap_region(HeapRegion *hr) {
1204 if (hr->used() > 0 && hr->max_live_bytes() == 0 && !hr->is_young() && !hr->is_archive()) {
1205 _freed_bytes += hr->used();
1206 hr->set_containing_set(NULL);
1207 if (hr->is_humongous()) {
1208 _humongous_regions_removed++;
1209 _g1h->free_humongous_region(hr, _local_cleanup_list);
1210 } else {
1211 _old_regions_removed++;
1212 _g1h->free_region(hr, _local_cleanup_list, false /* skip_remset */, false /* skip_hcc */, true /* locked */);
1653 }
1654
1655 assert(_global_mark_stack.is_empty(), "Marking should have completed");
1656
1657 // Unload Klasses, String, Symbols, Code Cache, etc.
1658 if (ClassUnloadingWithConcurrentMark) {
1659 GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
1660 bool purged_classes = SystemDictionary::do_unloading(&g1_is_alive, _gc_timer_cm, false /* Defer cleaning */);
1661 _g1h->complete_cleaning(&g1_is_alive, purged_classes);
1662 } else {
1663 GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
1664 // No need to clean string table and symbol table as they are treated as strong roots when
1665 // class unloading is disabled.
1666 _g1h->partial_cleaning(&g1_is_alive, false, false, G1StringDedup::is_enabled());
1667 }
1668 }
1669
1670 // When sampling object counts, we already swapped the mark bitmaps, so we need to use
1671 // the prev bitmap determining liveness.
1672 class G1ObjectCountIsAliveClosure: public BoolObjectClosure {
1673 G1CollectedHeap* _g1h;
1674 public:
1675 G1ObjectCountIsAliveClosure(G1CollectedHeap* g1h) : _g1h(g1h) { }
1676
1677 bool do_object_b(oop obj) {
1678 HeapWord* addr = (HeapWord*)obj;
1679 return addr != NULL &&
1680 (!_g1h->is_in_g1_reserved(addr) || !_g1h->is_obj_dead(obj));
1681 }
1682 };
1683
1684 void G1ConcurrentMark::report_object_count(bool mark_completed) {
1685 // Depending on the completion of the marking liveness needs to be determined
1686 // using either the next or prev bitmap.
1687 G1ObjectCountIsAliveClosure is_alive_prev(_g1h);
1688 G1CMIsAliveClosure is_alive_next(_g1h);
1689 BoolObjectClosure* is_alive;
1690 if (mark_completed) {
1691 is_alive = &is_alive_prev;
1692 } else {
1693 is_alive = &is_alive_next;
1694 }
1695 _gc_tracer_cm->report_object_count_after_gc(is_alive);
1696 }
1697
1698
1699 void G1ConcurrentMark::swap_mark_bitmaps() {
1700 G1CMBitMap* temp = _prev_mark_bitmap;
|