< prev index next > src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
Print this page
#include "gc/shared/weakProcessor.inline.hpp"
#include "logging/log.hpp"
#include "memory/iterator.inline.hpp"
#include "runtime/atomic.hpp"
class G1AdjustLiveClosure : public StackObj {
! G1AdjustClosure* _adjust_closure;
public:
! G1AdjustLiveClosure(G1AdjustClosure* cl) :
_adjust_closure(cl) { }
size_t apply(oop object) {
return object->oop_iterate_size(_adjust_closure);
}
#include "gc/shared/weakProcessor.inline.hpp"
#include "logging/log.hpp"
#include "memory/iterator.inline.hpp"
#include "runtime/atomic.hpp"
+ template <bool ALT_FWD>
class G1AdjustLiveClosure : public StackObj {
! G1AdjustClosure<ALT_FWD>* _adjust_closure;
public:
! G1AdjustLiveClosure(G1AdjustClosure<ALT_FWD>* cl) :
_adjust_closure(cl) { }
size_t apply(oop object) {
return object->oop_iterate_size(_adjust_closure);
}
_collector(collector),
_bitmap(collector->mark_bitmap()),
_worker_id(worker_id) { }
bool do_heap_region(HeapRegion* r) {
! G1AdjustClosure cl(_collector);
if (r->is_humongous()) {
// Special handling for humongous regions to get somewhat better
// work distribution.
oop obj = cast_to_oop(r->humongous_start_region()->bottom());
obj->oop_iterate(&cl, MemRegion(r->bottom(), r->top()));
} else if (!r->is_closed_archive() && !r->is_free()) {
// Closed archive regions never change references and only contain
// references into other closed regions and are always live. Free
// regions do not contain objects to iterate. So skip both.
! G1AdjustLiveClosure adjust(&cl);
r->apply_to_marked_objects(_bitmap, &adjust);
}
return false;
}
};
_collector(collector),
_bitmap(collector->mark_bitmap()),
_worker_id(worker_id) { }
bool do_heap_region(HeapRegion* r) {
! if (UseAltGCForwarding) {
+ return do_heap_region_impl<true>(r);
+ } else {
+ return do_heap_region_impl<false>(r);
+ }
+ }
+
+ private:
+ template <bool ALT_FWD>
+ bool do_heap_region_impl(HeapRegion* r) {
+ G1AdjustClosure<ALT_FWD> cl(_collector);
if (r->is_humongous()) {
// Special handling for humongous regions to get somewhat better
// work distribution.
oop obj = cast_to_oop(r->humongous_start_region()->bottom());
obj->oop_iterate(&cl, MemRegion(r->bottom(), r->top()));
} else if (!r->is_closed_archive() && !r->is_free()) {
// Closed archive regions never change references and only contain
// references into other closed regions and are always live. Free
// regions do not contain objects to iterate. So skip both.
! G1AdjustLiveClosure<ALT_FWD> adjust(&cl);
r->apply_to_marked_objects(_bitmap, &adjust);
}
return false;
}
};
G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
G1FullGCTask("G1 Adjust", collector),
_root_processor(G1CollectedHeap::heap(), collector->workers()),
_references_done(false),
_weak_proc_task(collector->workers()),
! _hrclaimer(collector->workers()),
- _adjust(collector) {
// Need cleared claim bits for the roots processing
ClassLoaderDataGraph::clear_claimed_marks();
}
! void G1FullGCAdjustTask::work(uint worker_id) {
Ticks start = Ticks::now();
ResourceMark rm;
// Adjust preserved marks first since they are not balanced.
G1FullGCMarker* marker = collector()->marker(worker_id);
marker->preserved_stack()->adjust_during_full_gc();
// Adjust the weak roots.
if (!Atomic::cmpxchg(&_references_done, false, true)) {
! G1CollectedHeap::heap()->ref_processor_stw()->weak_oops_do(&_adjust);
}
AlwaysTrueClosure always_alive;
! _weak_proc_task.work(worker_id, &always_alive, &_adjust);
! CLDToOopClosure adjust_cld(&_adjust, ClassLoaderData::_claim_strong);
! CodeBlobToOopClosure adjust_code(&_adjust, CodeBlobToOopClosure::FixRelocations);
! _root_processor.process_all_roots(&_adjust, &adjust_cld, &adjust_code);
// Now adjust pointers region by region
G1AdjustRegionClosure blk(collector(), worker_id);
G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
log_task("Adjust task", worker_id, start);
}
G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
G1FullGCTask("G1 Adjust", collector),
_root_processor(G1CollectedHeap::heap(), collector->workers()),
_references_done(false),
_weak_proc_task(collector->workers()),
! _hrclaimer(collector->workers()) {
// Need cleared claim bits for the roots processing
ClassLoaderDataGraph::clear_claimed_marks();
}
! template <bool ALT_FWD>
+ void G1FullGCAdjustTask::work_impl(uint worker_id) {
Ticks start = Ticks::now();
ResourceMark rm;
// Adjust preserved marks first since they are not balanced.
G1FullGCMarker* marker = collector()->marker(worker_id);
marker->preserved_stack()->adjust_during_full_gc();
+ G1AdjustClosure<ALT_FWD> adjust(collector());
// Adjust the weak roots.
if (!Atomic::cmpxchg(&_references_done, false, true)) {
! G1CollectedHeap::heap()->ref_processor_stw()->weak_oops_do(&adjust);
}
AlwaysTrueClosure always_alive;
! _weak_proc_task.work(worker_id, &always_alive, &adjust);
! CLDToOopClosure adjust_cld(&adjust, ClassLoaderData::_claim_strong);
! CodeBlobToOopClosure adjust_code(&adjust, CodeBlobToOopClosure::FixRelocations);
! _root_processor.process_all_roots(&adjust, &adjust_cld, &adjust_code);
// Now adjust pointers region by region
G1AdjustRegionClosure blk(collector(), worker_id);
G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
log_task("Adjust task", worker_id, start);
}
+
+ void G1FullGCAdjustTask::work(uint worker_id) {
+ if (UseAltGCForwarding) {
+ work_impl<true>(worker_id);
+ } else {
+ work_impl<false>(worker_id);
+ }
+ }
< prev index next >